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.ServiceLocator; import wenrgise.common.utility.UserInfo; import wenrgise.common.utility.WorkFlowServiceLocator2; 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.HrmLvEncashHdrBean; import wenrgise.hrms.ejb.facade.HrmFacade; import wenrgise.hrms.ejb.facade.HrmFacadeHome; import wenrgise.hrms.vo.HrmLvEncashQVO; import wenrgise.workflow.bean.WflAuthorizationBean; import wenrgise.workflow.bean.WflWorkListInfoBean; 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.WorkFlowFacade2; import wenrgise.workflow.ejb.facade.WorkFlowFacade2Home; public class HrmLvEncashBO extends HrmBaseBO { public HrmLvEncashBO() {} public HrmLvEncashBO(UserInfo oUserInfo) { super(oUserInfo); } public RecordMetaInfo getEmpLeaveEncashHdrMetaInfo(HrmLvEncashQVO oHrmLvEncashQVO) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashQVO.getHeaderPrimaryKey())); arylstParam.add(new DBObject(2, 1, 12, oHrmLvEncashQVO.getEmployeeNumber())); arylstParam.add(new DBObject(3, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmLvEncashQVO.getFromDate()))); arylstParam.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmLvEncashQVO.getToDate()))); arylstParam.add(new DBObject(5, 1, 12, oHrmLvEncashQVO.getChangeStatus())); arylstParam.add(new DBObject(6, 2, -5)); arylstParam.add(new DBObject(7, 2, 93)); arylstParam.add(new DBObject(8, 2, 12)); arylstParam.add(new DBObject(9, 2, 12)); arylstParam.add(new DBObject(10, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_HrEmpLeaveEncshDtlCount(?,?,?,?,?,?,?,?,?,?)"); RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo(); DBObject oTotalRecord = arylstOutArray.get(0); oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue()); DBObject oTimeObject = arylstOutArray.get(1); oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject()); return oRecordMetaInfo; } public ArrayList getEmpLeaveEncashHeader(HrmLvEncashQVO oHrmLvEncashQVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; QueryRow oRow = null; QueryValue oValue = null; ArrayList arylstList = null; Iterator itrBean = null; String sLevel = null; ArrayList arylstEmpLeaveEncashDetail = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, -5, new Long(lStartPosition))); arylstParam.add(new DBObject(2, 1, -5, new Long(lLastPosition))); arylstParam.add(new DBObject(3, 1, 12, oHrmLvEncashQVO.getHeaderPrimaryKey())); arylstParam.add(new DBObject(4, 1, 12, oHrmLvEncashQVO.getEmployeeNumber())); arylstParam.add(new DBObject(5, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmLvEncashQVO.getFromDate()))); arylstParam.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmLvEncashQVO.getToDate()))); arylstParam.add(new DBObject(7, 1, 12, oHrmLvEncashQVO.getChangeStatus())); arylstParam.add(new DBObject(8, 2, -10)); arylstParam.add(new DBObject(9, 2, 12)); arylstParam.add(new DBObject(10, 2, 12)); arylstParam.add(new DBObject(11, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_HrEmpLeaveEncashDtl(?,?,?,?,?,?,?,?,?,?,?)"); arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject(); if (arylstList.size() == 0) throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); count = 0; itrBean = arylstList.iterator(); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); while (itrBean.hasNext()) { if (count == 0) arylstEmpLeaveEncashDetail = new ArrayList(); count++; oRow = itrBean.next(); HrmLvEncashHdrBean oHrmLvEncashHdrBean = new HrmLvEncashHdrBean(); if (EnrgiseUtil.checkString(oHrmLvEncashQVO.getWorkListId())) { WflWorkListInfoBean oInfoBean = new WflWorkListInfoBean(); oInfoBean = getLevel(oHrmLvEncashQVO.getWorkListId()); sLevel = oInfoBean.getONode().getLevel(); oHrmLvEncashHdrBean.setLevel(sLevel); } else { sLevel = "0"; oHrmLvEncashHdrBean.setLevel("0"); } oHrmLvEncashHdrBean.setEmployeeNumber(oRow.get("EMP_NO").getString()); oHrmLvEncashHdrBean.setFirstName(oRow.get("FIRST_NAME").getString()); oHrmLvEncashHdrBean.setMiddleName(oRow.get("MIDDLE_NAME").getString()); oHrmLvEncashHdrBean.setLastName(oRow.get("LAST_NAME").getString()); oHrmLvEncashHdrBean.setHeaderPrimaryKey(oRow.get("ID").getString()); oHrmLvEncashHdrBean.setEmployeeId(oRow.get("E_PER_DTL_ID").getString()); oHrmLvEncashHdrBean.setLeaveCodeId(oRow.get("LEAVE_ATTR_DT_ID").getString()); oHrmLvEncashHdrBean.setLeaveCodes(oRow.get("LEAVE_DESCRIPTION").getString()); oHrmLvEncashHdrBean.setDescription(oRow.get("NAME").getString()); oHrmLvEncashHdrBean.setGrade(oRow.get("GRADE").getString()); oHrmLvEncashHdrBean.setDesignation(oRow.get("DESIGNATION").getString()); oHrmLvEncashHdrBean.setLocation(oRow.get("LOCATION").getString()); oHrmLvEncashHdrBean.setEncashedAmount(oRow.get("encashment_amt").getString()); oHrmLvEncashHdrBean.setPfDeduction(oRow.get("PF_DEDN_AMOUNT").getString()); oHrmLvEncashHdrBean.setTaxAmount(oRow.get("IT_AMOUNT").getString()); oHrmLvEncashHdrBean.setDateApplied(EnrgiseUtil.convertToString(oRow.get("APPLICATION_DATE").getDate())); oHrmLvEncashHdrBean.setDaysEncashed(oRow.get("DAYS_ENCASHED").getString()); oHrmLvEncashHdrBean.setChangeStatus(oRow.get("APPROVED_FLAG").getString()); oHrmLvEncashHdrBean.setEligibleAmount(oRow.get("ELIG_AMOUNT").getString()); oHrmLvEncashHdrBean.setLvTxnId(oRow.get("TXN_ID").getString()); oHrmLvEncashHdrBean.setLvApplnFromDate(EnrgiseUtil.convertToString(oRow.get("FROM_DATE").getDate())); oHrmLvEncashHdrBean.setLvApplnToDate(EnrgiseUtil.convertToString(oRow.get("TO_DATE").getDate())); arylstEmpLeaveEncashDetail.add(oHrmLvEncashHdrBean); } return arylstEmpLeaveEncashDetail; } public WflWorkListInfoBean getLevel(String sWorkListId) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { try { HrmFacadeHome oHome = (HrmFacadeHome)ServiceLocator.getLocator().getService("HrmFacade"); HrmFacade oHrmFacade = oHome.create(); return oHrmFacade.getWorkListInfo(sWorkListId); } catch (CreateException oCrtExcep) { throw new EnrgiseSystemException(oCrtExcep); } catch (RemoteException oRemExcep) { throw new EnrgiseSystemException(oRemExcep); } } public void initializeBOImpl() { this.headerTable = "HRM_LEAVE_ENCASH"; } public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {} public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {} public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException { return "saveNewHeaderImpl"; } public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {} public LovVO getHrmEncshLvCodeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("ID"); arylstHeaderList.add("hrm.HrmLeaveEncashment.leaveCode"); arylstHeaderList.add("hrm.HrmLeaveEncashment.description"); arylstHeaderList.add("hrm.HrmLeaveEncashment.leavePeriodicity"); arylstHeaderList.add("hrm.HrmLeaveEncashment.leaveLimit"); oLovVO.setHeaderList(arylstHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); String sQuerySearch2 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getSearchField2() != null) sQuerySearch2 = oLovQueryVO.getSearchField2(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1)); arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2)); arylstParam.add(new DBObject(3, 2, -10)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 12)); arylstParam.add(new DBObject(6, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLOV.proc_GetHrmEncLvCdLOVdata(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = arylstList.iterator(); while (iter.hasNext()) { if (count == 0) arylstList = new ArrayList(); count++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("CODE").getString()); oLOVBean.setDetailField3(oRow.get("LEAVE_DESCRIPTION").getString()); oLOVBean.setDetailField4(oRow.get("PERIODICITY").getString()); oLOVBean.setDetailField5(oRow.get("ENCASHABLE_LIMIT").getString()); arylstList.add(oLOVBean); } oLovVO.setDetailList(arylstList); return oLovVO; } public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException { String returnString = null; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); DateUtility d = new DateUtility(); String sItAmount = new String(); String sPfAmount = new String(); String sNetAmount = new String(); HrmLvEncashHdrBean oHrmLvEncashHdrBean = (HrmLvEncashHdrBean)oBaseHeaderBean; String sGross = calculateGrossEncash(oHrmLvEncashHdrBean); sNetAmount = calculateNetEncashAmount(oHrmLvEncashHdrBean); sItAmount = calculateITAmount(oHrmLvEncashHdrBean); if (ScreenMode.equalsIgnoreCase("N")) { arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, "i")); arylstParam.add(new DBObject(2, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(3, 1, 12, oHrmLvEncashHdrBean.getLeaveCodeId())); arylstParam.add(new DBObject(4, 1, 12, oHrmLvEncashHdrBean.getLeaveCodes())); arylstParam.add(new DBObject(5, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmLvEncashHdrBean.getDateApplied()))); arylstParam.add(new DBObject(6, 1, 12, oHrmLvEncashHdrBean.getDaysEncashed())); arylstParam.add(new DBObject(7, 1, 12, sGross)); arylstParam.add(new DBObject(8, 1, 12, sPfAmount)); arylstParam.add(new DBObject(9, 1, 12, sItAmount)); arylstParam.add(new DBObject(10, 1, 12, sNetAmount)); arylstParam.add(new DBObject(11, 1, 12, oHrmLvEncashHdrBean.getLvTxnId())); arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getUserTypeId())); arylstParam.add(new DBObject(13, 1, 12, this.oUserInfo.getSiteId())); arylstParam.add(new DBObject(14, 1, 12, null)); arylstParam.add(new DBObject(15, 2, 12)); arylstParam.add(new DBObject(16, 2, 12)); arylstParam.add(new DBObject(17, 2, 12)); arylstParam.add(new DBObject(18, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_UpsertHrEmpLeaveEncashHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); returnString = (String)oOutObject.getObject(); } else if (ScreenMode.equalsIgnoreCase("U")) { arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, "u")); arylstParam.add(new DBObject(2, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(3, 1, 12, oHrmLvEncashHdrBean.getLeaveCodeId())); arylstParam.add(new DBObject(4, 1, 12, oHrmLvEncashHdrBean.getLeaveCodes())); arylstParam.add(new DBObject(5, 1, 12, oHrmLvEncashHdrBean.getDateApplied())); arylstParam.add(new DBObject(6, 1, 12, oHrmLvEncashHdrBean.getDaysEncashed())); arylstParam.add(new DBObject(7, 1, 12, oHrmLvEncashHdrBean.getEligibleAmount())); arylstParam.add(new DBObject(8, 1, 12, sPfAmount)); arylstParam.add(new DBObject(9, 1, 12, sItAmount)); arylstParam.add(new DBObject(10, 1, 12, sNetAmount)); arylstParam.add(new DBObject(11, 1, 12, oHrmLvEncashHdrBean.getLvTxnId())); arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getUserTypeId())); arylstParam.add(new DBObject(13, 1, 12, this.oUserInfo.getSiteId())); arylstParam.add(new DBObject(14, 1, 12, oHrmLvEncashHdrBean.getHeaderPrimaryKey())); arylstParam.add(new DBObject(15, 2, 12)); arylstParam.add(new DBObject(16, 2, 12)); arylstParam.add(new DBObject(17, 2, 12)); arylstParam.add(new DBObject(18, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_UpsertHrEmpLeaveEncashHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); returnString = (String)oOutObject.getObject(); } else if (ScreenMode.equalsIgnoreCase("D")) { arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getHeaderPrimaryKey())); arylstParam.add(new DBObject(2, 2, 12)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_DelHrEmpLeaveEncashHdr(?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); returnString = null; } return returnString; } private void checkValidTaxAmount(String sGross, String sPfAmount, String sItAmount) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oErrorList = new ArrayList(); if (Double.parseDouble(sItAmount) > Double.parseDouble(sGross)) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.taxAmount"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("hrm.HrmEmpEncash.taxAmountError", oParams, "E")); } reportError(oErrorList); } private String calculateNetEncashAmount(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseSystemException { String sIT = calculateITAmount(oHrmLvEncashHdrBean); String sGross = calculateGrossEncash(oHrmLvEncashHdrBean); double dNet = Double.parseDouble(sGross) - Double.parseDouble(sIT); return String.valueOf(dNet); } private String calculateITAmount(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseSystemException { double dTaxAmt = 0.0D; if (EnrgiseUtil.checkString(oHrmLvEncashHdrBean.getTaxAmount())) dTaxAmt = Double.parseDouble(oHrmLvEncashHdrBean.getTaxAmount()); return String.valueOf(dTaxAmt); } private String calculatePFAmount(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseSystemException { ArrayList oList = new ArrayList(); String sBasic = new String(); String sDA = new String(); double dPFAmount = 0.0D; double dBasic = 0.0D; double dDA = 0.0D; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); QueryRow oRow = null; QueryValue oValue = null; ArrayList arylstList = null; Iterator itrBean = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(2, 2, 12)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 12)); arylstParam.add(new DBObject(6, 2, 12)); arylstParam.add(new DBObject(7, 2, 12)); arylstParam.add(new DBObject(8, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.procCalculateEncashAmount(?,?,?,?,?,?,?,?)"); DBObject oBasic = arylstOutArray.get(0); DBObject oDA = arylstOutArray.get(3); sBasic = ((String)oBasic.getObject()).toString(); sDA = ((String)oDA.getObject()).toString(); dBasic = Double.parseDouble(sBasic); dDA = Double.parseDouble(sDA); dPFAmount = (dBasic + dDA) * 12 / 100; return String.valueOf(dPFAmount * Double.parseDouble(oHrmLvEncashHdrBean.getDaysEncashed()) / 30); } private String calculateGrossEncash(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseSystemException { String sGrossAmount = new String(); String sBasic = new String(); String sDA = new String(); String sHRA = new String(); String sMedical = new String(); double dTotal = 0.0D; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstList = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(2, 2, 12)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 12)); arylstParam.add(new DBObject(6, 2, 12)); arylstParam.add(new DBObject(7, 2, 12)); arylstParam.add(new DBObject(8, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.procCalculateEncashAmount(?,?,?,?,?,?,?,?)"); DBObject oBasic = arylstOutArray.get(0); DBObject oDA = arylstOutArray.get(3); DBObject oHRA = arylstOutArray.get(1); DBObject oMedical = arylstOutArray.get(2); sBasic = ((String)oBasic.getObject()).toString(); sDA = ((String)oDA.getObject()).toString(); sHRA = ((String)oHRA.getObject()).toString(); sMedical = ((String)oMedical.getObject()).toString(); dTotal = Double.parseDouble(sBasic) + Double.parseDouble(sHRA) + Double.parseDouble(sMedical) + Double.parseDouble(sDA); sGrossAmount = String.valueOf(dTotal * Double.parseDouble(oHrmLvEncashHdrBean.getDaysEncashed()) / 30); return sGrossAmount; } 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((HrmLvEncashHdrBean)oBaseHeaderBean); checkHeaderFields((HrmLvEncashHdrBean)oBaseHeaderBean); } reportError(arylstErrorList); } public String getEmpGrade(String sEmpId) throws EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; String sAllFlag = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sEmpId)); arylstParam.add(new DBObject(2, 2, 12)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "hrmlvencash.procGetEmpGrade(?,?,?,?,?)"); DBObject oErr = arylstOutArray.get(0); String sGrade = ((String)oErr.getObject()).toString(); return sGrade; } private void checkMandatoryHeader(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList oErrorList = new ArrayList(); String sGrade = getEmpGrade(oHrmLvEncashHdrBean.getEmployeeId()); if (sGrade.equalsIgnoreCase("O")) if (!EnrgiseUtil.checkString(oHrmLvEncashHdrBean.getLeaveCodes())) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.leaveCodes"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmLvEncashHdrBean.getDateApplied())) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.dateApplied"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmLvEncashHdrBean.getDaysEncashed())) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.daysEncashed"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } reportError(oErrorList); } 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(); HrmLvEncashHdrBean oHrmLvEncashHdrBean = (HrmLvEncashHdrBean)oBaseHeaderBean; if (bHeaderDataChanged) { if (!sScreenMode.equalsIgnoreCase("D")) { checkUniqueHeader((HrmLvEncashHdrBean)oBaseHeaderBean, arylstErrorList); checkDatesConstraint((HrmLvEncashHdrBean)oBaseHeaderBean, arylstErrorList); String sGross = calculateGrossEncash(oHrmLvEncashHdrBean); String sPfAmount = null; String sItAmount = calculateITAmount(oHrmLvEncashHdrBean); checkValidTaxAmount(sGross, sPfAmount, sItAmount); checkDaysEncashed(oHrmLvEncashHdrBean); checkMonthlyEncashment(oHrmLvEncashHdrBean); } if (sScreenMode.equalsIgnoreCase("D")) if (!oHrmLvEncashHdrBean.getChangeStatus().equalsIgnoreCase("N")) if (arylstErrorList.isEmpty()) arylstErrorList.add(new EnrgiseApplicationException("wenrgise.common.deletion.rejected")); } reportError(arylstErrorList); } private void checkDaysEncashed(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oErrorList = new ArrayList(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(2, 1, 12, oHrmLvEncashHdrBean.getDaysEncashed())); arylstParam.add(new DBObject(3, 1, 12, oHrmLvEncashHdrBean.getLeaveCodeId())); arylstParam.add(new DBObject(4, 1, 12, oHrmLvEncashHdrBean.getLvApplnFromDate())); arylstParam.add(new DBObject(5, 1, 12, oHrmLvEncashHdrBean.getLvApplnToDate())); arylstParam.add(new DBObject(6, 2, 12)); arylstParam.add(new DBObject(7, 2, 12)); arylstParam.add(new DBObject(8, 2, 12)); arylstParam.add(new DBObject(9, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proccheckencashdays(?,?,?,?,?,?,?,?,?)"); DBObject oErr = arylstOutArray.get(0); String sErr = ((String)oErr.getObject()).toString(); if (Integer.parseInt(sErr) == 0) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.daysEncashed"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("hrm.HrmEmpEncash.daysEncashedError", oParams, "E")); } reportError(oErrorList); } private void checkMonthlyEncashment(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList oErrorList = new ArrayList(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(2, 2, 12)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proccheckmonthlyencashment(?,?,?,?,?)"); DBObject oErr = arylstOutArray.get(0); String sErr = ((String)oErr.getObject()).toString(); if (Integer.parseInt(sErr) == 0) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.daysEncashed"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("hrm.HrmEmpEncash.daysEncashedError2", oParams, "E")); } reportError(oErrorList); } private void checkUniqueHeader(HrmLvEncashHdrBean oHrmLvEncashHdrBean, ArrayList arylstErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParam.add(new DBObject(2, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmLvEncashHdrBean.getDateApplied()))); arylstParam.add(new DBObject(3, 2, 4)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 12)); arylstParam.add(new DBObject(6, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_Lv_encash_chk(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); int iVal = ((Integer)oOutObject.getObject()).intValue(); if (iVal > 0) { ArrayList arylstParams = new ArrayList(); arylstErrorList.add(new EnrgiseMessageKeyException("hrm.HrmLvEncash.EncashDispute", arylstParams, "E")); } } private void checkDatesConstraint(HrmLvEncashHdrBean oHrmLvEncashHdrBean, ArrayList arylstErrorList) throws EnrgiseApplicationException, EnrgiseSystemException { DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); if (EnrgiseUtil.checkString(oHrmLvEncashHdrBean.getDateApplied())) { int dateFlag2 = EnrgiseUtil.compareDates(dateFormat, EnrgiseUtil.convertToString(EnrgiseUtil.getSysDate()), oHrmLvEncashHdrBean.getDateApplied()); if (dateFlag2 == -1 && dateFlag2 != -2) arylstErrorList.add(new EnrgiseApplicationException("hrm.HrmEmpEncash.dateConstraintViolated2")); } } public String getGenderInfo(String sEmpNo) throws EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; String sGender = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sEmpNo)); arylstParam.add(new DBObject(2, 2, -10)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_GetGenderInfo(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; QueryValue oValue = null; HashMap oColumns = null; Iterator itrBean = arylstList.iterator(); while (itrBean.hasNext()) { oRow = itrBean.next(); sGender = oRow.get("SEX").getString(); } return sGender; } public LovVO getHrmLeaveTypesLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { String sEmpNo = oLovQueryVO.getProperty("employeeNumber"); DateUtility d = new DateUtility(); String str = d.getSysDate(); String monOfSysDate = str.substring(3, 5); String yearOfSysDate = str.substring(6, 10); String yyyymm = String.valueOf(yearOfSysDate).concat(String.valueOf(monOfSysDate)); LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("ID"); arylstHeaderList.add("hrm.HrmEmpEncash.leaveCodes"); arylstHeaderList.add("hrm.HrmEmpEncash.description"); arylstHeaderList.add("allFlag"); arylstHeaderList.add("totalEncashLimit"); arylstHeaderList.add("txnId"); arylstHeaderList.add("hrm.HrmLeaveApplication.fromDate"); arylstHeaderList.add("hrm.HrmLeaveApplication.toDate"); oLovVO.setHeaderList(arylstHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("H"); arylstVisibility.add("H"); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); String sQuerySearch2 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getSearchField2() != null) sQuerySearch2 = oLovQueryVO.getSearchField2(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1)); arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2)); arylstParam.add(new DBObject(3, 1, 12, sEmpNo)); arylstParam.add(new DBObject(4, 2, -10)); arylstParam.add(new DBObject(5, 2, 12)); arylstParam.add(new DBObject(6, 2, 12)); arylstParam.add(new DBObject(7, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_GetHrmLeaveTypesLOVdata(?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = arylstList.iterator(); while (iter.hasNext()) { if (count == 0) arylstList = new ArrayList(); count++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("LEAVE_DESCRIPTION").getString()); oLOVBean.setDetailField3(oRow.get("NAME").getString()); oLOVBean.setDetailField4(oRow.get("ALL_FLAG").getString()); oLOVBean.setDetailField5(oRow.get("ENCASH_LIMIT_SRVC_PRD").getString()); oLOVBean.setDetailField6(oRow.get("TXN_ID").getString()); oLOVBean.setDetailField7(EnrgiseUtil.convertToString(oRow.get("FROM_DATE").getDate())); oLOVBean.setDetailField8(EnrgiseUtil.convertToString(oRow.get("TO_DATE").getDate())); arylstList.add(oLOVBean); } arylstList = checkLOVConstraint(arylstList, oLovQueryVO); oLovVO.setDetailList(arylstList); return oLovVO; } private ArrayList checkLOVConstraint(ArrayList arylstList, LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LOVBean oLOVBean = null; ArrayList arylstNewList = new ArrayList(); Iterator itrBean = arylstList.iterator(); while (itrBean.hasNext()) { oLOVBean = itrBean.next(); String sAllFlag = oLOVBean.getDetailField4(); if (sAllFlag.equalsIgnoreCase("Y")) { arylstNewList.add(oLOVBean); continue; } String sAttrId = oLOVBean.getDetailField1(); String sQuery = String.valueOf(" Select ELIG_SQL as ELIG_SQL from HRM_LEAVE_ATTR_DTL where ID= ").concat(String.valueOf(sAttrId)); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstList1 = oBean.executeQuery(sQuery); Iterator itrBean1 = arylstList1.iterator(); if (itrBean1.hasNext()) { QueryRow oRow = itrBean1.next(); String sSql = oRow.get("ELIG_SQL").getString(); if (EnrgiseUtil.checkString(sSql)) { String sEmpNo = oLovQueryVO.getProperty("employeeNumber"); HrmCommonBO oBO = new HrmCommonBO(); String sEmpId = oBO.getRefList1("HRM_EMP_PERS", "EMP_NO", sEmpNo, "ID"); StringBuffer s = new StringBuffer(sSql); s.replace(s.lastIndexOf("?"), s.lastIndexOf("?") + 1, sEmpId); ArrayList arylstList2 = oBean.executeQuery(s.toString()); if (arylstList2.size() != 0) arylstNewList.add(oLOVBean); } } } return arylstNewList; } public ArrayList getHrEmpEncashDaysEncashed(String sLeaveId, String sEmpId) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; ArrayList arylstEmpLeaveEncash = null; Iterator itrBean = null; QueryRow oRow = null; QueryValue oValue = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sEmpId)); arylstParam.add(new DBObject(2, 1, 12, sLeaveId)); arylstParam.add(new DBObject(3, 2, -10)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 12)); arylstParam.add(new DBObject(6, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVENCASH.proc_GetHrmDaysEncashedData(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); if (arylstList.size() == 0) throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); itrBean = arylstList.iterator(); while (itrBean.hasNext()) { if (count == 0) arylstEmpLeaveEncash = new ArrayList(); count++; oRow = itrBean.next(); HrmLvEncashHdrBean oHrmLvEncashHdrBean = new HrmLvEncashHdrBean(); oHrmLvEncashHdrBean.setTotalDaysEncashed(oRow.get("total_days_encashed").getString()); arylstEmpLeaveEncash.add(oHrmLvEncashHdrBean); } return arylstEmpLeaveEncash; } private void checkHeaderFields(HrmLvEncashHdrBean oHrmLvEncashHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException {} public String approveLeaveEncash(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { String sLeaveEncash = null; 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")) { sLeaveEncash = approveLeaveEncashHdr(oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, arylstDetailBeanArray, bDetailDataChanged, oDetailPicked); approveLeaveEncashTxn(oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, arylstDetailBeanArray, bDetailDataChanged, oDetailPicked); } return sLeaveEncash; } private String approveLeaveEncashHdr(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = null; HrmLvEncashHdrBean oHrmLvEncashHdrBean = (HrmLvEncashHdrBean)oBaseHeaderBean; String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : ""; oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey)); arylstParameters.add(new DBObject(2, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParameters.add(new DBObject(3, 1, 12, oHrmLvEncashHdrBean.getLeaveCodeId())); arylstParameters.add(new DBObject(4, 1, 12, oHrmLvEncashHdrBean.getDaysEncashed())); arylstParameters.add(new DBObject(5, 2, 12)); arylstParameters.add(new DBObject(6, 2, 12)); arylstParameters.add(new DBObject(7, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMLVENCASH.proc_UpsertApproveLvEncashHdr(?,?,?,?,?,?,?)"); return sHeaderPrimaryKey; } private void approveLeaveEncashTxn(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = null; HrmLvEncashHdrBean oHrmLvEncashHdrBean = (HrmLvEncashHdrBean)oBaseHeaderBean; String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : ""; oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey)); arylstParameters.add(new DBObject(2, 1, 12, oHrmLvEncashHdrBean.getEmployeeId())); arylstParameters.add(new DBObject(3, 1, 12, oHrmLvEncashHdrBean.getLvTxnId())); arylstParameters.add(new DBObject(4, 2, 12)); arylstParameters.add(new DBObject(5, 2, 12)); arylstParameters.add(new DBObject(6, 2, 4)); ArrayList arylstPK = oBean.callProc(arylstParameters, "HRMLVENCASH.proc_UpsertApproveLvEncashTxn(?,?,?,?,?,?)"); } public String rejectLvEncash(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = null; HrmLvEncashHdrBean oHrmLvEncashHdrBean = (HrmLvEncashHdrBean)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, "HRMLVENCASH.procRejectLvEncash(?,?,?,?)"); } return sHeaderPrimaryKey; } public String submitLvEncash(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); String sLeaveEncash = null; HrmLvEncashHdrBean oHrmLvEncashHdrBean = (HrmLvEncashHdrBean)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.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, "HRMLVENCASH.procSubmitLvEncash(?,?,?,?)"); } ArrayList arylstParam = new ArrayList(); ArrayList oErrorList = new ArrayList(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmLvEncashHdrBean.getLvTxnId())); arylstParam.add(new DBObject(2, 2, 12)); arylstParam.add(new DBObject(3, 2, 12)); arylstParam.add(new DBObject(4, 2, 12)); arylstParam.add(new DBObject(5, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "hrmlvencash.procchecksubmit(?,?,?,?,?)"); DBObject oErr = arylstOutArray.get(0); String sErr = ((String)oErr.getObject()).toString(); if (Integer.parseInt(sErr) == 0) { MessageKey oMessageKey = new MessageKey("hrm.HrmEmpEncash.daysEncashed"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("hrm.HrmEmpEncash.submitError", oParams, "E")); reportError(oErrorList); } return oBaseHeaderBean.getHeaderPrimaryKey(); } public WflStatus callWorkFlow(BaseHeaderBean oBaseHeaderBean, ArrayList arylstDetailBeanArray, String activity, String initiatedFlag) throws EnrgiseApplicationException, EnrgiseSystemException { try { WorkFlowFacade2Home oHome = (WorkFlowFacade2Home)WorkFlowServiceLocator2.getLocator().getService("WorkFlowFacade2"); WorkFlowFacade2 workFlowFacade = oHome.create(); HrmLvEncashHdrBean oHdrBean = (HrmLvEncashHdrBean)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(oHdrBean.getHeaderPrimaryKey()); wflDocumentInfoImpl.setDocumentType("Leave"); wflDocumentInfoImpl.setInitiatedFlag(initiatedFlag); String documentTypeId = workFlowFacade.getDocumentTypeId("LvEncash"); 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("Leave Encashment No: ").concat(String.valueOf(oHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for approval"))); wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for approval: Leave Encashment No:").concat(String.valueOf(oHdrBean.getHeaderPrimaryKey()))); } else if (!activity.equalsIgnoreCase("Approve")) { wflDocumentInfoImpl.setDocumentNumber(String.valueOf(String.valueOf("Leave Encashment No: ").concat(String.valueOf(oHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for rejection"))); wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for rejection: Leave Encashment No:").concat(String.valueOf(oHdrBean.getHeaderPrimaryKey()))); } wflDocumentInfoImpl.setModuleId("8"); wflDocumentInfoImpl.setCreator((WflResource)wflResourceImpl); wflDocumentInfoImpl.setRequesterAction(activityId); HashMap oProp = new HashMap(); oProp.put("LvEncash", "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); } } public LovVO getHrmLvEncashEmpNoNLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("ID"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.employeeNo"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.firstName"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.middleName"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.lastName"); arylstHeaderList.add("hrm.HrmEmpLoanAppln.grade"); arylstHeaderList.add("hrm.HrmEmpLoanAppln.designation"); arylstHeaderList.add("hrm.HrmEmpLoanAppln.location"); 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"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; ArrayList oParameters = new ArrayList(); ArrayList oList = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); String sQuerySearch2 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getSearchField2() != null) sQuerySearch2 = oLovQueryVO.getSearchField2(); String sSiteId = oLovQueryVO.getProperty("ListSiteId"); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, sQuerySearch1)); oParameters.add(new DBObject(2, 1, 12, sQuerySearch2)); oParameters.add(new DBObject(3, 1, 12, sSiteId)); 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, "hrmlvencash.procGetEmpLOVN(?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); oList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = oList.iterator(); while (iter.hasNext()) { if (count == 0) oList = new ArrayList(); count++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("EMP_NO").getString()); oLOVBean.setDetailField3(oRow.get("FIRST_NAME").getString()); oLOVBean.setDetailField4(oRow.get("MIDDLE_NAME").getString()); oLOVBean.setDetailField5(oRow.get("LAST_NAME").getString()); oLOVBean.setDetailField6(oRow.get("GRADE").getString()); oLOVBean.setDetailField7(oRow.get("DESIGNATION").getString()); oLOVBean.setDetailField8(oRow.get("LOCATION").getString()); oList.add(oLOVBean); } oLovVO.setDetailList(oList); return oLovVO; } public LovVO getHrmLvEncashEmpNoQLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderList = new ArrayList(); arylstHeaderList.add("ID"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.employeeNo"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.firstName"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.middleName"); arylstHeaderList.add("hrm.HrmEmpPersonalDetails.lastName"); arylstHeaderList.add("hrm.HrmEmpLoanAppln.grade"); arylstHeaderList.add("hrm.HrmEmpLoanAppln.designation"); arylstHeaderList.add("hrm.HrmEmpLoanAppln.location"); 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"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; ArrayList oParameters = new ArrayList(); ArrayList oList = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); String sQuerySearch2 = new String(); String sSiteId = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getSearchField2() != null) sQuerySearch2 = oLovQueryVO.getSearchField2(); sSiteId = oLovQueryVO.getProperty("ListSiteId"); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, sQuerySearch1)); oParameters.add(new DBObject(2, 1, 12, sQuerySearch2)); oParameters.add(new DBObject(3, 1, 12, sSiteId)); 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, "hrmlvencash.procGetEmpLOVQ(?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); oList = (ArrayList)oOutObject.getObject(); QueryRow oRow = null; Iterator iter = oList.iterator(); while (iter.hasNext()) { if (count == 0) oList = new ArrayList(); count++; oRow = iter.next(); LOVBean oLOVBean = new LOVBean(); oLOVBean.setDetailField1(oRow.get("ID").getString()); oLOVBean.setDetailField2(oRow.get("EMP_NO").getString()); oLOVBean.setDetailField3(oRow.get("FIRST_NAME").getString()); oLOVBean.setDetailField4(oRow.get("MIDDLE_NAME").getString()); oLOVBean.setDetailField5(oRow.get("LAST_NAME").getString()); oLOVBean.setDetailField6(oRow.get("GRADE").getString()); oLOVBean.setDetailField7(oRow.get("DESIGNATION").getString()); oLOVBean.setDetailField8(oRow.get("LOCATION").getString()); oList.add(oLOVBean); } oLovVO.setDetailList(oList); return oLovVO; } }