Creating a New Customer Flow
In this document, we will explain the process of creating a new customer. The process involves the following steps: initiating the customer creation, processing the customer data, writing the data to the database, and establishing a database connection.
The flow starts with initiating the customer creation process by receiving customer data in JSON format. This data is then processed internally and prepared for database insertion. The system ensures that a connection to the database is established, and if not, it creates a new one. Finally, the customer data is written to the database.
Flow drill down
writeCreateCustomerExternal
writeCreateCustomerExternal
First, the writeCreateCustomerExternal
writeCreateCustomerInternal
@POST
@Produces("application/json")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/createCustomer")
public Response writeCreateCustomerExternal(
ProcessedTransactionCreateCustomerJSON myCreatedCustomer)
{
Response myResponse = writeCreateCustomerInternal(myCreatedCustomer);
HBankDataAccess myHBankDataAccess = new HBankDataAccess();
myHBankDataAccess.terminate();
return myResponse;
}
writeCreateCustomerInternal
writeCreateCustomerInternal
Next, the writeCreateCustomerInternal
writeCreateCustomer
public Response writeCreateCustomerInternal(
ProcessedTransactionCreateCustomerJSON myCreatedCustomer)
{
com.ibm.cics.cip.bankliberty.web.db2.ProcessedTransaction myProcessedTransactionDB2 = new com.ibm.cics.cip.bankliberty.web.db2.ProcessedTransaction();
if (myProcessedTransactionDB2.writeCreateCustomer(
myCreatedCustomer.getSortCode(),
myCreatedCustomer.getAccountNumber(), 0.00,
myCreatedCustomer.getCustomerDOB(),
myCreatedCustomer.getCustomerName(),
myCreatedCustomer.getCustomerNumber()))
{
return Response.ok().build();
}
else
{
return Response.serverError().build();
}
}
writeCreateCustomer
writeCreateCustomer
Then, the writeCreateCustomer
public boolean writeCreateCustomer(String sortCode2, String accountNumber,
double amountWhichWillBeZero, Date customerDOB, String customerName,
String customerNumber)
{
logger.entering(this.getClass().getName(), WRITE_CREATE_CUSTOMER);
sortOutDateTimeTaskString();
String createCustomerDescription = "";
createCustomerDescription = createCustomerDescription
.concat(padSortCode(Integer.parseInt(sortCode2)));
createCustomerDescription = createCustomerDescription
.concat(padCustomerNumber(customerNumber));
StringBuilder myStringBuilder = new StringBuilder();
for (int z = customerName.length(); z < 14; z++)
{
myStringBuilder.append("0");
}
myStringBuilder.append(customerName);
createCustomerDescription = createCustomerDescription
.concat(myStringBuilder.substring(0, 14));
openConnection
openConnection
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 "
openConnectionInternal
openConnectionInternal
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