Deleting a Bank Account Flow
In this document, we will explain the process of deleting a bank account. The process involves several steps, including initiating the deletion, processing the deletion internally, writing the deletion to the database, and managing the database connection.
The flow starts with initiating the account deletion by receiving the account details in JSON format. Then, it processes the deletion internally by interacting with the database to check if the deletion was successful. If successful, it writes the account deletion details to the database, preparing and executing the SQL statement. Finally, it ensures that a connection to the DB2
Flow drill down
Handling the deletion of an account
First, the writeDeleteAccountExternal
writeDeleteAccountInternal
@POST
@Produces("application/json")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/deleteAccount")
public Response writeDeleteAccountExternal(
ProcessedTransactionAccountJSON myDeletedAccount)
{
Response myResponse = writeDeleteAccountInternal(myDeletedAccount);
HBankDataAccess myHBankDataAccess = new HBankDataAccess();
myHBankDataAccess.terminate();
return myResponse;
}
Processing the account deletion internally
Next, the writeDeleteAccountInternal
public Response writeDeleteAccountInternal(
ProcessedTransactionAccountJSON myDeletedAccount)
{
com.ibm.cics.cip.bankliberty.web.db2.ProcessedTransaction myProcessedTransactionDB2 = new com.ibm.cics.cip.bankliberty.web.db2.ProcessedTransaction();
if (myProcessedTransactionDB2.writeDeleteAccount(
myDeletedAccount.getSortCode(),
myDeletedAccount.getAccountNumber(),
myDeletedAccount.getActualBalance(),
myDeletedAccount.getLastStatement(),
myDeletedAccount.getNextStatement(),
myDeletedAccount.getCustomerNumber(),
myDeletedAccount.getType()))
{
return Response.ok().build();
}
else
{
return Response.serverError().build();
}
}
Writing the account deletion to the database
Then, the writeDeleteAccount
public boolean writeDeleteAccount(String sortCode2, String accountNumber,
BigDecimal actualBalance, Date lastStatement, Date nextStatement,
String customerNumber, String accountType)
{
logger.entering(this.getClass().getName(), WRITE_DELETE_ACCOUNT);
PROCTRAN myPROCTRAN = new PROCTRAN();
Calendar myCalendar = Calendar.getInstance();
myCalendar.setTime(lastStatement);
myPROCTRAN.setProcDescDelaccLastDd(myCalendar.get(Calendar.DATE));
myPROCTRAN.setProcDescDelaccLastMm(myCalendar.get(Calendar.MONTH) + 1);
myPROCTRAN.setProcDescDelaccLastYyyy(myCalendar.get(Calendar.YEAR));
myCalendar.setTime(nextStatement);
myPROCTRAN.setProcDescDelaccNextDd(myCalendar.get(Calendar.DATE));
myPROCTRAN.setProcDescDelaccNextMm(myCalendar.get(Calendar.MONTH) + 1);
myPROCTRAN.setProcDescDelaccNextYyyy(myCalendar.get(Calendar.YEAR));
myPROCTRAN.setProcDescDelaccAcctype(accountType);
myPROCTRAN.setProcDescDelaccCustomer(Integer.parseInt(customerNumber));
Opening a database connection
Moving to the openConnection
DB2
openConnectionInternal
protected void openConnection()
{
// Open a connection to the DB2 database
logger.entering(this.getClass().getName(), "openConnection()");
Integer taskNumberInteger = Task.getTask().getTaskNumber();
String db2ConnString = DB2CONN.concat(taskNumberInteger.toString());
logger.log(Level.FINE,
() -> "Attempting to get DB2CONN for task number "
+ taskNumberInteger.toString());
this.conn = (Connection) cornedBeef.get(db2ConnString);
if (this.conn == null)
{
HBankDataAccess.incrementConnCount();
logger.log(Level.FINE,
() -> "Attempting to create DB2CONN for task number "
+ taskNumberInteger.toString());
// Attempt to open a connection
openConnectionInternal();
logger.log(Level.FINE,
() -> "Creation succcessful for DB2CONN for task number "
Establishing a new database connection
Finally, the openConnectionInternal
@SuppressWarnings("unchecked")
void openConnectionInternal()
{
logger.entering(this.getClass().getName(), "openConnectionInternal");
String jndiString = "jdbc/defaultCICSDataSource";
Context ctx;
try
{
ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(jndiString);
logger.log(Level.FINE, () -> "jndi string is " + jndiString);
// If there is no current connection
if (this.conn == null)
{
logger.log(Level.FINE,
() -> "About to attempt to get DB2 connection");
// Try and get a connection
this.conn = ds.getConnection();
this.conn.setTransactionIsolation(
Connection.TRANSACTION_READ_UNCOMMITTED);
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human