package wenrgise.workflow.ejb.business; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Iterator; import wenrgise.common.bean.BaseHeaderBean; import wenrgise.common.bean.LOVBean; import wenrgise.common.exception.EnrgiseApplicationException; import wenrgise.common.exception.EnrgiseMessageKeyException; import wenrgise.common.exception.EnrgiseSystemException; import wenrgise.common.utility.EnrgiseUtil; import wenrgise.common.utility.MessageKey; import wenrgise.common.utility.RecordMetaInfo; import wenrgise.common.utility.UserInfo; import wenrgise.common.vo.BaseHeaderVO; import wenrgise.common.vo.LovQueryVO; import wenrgise.common.vo.LovVO; import wenrgise.ejb.common.business.BaseBO; import wenrgise.ejb.common.helper.DBObject; import wenrgise.ejb.common.helper.QueryRow; import wenrgise.ejb.common.utility.DBUtilitiesBean; import wenrgise.workflow.bean.WflDocMstAttrDtlBean; import wenrgise.workflow.bean.WflDocMstConditionsDtlBean; import wenrgise.workflow.bean.WflDocMstHdrBean; import wenrgise.workflow.bean.WflDtlDocTypeDtlBean; import wenrgise.workflow.vo.WflDocMstQVO; public class WflDocMstBO extends BaseBO { public WflDocMstBO() {} public WflDocMstBO(UserInfo oUserInfo) { super(oUserInfo); } public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {} public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException { return "saveNewHeaderImpl ille!"; } public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oErrorList = new ArrayList(); if (bHeaderDataChanged) if (!sScreenMode.equalsIgnoreCase("D")) { checkMandatoryHdr((WflDocMstHdrBean)oBaseHeaderBean); checkNumericFields((WflDocMstHdrBean)oBaseHeaderBean, oErrorList); } if (bDetailDataChanged) if (sScreenName.equalsIgnoreCase("WflWorkflowConditions")) { Iterator oIt = oDetailBeanArray.iterator(); int count = 1; while (oIt.hasNext()) { WflDocMstConditionsDtlBean oWflDocMstConditionsDtlBean = oIt.next(); if (!oWflDocMstConditionsDtlBean.getStatus().equalsIgnoreCase("D")) checkMandatoryDtls(oWflDocMstConditionsDtlBean, count, oDetailBeanArray); count++; } } else if (sScreenName.equalsIgnoreCase("WFLDoctAttrDetail")) { Iterator oIt1 = oDetailBeanArray.iterator(); int count = 1; while (oIt1.hasNext()) { WflDocMstAttrDtlBean oWflDocMstAttrDtlBean = oIt1.next(); if (!oWflDocMstAttrDtlBean.getStatus().equalsIgnoreCase("D")) checkMandatoryDtls(oWflDocMstAttrDtlBean, count, oErrorList); count++; } } else if (sScreenName.equalsIgnoreCase("WflDtlDocType")) { Iterator oIt1 = oDetailBeanArray.iterator(); int count = 1; while (oIt1.hasNext()) { WflDtlDocTypeDtlBean oWflDtlDocTypeDtlBean = oIt1.next(); if (!oWflDtlDocTypeDtlBean.getStatus().equalsIgnoreCase("D")) checkMandatoryDtlsDocType(oWflDtlDocTypeDtlBean, count, oErrorList); count++; } } reportError(oErrorList); } public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {} public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oErrorList = new ArrayList(); if (bHeaderDataChanged) if (sScreenName.equalsIgnoreCase("WFLDoctAttrDetail")) checkUniqueHeader((WflDocMstHdrBean)oBaseHeaderBean); if (bDetailDataChanged) if (!sScreenMode.equalsIgnoreCase("D")) { if (sScreenName.equalsIgnoreCase("WflWorkflowConditions")) { Iterator oIt1 = oDetailBeanArray.iterator(); checkUniqueMaterialDtl(oBaseHeaderBean.getHeaderPrimaryKey(), oDetailBeanArray, oErrorList); } if (sScreenName.equalsIgnoreCase("WflDtlDocType")) { Iterator oIt1 = oDetailBeanArray.iterator(); EnrgiseUtil.checkDuplicate(oDetailBeanArray, "txtDtlDocCode", "WFL.WFLDtlDocType.dtlDocCode", oErrorList, true); checkUniqueDocDtl(oBaseHeaderBean.getHeaderPrimaryKey(), oDetailBeanArray, oErrorList); } if (sScreenName.equalsIgnoreCase("WFLDoctAttrDetail")) { EnrgiseUtil.checkDuplicate(oDetailBeanArray, "txtAttrName", "WFL.WFLDocAttrDtl.attbName", oErrorList, true); checkUniqueDocAttrDtl(oBaseHeaderBean.getHeaderPrimaryKey(), oDetailBeanArray, oErrorList); } } reportError(oErrorList); } public void initializeBOImpl() { this.headerTable = "WFL_DOC_TYPE_MST"; } public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException { if (sScreenName.equalsIgnoreCase("WFLDoctAttrDetail")) { saveWflDocAttrDtls(sHeaderPrimaryKey, oDetailBeanArray); } else if (sScreenName.equalsIgnoreCase("WflWorkflowConditions")) { saveWflDocConditionsDtls(sHeaderPrimaryKey, oDetailBeanArray); } else if (sScreenName.equalsIgnoreCase("WflDtlDocType")) { saveWflDtlDocTypeDtls(sHeaderPrimaryKey, oDetailBeanArray); } } public RecordMetaInfo getWflDocTypeHdrMetaInfo(WflDocMstQVO oWflDocMstQVO) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, oWflDocMstQVO.getHeaderPrimaryKey())); oParameters.add(new DBObject(2, 2, -5)); oParameters.add(new DBObject(3, 2, 93)); oParameters.add(new DBObject(4, 2, 12)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetWFlDocTypeHdrMetaInfo(?,?,?,?,?,?)"); RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo(); DBObject oTimeObject = oOutArray.get(1); oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject()); DBObject oTotalRecord = oOutArray.get(0); oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue()); return oRecordMetaInfo; } public ArrayList getWflDocTypeHdrInfo(WflDocMstQVO oWflDocMstQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList oHeaderList = null; if (oWflDocMstQVO == null) oWflDocMstQVO = new WflDocMstQVO(); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, -5, new Long(lStartPosition))); oParameters.add(new DBObject(2, 1, -5, new Long(lLastPosition))); oParameters.add(new DBObject(3, 1, 12, oWflDocMstQVO.getHeaderPrimaryKey())); oParameters.add(new DBObject(4, 2, -10)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 12)); oParameters.add(new DBObject(7, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetWFlDocTypeHdrInfo(?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); ArrayList oList = (ArrayList)oOutObject.getObject(); if (oList.size() == 0) throw new EnrgiseApplicationException("wenrgise.workflow.norecordfound", "M"); QueryRow oRow = null; Iterator oIt = oList.iterator(); while (oIt.hasNext()) { if (count == 0) oHeaderList = new ArrayList(); count++; oRow = oIt.next(); WflDocMstHdrBean oWflDocMstHdrBean = new WflDocMstHdrBean(); oWflDocMstHdrBean.setHeaderPrimaryKey(oRow.get("ID").getString()); oWflDocMstHdrBean.setDocumentCode(oRow.get("doc_type_code").getString()); oWflDocMstHdrBean.setDocumentDesc(oRow.get("doc_type_desc").getString()); oWflDocMstHdrBean.setMaxAppLevel(oRow.get("max_aprooval_level").getString()); oHeaderList.add(oWflDocMstHdrBean); } return oHeaderList; } public RecordMetaInfo getWflDocTypeAttrDtlMetaInfo(String sPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, new String(sPrimaryKey))); oParameters.add(new DBObject(2, 2, -5)); oParameters.add(new DBObject(3, 2, 93)); oParameters.add(new DBObject(4, 2, 12)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetWFlDocTypeDtlMetaInfo(?,?,?,?,?,?)"); RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo(); DBObject oTotalRecord = oOutArray.get(0); oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue()); DBObject oTimeObject = oOutArray.get(1); oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject()); System.out.println(oRecordMetaInfo); return oRecordMetaInfo; } public ArrayList getWflDocTypeAttrDtlInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); QueryRow oRow = null; ArrayList oList = null; Iterator oIt = null; ArrayList oDtlList = new ArrayList(); ArrayList oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, new Long(lDetailFirstPosition))); oParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition))); oParameters.add(new DBObject(3, 1, 12, lPrimaryKey)); oParameters.add(new DBObject(4, 2, -10)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 12)); oParameters.add(new DBObject(7, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetWFlDocTypeDtlInfo(?,?,?,?,?,?,?)"); oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject(); oIt = oList.iterator(); while (oIt.hasNext()) { oRow = oIt.next(); WflDocMstAttrDtlBean oWflDocMstAttrDtlBean = new WflDocMstAttrDtlBean(); oWflDocMstAttrDtlBean.setDetailId(oRow.get("Id").getString()); oWflDocMstAttrDtlBean.setTxtAttrName(oRow.get("attr_name").getString()); oWflDocMstAttrDtlBean.setTxtType(oRow.get("attr_type").getString()); oWflDocMstAttrDtlBean.setTxtDesc(oRow.get("attr_desc").getString()); oWflDocMstAttrDtlBean.setTxtLovKey(oRow.get("attr_lov_key").getString()); oDtlList.add(oWflDocMstAttrDtlBean); } return oDtlList; } public RecordMetaInfo getWflDocTypeConditionsDtlMetaInfo(String sPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, new String(sPrimaryKey))); oParameters.add(new DBObject(2, 2, -5)); oParameters.add(new DBObject(3, 2, 93)); oParameters.add(new DBObject(4, 2, 12)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetWFlDocCondDtlMetaInfo(?,?,?,?,?,?)"); RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo(); DBObject oTotalRecord = oOutArray.get(0); oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue()); DBObject oTimeObject = oOutArray.get(1); oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject()); System.out.println(oRecordMetaInfo); return oRecordMetaInfo; } public ArrayList getWflDocTypeConditionsDtlInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); QueryRow oRow = null; ArrayList oList = null; Iterator oIt = null; ArrayList oDtlList = new ArrayList(); ArrayList oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, new Long(lDetailFirstPosition))); oParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition))); oParameters.add(new DBObject(3, 1, 12, lPrimaryKey)); oParameters.add(new DBObject(4, 2, -10)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 12)); oParameters.add(new DBObject(7, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetWFlDocCondDtlInfo(?,?,?,?,?,?,?)"); oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject(); oIt = oList.iterator(); while (oIt.hasNext()) { oRow = oIt.next(); WflDocMstConditionsDtlBean oWflDocMstConditionsDtlBean = new WflDocMstConditionsDtlBean(); oWflDocMstConditionsDtlBean.setDetailId(oRow.get("Id").getString()); oWflDocMstConditionsDtlBean.setDocTypeDtlDesc(oRow.get("condition_desc").getString()); oWflDocMstConditionsDtlBean.setConditionExpression(oRow.get("condition_expression").getString()); oDtlList.add(oWflDocMstConditionsDtlBean); } return oDtlList; } public RecordMetaInfo getDtlDocTypeMetaInfo(String sPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, new String(sPrimaryKey))); oParameters.add(new DBObject(2, 2, -5)); oParameters.add(new DBObject(3, 2, 93)); oParameters.add(new DBObject(4, 2, 12)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_GetDtlDocTypeMetaInfo(?,?,?,?,?,?)"); RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo(); DBObject oTotalRecord = oOutArray.get(0); oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue()); DBObject oTimeObject = oOutArray.get(1); oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject()); System.out.println(oRecordMetaInfo); return oRecordMetaInfo; } public ArrayList getDtlDocTypeInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); QueryRow oRow = null; ArrayList oList = null; Iterator oIt = null; ArrayList oDtlList = new ArrayList(); ArrayList oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, new Long(lDetailFirstPosition))); oParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition))); oParameters.add(new DBObject(3, 1, 12, lPrimaryKey)); oParameters.add(new DBObject(4, 2, -10)); oParameters.add(new DBObject(5, 2, 12)); oParameters.add(new DBObject(6, 2, 12)); oParameters.add(new DBObject(7, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_DtlDocTypeInfo(?,?,?,?,?,?,?)"); oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject(); oIt = oList.iterator(); while (oIt.hasNext()) { oRow = oIt.next(); WflDtlDocTypeDtlBean oWflDtlDocTypeDtlBean = new WflDtlDocTypeDtlBean(); oWflDtlDocTypeDtlBean.setDetailId(oRow.get("Id").getString()); oWflDtlDocTypeDtlBean.setTxtDtlDocCode(oRow.get("doc_dtl_code").getString()); oWflDtlDocTypeDtlBean.setTxtDtlDocDesc(oRow.get("doc_dtl_desc").getString()); oWflDtlDocTypeDtlBean.setTxtConditionId(oRow.get("condition_id").getString()); oWflDtlDocTypeDtlBean.setTxtPriority(oRow.get("priority").getString()); oWflDtlDocTypeDtlBean.setTxtExp(oRow.get("condition_expression").getString()); oWflDtlDocTypeDtlBean.setTxtConDesc(oRow.get("condition_desc").getString()); oWflDtlDocTypeDtlBean.setDisabbutCondDesc("true"); oDtlList.add(oWflDtlDocTypeDtlBean); } return oDtlList; } public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException { String returnString = null; ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); WflDocMstHdrBean oWflDocMstHdrBean = (WflDocMstHdrBean)oBaseHeaderBean; if (ScreenMode.equalsIgnoreCase("N")) { oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "N")); oParameters.add(new DBObject(2, 1, 12, null)); oParameters.add(new DBObject(3, 1, 12, oWflDocMstHdrBean.getDocumentCode())); oParameters.add(new DBObject(4, 1, 12, oWflDocMstHdrBean.getDocumentDesc())); oParameters.add(new DBObject(5, 1, 12, oWflDocMstHdrBean.getMaxAppLevel())); oParameters.add(new DBObject(6, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(9, 2, 12)); oParameters.add(new DBObject(10, 2, 12)); oParameters.add(new DBObject(11, 2, 12)); oParameters.add(new DBObject(12, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_UpsertWflDocTypeMstHdr(?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); returnString = (String)oOutObject.getObject(); } else if (ScreenMode.equalsIgnoreCase("U")) { oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "U")); oParameters.add(new DBObject(2, 1, 12, oWflDocMstHdrBean.getHeaderPrimaryKey())); oParameters.add(new DBObject(3, 1, 12, oWflDocMstHdrBean.getDocumentCode())); oParameters.add(new DBObject(4, 1, 12, oWflDocMstHdrBean.getDocumentDesc())); oParameters.add(new DBObject(5, 1, 12, oWflDocMstHdrBean.getMaxAppLevel())); oParameters.add(new DBObject(6, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(9, 2, 12)); oParameters.add(new DBObject(10, 2, 12)); oParameters.add(new DBObject(11, 2, 12)); oParameters.add(new DBObject(12, 2, 12)); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_UpsertWflDocTypeMstHdr(?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); returnString = (String)oOutObject.getObject(); } else if (ScreenMode.equalsIgnoreCase("D")) { oParameters.add(new DBObject(1, 1, 12, oWflDocMstHdrBean.getHeaderPrimaryKey())); ArrayList oOutArray = oBean.callProc(oParameters, "WflDocumentMst.proc_DeleteWflDocTypeMstHdr(?)"); } return returnString; } private void saveWflDocAttrDtls(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException { boolean bInsert = false; boolean bUpdate = false; boolean bDelete = false; ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = null; DBUtilitiesBean oBean1 = null; Iterator oIt = oDetailBeanArray.iterator(); while (oIt.hasNext()) { WflDocMstAttrDtlBean oWflDocMstAttrDtlBean = oIt.next(); if (oWflDocMstAttrDtlBean.getStatus().equals("N")) { if (!bInsert) { oBean = new DBUtilitiesBean(); oBean.createBatch("WflDocumentMst.proc_UpsertWflDocMstAttrDtl(?,?,?,?,?,?,?,?,?,?)"); bInsert = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "N")); oParameters.add(new DBObject(2, 1, 12, null)); oParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey)); oParameters.add(new DBObject(4, 1, 12, oWflDocMstAttrDtlBean.getTxtAttrName())); oParameters.add(new DBObject(5, 1, 12, oWflDocMstAttrDtlBean.getTxtDesc())); oParameters.add(new DBObject(6, 1, 12, oWflDocMstAttrDtlBean.getTxtType())); oParameters.add(new DBObject(7, 1, 12, oWflDocMstAttrDtlBean.getTxtLovKey())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(10, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(oParameters); continue; } if (oWflDocMstAttrDtlBean.getStatus().equals("U")) { if (!bUpdate) { oBean = new DBUtilitiesBean(); oBean.createBatch("WflDocumentMst.proc_UpsertWflDocMstAttrDtl(?,?,?,?,?,?,?,?,?,?)"); bUpdate = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "U")); oParameters.add(new DBObject(2, 1, 12, oWflDocMstAttrDtlBean.getDetailId())); oParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey)); oParameters.add(new DBObject(4, 1, 12, oWflDocMstAttrDtlBean.getTxtAttrName())); oParameters.add(new DBObject(5, 1, 12, oWflDocMstAttrDtlBean.getTxtDesc())); oParameters.add(new DBObject(6, 1, 12, oWflDocMstAttrDtlBean.getTxtType())); oParameters.add(new DBObject(7, 1, 12, oWflDocMstAttrDtlBean.getTxtLovKey())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(10, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(oParameters); continue; } if (oWflDocMstAttrDtlBean.getStatus().equals("D")) { if (!bDelete) { oBean1 = new DBUtilitiesBean(); oBean1.createBatch("WflDocumentMst.proc_DeleteWflDocMstAttrDtl(?)"); bDelete = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, oWflDocMstAttrDtlBean.getDetailId())); oBean1.addToBatch(oParameters); } } if (bInsert) oBean.executeBatch(); if (bUpdate) oBean.executeBatch(); if (bDelete) oBean1.executeBatch(); } private void saveWflDocConditionsDtls(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException { boolean bInsert = false; boolean bUpdate = false; boolean bDelete = false; ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = null; DBUtilitiesBean oBean1 = null; Iterator oIt = oDetailBeanArray.iterator(); while (oIt.hasNext()) { WflDocMstConditionsDtlBean oWflDocMstConditionsDtlBean = oIt.next(); if (oWflDocMstConditionsDtlBean.getStatus().equals("N")) { if (!bInsert) { oBean = new DBUtilitiesBean(); oBean.createBatch("WflDocumentMst.proc_UpsertWflDocMstCondDtl(?,?,?,?,?,?,?,?)"); bInsert = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "N")); oParameters.add(new DBObject(2, 1, 12, null)); oParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey)); oParameters.add(new DBObject(4, 1, 12, oWflDocMstConditionsDtlBean.getDocTypeDtlDesc())); oParameters.add(new DBObject(5, 1, 12, oWflDocMstConditionsDtlBean.getConditionExpression())); oParameters.add(new DBObject(6, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(oParameters); continue; } if (oWflDocMstConditionsDtlBean.getStatus().equals("U")) { if (!bUpdate) { oBean = new DBUtilitiesBean(); oBean.createBatch("WflDocumentMst.proc_UpsertWflDocMstCondDtl(?,?,?,?,?,?,?,?)"); bUpdate = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "U")); oParameters.add(new DBObject(2, 1, 12, oWflDocMstConditionsDtlBean.getDetailId())); oParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey)); oParameters.add(new DBObject(4, 1, 12, oWflDocMstConditionsDtlBean.getDocTypeDtlDesc())); oParameters.add(new DBObject(5, 1, 12, oWflDocMstConditionsDtlBean.getConditionExpression())); oParameters.add(new DBObject(6, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(oParameters); continue; } if (oWflDocMstConditionsDtlBean.getStatus().equals("D")) { if (!bDelete) { oBean1 = new DBUtilitiesBean(); oBean1.createBatch("WflDocumentMst.proc_DeleteWflDocMstCondDtl(?)"); bDelete = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, oWflDocMstConditionsDtlBean.getDetailId())); oBean1.addToBatch(oParameters); } } if (bInsert) oBean.executeBatch(); if (bUpdate) oBean.executeBatch(); if (bDelete) oBean1.executeBatch(); } private void saveWflDtlDocTypeDtls(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException { boolean bInsert = false; boolean bUpdate = false; boolean bDelete = false; ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = null; DBUtilitiesBean oBean1 = null; Iterator oIt = oDetailBeanArray.iterator(); while (oIt.hasNext()) { WflDtlDocTypeDtlBean oWflDtlDocTypeDtlBean = oIt.next(); if (oWflDtlDocTypeDtlBean.getStatus().equals("N")) { if (!bInsert) { oBean = new DBUtilitiesBean(); oBean.createBatch("WflDocumentMst.proc_UpsertWflDtlDocTypeDtls(?,?,?,?,?,?,?,?,?)"); bInsert = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "N")); oParameters.add(new DBObject(2, 1, 12, null)); oParameters.add(new DBObject(3, 1, 12, oWflDtlDocTypeDtlBean.getTxtDtlDocCode())); oParameters.add(new DBObject(4, 1, 12, oWflDtlDocTypeDtlBean.getTxtDtlDocDesc())); oParameters.add(new DBObject(5, 1, 12, oWflDtlDocTypeDtlBean.getTxtConditionId())); oParameters.add(new DBObject(6, 1, 12, oWflDtlDocTypeDtlBean.getTxtPriority())); oParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(oParameters); continue; } if (oWflDtlDocTypeDtlBean.getStatus().equals("U")) { if (!bUpdate) { oBean = new DBUtilitiesBean(); oBean.createBatch("WflDocumentMst.proc_UpsertWflDtlDocTypeDtls(?,?,?,?,?,?,?,?,?)"); bUpdate = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "U")); oParameters.add(new DBObject(2, 1, 12, oWflDtlDocTypeDtlBean.getDetailId())); oParameters.add(new DBObject(3, 1, 12, oWflDtlDocTypeDtlBean.getTxtDtlDocCode())); oParameters.add(new DBObject(4, 1, 12, oWflDtlDocTypeDtlBean.getTxtDtlDocDesc())); oParameters.add(new DBObject(5, 1, 12, oWflDtlDocTypeDtlBean.getTxtConditionId())); oParameters.add(new DBObject(6, 1, 12, oWflDtlDocTypeDtlBean.getTxtPriority())); oParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getUserId())); oParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId())); oParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(oParameters); continue; } if (oWflDtlDocTypeDtlBean.getStatus().equals("D")) { if (!bDelete) { oBean1 = new DBUtilitiesBean(); oBean1.createBatch("WflDocumentMst.proc_DeleteWflDtlDocTypeDtls(?)"); bDelete = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, oWflDtlDocTypeDtlBean.getDetailId())); oBean1.addToBatch(oParameters); } } if (bInsert) oBean.executeBatch(); if (bUpdate) oBean.executeBatch(); if (bDelete) oBean1.executeBatch(); } public LovVO getWflDocCodeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { String sQuery = "Select distinct wdtm.id as Id,wdtm.doc_type_code as doc_type_code,wdtm.DOC_TYPE_DESC as DOC_TYPE_DESC,wdtm.max_aprooval_level as max_aprooval_level from wfl_doc_type_mst wdtm"; if (oLovQueryVO.getSearchField1() != null) sQuery = String.valueOf(String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" where upper(wdtm.doc_type_code) LIKE upper('%"))).concat(String.valueOf(oLovQueryVO.getSearchField1()))).concat(String.valueOf("%') ")); System.out.println(sQuery); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oList = oBean.executeQuery(sQuery); LovVO oLovVO = new LovVO(); ArrayList oHeaderList = new ArrayList(); oHeaderList.add(""); oHeaderList.add("WFL.WFLDocAttrDtl.documentCode"); oHeaderList.add("WFL.WFLDocAttrDtl.documentDesc"); oHeaderList.add("WFL.WFLDocAttrDtl.maxAppLevel"); oLovVO.setHeaderList(oHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; QueryRow oRow = null; Iterator oIt = oList.iterator(); while (oIt.hasNext()) { if (count == 0) oList = new ArrayList(); count++; oRow = oIt.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("Id").getString()); oLOVBean.setDetailField2(oRow.get("doc_type_code").getString()); oLOVBean.setDetailField3(oRow.get("DOC_TYPE_DESC").getString()); oLOVBean.setDetailField4(oRow.get("max_aprooval_level").getString()); oList.add(oLOVBean); } oLovVO.setDetailList(oList); return oLovVO; } public LovVO getWflDtlDocCodeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { String sQuery = String.valueOf("select wc.id,wc.condition_desc,wc.condition_expression from wfl_condition wc where wc.doc_type_hdr_id=").concat(String.valueOf(oLovQueryVO.getProperty("documentId"))); if (oLovQueryVO.getSearchField1() != null) sQuery = String.valueOf(String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and upper(wc.condition_desc) LIKE upper('%"))).concat(String.valueOf(oLovQueryVO.getSearchField1()))).concat(String.valueOf("%') ")); System.out.println(sQuery); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oList = oBean.executeQuery(sQuery); LovVO oLovVO = new LovVO(); ArrayList oHeaderList = new ArrayList(); oHeaderList.add(""); oHeaderList.add("WFL.WFLDtlDocType.conditionDesc"); oHeaderList.add("WFL.WFLDtlDocType.exp"); oLovVO.setHeaderList(oHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; QueryRow oRow = null; Iterator oIt = oList.iterator(); while (oIt.hasNext()) { if (count == 0) oList = new ArrayList(); count++; oRow = oIt.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("id").getString()); oLOVBean.setDetailField2(oRow.get("condition_desc").getString()); oLOVBean.setDetailField3(oRow.get("condition_expression").getString()); oList.add(oLOVBean); } oLovVO.setDetailList(oList); return oLovVO; } private void checkMandatoryDtls(WflDocMstConditionsDtlBean oWflDocMstConditionsDtlBean, int count, ArrayList oDetailBeanArray) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList oList = new ArrayList(); if (!EnrgiseUtil.checkString(oWflDocMstConditionsDtlBean.getDocTypeDtlDesc())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("wfl.WorkFlowConditions.docDtlDesc"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } if (!EnrgiseUtil.checkString(oWflDocMstConditionsDtlBean.getConditionExpression())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("wfl.WorkFlowConditions.condExp"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } reportError(oList); } private void checkMandatoryHdr(WflDocMstHdrBean oWflDocMstHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList oList = new ArrayList(); if (!EnrgiseUtil.checkString(oWflDocMstHdrBean.getDocumentCode())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDocAttrDtl.documentCode"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryfieldmissing", oParam, "E")); } if (!EnrgiseUtil.checkString(oWflDocMstHdrBean.getDocumentDesc())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDocAttrDtl.documentDesc"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryfieldmissing", oParam, "E")); } reportError(oList); } private void checkMandatoryDtls(WflDocMstAttrDtlBean oWflDocMstAttrDtlBean, int count, ArrayList oDetailBeanArray) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList oList = new ArrayList(); if (!EnrgiseUtil.checkString(oWflDocMstAttrDtlBean.getTxtAttrName())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDocAttrDtl.attbName"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } if (!EnrgiseUtil.checkString(oWflDocMstAttrDtlBean.getTxtType())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDocAttrDtl.type"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } reportError(oList); } private void checkNumericFields(WflDocMstHdrBean oWflDocMstHdrBean, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { if (!EnrgiseUtil.checkNumber(oWflDocMstHdrBean.getMaxAppLevel(), 10, 4, "P")) { MessageKey oMessageKey = new MessageKey("WFL.WFLDocAttrDtl.maxAppLevel"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.invalidNumber", oParams)); } } private void checkUniqueMaterialDtl(String sHeaderPrimaryKey, ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { Iterator oIt1 = oDetailBeanArray.iterator(); int rowCount = 1; while (oIt1.hasNext()) { WflDocMstConditionsDtlBean oWflDocMstConditionsDtlBean = oIt1.next(); if (!EnrgiseUtil.checkString(oWflDocMstConditionsDtlBean.getDetailId())) { String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(" Select ID as ID from wfl_condition where CONDITION_DESC= '").concat(String.valueOf(oWflDocMstConditionsDtlBean.getDocTypeDtlDesc()))).concat(String.valueOf("' and CONDITION_EXPRESSION='"))).concat(String.valueOf(oWflDocMstConditionsDtlBean.getConditionExpression()))).concat(String.valueOf("' ")); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oList = oBean.executeQuery(sQuery); Iterator oIt = oList.iterator(); if (oIt.hasNext()) { ArrayList oParams = new ArrayList(); MessageKey oMessageKey = new MessageKey("wfl.WorkFlowConditions.docDtlDesc"); MessageKey oMessageKey1 = new MessageKey("wfl.WorkFlowConditions.condExp"); oParams.add(oMessageKey); oParams.add(oMessageKey1); oParams.add(new Integer(rowCount)); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.workflow.detail.UniqueKeyConstraint", oParams)); } } rowCount++; } } private void checkMandatoryDtlsDocType(WflDtlDocTypeDtlBean oWflDtlDocTypeDtlBean, int count, ArrayList oDetailBeanArray) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList oList = new ArrayList(); if (!EnrgiseUtil.checkString(oWflDtlDocTypeDtlBean.getTxtDtlDocCode())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDtlDocType.dtlDocCode"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } if (!EnrgiseUtil.checkString(oWflDtlDocTypeDtlBean.getTxtDtlDocDesc())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDtlDocType.dtlDocDesc"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } if (!EnrgiseUtil.checkString(oWflDtlDocTypeDtlBean.getTxtConDesc())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDtlDocType.conditionDesc"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } if (!EnrgiseUtil.checkString(oWflDtlDocTypeDtlBean.getTxtExp())) { ArrayList oParam = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDtlDocType.exp"); oParam.add(oMessageKey); oList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryfieldmissing", oParam, "E")); } reportError(oList); } private void checkUniqueDocDtl(String sHeaderPrimaryKey, ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { Iterator oIt1 = oDetailBeanArray.iterator(); int rowCount = 1; while (oIt1.hasNext()) { WflDtlDocTypeDtlBean oWflDtlDocTypeDtlBean = oIt1.next(); if (!EnrgiseUtil.checkString(oWflDtlDocTypeDtlBean.getTxtDtlDocCode())) { String sQuery = String.valueOf(String.valueOf(String.valueOf(" select a.id as Id from wfl_doc_type_dtl a where a.id= ").concat(String.valueOf(sHeaderPrimaryKey))).concat(String.valueOf(" and a.doc_dtl_code="))).concat(String.valueOf(oWflDtlDocTypeDtlBean.getTxtDtlDocCode())); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oList = oBean.executeQuery(sQuery); Iterator oIt = oList.iterator(); if (oIt.hasNext()) { ArrayList oParams = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDtlDocType.dtlDocCode"); oParams.add(oMessageKey); oParams.add(new Integer(rowCount)); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.workflow.detail.UniqueKeyConstraint", oParams)); } } rowCount++; } } private void checkUniqueDocAttrDtl(String sHeaderPrimaryKey, ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { int rowCount = 1; Iterator oIt1 = oDetailBeanArray.iterator(); while (oIt1.hasNext()) { WflDocMstAttrDtlBean oWflDocMstAttrDtlBean = oIt1.next(); String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf("select t.id from wfl_doc_attributes t where t.doc_type_hdr_id=").concat(String.valueOf(sHeaderPrimaryKey))).concat(String.valueOf(" and t.attr_name='"))).concat(String.valueOf(oWflDocMstAttrDtlBean.getTxtAttrName()))).concat(String.valueOf("'")); System.out.println(sQuery); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oList = oBean.executeQuery(sQuery); Iterator oIt = oList.iterator(); while (oIt.hasNext()) { QueryRow oRow = oIt.next(); if (!oRow.get("ID").getString().equalsIgnoreCase(oWflDocMstAttrDtlBean.getDetailId())) { ArrayList oParams = new ArrayList(); MessageKey oMessageKey = new MessageKey("WFL.WFLDtlDocType.dtlDocCode"); oParams.add(oMessageKey); oParams.add(new Integer(rowCount)); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.workflow.detail.UniqueKeyConstraint", oParams)); } } rowCount++; } } private void checkUniqueHeader(WflDocMstHdrBean oWflDocMstHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { String sQuery = String.valueOf(String.valueOf(" select t.id from wfl_doc_type_mst t where t.doc_type_code='").concat(String.valueOf(oWflDocMstHdrBean.getDocumentCode()))).concat(String.valueOf("'")); System.out.println(sQuery); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oList = oBean.executeQuery(sQuery); Iterator oIt = oList.iterator(); if (oIt.hasNext()) { QueryRow oRow = oIt.next(); if (!oRow.get("ID").getString().equalsIgnoreCase(oWflDocMstHdrBean.getHeaderPrimaryKey())) throw new EnrgiseApplicationException("wenrgise.common.header.uniqueConstraintViolated", "E"); } } }