412 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
Adding code to the BTTBankProcess project
Implement the DepositSnippetImplement class by performing the following tasks:
1. Open DepositSnippetImplement.java from the
btt.bank.business.logic.snippets package.
2. Add the import statements shown in Example 8-33.
Example 8-33 Additional import statements for DepositSnippetImplement.java
import com.ibm.btt.base.Context;
import com.ibm.btt.formatter.client.FormatElement;
import com.ibm.btt.services.jdbcjournalservice.Journal;
3. Add the code shown in Example 8-34 in the execute method.
Example 8-34 The execute method for the DepositSnippetImplement class
public int execute() throws BTTBPException {
System.out.println("Executed depositServerOp.snippets.initial");
//User code here
try{
// initialize context hierarchy
Context BPContext = getContext() ;
if(BPContext.getParent() == null){
Context parent= Context.getContextByInstanceID(getSystemData()
.getInstanceId());
BPContext.chainTo(parent);
}
// set data to deposit context
String hostBuff = ((FormatElement)getFormat("withdrawalCSRequestFmt"))
.format(BPContext);
setValueAt("HostBuff", hostBuff);
System.out.println("deposit BP context:\n" +
BPContext.getKeyedCollection());
// writes to the journal using the appropriate format
Journal journal = (Journal)getService("JournalService");
int recordNum = journal.addRecord(BPContext,"preSendJournalFmt");
// Set hard coded response data to deposit context
BPContext.setValueAt("TrxReplyCode", "00");
BPContext.setValueAt("AccountBalance", "10000");
BPContext.setValueAt("TrxErrorMessage", "depositOK");
// Update the electronic journal record
journal.updateRecord(recordNum,getContext(),"afterRecJournalFmt");
journal.releaseServiceRequester();
} catch(Exception e){