package wenrgise.hrms.ejb.business; import java.rmi.RemoteException; import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import javax.ejb.CreateException; import javax.ejb.RemoveException; import wenrgise.common.bean.BaseHeaderBean; import wenrgise.common.bean.LOVBean; import wenrgise.common.ejb.business.HrmCommonBO; import wenrgise.common.exception.EnrgiseApplicationException; import wenrgise.common.exception.EnrgiseMessageKeyException; import wenrgise.common.exception.EnrgiseSystemException; import wenrgise.common.utility.DateUtility; import wenrgise.common.utility.EnrgiseUtil; import wenrgise.common.utility.MessageKey; import wenrgise.common.utility.RecordMetaInfo; import wenrgise.common.utility.UserInfo; import wenrgise.common.utility.WorkFlowServiceLocator; import wenrgise.common.vo.BaseHeaderVO; import wenrgise.common.vo.LovQueryVO; import wenrgise.common.vo.LovVO; import wenrgise.ejb.common.helper.DBObject; import wenrgise.ejb.common.helper.QueryRow; import wenrgise.ejb.common.helper.QueryValue; import wenrgise.ejb.common.utility.DBUtilitiesBean; import wenrgise.hrms.bean.HrmTransCnclOrderSingEmpHdrBean; import wenrgise.hrms.vo.HrmATDTransCnclOrderSingleEmpQVO; import wenrgise.workflow.bean.WflAuthorizationBean; import wenrgise.workflow.core.WflDocumentInfo; import wenrgise.workflow.core.WflResource; import wenrgise.workflow.core.WflSite; import wenrgise.workflow.core.WflStatus; import wenrgise.workflow.core.impl.WflDocumentInfoImpl; import wenrgise.workflow.core.impl.WflResourceImpl; import wenrgise.workflow.core.impl.WflSiteImpl; import wenrgise.workflow.ejb.facade.WorkFlowFacade; import wenrgise.workflow.ejb.facade.WorkFlowFacadeHome; public class HrmATDTransCnclOrderForSingleEmpBO extends HrmBaseBO { public HrmATDTransCnclOrderForSingleEmpBO() {} public HrmATDTransCnclOrderForSingleEmpBO(UserInfo oUserInfo) { super(oUserInfo); } public LovVO getHrmTrnCnclOrderApplnNoLOVQdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("appNoId"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.appNo"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.appDate"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.employeeName"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.transOrderNo"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.transOrderDate"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.transEffectDate"); oLovVO.setHeaderList(arylstHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int iCount = 0; String employeeId = null; ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getProperty("employeeId") != null) { employeeId = oLovQueryVO.getProperty("employeeId"); System.out.println(employeeId); } arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1)); arylstParameters.add(new DBObject(2, 1, 12, employeeId)); arylstParameters.add(new DBObject(3, 2, -10)); arylstParameters.add(new DBObject(4, 2, 12)); arylstParameters.add(new DBObject(5, 2, 12)); arylstParameters.add(new DBObject(6, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetTrnsCnOrdAppLOVQdata(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = arylstList.iterator(); while (iter.hasNext()) { if (iCount == 0) arylstList = new ArrayList(); iCount++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("APPLICATION_NO").getString()); oLOVBean.setDetailField3(EnrgiseUtil.convertToString(oRow.get("APPLICATION_DATE").getDate())); oLOVBean.setDetailField4(oRow.get("EMPNAME").getString()); oLOVBean.setDetailField5(oRow.get("TRANSFER_ORDER_NO").getString()); oLOVBean.setDetailField6(EnrgiseUtil.convertToString(oRow.get("TRANSFER_ORDER_DATE").getDate())); oLOVBean.setDetailField7(EnrgiseUtil.convertToString(oRow.get("TRANSFER_EFFECT_DATE").getDate())); arylstList.add(oLOVBean); } oLovVO.setDetailList(arylstList); return oLovVO; } public LovVO getHrmTrnCnclOrderApplnNoLOVIdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("appNoId"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.appNo"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.appDate"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.employeeName"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.transOrderNo"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.transOrderDate"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.transEffectDate"); oLovVO.setHeaderList(arylstHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int iCount = 0; String employeeId = null; ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getProperty("employeeId") != null) { employeeId = oLovQueryVO.getProperty("employeeId"); System.out.println(employeeId); } arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1)); arylstParameters.add(new DBObject(2, 1, 12, employeeId)); arylstParameters.add(new DBObject(3, 2, -10)); arylstParameters.add(new DBObject(4, 2, 12)); arylstParameters.add(new DBObject(5, 2, 12)); arylstParameters.add(new DBObject(6, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetTrnsCnOrdAppLOVIdata(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = arylstList.iterator(); while (iter.hasNext()) { if (iCount == 0) arylstList = new ArrayList(); iCount++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("APPLICATION_NO").getString()); oLOVBean.setDetailField3(EnrgiseUtil.convertToString(oRow.get("APPLICATION_DATE").getDate())); oLOVBean.setDetailField4(oRow.get("EMPNAME").getString()); oLOVBean.setDetailField5(oRow.get("TRANSFER_ORDER_NO").getString()); oLOVBean.setDetailField6(EnrgiseUtil.convertToString(oRow.get("TRANSFER_ORDER_DATE").getDate())); oLOVBean.setDetailField7(EnrgiseUtil.convertToString(oRow.get("TRANSFER_EFFECT_DATE").getDate())); arylstList.add(oLOVBean); } arylstList = checkLOVConstraint(arylstList); oLovVO.setDetailList(arylstList); return oLovVO; } public LovVO getHrmTrnCnclOrderNoLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("orderId"); arylstHeaderList.add("hrm.HrmATDTransCnclOrderForSingleEmp.orderNo"); oLovVO.setHeaderList(arylstHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int iCount = 0; ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1)); arylstParameters.add(new DBObject(2, 2, -10)); arylstParameters.add(new DBObject(3, 2, 12)); arylstParameters.add(new DBObject(4, 2, 12)); arylstParameters.add(new DBObject(5, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnsCnclOrdLOVdata(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = arylstList.iterator(); while (iter.hasNext()) { if (iCount == 0) arylstList = new ArrayList(); iCount++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("ORDER_NO").getString()); arylstList.add(oLOVBean); } oLovVO.setDetailList(arylstList); return oLovVO; } public RecordMetaInfo getHrmEmpTransCnclOrderHdrMetaInfo(HrmATDTransCnclOrderSingleEmpQVO oHrmATDTransCnclOrderSingleEmpQVO) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int iCount = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); if (EnrgiseUtil.checkString(oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey())) { String[] sPrimaryKey = oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey().split(","); System.out.println(sPrimaryKey[0]); System.out.println(sPrimaryKey[1]); oHrmATDTransCnclOrderSingleEmpQVO.setHeaderPrimaryKey(sPrimaryKey[0]); oHrmATDTransCnclOrderSingleEmpQVO.setHeaderPrimaryKey1(sPrimaryKey[1]); } arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey())); arylstParameters.add(new DBObject(2, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey1())); arylstParameters.add(new DBObject(3, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getOrderNo())); arylstParameters.add(new DBObject(4, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getAppNo())); arylstParameters.add(new DBObject(5, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getEmployeeId())); arylstParameters.add(new DBObject(6, 2, -5)); arylstParameters.add(new DBObject(7, 2, 93)); arylstParameters.add(new DBObject(8, 2, 12)); arylstParameters.add(new DBObject(9, 2, 12)); arylstParameters.add(new DBObject(10, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.proc_HrEmpTransCnclOrdHdrCount(?,?,?,?,?,?,?,?,?,?)"); RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo(); DBObject oTimeObject = arylstOutArray.get(1); oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject()); DBObject oTotalRecord = arylstOutArray.get(0); oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue()); return oRecordMetaInfo; } public ArrayList getHrmEmpTransCnclOrderHeaderInfo(HrmATDTransCnclOrderSingleEmpQVO oHrmATDTransCnclOrderSingleEmpQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int iCount = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList arylstHeaderList = null; if (oHrmATDTransCnclOrderSingleEmpQVO == null) oHrmATDTransCnclOrderSingleEmpQVO = new HrmATDTransCnclOrderSingleEmpQVO(); if (EnrgiseUtil.checkString(oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey())) { String[] sPrimaryKey = oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey().split(","); System.out.println(sPrimaryKey[0]); System.out.println(sPrimaryKey[1]); oHrmATDTransCnclOrderSingleEmpQVO.setHeaderPrimaryKey(sPrimaryKey[0]); oHrmATDTransCnclOrderSingleEmpQVO.setHeaderPrimaryKey1(sPrimaryKey[1]); } arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, -5, new Long(lStartPosition))); arylstParameters.add(new DBObject(2, 1, -5, new Long(lLastPosition))); arylstParameters.add(new DBObject(3, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey())); arylstParameters.add(new DBObject(4, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getHeaderPrimaryKey1())); arylstParameters.add(new DBObject(5, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getOrderNo())); arylstParameters.add(new DBObject(6, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getAppNo())); arylstParameters.add(new DBObject(7, 1, 12, oHrmATDTransCnclOrderSingleEmpQVO.getEmployeeId())); arylstParameters.add(new DBObject(8, 2, -10)); arylstParameters.add(new DBObject(9, 2, 12)); arylstParameters.add(new DBObject(10, 2, 12)); arylstParameters.add(new DBObject(11, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.proc_GetHrEmpTransCnclOrderHdr(?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); if (arylstList.size() == 0) throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); QueryRow oRow = null; HashMap oColumns = null; Iterator oIt = arylstList.iterator(); while (oIt.hasNext()) { if (iCount == 0) arylstHeaderList = new ArrayList(); iCount++; oRow = oIt.next(); HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = new HrmTransCnclOrderSingEmpHdrBean(); oHrmTransCnclOrderSingEmpHdrBean.setAppNoId(oRow.get("APP_ID").getString()); oHrmTransCnclOrderSingEmpHdrBean.setAppNo(oRow.get("APPLICATION_NO").getString()); oHrmTransCnclOrderSingEmpHdrBean.setAppDate(EnrgiseUtil.convertToString(oRow.get("APPLICATION_DATE").getDate())); oHrmTransCnclOrderSingEmpHdrBean.setOrderNo(oRow.get("ORDER_NO").getString()); oHrmTransCnclOrderSingEmpHdrBean.setOrderDate(EnrgiseUtil.convertToString(oRow.get("ORDER_DATE").getDate())); oHrmTransCnclOrderSingEmpHdrBean.setHeaderPrimaryKey(oRow.get("CNCL_ORDER_HDR_ID").getString()); oHrmTransCnclOrderSingEmpHdrBean.setGeneratedBy(oRow.get("SELF_OFFICE_FLAG").getString()); oHrmTransCnclOrderSingEmpHdrBean.setCancDefFlag(oRow.get("CANCEL_DEFER_FLAG").getString()); oHrmTransCnclOrderSingEmpHdrBean.setCancStatus(oRow.get("APPROVED_FLAG").getString()); oHrmTransCnclOrderSingEmpHdrBean.setDefDate(EnrgiseUtil.convertToString(oRow.get("DEFER_DATE").getDate())); oHrmTransCnclOrderSingEmpHdrBean.setHeaderPrimaryKey1(oRow.get("CNCL_ORDER_DTL_ID").getString()); oHrmTransCnclOrderSingEmpHdrBean.setDefPeriod(oRow.get("DEFER_PERIOD").getString()); oHrmTransCnclOrderSingEmpHdrBean.setEmployeeName(oRow.get("EMPNAME").getString()); oHrmTransCnclOrderSingEmpHdrBean.setTransOrderNo(oRow.get("TRANSFER_ORDER_NO").getString()); oHrmTransCnclOrderSingEmpHdrBean.setTransOrderDate(EnrgiseUtil.convertToString(oRow.get("TRANSFER_ORDER_DATE").getDate())); oHrmTransCnclOrderSingEmpHdrBean.setTransEffectDate(EnrgiseUtil.convertToString(oRow.get("TRANSFER_EFFECT_DATE").getDate())); oHrmTransCnclOrderSingEmpHdrBean.setApproverNoId(oRow.get("APPROVER_ID").getString()); oHrmTransCnclOrderSingEmpHdrBean.setApproverName(oRow.get("APPROVER_NAME").getString()); arylstHeaderList.add(oHrmTransCnclOrderSingEmpHdrBean); } return arylstHeaderList; } public void initializeBOImpl() { this.headerTable = "HRM_EMP_TRANS_ORDER_HDR"; } public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {} public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {} public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException { String returnString = null; ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); DateUtility d = new DateUtility(); String defPeriod = null; String defDate = null; HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = (HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean; if (ScreenMode.equalsIgnoreCase("N")) { if (EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getDefDate())) oHrmTransCnclOrderSingEmpHdrBean.setDefPeriod(defPeriod); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, "N")); arylstParameters.add(new DBObject(2, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getOrderNo())); arylstParameters.add(new DBObject(3, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransCnclOrderSingEmpHdrBean.getOrderDate()))); arylstParameters.add(new DBObject(4, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getGeneratedBy())); arylstParameters.add(new DBObject(5, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getCancDefFlag())); arylstParameters.add(new DBObject(6, 1, 12, "A")); arylstParameters.add(new DBObject(7, 1, 12, null)); arylstParameters.add(new DBObject(8, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getAppNoId())); arylstParameters.add(new DBObject(9, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getDefPeriod())); arylstParameters.add(new DBObject(10, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransCnclOrderSingEmpHdrBean.getDefDate()))); arylstParameters.add(new DBObject(11, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransCnclOrderSingEmpHdrBean.getTransEffectDate()))); arylstParameters.add(new DBObject(12, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getApproverNoId())); arylstParameters.add(new DBObject(13, 1, 12, this.oUserInfo.getUserTypeId())); arylstParameters.add(new DBObject(14, 1, 12, this.oUserInfo.getSiteId())); arylstParameters.add(new DBObject(15, 1, 12, null)); arylstParameters.add(new DBObject(16, 1, 12, null)); arylstParameters.add(new DBObject(17, 2, 12)); arylstParameters.add(new DBObject(18, 2, 12)); arylstParameters.add(new DBObject(19, 2, 12)); arylstParameters.add(new DBObject(20, 2, 12)); arylstParameters.add(new DBObject(21, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.proc_UpsertHrEmpTrnsCnclorder(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); String String1 = (String)oOutObject.getObject(); System.out.println(String1); DBObject oOutObject1 = arylstOutArray.get(1); String String2 = (String)oOutObject1.getObject(); System.out.println(String2); returnString = String.valueOf(String.valueOf(String1).concat(String.valueOf(","))).concat(String.valueOf(String2)); System.out.println(returnString); } else if (ScreenMode.equalsIgnoreCase("U")) { arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, "U")); arylstParameters.add(new DBObject(2, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getOrderNo())); arylstParameters.add(new DBObject(3, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransCnclOrderSingEmpHdrBean.getOrderDate()))); arylstParameters.add(new DBObject(4, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getGeneratedBy())); arylstParameters.add(new DBObject(5, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getCancDefFlag())); arylstParameters.add(new DBObject(6, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getCancStatus())); arylstParameters.add(new DBObject(7, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey())); arylstParameters.add(new DBObject(8, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getAppNoId())); arylstParameters.add(new DBObject(9, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getDefPeriod())); arylstParameters.add(new DBObject(10, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransCnclOrderSingEmpHdrBean.getDefDate()))); arylstParameters.add(new DBObject(11, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransCnclOrderSingEmpHdrBean.getTransEffectDate()))); arylstParameters.add(new DBObject(12, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getApproverNoId())); arylstParameters.add(new DBObject(13, 1, 12, this.oUserInfo.getUserTypeId())); arylstParameters.add(new DBObject(14, 1, 12, this.oUserInfo.getSiteId())); arylstParameters.add(new DBObject(15, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey())); arylstParameters.add(new DBObject(16, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey1())); arylstParameters.add(new DBObject(17, 2, 12)); arylstParameters.add(new DBObject(18, 2, 12)); arylstParameters.add(new DBObject(19, 2, 12)); arylstParameters.add(new DBObject(20, 2, 12)); arylstParameters.add(new DBObject(21, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.proc_UpsertHrEmpTrnsCnclorder(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); String String1 = (String)oOutObject.getObject(); System.out.println(String1); DBObject oOutObject1 = arylstOutArray.get(1); String String2 = (String)oOutObject1.getObject(); System.out.println(String2); returnString = String.valueOf(String.valueOf(String1).concat(String.valueOf(","))).concat(String.valueOf(String2)); System.out.println(returnString); } else if (ScreenMode.equalsIgnoreCase("D")) { HrmCommonBO oCommonBO = new HrmCommonBO(); oCommonBO.deleteChildDetailRec("HRM_EMP_TRNS_CNCL_ODR_DTL", "TRANS_CNCL_ORDER_HDR_ID", oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey(), null); arylstParameters.add(new DBObject(1, 1, 12, oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey())); arylstParameters.add(new DBObject(2, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.proc_DelHrTrnsCnclOrdHdr(?,?)"); DBObject oOutObject = arylstOutArray.get(0); returnString = null; } return returnString; } public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstErrorList = new ArrayList(); if (bHeaderDataChanged) if (!sScreenMode.equalsIgnoreCase("D")) checkMandatoryHeader((HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean); reportError(arylstErrorList); } private void checkMandatoryHeader(HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oErrorList = new ArrayList(); ArrayList oParams = new ArrayList(); if (!EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getAppNo())) { MessageKey oMessageKey = new MessageKey("hrm.HrmTransCnclOrder.appNo"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getOrderNo())) { MessageKey oMessageKey = new MessageKey("hrm.HrmTransCnclOrder.orderNo"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getOrderDate())) { MessageKey oMessageKey = new MessageKey("hrm.HrmTransCnclOrder.orderDate"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getApproverNoId())) { MessageKey oMessageKey = new MessageKey("hrm.HrmATDTransOrderForSingleEmp.approvedBy"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } reportError(oErrorList); } private void checkHeaderFields(HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList arylstList1 = new ArrayList(); if (oHrmTransCnclOrderSingEmpHdrBean.getCancDefFlag().equalsIgnoreCase("D")) if (!EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getDefDate())) arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransCnclOrder.defer.value")); reportError(arylstList1); } public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList arylstParam6, boolean param7, Timestamp param8) {} public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstErrorList = new ArrayList(); HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = (HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean; if (bHeaderDataChanged) { if (!sScreenMode.equalsIgnoreCase("D")) { checkUniqueHeader((HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean); checkDatesConstraint((HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean, arylstErrorList); } if (sScreenMode.equalsIgnoreCase("D")) { HrmCommonBO oCommonBO = new HrmCommonBO(); if (!oHrmTransCnclOrderSingEmpHdrBean.getCancStatus().equalsIgnoreCase("N")) if (arylstErrorList.isEmpty()) arylstErrorList.add(new EnrgiseApplicationException("wenrgise.common.deletion.rejected")); } } reportError(arylstErrorList); } private void checkUniqueHeader(HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { String sQuery = String.valueOf(String.valueOf(" Select ID as ID from HRM_EMP_TRNS_CNCL_ODR_HDR where ORDER_NO= '").concat(String.valueOf(oHrmTransCnclOrderSingEmpHdrBean.getOrderNo()))).concat(String.valueOf("'")); System.out.println(sQuery); DBUtilitiesBean oBean = new DBUtilitiesBean(); System.out.println(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey()); ArrayList arylstList = oBean.executeQuery(sQuery); Iterator oIt = arylstList.iterator(); if (oIt.hasNext()) { QueryRow oRow = oIt.next(); if (!oRow.get("ID").getString().equalsIgnoreCase(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey())) throw new EnrgiseApplicationException("wenrgise.common.header.uniqueConstraintViolated", "M"); } } private void checkDatesConstraint(HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean, ArrayList arylstErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); if (EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getOrderDate())) { int iDateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmTransCnclOrderSingEmpHdrBean.getOrderDate(), oHrmTransCnclOrderSingEmpHdrBean.getAppDate()); if (iDateFlag == -1 && iDateFlag != -2) arylstErrorList.add(new EnrgiseApplicationException("wenrgise.empTransCnclOrder.orderdateConstraintViolated")); } if (EnrgiseUtil.checkString(oHrmTransCnclOrderSingEmpHdrBean.getDefDate())) { int iDateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmTransCnclOrderSingEmpHdrBean.getDefDate(), oHrmTransCnclOrderSingEmpHdrBean.getTransEffectDate()); if (iDateFlag == -1 && iDateFlag != -2) arylstErrorList.add(new EnrgiseApplicationException("wenrgise.empTransCnclOrder.defdateConstraintViolated")); } } public String getHrAppInfo(String sAppId) throws EnrgiseSystemException { ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int iCount = 0; String sStatus = null; arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sAppId)); arylstParameters.add(new DBObject(2, 2, -10)); arylstParameters.add(new DBObject(3, 2, 12)); arylstParameters.add(new DBObject(4, 2, 12)); arylstParameters.add(new DBObject(5, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnCnlOrddata(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; QueryValue oValue = null; HashMap oColumns = null; Iterator oIt = arylstList.iterator(); while (oIt.hasNext()) { oRow = oIt.next(); sStatus = oRow.get("APPROVED_FLAG").getString(); } return sStatus; } private ArrayList checkLOVConstraint(ArrayList arylstList) throws EnrgiseSystemException { LOVBean def = null; ArrayList arylstNewList = new ArrayList(); Iterator oit = arylstList.iterator(); while (oit.hasNext()) { def = oit.next(); String Id = def.getDetailField1(); String sFlag = getHrAppInfo(Id); if (sFlag == null) arylstNewList.add(def); if (sFlag != null) if (!sFlag.equalsIgnoreCase("P") && !sFlag.equalsIgnoreCase("N") && !sFlag.equalsIgnoreCase("A")) arylstNewList.add(def); } return arylstNewList; } public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException { return "To Be Done"; } public String submitTranCnclOrder(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = null; HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = (HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean; String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : ""; WflStatus status = null; if (!EnrgiseUtil.checkString(oBaseHeaderBean.getWorkListId())) { status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Approve", "Initiated"); } else { status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Approve", (String)null); } if (status.getStatus().equalsIgnoreCase("Pending")) { oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey)); arylstParameters.add(new DBObject(2, 2, 12)); arylstParameters.add(new DBObject(3, 2, 12)); arylstParameters.add(new DBObject(4, 2, 4)); ArrayList arrayList = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.procSubmitTranCnclOrder(?,?,?,?)"); } return sHeaderPrimaryKey; } public String approveTranCnclOrder(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = null; HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = (HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean; String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : ""; WflStatus status = null; if (!EnrgiseUtil.checkString(oBaseHeaderBean.getWorkListId())) { status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Approve", "Initiated"); } else { status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Approve", (String)null); } if (status.getStatus().equalsIgnoreCase("FinallyApproved")) { oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey)); arylstParameters.add(new DBObject(2, 2, 12)); arylstParameters.add(new DBObject(3, 2, 12)); arylstParameters.add(new DBObject(4, 2, 4)); ArrayList arrayList = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.procApproveTranCnclOrder(?,?,?,?)"); } return sHeaderPrimaryKey; } public String rejectTranCnclOrder(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = null; HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = (HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean; String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : ""; WflStatus status = null; if (!EnrgiseUtil.checkString(oBaseHeaderBean.getWorkListId())) { status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Reject", "Initiated"); } else { status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Reject", (String)null); } if (status.getStatus().equalsIgnoreCase("Rejected")) { oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey)); arylstParameters.add(new DBObject(2, 2, 12)); arylstParameters.add(new DBObject(3, 2, 12)); arylstParameters.add(new DBObject(4, 2, 4)); ArrayList arrayList = oBean.callProc(arylstParameters, "HRMEMPTRANSCNCLORDER.procRejectTranCnclOrder(?,?,?,?)"); } return sHeaderPrimaryKey; } public WflStatus callWorkFlow(BaseHeaderBean oBaseHeaderBean, ArrayList arylstDetailBeanArray, String activity, String initiatedFlag) throws EnrgiseApplicationException, EnrgiseSystemException { try { WorkFlowFacadeHome oHome = (WorkFlowFacadeHome)WorkFlowServiceLocator.getLocator().getService("WorkFlowFacade"); WorkFlowFacade workFlowFacade = oHome.create(); HrmTransCnclOrderSingEmpHdrBean oHrmTransCnclOrderSingEmpHdrBean = (HrmTransCnclOrderSingEmpHdrBean)oBaseHeaderBean; WflResourceImpl wflResourceImpl = new WflResourceImpl(); wflResourceImpl.setEmployeeId(this.oUserInfo.getUserTypeId()); WflSiteImpl wflSiteImpl = new WflSiteImpl(); wflSiteImpl.setSiteId(this.oUserInfo.getSiteId()); wflResourceImpl.setLoginSite((WflSite)wflSiteImpl); WflDocumentInfoImpl wflDocumentInfoImpl = new WflDocumentInfoImpl(); wflDocumentInfoImpl.setRequester((WflResource)wflResourceImpl); wflDocumentInfoImpl.setDocumentId(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey()); wflDocumentInfoImpl.setDocumentType("Transfer"); wflDocumentInfoImpl.setInitiatedFlag(initiatedFlag); String documentTypeId = workFlowFacade.getDocumentTypeId("TransCnclOrder"); if (documentTypeId == null) throw new EnrgiseSystemException(); if (!EnrgiseUtil.checkString(initiatedFlag)) wflDocumentInfoImpl.setWorkListId(oBaseHeaderBean.getWorkListId()); String activityId = workFlowFacade.getActivityId(activity); if (activityId == null) throw new EnrgiseSystemException(); wflDocumentInfoImpl.setDocumentTypeId(documentTypeId); if (!activity.equalsIgnoreCase("Reject")) { wflDocumentInfoImpl.setDocumentNumber(String.valueOf(String.valueOf("Transfer Cancellation Order No:").concat(String.valueOf(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for approval"))); wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for approval:Training Requirement:").concat(String.valueOf(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey()))); } else if (!activity.equalsIgnoreCase("Approve")) { wflDocumentInfoImpl.setDocumentNumber(String.valueOf(String.valueOf("Transfer Cancellation Order No:").concat(String.valueOf(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for rejection"))); wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for rejection:Deputation Application No:").concat(String.valueOf(oHrmTransCnclOrderSingEmpHdrBean.getHeaderPrimaryKey()))); } wflDocumentInfoImpl.setModuleId("8"); wflDocumentInfoImpl.setCreator((WflResource)wflResourceImpl); wflDocumentInfoImpl.setRequesterAction(activityId); HashMap oProp = new HashMap(); oProp.put("1", "1"); wflDocumentInfoImpl.setDocumentAttributes(oProp); WflAuthorizationBean wflAuthBean = workFlowFacade.canDo((WflDocumentInfo)wflDocumentInfoImpl); if (EnrgiseUtil.checkString(wflAuthBean.getErrorCode())) throw new EnrgiseApplicationException(wflAuthBean.getErrorCode()); if (!wflAuthBean.isAuthStatus()) throw new EnrgiseApplicationException("wenrgise.workflow.submit.notauthorized"); WflStatus wflStatus = workFlowFacade.process((WflDocumentInfo)wflDocumentInfoImpl); if (wflStatus.getStatus().equals("Error")) throw new EnrgiseSystemException(); workFlowFacade.remove(); return wflStatus; } catch (RemoteException oRtEx) { throw new EnrgiseSystemException("wenrgise.workflow.connect", oRtEx); } catch (CreateException oCx) { throw new EnrgiseSystemException("wenrgise.workflow.connect", oCx); } catch (RemoveException oRx) { throw new EnrgiseSystemException("wenrgise.workflow.connect", oRx); } } }