Customer Management in Webui
Understanding Customer in Webui
The Customer
Customer Attributes
The Customer
customerNumbersortcodenameaddress (date of birth)dobcreditScorecreditScoreReviewDateeditingCustomer
These attributes are defined in the Customer
private String customerNumber;
private String sortcode;
private String name;
private String address;
private Date dob;
private String creditScore;
private Date creditScoreReviewDate;
private Boolean editingCustomer;
Creating a Customer
To create a new customer, click on the 'Create customer' button on the landing page. This action will invoke the addToDB
Viewing Customer Details
To view customer details, click the 'View customer details' button on the landing page. This will display all stored information about the customer.
Adding a Customer to the Database
The addToDBCustomerJSONCustomerResource
The addToDBCustomerJSONCustomerResource
public String addToDB()
{
CustomerResource myCustomerResource = new CustomerResource();
CustomerJSON myCustomerJSON = new CustomerJSON();
myCustomerJSON.setCustomerAddress(this.getAddress());
myCustomerJSON.setCustomerName(this.getName());
myCustomerJSON.setDateOfBirth(this.getDob());
myCustomerJSON.setSortCode(this.getSortcode());
Response myCustomerResponse = myCustomerResource
.createCustomerExternal(myCustomerJSON);
String myCustomerString = null;
JSONObject myCustomer = null;
if (myCustomerResponse.getStatus() == 201)
{
myCustomerString = myCustomerResponse.getEntity().toString();
try
{
Updating Customer Information
The updateThisCustomerJSONCustomerResource
Deleting a Customer from the Database
The deleteFromDBCustomerResource
The deleteFromDBCustomerResource
public boolean deleteFromDB()
{
CustomerResource myCustomerResource = new CustomerResource();
Response myCustomerResponse = myCustomerResource.deleteCustomerExternal(
Long.parseLong(this.getCustomerNumber()));
String myCustomerString = null;
JSONObject myCustomer = null;
if (myCustomerResponse.getStatus() == 200)
{
myCustomerString = myCustomerResponse.getEntity().toString();
try
{
myCustomer = JSONObject.parse(myCustomerString);
}
catch (IOException e)
{
logger.log(Level.SEVERE, e::toString);
Checking if a Customer Exists in the Database
The inDBCustomerResource
The inDBCustomerResource
/**
* inDB
*
* Checks if the customer is in the database
*
* @return
*/
public boolean inDB()
{
CustomerResource myCustomerResource = new CustomerResource();
Response myCustomerResponse = null;
String myCustomerString = null;
JSONObject myCustomer = null;
myCustomerResponse = myCustomerResource
.getCustomerExternal(Long.parseLong(this.customerNumber));
if (myCustomerResponse.getStatus() == 200)
{
myCustomerString = myCustomerResponse.getEntity().toString();
try
Displaying Customer Information
The showInfo
The showInfo
/**
* showInfo
*
* Displays all the info stored about the customer Will show a credit score
* if the customer is being edited
*
*/
public void showInfo()
{
if (Boolean.FALSE.equals(editingCustomer))
{
logger.log(Level.INFO, () -> DASHES + this.customerNumber + ":"
+ this.sortcode + DASHES);
logger.log(Level.INFO, () -> "Sortcode - " + this.sortcode);
logger.log(Level.INFO, () -> "Customer name - " + this.getName());
logger.log(Level.INFO,
() -> "Customer address - " + this.getAddress());
logger.log(Level.INFO, () -> "Customer Date of Birth - "
+ this.getDob().toString());
logger.log(Level.INFO, () -> "Customer is new");
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human