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
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
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
getCustomersInternal
@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
getCustomersByNameInternal
@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
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
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
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