Skip to main content

Customer Data Retrieval Flow

In this document, we will explain the process of retrieving customer data based on various filters. The process involves checking if the filter is empty, retrieving all customers, retrieving customers by number, and retrieving customers by name.

The flow is straightforward and involves checking if the filter is empty, retrieving all customers if it is, retrieving customers by number if the filter specifies a customer number, and retrieving customers by name if the filter specifies a customer name.

Flow drill down


Handling customer data retrieval based on different filters

The doGet method handles customer data retrieval based on different filters. It first checks if the filter is empty, then retrieves all customers. If the filter specifies a customer number, it retrieves the customer with that number. If the filter specifies a customer name, it retrieves customers matching that name. Finally, it processes the response to extract customer details and adds them to the list of customers.

	public void doGet(int limit, int offset, String filter) throws IOException
{

CustomerResource myCustomerResource = new CustomerResource();

Response myCustomerResponse = null;

String myCustomerString = null;

try
{
if (filter.length() == 0)
{

myCustomerResponse = myCustomerResource
.getCustomersExternal(limit, offset, false);

}
if (filter.startsWith(" AND CUSTOMER_NUMBER = "))
{



Counting customers based on filter

The howMany method counts the number of customers based on the provided filter. It checks if the filter specifies a customer name or number and retrieves the count accordingly. If no filter is provided, it retrieves the total count of customers.

	private void howMany(String filter)
{

CustomerResource myCustomerResource = new CustomerResource();
Response myCustomerResponse = null;

// 0123456789012345678901234

try
{
if (filter.startsWith(" AND CUSTOMER_NAME like '"))
{

String customerNameFilter = filter.substring(25);
customerNameFilter = customerNameFilter.substring(0,
customerNameFilter.length() - 1);

myCustomerResponse = myCustomerResource
.getCustomersByNameExternal(customerNameFilter, 0, 0,
true);
String myCustomersString = myCustomerResponse.getEntity()


Retrieving customers externally

The getCustomersExternal method retrieves customer data externally. It calls the getCustomersInternal method to fetch the data and then terminates the data access session.

	@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getCustomersExternal(@QueryParam("limit") Integer limit,
@QueryParam("offset") Integer offset,
@QueryParam("countOnly") Boolean countOnly)
{
logger.entering(this.getClass().getName(),
"getCustomersExternal(Integer limit, Integer offset, Boolean countOnly) "
+ limit + " " + offset + " " + countOnly);
boolean countOnlyReal = false;
if (countOnly != null)
{
countOnlyReal = countOnly.booleanValue();
}
Response myResponse = getCustomersInternal(limit, offset,
countOnlyReal);
HBankDataAccess myHBankDataAccess = new HBankDataAccess();
myHBankDataAccess.terminate();
logger.exiting(this.getClass().getName(),
"getCustomersExternal(Integer limit, Integer offset, Boolean countOnly)",
myResponse);


Retrieving customers by name externally

The getCustomersByNameExternal method retrieves customers by name externally. It calls the getCustomersByNameInternal method to fetch the data based on the provided name, limit, and offset.

	@GET
@Path("/name")
@Produces(MediaType.APPLICATION_JSON)
public Response getCustomersByNameExternal(@QueryParam("name") String name,
@QueryParam("limit") Integer limit,
@QueryParam("offset") Integer offset,
@QueryParam("countOnly") Boolean countOnly)
{
logger.entering(this.getClass().getName(),
"getCustomersByNameExternal(String name, Integer limit, Integer offset, Boolean countOnly) "
+ name + " " + limit + " " + offset + " " + countOnly);

boolean countOnlyReal = false;
if (countOnly != null)
{
countOnlyReal = countOnly.booleanValue();
}
if (offset == null)
{
offset = 0;
}


Retrieving customers by name internally

The getCustomersByNameInternal method retrieves customers by name internally. It fetches the data from the VSAM customer database and constructs a JSON response with the customer details.

	public Response getCustomersByNameInternal(@QueryParam("name") String name,
@QueryParam("limit") int limit, @QueryParam("offset") int offset,
boolean countOnly)
{
logger.entering(this.getClass().getName(),
"getCustomersByNameInternal(String name, Integer limit, Integer offset, Boolean countOnly) "
+ name + " " + limit + " " + offset + " " + countOnly);
Integer sortCode = this.getSortCode();

JSONObject response = new JSONObject();
JSONArray customers = null;

if (countOnly)
{
com.ibm.cics.cip.bankliberty.web.vsam.Customer vsamCustomer = new com.ibm.cics.cip.bankliberty.web.vsam.Customer();
long numberOfCustomers = 0;
numberOfCustomers = vsamCustomer
.getCustomersByNameCountOnly(sortCode.intValue(), name);
response.put(JSON_NUMBER_OF_CUSTOMERS, numberOfCustomers);
}
else


Retrieving customers internally

The getCustomersInternal method retrieves customer data internally. It fetches the data from the VSAM customer database and constructs a JSON response with the customer details.

	public Response getCustomersInternal(@QueryParam("limit") Integer limit,
@QueryParam("offset") Integer offset, boolean countOnly)
{
logger.entering(this.getClass().getName(),
"getCustomersInternal(Integer limit, Integer offset, Boolean countOnly) "
+ limit + " " + offset + " " + countOnly);
Integer sortCode = this.getSortCode();

JSONObject response = new JSONObject();
JSONArray customers = null;

if (offset == null)
{
offset = 0;
}

if (limit == null)
{
limit = 250000;
}



Retrieving customers by name from VSAM

The getCustomersByName method retrieves customers by name from the VSAM customer database. It iterates through the records, filters them based on the provided name, and constructs an array of customer objects.

	public Customer[] getCustomersByName(int sortCode, int limit, int offset,
String name)
{
logger.entering(this.getClass().getName(),
GET_CUSTOMERS_BY_NAME_WITH_OFFSET_AND_LIMIT);
Customer[] temp = new Customer[1000000];

int stored = 0;

customerFile.setName(FILENAME);

myCustomer = new CUSTOMER();

holder = new RecordHolder();
keyHolder = new KeyHolder();
byte[] key = buildKey(sortCode, 0);

// We need to convert the key to EBCDIC
String keyString = new String(key);
try
{

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human