package wenrgise.hrms.ejb.business; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; 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.BaseDetailVO; import wenrgise.common.vo.BaseHeaderVO; import wenrgise.common.vo.BaseQueryVO; 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.HrmPrmCriteriaDtlBean; import wenrgise.hrms.bean.HrmPrmCriteriaHdrBean; import wenrgise.hrms.bean.HrmPrmExperienceDtlBean; import wenrgise.hrms.bean.HrmPrmGenAssDtlBean; import wenrgise.hrms.bean.HrmPrmGenAssHdrBean; import wenrgise.hrms.bean.HrmTrngEmpAttHdrBean; import wenrgise.hrms.vo.HrmPrmCriteriaQVO; import wenrgise.hrms.vo.HrmTrngEmpAttQVO; public class HrmPrmGenAssBO extends HrmBaseBO { public HrmPrmGenAssBO() {} public HrmPrmGenAssBO(UserInfo oUserInfo) { super(oUserInfo); } public RecordMetaInfo getHrmTrngEmpAttHdrMetaInfo(HrmTrngEmpAttQVO oHrmTrngEmpAttQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); String sId = oHrmTrngEmpAttQueryVO.getCourseNameId(); oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, sId)); 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, "HRMPRMCRITERIA.proc_HrEmpTrngAttHdrCount(?,?,?,?,?,?)"); 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 getHrmTrngEmpAttHeaderInfo(HrmTrngEmpAttQVO oHrmTrngEmpAttQueryVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList oHeaderList = null; if (oHrmTrngEmpAttQueryVO == null) oHrmTrngEmpAttQueryVO = new HrmTrngEmpAttQVO(); String sId = oHrmTrngEmpAttQueryVO.getCourseNameId(); String sPK = oHrmTrngEmpAttQueryVO.getHeaderPrimaryKey(); 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, sId)); oParameters.add(new DBObject(4, 1, 12, sPK)); oParameters.add(new DBObject(5, 2, -10)); oParameters.add(new DBObject(6, 2, 12)); oParameters.add(new DBObject(7, 2, 12)); oParameters.add(new DBObject(8, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "HRMPRMCRITERIA.proc_HrEmpTrngAttHdr(?,?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); ArrayList oList = (ArrayList)oOutObject.getObject(); if (oList.size() == 0) throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); QueryRow oRow = null; HashMap oColumns = null; Iterator oIt = oList.iterator(); while (oIt.hasNext()) { if (count == 0) oHeaderList = new ArrayList(); count++; oRow = oIt.next(); HrmTrngEmpAttHdrBean oHrmTrngEmpAttHdrBean = new HrmTrngEmpAttHdrBean(); oHrmTrngEmpAttHdrBean.setHeaderPrimaryKey(oRow.get("ID").getString()); oHrmTrngEmpAttHdrBean.setCourseName(oRow.get("CRS_NAME").getString()); oHrmTrngEmpAttHdrBean.setInstitutionName(oRow.get("INST_NAME").getString()); oHrmTrngEmpAttHdrBean.setStartDate(EnrgiseUtil.convertToString(oRow.get("START_DATE").getDate())); oHrmTrngEmpAttHdrBean.setEndDate(EnrgiseUtil.convertToString(oRow.get("END_DATE").getDate())); oHeaderList.add(oHrmTrngEmpAttHdrBean); } return oHeaderList; } public RecordMetaInfo getHrmPrmCriteriaDetailMetaInfo(BaseQueryVO oBaseQVO) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); HrmPrmCriteriaQVO oQVO = (HrmPrmCriteriaQVO)oBaseQVO; oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, oQVO.getToGradeId())); oParameters.add(new DBObject(2, 1, 12, oQVO.getHeaderPrimaryKey())); oParameters.add(new DBObject(3, 2, -5)); oParameters.add(new DBObject(4, 2, 93)); 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, "HRMPRMCRITERIA.proc_PrmCriteriaDtlCount(?,?,?,?,?,?,?)"); 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()); return oRecordMetaInfo; } public ArrayList getHrmPrmCriteriaDetailInfo(BaseQueryVO oBaseQVO, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList oParameters = new ArrayList(); HrmPrmCriteriaQVO oQVO = (HrmPrmCriteriaQVO)oBaseQVO; DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; BaseDetailVO oBaseDetailVO = null; ArrayList arylstDetail = null; oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition))); oParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition))); oParameters.add(new DBObject(3, 1, 12, oQVO.getToGradeId())); oParameters.add(new DBObject(4, 1, 12, oQVO.getHeaderPrimaryKey())); oParameters.add(new DBObject(5, 2, -10)); oParameters.add(new DBObject(6, 2, 12)); oParameters.add(new DBObject(7, 2, 12)); oParameters.add(new DBObject(8, 2, 4)); ArrayList oOutArray = oBean.callProc(oParameters, "HRMPRMCRITERIA.proc_PrmCriteriaDtl(?,?,?,?,?,?,?,?)"); DBObject oOutObject = oOutArray.get(0); ArrayList oList = (ArrayList)oOutObject.getObject(); if (oList.size() == 0) throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); QueryRow oRow = null; QueryValue oValue = null; HashMap oColumns = null; Iterator oIt = oList.iterator(); while (oIt.hasNext()) { if (count == 0) arylstDetail = new ArrayList(); count++; oRow = oIt.next(); HrmPrmCriteriaDtlBean oDtlBean = new HrmPrmCriteriaDtlBean(); oDtlBean.setDetailId(oRow.get("ID").getString()); oDtlBean.setTxtDescription(oRow.get("description").getString()); oDtlBean.setTxtCriteriaStartDate(EnrgiseUtil.convertToString(oRow.get("criteria_fr_dt").getDate())); oDtlBean.setDisabbutCriteriaEndDate("true"); oDtlBean.setDisabbutCriteriaStartDate("true"); oDtlBean.setTxtCriteriaEndDate(EnrgiseUtil.convertToString(oRow.get("criteria_to_dt").getDate())); oDtlBean.setTxtMinServicePeriod(oRow.get("min_service_period").getString()); oDtlBean.setTxtReqYears(oRow.get("years_in_current_post").getString()); oDtlBean.setTxtYearAPAR(oRow.get("no_of_years_apar").getString()); arylstDetail.add(oDtlBean); } return arylstDetail; } public void initializeBOImpl() { this.headerTable = "HRM_EMP_TRNG_HDR"; } public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {} public void saveDetailImpl(BaseHeaderBean oBaseHdrBean, String sScreenName, 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(); HrmPrmCriteriaHdrBean oHdrBean = (HrmPrmCriteriaHdrBean)oBaseHdrBean; while (oIt.hasNext()) { HrmPrmCriteriaDtlBean oDtlBean = oIt.next(); if (oDtlBean.getStatus().equals("N")) { if (!bInsert) { oBean = new DBUtilitiesBean(); oBean.createBatch("HRMPRMCRITERIA.proc_UpsertPrmCriteriaDtl(?,?,?,?,?,?,?,?,?,?,?,?)"); bInsert = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "N")); oParameters.add(new DBObject(2, 1, 12, oHdrBean.getHeaderPrimaryKey())); oParameters.add(new DBObject(3, 1, 12, oHdrBean.getToGradeId())); oParameters.add(new DBObject(4, 1, 12, oDtlBean.getTxtDescription())); oParameters.add(new DBObject(5, 1, 12, oDtlBean.getTxtCriteriaStartDate())); oParameters.add(new DBObject(6, 1, 12, oDtlBean.getTxtCriteriaEndDate())); oParameters.add(new DBObject(7, 1, 12, oDtlBean.getTxtMinServicePeriod())); oParameters.add(new DBObject(8, 1, 12, oDtlBean.getTxtReqYears())); oParameters.add(new DBObject(9, 1, 12, oDtlBean.getTxtYearAPAR())); oParameters.add(new DBObject(10, 1, 12, "200")); oParameters.add(new DBObject(11, 1, 12, "200")); oParameters.add(new DBObject(12, 1, 12, oDtlBean.getDetailId())); oBean.addToBatch(oParameters); } if (oDtlBean.getStatus().equals("U")) { if (!bUpdate) { oBean = new DBUtilitiesBean(); oBean.createBatch("HRMPRMCRITERIA.proc_UpsertPrmCriteriaDtl(?,?,?,?,?,?,?,?,?,?,?,?)"); bUpdate = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, "U")); oParameters.add(new DBObject(2, 1, 12, oHdrBean.getHeaderPrimaryKey())); oParameters.add(new DBObject(3, 1, 12, oHdrBean.getHeaderPrimaryKey())); oParameters.add(new DBObject(4, 1, 12, oDtlBean.getTxtDescription())); oParameters.add(new DBObject(5, 1, 12, oDtlBean.getTxtCriteriaStartDate())); oParameters.add(new DBObject(6, 1, 12, oDtlBean.getTxtCriteriaEndDate())); oParameters.add(new DBObject(7, 1, 12, oDtlBean.getTxtMinServicePeriod())); oParameters.add(new DBObject(8, 1, 12, oDtlBean.getTxtReqYears())); oParameters.add(new DBObject(9, 1, 12, oDtlBean.getTxtYearAPAR())); oParameters.add(new DBObject(10, 1, 12, "200")); oParameters.add(new DBObject(11, 1, 12, "200")); oParameters.add(new DBObject(12, 1, 12, oDtlBean.getDetailId())); oBean.addToBatch(oParameters); } if (oDtlBean.getStatus().equals("D")) { if (!bDelete) { oBean = new DBUtilitiesBean(); oBean.createBatch("HRMPRMCRITERIA.proc_DeletePrmCriteriaDtl(?)"); bDelete = true; } oParameters = new ArrayList(); oParameters.add(new DBObject(1, 1, 12, oDtlBean.getDetailId())); oBean.addToBatch(oParameters); } } if (bInsert) oBean.executeBatch(); if (bUpdate) oBean.executeBatch(); if (bDelete) oBean.executeBatch(); } public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {} public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException { return "!"; } public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp param2, String param3, String param4, boolean param5, ArrayList oDtlBeanArray, boolean param7, Timestamp param8) throws EnrgiseSystemException, EnrgiseApplicationException {} private void checkMandatoryHeader(HrmPrmCriteriaHdrBean oHdrBean, ArrayList arylstErrorList) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList arylstParams = new ArrayList(); if (!EnrgiseUtil.checkString(oHdrBean.getHeaderPrimaryKey())) { MessageKey oMessageKey = new MessageKey("hrm.HrmPrmCriteria.fromPost"); arylstParams = new ArrayList(); arylstParams.add(oMessageKey); arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", arylstParams, "E")); } if (!EnrgiseUtil.checkString(oHdrBean.getToGradeCode())) { MessageKey oMessageKey = new MessageKey("hrm.HrmPrmCriteria.toPost"); arylstParams = new ArrayList(); arylstParams.add(oMessageKey); arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", arylstParams, "E")); } } public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {} public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String param1) throws EnrgiseSystemException { HrmPrmGenAssHdrBean oHdrBean = (HrmPrmGenAssHdrBean)oBaseHeaderBean; return "saveHeaderImpl toBeDone"; } public void additionalBusinessValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList oDtlBeanArray, boolean param7, Timestamp param8) throws EnrgiseApplicationException, EnrgiseSystemException {} public LovVO getPrmNoLOV(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList oHeaderList = new ArrayList(); oHeaderList.add("hrm.id"); oHeaderList.add("hrm.HrmPrmGenAss.prmNo"); oHeaderList.add("hrm.HrmPrmGenAss.description"); oHeaderList.add("hrm.id"); oHeaderList.add("hrm.id"); oLovVO.setHeaderList(oHeaderList); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); arylstVisibility.add("V"); arylstVisibility.add("H"); arylstVisibility.add("H"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; ArrayList arylstParameters = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); String sQuerySearch2 = new String(); String sHierarchy = null; if (oLovQueryVO.getProperty("hierarchy") != null) sHierarchy = oLovQueryVO.getProperty("hierarchy").trim(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); if (oLovQueryVO.getSearchField2() != null) sQuerySearch2 = oLovQueryVO.getSearchField2(); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1)); arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2)); 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, "HRMPRMGENASS.proc_GetPrmNoticeLOV(?,?,?,?,?,?)"); 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("notice_no").getString()); oLOVBean.setDetailField3(oRow.get("description").getString()); arylstList.add(oLOVBean); } oLovVO.setDetailList(arylstList); return oLovVO; } public String generateAssessment(HrmPrmGenAssHdrBean oHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { String sPrmId = oHdrBean.getPrmId(); if (!EnrgiseUtil.checkString(sPrmId)) { MessageKey oMessageKey = new MessageKey("hrm.HrmPrmGenAss.prmNo"); ArrayList arylstParams = new ArrayList(); ArrayList arylstErrorList = new ArrayList(); arylstParams.add(oMessageKey); arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", arylstParams, "E")); reportError(arylstErrorList); } if (!EnrgiseUtil.checkString(oHdrBean.getSiteId())) { MessageKey oMessageKey = new MessageKey("hrm.HrmPrmGenAss.siteCode"); ArrayList arylstParams = new ArrayList(); ArrayList arylstErrorList = new ArrayList(); arylstParams.add(oMessageKey); arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", arylstParams, "E")); reportError(arylstErrorList); } ArrayList arylstNtcDtlId = getToPositions(sPrmId); Iterator itrNtcDtlId = arylstNtcDtlId.iterator(); while (itrNtcDtlId.hasNext()) { String sFromPost = null; String sNtcDtlId = itrNtcDtlId.next(); ArrayList arylstEmpList = getEmpList(sNtcDtlId); if (arylstEmpList.size() == 0) continue; getPostExpList(arylstEmpList); ArrayList arylstExpTable = getExpTable(sNtcDtlId); Iterator itrEmpList = arylstEmpList.iterator(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); int iExp = Integer.parseInt(oDtlBean.getCompanyExp()); sFromPost = oDtlBean.getFromPost(); oDtlBean.setExpPoints(getExpPoints(iExp, arylstExpTable)); } getRatingPointsList(sFromPost, arylstEmpList); ArrayList arylstCriteria = getCriteriaTable(sFromPost, sNtcDtlId); itrEmpList = arylstEmpList.iterator(); ArrayList arylstFilteredEmpList = new ArrayList(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); int iEmpMinSrv = (oDtlBean.getCompanyExp() == null) ? 0 : Integer.parseInt(oDtlBean.getCompanyExp()); int iEmpReqYrs = (oDtlBean.getPostExp() == null) ? 0 : Integer.parseInt(oDtlBean.getPostExp()); Date dToday = new Date(); String sDate = EnrgiseUtil.convertToString(dToday); if (isInCriteria(sDate, iEmpMinSrv, iEmpReqYrs, 1, arylstCriteria)) arylstFilteredEmpList.add(oDtlBean); } insertData(oHdrBean.getSiteId(), sNtcDtlId, arylstFilteredEmpList); } return "ok"; } private ArrayList getEmpList(String sPromNo) throws EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sPromNo)); 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, "HRMPRMGENASS.proc_GetEmpList(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); while (iter.hasNext()) { oRow = iter.next(); HrmPrmGenAssDtlBean oDtlBean = new HrmPrmGenAssDtlBean(); oDtlBean.setEmpId(oRow.get("ID").getString()); oDtlBean.setCompanyExp(oRow.get("comp_exp").getString()); oDtlBean.setFromPost(oRow.get("from_post").getString()); oDtlBean.setDesigId(oRow.get("designation_id").getString()); oDtlBean.setScaleId(oRow.get("scale_id").getString()); arylstList.add(oDtlBean); } return arylstList; } private void getRatingPointsList(String sPosHdrId, ArrayList arylstEmpList) throws EnrgiseSystemException { Iterator itrEmp = arylstEmpList.iterator(); StringBuffer sbEmpIds = new StringBuffer(); while (itrEmp.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmp.next(); sbEmpIds.append(oDtlBean.getEmpId()); sbEmpIds.append(","); } sbEmpIds.setLength(sbEmpIds.length() - 1); String sEmpIds = sbEmpIds.toString(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sEmpIds)); arylstParameters.add(new DBObject(2, 1, 12, sPosHdrId)); 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, "HRMPRMGENASS.proc_GetRatingPointsList(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); HashMap mapEmpRating = new HashMap(); while (iter.hasNext()) { oRow = iter.next(); mapEmpRating.put(oRow.get("ID").getString(), String.valueOf(String.valueOf(oRow.get("rating").getString()).concat(String.valueOf(":"))).concat(String.valueOf(oRow.get("rating_point").getString()))); } Iterator itrEmpList = arylstEmpList.iterator(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); String sRating = (String)mapEmpRating.get(oDtlBean.getEmpId()); String[] sRatingArr = sRating.split(":"); oDtlBean.setRating(sRatingArr[0]); oDtlBean.setRatingPoints(sRatingArr[1]); } } private void getTestPointsList(String sPosHdrId, ArrayList arylstEmpList) throws EnrgiseSystemException { Iterator itrEmp = arylstEmpList.iterator(); StringBuffer sbEmpIds = new StringBuffer(); while (itrEmp.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmp.next(); sbEmpIds.append(oDtlBean.getEmpId()); sbEmpIds.append(","); } sbEmpIds.setLength(sbEmpIds.length() - 1); String sEmpIds = sbEmpIds.toString(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sEmpIds)); arylstParameters.add(new DBObject(2, 1, 12, sPosHdrId)); 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, "HRMPRMGENASS.proc_GetRatingPointsList(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); HashMap mapEmpRating = new HashMap(); while (iter.hasNext()) { oRow = iter.next(); mapEmpRating.put(oRow.get("ID").getString(), oRow.get("rating").getString()); } Iterator itrEmpList = arylstEmpList.iterator(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); oDtlBean.setRatingPoints((String)mapEmpRating.get(oDtlBean.getEmpId())); } } private void getPostExpList(ArrayList arylstEmpList) throws EnrgiseSystemException { if (arylstEmpList.size() == 0) return; Iterator itrEmp = arylstEmpList.iterator(); StringBuffer sbEmpIds = new StringBuffer(); while (itrEmp.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmp.next(); sbEmpIds.append(oDtlBean.getEmpId()); sbEmpIds.append(","); } sbEmpIds.setLength(sbEmpIds.length() - 1); String sEmpIds = sbEmpIds.toString(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sEmpIds)); 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, "HRMPRMGENASS.proc_GetPostExpList(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); HashMap mapEmpPostExp = new HashMap(); while (iter.hasNext()) { oRow = iter.next(); mapEmpPostExp.put(oRow.get("ID").getString(), oRow.get("post_exp").getString()); } Iterator itrEmpList = arylstEmpList.iterator(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); oDtlBean.setPostExp((String)mapEmpPostExp.get(oDtlBean.getEmpId())); } } private void getEmpCategoryList(ArrayList arylstEmpList) throws EnrgiseSystemException { Iterator itrEmp = arylstEmpList.iterator(); StringBuffer sbEmpIds = new StringBuffer(); while (itrEmp.hasNext()) { sbEmpIds.append(itrEmp.next()); sbEmpIds.append(","); } sbEmpIds.setLength(sbEmpIds.length() - 1); String sEmpIds = sbEmpIds.toString(); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sEmpIds)); 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, "HRMPRMGENASS.proc_GetEmpCategory(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); HashMap mapEmpCategory = new HashMap(); while (iter.hasNext()) { oRow = iter.next(); mapEmpCategory.put(oRow.get("ID").getString(), oRow.get("category").getString()); } Iterator itrEmpList = arylstList.iterator(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); oDtlBean.setCategory((String)mapEmpCategory.get(oDtlBean.getEmpId())); } } public static void main(String[] s) { try { HrmPrmGenAssBO o = new HrmPrmGenAssBO(); HrmPrmGenAssHdrBean oh = new HrmPrmGenAssHdrBean(); oh.setPosInfHdrId("100029"); oh.setPrmNo("100001"); oh.setSiteId("100"); o.generateAssessment(oh); } catch (Exception exception) {} } private ArrayList getExpTable(String sNtcDtlId) throws EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sNtcDtlId)); 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, "HRMPRMGENASS.proc_GetMonExpDtls(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); while (iter.hasNext()) { oRow = iter.next(); HrmPrmExperienceDtlBean oDtlBean = new HrmPrmExperienceDtlBean(); oDtlBean.setStartField(oRow.get("MIN_EXPERIENCE").getString()); oDtlBean.setEndField(oRow.get("MAX_EXPERIENCE").getString()); oDtlBean.setTxtAccBasis(oRow.get("FLAT_MONTH_FLAG").getString()); oDtlBean.setTxtMonthsExp(oRow.get("MONTHS_EXPERIENCE").getString()); oDtlBean.setTxtPointsAwarded(oRow.get("POINTS_ACCUMULATED").getString()); arylstList.add(oDtlBean); } return arylstList; } private ArrayList getCriteriaTable(String sFromPostId, String sNtcDtlId) throws EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sNtcDtlId)); arylstParameters.add(new DBObject(2, 1, 12, sFromPostId)); 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, "HRMPRMGENASS.proc_PrmCriteriaList(?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); while (iter.hasNext()) { oRow = iter.next(); HrmPrmCriteriaDtlBean oDtlBean = new HrmPrmCriteriaDtlBean(); oDtlBean.setTxtCriteriaStartDate(EnrgiseUtil.convertToString(oRow.get("criteria_fr_dt").getDate())); oDtlBean.setTxtCriteriaEndDate(EnrgiseUtil.convertToString(oRow.get("criteria_to_dt").getDate())); oDtlBean.setTxtMinServicePeriod(oRow.get("min_service_period").getString()); oDtlBean.setTxtReqYears(oRow.get("years_in_current_post").getString()); oDtlBean.setTxtYearAPAR(oRow.get("no_of_years_apar").getString()); arylstList.add(oDtlBean); } return arylstList; } private boolean isInCriteria(String sDate, int iEmpMinSvc, int iEmpReqYrs, int iEmpYrsApr, ArrayList arylstExpTable) throws EnrgiseSystemException { int iExp = 0; boolean returnVal = true; Iterator itrExpTable = arylstExpTable.iterator(); while (itrExpTable.hasNext()) { HrmPrmCriteriaDtlBean oExpBean = itrExpTable.next(); int iStart = EnrgiseUtil.compareDates(new SimpleDateFormat("dd-MMM-yyyy"), sDate, oExpBean.getTxtCriteriaStartDate()); int iEnd = EnrgiseUtil.compareDates(new SimpleDateFormat("dd-MMM-yyyy"), sDate, oExpBean.getTxtCriteriaEndDate()); if (iStart >= 0 && iEnd <= 0) { int iMinSvc = Integer.parseInt(oExpBean.getTxtMinServicePeriod()); int iReqYrs = Integer.parseInt(oExpBean.getTxtReqYears()); int iYrsApr = Integer.parseInt(oExpBean.getTxtYearAPAR()); if (iMinSvc < iEmpMinSvc) returnVal = false; if (iReqYrs < iEmpReqYrs) returnVal = false; if (iYrsApr < iEmpYrsApr) returnVal = false; } } return returnVal; } private String getExpPoints(int iExp, ArrayList arylstExpTable) throws EnrgiseSystemException { int iExpPts = 0; Iterator itrExpTable = arylstExpTable.iterator(); while (itrExpTable.hasNext()) { HrmPrmExperienceDtlBean oExpBean = itrExpTable.next(); int iStart = Integer.parseInt(oExpBean.getStartField()); int iEnd = Integer.parseInt(oExpBean.getEndField()); if (iExp >= iStart && iExp <= iEnd) { if (oExpBean.getTxtAccBasis().equals("F")) { iExpPts = Integer.parseInt(oExpBean.getTxtPointsAwarded()); continue; } int iMonths = Integer.parseInt(oExpBean.getTxtMonthsExp()); int iPts = Integer.parseInt(oExpBean.getTxtPointsAwarded()); iExpPts = iExp * iPts / iMonths; } } return String.valueOf(iExpPts); } private void insertData(String sSiteId, String sPromNoticeId, ArrayList arylstEmpList) throws EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); oBean.createBatch("HRMPRMGENASS.proc_InsertPrmAss(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); Iterator itrEmpList = arylstEmpList.iterator(); while (itrEmpList.hasNext()) { HrmPrmGenAssDtlBean oDtlBean = itrEmpList.next(); arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sSiteId)); arylstParameters.add(new DBObject(2, 1, 12, oDtlBean.getCategory())); arylstParameters.add(new DBObject(3, 1, 12, oDtlBean.getCompanyExp())); arylstParameters.add(new DBObject(4, 1, 12, oDtlBean.getExpPoints())); arylstParameters.add(new DBObject(5, 1, 12, oDtlBean.getRating())); arylstParameters.add(new DBObject(6, 1, 12, oDtlBean.getRatingPoints())); arylstParameters.add(new DBObject(7, 1, 12, null)); arylstParameters.add(new DBObject(8, 1, 12, null)); arylstParameters.add(new DBObject(9, 1, 12, null)); arylstParameters.add(new DBObject(10, 1, 12, null)); arylstParameters.add(new DBObject(11, 1, 12, null)); arylstParameters.add(new DBObject(12, 1, 12, null)); arylstParameters.add(new DBObject(13, 1, 12, null)); arylstParameters.add(new DBObject(14, 1, 12, null)); arylstParameters.add(new DBObject(15, 1, 12, oDtlBean.getEmpId())); arylstParameters.add(new DBObject(16, 1, 12, sPromNoticeId)); arylstParameters.add(new DBObject(17, 1, 12, oDtlBean.getPostExp())); arylstParameters.add(new DBObject(18, 1, 12, this.oUserInfo.getUserTypeId())); arylstParameters.add(new DBObject(19, 1, 12, this.oUserInfo.getSiteId())); arylstParameters.add(new DBObject(20, 1, 12, oDtlBean.getDesigId())); arylstParameters.add(new DBObject(21, 1, 12, oDtlBean.getScaleId())); oBean.addToBatch(arylstParameters); } oBean.executeBatch(); } private ArrayList getToPositions(String sPrmId) throws EnrgiseSystemException { DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstParameters = new ArrayList(); arylstParameters.add(new DBObject(1, 1, 12, sPrmId)); 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, "HRMPRMGENASS.proc_GetPosHdrList(?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); Iterator iter = arylstList.iterator(); QueryRow oRow = null; arylstList = new ArrayList(); while (iter.hasNext()) { oRow = iter.next(); HrmPrmExperienceDtlBean oDtlBean = new HrmPrmExperienceDtlBean(); String sPosHdrId = oRow.get("id").getString(); arylstList.add(sPosHdrId); } return arylstList; } }