Skip to main content

Customer List Feature Overview

Overview

The Customer List in the WebUI is a feature that allows users to view and manage a list of customers. It retrieves customer data from the backend and displays it in a user-friendly format. The Customer List can be filtered by customer name or customer number to narrow down the search results. It also provides functionality to count the number of customers that match the given filter criteria.

Implementation

The Customer List is implemented in the CustomerList class, which handles the data retrieval and processing. The CustomerList class uses the CustomerResource class to fetch customer data from external sources. The retrieved customer data is stored in a list of Customer objects, which can be accessed and manipulated as needed.


The CustomerList class handles the data retrieval and processing for the Customer List feature. It uses the CustomerResource class to fetch customer data from external sources and stores the retrieved data in a list of Customer objects.

public class CustomerList
{


private static Logger logger = Logger
.getLogger("com.ibm.cics.cip.bankliberty.webui.dataAccess");

private List<Customer> listOfCustomers = new ArrayList<>();

private static String sortcode = null;

private int count;

private static final String JSON_SORT_CODE = "sortCode";

private static final String JSON_ID = "id";

private static final String JSON_CUSTOMER_NAME = "customerName";

private static final String JSON_CUSTOMER_ADDRESS = "customerAddress";

Main Functions

There are several main functions in the CustomerList class. Some of them are getCount, howMany, doGet, getCustomer, and size. Below, we will dive a little into getCount and howMany.

getCount

The getCount function is used to get the count of customers that match a given filter. It calls the howMany function if the list of customers is empty.


The getCount function checks if the list of customers is empty and calls the howMany function to get the count of customers that match the given filter.

	public int getCount(String filter)
{
if (this.listOfCustomers.isEmpty())
{
howMany(filter);
}
return this.count;
}

howMany

The howMany function is used to determine the number of customers that match a given filter. It interacts with the CustomerResource class to fetch customer data based on the filter criteria.


The howMany function uses the CustomerResource class to fetch customer data based on the filter criteria and processes the response to determine the number of matching 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()

doGet

The doGet function retrieves a list of customers based on the provided limit, offset, and filter. It uses the CustomerResource class to fetch customer data and processes the response to populate the list of customers.


The doGet function interacts with the CustomerResource class to fetch customer data based on the provided limit, offset, and filter, and processes the response to populate 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 = "))
{

getCustomer

The getCustomer function returns a customer object from the list of customers based on the provided index.


The getCustomer function retrieves a customer object from the list of customers based on the provided index.

	public Customer getCustomer(int i)
{
return this.listOfCustomers.get(i);
}

size

The size function returns the size of the list of customers.


The size function returns the number of customers in the list.

	public int size()
{
return this.listOfCustomers.size();
}

 

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