...
The new process class must extend com.crm.process.CRMProcessRunBean class.
Note that:
- A method having only one input parameter, the process run log ID, must be created. This method will be used to implement any business functionality required after the process run definition submission.
- If a multithreaded process is needed, please follow the instructions on how to Implement a multithreaded process.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
/** * Session Bean implementation class CRMProcessRewardSettlementBean */ @Stateless @LocalBean public class CRMProcessRewardSettlementBean extends CRMProcessRunBean { /** * */ private static final long serialVersionUID = 1L; @EJB private RewardSettlementProcessRunDefinitionXMLUtilBean rewardSettlementProcessRunDefinitionXMLUtilBean; @EJB private RewardDefinitionXMLUtilBean rewardDefinitionXMLUtilBean; @EJB private CRMBOInvoiceBean invoiceBean; @EJB private CRMBOCreditNoteBean creditNoteBean; @EJB private CRMBOAccountReceivableBean accountReceivableBean; @EJB private CRMBOUnitBean unitBean; @EJB private CRMBORewardAwardTransactionBean rewardAwardTransactionBean; @EJB private CRMBORewardSpendTransactionBean rewardSpendTransactionBean; @EJB private CRMProcessFinTransactionBean processFinTransactionBean; @EJB private CRMBORewardsParticipatingMerchantBean rewardsParticipatingMerchantBean; @EJB private CRMBOAwardEventBean awardEventBean; @EJB private CRMBORewardsParticipatingMerchantGroupBean rewardsParticipatingMerchantGroupBean; @EJB private CRMBOUnitGroupBean unitGroupBean; @EJB private CRMBORewardDefinitionBean rewardDefinitionBean; /** * @see CRMProcessRunBean#CRMProcessRunBean() */ public CRMProcessRewardSettlementBean() { //do nothing } public void execute(String processRunLogID) throws Exception { CRMDOProcessRunLog processRun = (CRMDOProcessRunLog)processRunLogBean.load(processRunLogID); execute(processRun); } public void execute(CRMDOProcessRunLog processRun) throws Exception { CRMDOProcessRunDefinition processRunDefinition = processRun.getProcessRunDefinition(); RewardSettlementRunDefinition rewardSettlementRunDefinition = new RewardSettlementRunDefinition(); rewardSettlementRunDefinition.setProcessRunDefinition(processRunDefinition); rewardSettlementRunDefinition = rewardSettlementProcessRunDefinitionXMLUtilBean.loadFromXML(rewardSettlementRunDefinition); rewardSettlementRunDefinition = rewardSettlementProcessRunDefinitionXMLUtilBean.initialize(rewardSettlementRunDefinition); CRMDORewardDefinition rewardDefinition=(CRMDORewardDefinition)rewardDefinitionBean.loadActiveDefinition(); rewardDefinition=rewardDefinitionXMLUtilBean.initialize(rewardDefinition); processRun.setStatus(ProcessRunLogStatus.IN_PROGRESS); processRun.setStartDate(getCurrentDate()); processRunLogBean.save(processRun); Boolean processComplete = new Boolean(false); try { if(rewardSettlementRunDefinition!=null && rewardSettlementRunDefinition.getRewardSettlementType()!=null && !rewardSettlementRunDefinition.getRewardSettlementType().equals(RewardSettlementType.CREDIT) ) { createInvoices(processRun, rewardSettlementRunDefinition,rewardDefinition); createCreditNotesForPurchaseCustEvent(processRun, rewardSettlementRunDefinition,rewardDefinition); processComplete = new Boolean(true); } if(rewardSettlementRunDefinition!=null && rewardSettlementRunDefinition.getRewardSettlementType()!=null && !rewardSettlementRunDefinition.getRewardSettlementType().equals(RewardSettlementType.DEBIT) ) { createCreditNotes(processRun, rewardSettlementRunDefinition,rewardDefinition); createInvoicesForSpendCustEvent(processRun, rewardSettlementRunDefinition,rewardDefinition); processComplete = new Boolean(true); } } catch(Exception e) { saveEntityLogRecord(processRun,"", "",ProcessRunLogEntityStatus.FAILED,e.getClass().getSimpleName(),ExceptionUtil.getStackTrace(e)); processRun.setStatus(ProcessRunLogStatus.FAILED); processRunLogBean.save(processRun); processRun = saveNextProcessRun(processRun); } if (processComplete) { processRun.setStatus(ProcessRunLogStatus.COMPLETED); processRun.setEndDate(getCurrentDate()); processRun = saveNextProcessRun(processRun); processRunLogBean.save(processRun); } } ... } |
...
7. Define the process in modules metadata file
To define the process in the modules metadata file:
- Create a new process entry under the right module (module id must be equal to the process run definition's module attribute) and give your process the right id (process id must be equal to the process run definition's process attribute).
- Set the value of <ejbname> to the name of the process class you created (step 4). Use the name defined in EJB binding file, after prefix 'ejb/' (ibm-ejb-jar-bnd.xml
...
...
- ).
- Set the value of <methodname> to the name of the method used for executing the process run definition (step 4.1)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ejb-jar-bnd> ... <module> <moduleid>REWARDS</moduleid> ... <feature> ... <additionalprocesses> <process> <id>REWARD_SETTLEMENT_PROCESSING</id> <name>key_execute_reward_settlement_run_definition</name> <description>key_execute_reward_settlement_run_defintion</description> <methods> <method> <ejbname>CRMProcessRewardSettlement</ejbname> <methodname>execute</methodname> <scheduled>true</scheduled> </method> </methods> <batch>true</batch> </process> ... </additionalprocesses> </feature> </module> ... |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<ejb-jar-bnd> ... <session name="CRMProcessProcessSmsRunCRMProcessRewardSettlementBean" simple-binding-name="ejb/CRMProcessProcessSmsRunCRMProcessRewardSettlement" /> ... </ejb-jar-bnd> |
The process must also be added in the CrmEJB/ejbModule/META-INF/ibm-ejb-jar-ext.xml to define how much time the process could been executing on WebSphere server as follows:
...