Customer Deletion Process
In this document, we will explain the process of deleting a customer and their associated accounts from the database. The process involves multiple steps, including initiating the deletion, handling external and internal requests, and ensuring all associated accounts are properly deleted.
The flow starts with initiating the customer deletion process. This involves calling an external function to handle the deletion request. The external function then calls an internal function to perform the actual deletion. The internal function first deletes all associated accounts by calling another function for each account. Once all accounts are deleted, the customer record is deleted, and the transaction is logged.
Flow drill down
deleteFromDB
Function
deleteFromDB
Diving into the deleteFromDB
deleteCustomerExternal
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);
deleteCustomerExternal
Function
deleteCustomerExternal
The deleteCustomerExternal
deleteCustomerInternal
@DELETE
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteCustomerExternal(@PathParam(JSON_ID) Long id)
{
logger.entering(this.getClass().getName(),
"deleteCustomerExtnernal(Long id) for customerNumber " + id);
Response myResponse = deleteCustomerInternal(id);
HBankDataAccess myHBankDataAccess = new HBankDataAccess();
myHBankDataAccess.terminate();
logger.exiting(this.getClass().getName(),
"deleteCustomerExternal(Long id)", myResponse);
return myResponse;
}
deleteCustomerInternal
Function
deleteCustomerInternal
The deleteCustomerInternal
deleteAccountInternal
public Response deleteCustomerInternal(Long id)
{
logger.entering(this.getClass().getName(),
"deleteCustomerInternal(Long id) for customerNumber " + id);
Integer sortCode = this.getSortCode();
JSONObject response = new JSONObject();
if (id.longValue() < 0)
{
// Customer number cannot be negative
response.put(JSON_ERROR_MSG, "Customer number cannot be negative");
Response myResponse = Response.status(404)
.entity(response.toString()).build();
logger.log(Level.WARNING,
() -> "Customer number supplied was negative in deleteCustomerInternal()");
logger.exiting(this.getClass().getName(),
DELETE_CUSTOMER_INTERNAL_EXIT, myResponse);
return myResponse;
}
deleteAccountInternal
Function
deleteAccountInternal
The deleteAccountInternal
public Response deleteAccountInternal(Long accountNumber)
{
logger.entering(this.getClass().getName(), DELETE_ACCOUNT);
Response myResponse = null;
JSONObject response = new JSONObject();
Integer sortCode = this.getSortCode();
com.ibm.cics.cip.bankliberty.web.db2.Account db2Account = new Account();
db2Account = db2Account.deleteAccount(accountNumber.intValue(),
sortCode.intValue());
if (db2Account != null)
{
response.put(JSON_SORT_CODE, db2Account.getSortcode().trim());
response.put("id", db2Account.getAccountNumber());
response.put(JSON_CUSTOMER_NUMBER, db2Account.getCustomerNumber());
response.put(JSON_ACCOUNT_TYPE, db2Account.getType().trim());
response.put(JSON_AVAILABLE_BALANCE,
BigDecimal.valueOf(db2Account.getAvailableBalance()));
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human