...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
/** * Session Bean implementation class CRMUISmsInfocasMessageRunDefinitionCRMUISmsMessageRunDefinition */ @Stateless(mappedName = "ejb/CRMUISmsInfocasMessageRunDefinitionCRMUISmsMessageRunDefinition") @LocalBean public class CRMUISmsInfocasMessageRunDefinitionBeanCRMUISmsMessageRunDefinitionBean extends CRMUIProcessRunDefinitionBean { private static final long serialVersionUID = 1L; private static final String PROCESS_RUN_LOG_ENTRIES_EXIST = "PROCESS_RUN_LOG_ENTRIES_EXIST"; private static final String IS_PROCESS_RUN_DEF_LATEST_VERSION = "IS_PROCESS_RUN_DEF_LATEST_VERSION"; //Declare module and process id as defined in metadata private static final String MODULE_ID = "SMS_SERVICES"; private static final String PROCESS_ID = "SMS_INFOCAS_MESSAGE_PROCESS"; @EJB private CRMBOProcessRunDefinitionBean processRunDefinitionBean; @EJB private CRMBOProcessRunLogBean processRunLogBean; @EJB private smsInfocasMessageRunDefinitionXMLUtilBean smsInfocasMessageRunDefinitionXMLUtilBean; /** * Default constructor. */ public CRMUISmsInfocasMessageRunDefinitionBeanCRMUISmsMessageRunDefinitionBean() { // TODO Auto-generated constructor stub } public smsInfocasMessageRunDefintionsmsMessageRunDefintion createButton() throws Exception { smsInfocasMessageRunDefintionsmsMessageRunDefintion definition = new smsInfocasMessageRunDefintionsmsMessageRunDefintion(); CRMDOProcessRunDefinition processRunDefinition = (CRMDOProcessRunDefinition)processRunDefinitionBean.construct(); processRunDefinition.setModule(MODULE_ID); processRunDefinition.setProcess(PROCESS_ID); definition.setProcessRunDefinition(processRunDefinition); definition.setSchedulerTask(new SchedulerTask()); definition.setMandatoryFields(); return definition; } public smsInfocasMessageRunDefintionsmsMessageRunDefintion loadForm(String id) throws Exception { CRMDOProcessRunDefinition processRunDefinition = (CRMDOProcessRunDefinition)processRunDefinitionBean.load(id); smsInfocasMessageRunDefintionsmsMessageRunDefintion definition = new smsInfocasMessageRunDefintionsmsMessageRunDefintion(); definition.setProcessRunDefinition(processRunDefinition); definition = smsInfocasMessageRunDefinitionXMLUtilBeansmsMessageRunDefinitionXMLUtilBean.loadProcessingRunDefinition(definition); ArrayList<CRMDO> provisioningRequestProcessingRuns = processRunLogBean.load(definition.getProcessRunDefinition()); if (provisioningRequestProcessingRuns!=null && provisioningRequestProcessingRuns.size() > 0) { definition.setAlias(PROCESS_RUN_LOG_ENTRIES_EXIST, "1"); } else { definition.setAlias(PROCESS_RUN_LOG_ENTRIES_EXIST, "0"); } Boolean isLatestVersion = isLatestVersion(processRunDefinition); if (isLatestVersion) { definition.setAlias(IS_PROCESS_RUN_DEF_LATEST_VERSION, "1"); } else { definition.setAlias(IS_PROCESS_RUN_DEF_LATEST_VERSION, "0"); } definition.setMandatoryFields(); return definition; } public smsInfocasMessageRunDefintionsmsMessageRunDefintion editButton(smsInfocasMessageRunDefintionsmsMessageRunDefintion definition) throws Exception { CRMDOProcessRunDefinition processRundefinition = (CRMDOProcessRunDefinition)processRunDefinitionBean.load(definition.getProcessRunDefinition().getId()); if (processRundefinition==null) { processRundefinition = processRunDefinitionBean.loadLatest(definition.getProcessRunDefinition().getCode()); } definition = loadForm(processRundefinition.getId()); if (definition.getAlias(PROCESS_RUN_LOG_ENTRIES_EXIST).equals("1")) { definition = amendInfocasMessageRunDefinitionamendMessageRunDefinition(definition); } return definition; } public smsInfocasMessageRunDefintionsmsMessageRunDefintion saveButton(smsInfocasMessageRunDefintionsmsMessageRunDefintion definition) throws Exception, MandatoryFieldException { definition.setMandatoryFields(); validateMandatoryFields(definition); definition = smsInfocasMessageRunDefinitionXMLUtilBeansmsMessageRunDefinitionXMLUtilBean.setInfocasMessageRunDefinitionXMLsetMessageRunDefinitionXML(definition); CRMDOProcessRunDefinition processRunDefinition = definition.getProcessRunDefinition(); if (processRunDefinition.getCode()==null) { processRunDefinition.setCode(processRunDefinitionBean.getNextSequenceNumber(SequenceNumber.PROCESSRUNDEFINITIONCODES)); } processRunDefinitionBean.validateAndSave(definition.getProcessRunDefinition()); if (definition.getBroadcastPeriod()==null) { throw new MandatoryFieldException(getCRMSession(), "key_broadcast_period"); } if (definition.getBroadcastInterval()==null) { throw new MandatoryFieldException(getCRMSession(), "key_broadcast_interval"); } ArrayList<CRMDO> provisioningRequestProcessingRuns = processRunLogBean.load(definition.getProcessRunDefinition()); if (provisioningRequestProcessingRuns!=null && provisioningRequestProcessingRuns.size() > 0) { definition.setAlias(PROCESS_RUN_LOG_ENTRIES_EXIST, "1"); } else { definition.setAlias(PROCESS_RUN_LOG_ENTRIES_EXIST, "0"); } Boolean isLatestVersion = isLatestVersion(processRunDefinition); if (isLatestVersion) { definition.setAlias(IS_PROCESS_RUN_DEF_LATEST_VERSION, "1"); } else { definition.setAlias(IS_PROCESS_RUN_DEF_LATEST_VERSION, "0"); } return definition; } public smsInfocasMessageRunDefintionsmsMessageRunDefintion submitButton(smsInfocasMessageRunDefintionsmsMessageRunDefintion definition) throws Exception { CRMDOProcessRunLog processRunLog = (CRMDOProcessRunLog)processRunLogBean.construct(definition.getProcessRunDefinition()); submit(processRunLog); return loadForm(definition.getProcessRunDefinition().getId()); } public smsInfocasMessageRunDefintionsmsMessageRunDefintion deleteButton(smsInfocasMessageRunDefintionsmsMessageRunDefintion definition) throws Exception { processRunDefinitionBean.validateAndDelete(definition.getProcessRunDefinition()); return definition; } public smsInfocasMessageRunDefintionsmsMessageRunDefintion amendInfocasMessageRunDefinitionamendMessageRunDefinition(smsInfocasMessageRunDefintionsmsMessageRunDefintion definition) throws Exception { CRMDOProcessRunDefinition processRunDefinition = definition.getProcessRunDefinition(); CRMDOProcessRunDefinition newProcessRunDefinition = (CRMDOProcessRunDefinition)processRunDefinition.clone(); newProcessRunDefinition.setVersion(new Integer(processRunDefinition.getVersion().intValue()+1)); newProcessRunDefinition.setProperty("name", new FieldAttribute("1")); newProcessRunDefinition.setProperty("altCode", new FieldAttribute("1")); definition.setProcessRunDefinition(newProcessRunDefinition); definition.setAlias(PROCESS_RUN_LOG_ENTRIES_EXIST, "0"); definition.setAlias(IS_PROCESS_RUN_DEF_LATEST_VERSION, "1"); return definition; } } |
...