package wenrgise.hrms.ejb.business; import java.sql.Timestamp; import java.util.ArrayList; 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.DateUtility; 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.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.HrmOrgCalMstDtlBean; import wenrgise.hrms.bean.HrmOrgCalMstHdrBean; import wenrgise.hrms.vo.HrmOrgCalMstQVO; public class HrmOrgCalMstBO extends HrmBaseBO { public HrmOrgCalMstBO() {} public HrmOrgCalMstBO(UserInfo oUserInfo) { super(oUserInfo); } public RecordMetaInfo getHrmCalHdrMetaInfo(HrmOrgCalMstQVO oHrmOrgCalMstQVO) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmOrgCalMstQVO.getHeaderPrimaryKey())); arylstParam.add(new DBObject(2, 1, 12, oHrmOrgCalMstQVO.getCalendarType())); arylstParam.add(new DBObject(3, 2, -5)); arylstParam.add(new DBObject(4, 2, 93)); 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, "HRMORGCALENDARMST.proc_HrCalCount(?,?,?,?,?,?,?)"); 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 getHrmCalHeaderInfo(HrmOrgCalMstQVO oHrmOrgCalMstQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList arylstHeaderList = null; if (oHrmOrgCalMstQVO == null) oHrmOrgCalMstQVO = new HrmOrgCalMstQVO(); 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, oHrmOrgCalMstQVO.getHeaderPrimaryKey())); arylstParam.add(new DBObject(4, 1, 12, oHrmOrgCalMstQVO.getCalendarType())); arylstParam.add(new DBObject(5, 2, -10)); 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, "HRMORGCALENDARMST.proc_GetHrCalHdrInfo(?,?,?,?,?,?,?,?)"); 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 itrBean = arylstList.iterator(); while (itrBean.hasNext()) { if (count == 0) arylstHeaderList = new ArrayList(); count++; oRow = itrBean.next(); HrmOrgCalMstHdrBean oCalHeader = new HrmOrgCalMstHdrBean(); oCalHeader.setHeaderPrimaryKey(oRow.get("ID").getString()); oCalHeader.setCalendarType(oRow.get("CALENDAR_TYPE").getString()); oCalHeader.setStartMonth(oRow.get("BEGIN_MONTH").getString()); oCalHeader.setDuration(oRow.get("DURATION_MONTH").getString()); arylstHeaderList.add(oCalHeader); } return arylstHeaderList; } public RecordMetaInfo getHrmCalDetailMetaInfo(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, lPrimaryKey)); arylstParam.add(new DBObject(2, 2, -5)); arylstParam.add(new DBObject(3, 2, 93)); 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, "HRMORGCALENDARMST.proc_HrCalDtlCount(?,?,?,?,?,?)"); 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 getHrmCalDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); int count = 0; BaseDetailVO oBaseDetailVO = null; ArrayList arylstHrmCalDetail = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition))); arylstParam.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition))); arylstParam.add(new DBObject(3, 1, 12, lPrimaryKey)); 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, "HRMORGCALENDARMST.proc_GetHrCalDtlInfo(?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); ArrayList arylstList = (ArrayList)oOutObject.getObject(); if (arylstList.size() == 0) throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); QueryRow oRow = null; QueryValue oValue = null; HashMap oColumns = null; Iterator itrBean = arylstList.iterator(); while (itrBean.hasNext()) { if (count == 0) arylstHrmCalDetail = new ArrayList(); count++; oRow = itrBean.next(); HrmOrgCalMstDtlBean oCalDetailBean = new HrmOrgCalMstDtlBean(); oCalDetailBean.setDetailId(oRow.get("ID").getString()); oCalDetailBean.setTxtSlabNumber(oRow.get("SLAB_NO").getString()); oCalDetailBean.setTxtSlabBeginMonth(oRow.get("SLAB_BEGIN_MONTH").getString()); oCalDetailBean.setTxtDuration(oRow.get("SLAB_DURATION_MONTH").getString()); arylstHrmCalDetail.add(oCalDetailBean); } return arylstHrmCalDetail; } public ArrayList getHrmCalHeaderInfoById(String sId) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList arylstHeaderList = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sId)); 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, "HRMORGCALENDARMST.proc_GetHrCalHdrInfoById(?,?,?,?,?)"); 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 itrBean = arylstList.iterator(); while (itrBean.hasNext()) { if (count == 0) arylstHeaderList = new ArrayList(); count++; oRow = itrBean.next(); HrmOrgCalMstHdrBean oCalHeader = new HrmOrgCalMstHdrBean(); oCalHeader.setHeaderPrimaryKey(oRow.get("ID").getString()); oCalHeader.setCalendarType(oRow.get("CALENDAR_TYPE").getString()); oCalHeader.setStartMonth(oRow.get("BEGIN_MONTH").getString()); oCalHeader.setDuration(oRow.get("DURATION_MONTH").getString()); arylstHeaderList.add(oCalHeader); } return arylstHeaderList; } public ArrayList getHrmCalHeaderInfoBySiteId(String sSiteId) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList arylstHeaderList = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sSiteId)); 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, "HRMORGCALENDARMST.proc_GetHrCalHdrInfoBySiteId(?,?,?,?,?)"); 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 itrBean = arylstList.iterator(); while (itrBean.hasNext()) { if (count == 0) arylstHeaderList = new ArrayList(); count++; oRow = itrBean.next(); HrmOrgCalMstHdrBean oCalHeader = new HrmOrgCalMstHdrBean(); oCalHeader.setHeaderPrimaryKey(oRow.get("ID").getString()); oCalHeader.setCalendarType(oRow.get("CALENDAR_TYPE").getString()); oCalHeader.setStartMonth(oRow.get("BEGIN_MONTH").getString()); oCalHeader.setDuration(oRow.get("DURATION_MONTH").getString()); arylstHeaderList.add(oCalHeader); } return arylstHeaderList; } public String getStartDate(String sCalId, String sDate) throws EnrgiseApplicationException, EnrgiseSystemException { DateUtility d = new DateUtility(); ArrayList arylstParam = new ArrayList(); String startDate = null; DBUtilitiesBean oBean = new DBUtilitiesBean(); Timestamp oWhenPicked = null; int count = 0; BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO(); ArrayList arylstHeaderList = null; arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sCalId)); 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, "HRMORGCALENDARMST.proc_GetHrCalHdrInfoById(?,?,?,?,?)"); 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 itrBean = arylstList.iterator(); while (itrBean.hasNext()) { oRow = itrBean.next(); String beginMonth = oRow.get("BEGIN_MONTH").getString(); String durationMonth = oRow.get("DURATION_MONTH").getString(); int beMon = Integer.parseInt(beginMonth); String monOfDate = sDate.substring(3, 5); String yearOfDate = sDate.substring(6, 10); int monDate = Integer.parseInt(monOfDate); int yrDate = Integer.parseInt(yearOfDate); if (beMon <= monDate) { if (beMon < 10) beginMonth = String.valueOf("0").concat(String.valueOf(beginMonth)); startDate = String.valueOf(String.valueOf(String.valueOf("01/").concat(String.valueOf(beginMonth))).concat(String.valueOf("/"))).concat(String.valueOf(yearOfDate)); continue; } if (beMon > monDate) { if (beMon < 10) beginMonth = String.valueOf("0").concat(String.valueOf(beginMonth)); startDate = String.valueOf(String.valueOf(String.valueOf("01/").concat(String.valueOf(beginMonth))).concat(String.valueOf("/"))).concat(String.valueOf(yrDate - 1)); } } return startDate; } public LovVO getHrmCalendarTypeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException { LovVO oLovVO = new LovVO(); ArrayList arylstHeaderNames = new ArrayList(); arylstHeaderNames.add("ID"); arylstHeaderNames.add("hrm.HrmCalendarMaster.calendarType"); oLovVO.setHeaderList(arylstHeaderNames); ArrayList arylstVisibility = new ArrayList(); arylstVisibility.add("H"); arylstVisibility.add("V"); oLovVO.setVisibilityList(arylstVisibility); int count = 0; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); String sQuerySearch1 = new String(); if (oLovQueryVO.getSearchField1() != null) sQuerySearch1 = oLovQueryVO.getSearchField1(); arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1)); 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, "HRMORGSETUPLOV.proc_GetCalendarTypeLOV(?,?,?,?,?)"); 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("CALENDAR_TYPE").getString()); arylstList.add(oLOVBean); } oLovVO.setDetailList(arylstList); return oLovVO; } public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException { System.out.println("Update ille!"); } public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException { return "saveNewHeaderImpl ille!"; } 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((HrmOrgCalMstHdrBean)oBaseHeaderBean); if (bDetailDataChanged) if (sScreenName.equalsIgnoreCase("HrmOrgCalMst")) { Iterator itrBean1 = arylstDetailBeanArray.iterator(); int iCount = 1; while (itrBean1.hasNext()) { HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean = itrBean1.next(); if (!oHrmOrgCalMstDtlBean.getStatus().equalsIgnoreCase("D")) checkMandatory(oHrmOrgCalMstDtlBean, iCount, arylstErrorList); iCount++; } } reportError(arylstErrorList); } public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {} public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstErrorList = new ArrayList(); HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean = (HrmOrgCalMstHdrBean)oBaseHeaderBean; if (bHeaderDataChanged) if (!sScreenMode.equalsIgnoreCase("D")) { checkUniqueHeader((HrmOrgCalMstHdrBean)oBaseHeaderBean); checkZeroDuration((HrmOrgCalMstHdrBean)oBaseHeaderBean); } if (bDetailDataChanged) if (!sScreenMode.equalsIgnoreCase("D")) if (sScreenName.equalsIgnoreCase("HrmOrgCalMst")) { Iterator itrBean1 = arylstDetailBeanArray.iterator(); int rowCount = 1; while (itrBean1.hasNext()) { HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean = itrBean1.next(); if (!oHrmOrgCalMstDtlBean.getStatus().equalsIgnoreCase("D")) { EnrgiseUtil.checkDuplicate(arylstDetailBeanArray, "txtSlabNumber", "hrm.HrmCalendarMaster.txtSlabNumber", arylstErrorList, true); checkDuration((HrmOrgCalMstHdrBean)oBaseHeaderBean, arylstDetailBeanArray); compareDuration((HrmOrgCalMstHdrBean)oBaseHeaderBean, arylstDetailBeanArray); checkStartMonth((HrmOrgCalMstHdrBean)oBaseHeaderBean, arylstDetailBeanArray); } } rowCount++; } reportError(arylstErrorList); } private void checkUniqueHeader(HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstList1 = new ArrayList(); ArrayList arylstParam = new ArrayList(); String sQuery = String.valueOf(String.valueOf(" Select ID as ID from HRM_CALENDAR_MST where calendar_type='").concat(String.valueOf(oHrmOrgCalMstHdrBean.getCalendarType()))).concat(String.valueOf("'")); DBUtilitiesBean oBean = new DBUtilitiesBean(); ArrayList arylstList = oBean.executeQuery(sQuery); Iterator itrBean = arylstList.iterator(); if (itrBean.hasNext()) { QueryRow oRow = itrBean.next(); if (!oRow.get("ID").getString().equalsIgnoreCase(oHrmOrgCalMstHdrBean.getHeaderPrimaryKey())) { arylstParam = new ArrayList(); arylstParam.add(""); arylstParam.add(new Integer(0)); arylstList1.add(new EnrgiseMessageKeyException("wenrgise.common.uniqueConstraintViolated", arylstParam)); } } reportError(arylstList1); } private void checkZeroDuration(HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstList1 = new ArrayList(); ArrayList arylstParam = new ArrayList(); if (Integer.parseInt(oHrmOrgCalMstHdrBean.getDuration()) == 0) { arylstParam = new ArrayList(); arylstParam.add(""); arylstParam.add(new Integer(0)); arylstList1.add(new EnrgiseMessageKeyException("hrm.HrmCalendarMaster.zeroDuration", arylstParam)); } reportError(arylstList1); } private void checkMandatoryHeader(HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException { ArrayList oErrorList = new ArrayList(); ArrayList oParams = new ArrayList(); if (!EnrgiseUtil.checkString(oHrmOrgCalMstHdrBean.getCalendarType())) { MessageKey oMessageKey = new MessageKey("hrm.HrmCalendarMaster.calendarType"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmOrgCalMstHdrBean.getStartMonth())) { MessageKey oMessageKey = new MessageKey("hrm.HrmCalendarMaster.startMonth"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmOrgCalMstHdrBean.getDuration())) { MessageKey oMessageKey = new MessageKey("hrm.HrmCalendarMaster.duration"); oParams = new ArrayList(); oParams.add(oMessageKey); oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E")); } reportError(oErrorList); } private void checkMandatory(HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean, int iCount, ArrayList arylstErrorList) throws EnrgiseSystemException, EnrgiseApplicationException { if (!EnrgiseUtil.checkString(oHrmOrgCalMstDtlBean.getTxtDuration())) { MessageKey oMessageKey = new MessageKey("hrm.HrmCalendarMaster.txtDuration"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oParams.add(new Integer(iCount)); arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E")); } if (!EnrgiseUtil.checkString(oHrmOrgCalMstDtlBean.getTxtSlabBeginMonth())) { MessageKey oMessageKey = new MessageKey("hrm.HrmCalendarMaster.txtSlabBeginMonth"); ArrayList oParams = new ArrayList(); oParams.add(oMessageKey); oParams.add(String.valueOf(iCount)); arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E")); } reportError(arylstErrorList); } private void compareDuration(HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean, ArrayList arylstDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstList = new ArrayList(); ArrayList arylstParam = new ArrayList(); int count = 0; Iterator itrBean = arylstDetailBeanArray.iterator(); int totalDuration = 0; while (itrBean.hasNext()) { HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean = arylstDetailBeanArray.get(count); int duration = Integer.parseInt(oHrmOrgCalMstDtlBean.getTxtDuration()); totalDuration += duration; count++; itrBean.next(); } if (totalDuration != Integer.parseInt(oHrmOrgCalMstHdrBean.getDuration())) if (arylstList.isEmpty()) { arylstParam = new ArrayList(); arylstParam.add(""); arylstParam.add(new Integer(0)); arylstList.add(new EnrgiseMessageKeyException("hrm.HrmCalendarMaster.durationValidation", arylstParam)); } reportError(arylstList); } private void checkDuration(HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean, ArrayList arylstDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstList = new ArrayList(); ArrayList arylstParam = new ArrayList(); int count = 0; Iterator itrBean = arylstDetailBeanArray.iterator(); int totalDuration = 0; while (itrBean.hasNext()) { HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean = arylstDetailBeanArray.get(count); int duration = Integer.parseInt(oHrmOrgCalMstDtlBean.getTxtDuration()); if (duration == 0) { arylstParam = new ArrayList(); arylstParam.add(""); arylstParam.add(new Integer(count)); arylstList.add(new EnrgiseMessageKeyException("hrm.HrmCalendarMaster.zeroDuration", arylstParam)); } count++; itrBean.next(); } reportError(arylstList); } private void checkStartMonth(HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean, ArrayList arylstDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException { ArrayList arylstList = new ArrayList(); ArrayList arylstParam = new ArrayList(); int count = 0; Iterator itrBean = arylstDetailBeanArray.iterator(); int newStartMonth = 0; HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean2 = arylstDetailBeanArray.get(0); if (EnrgiseUtil.checkString(oHrmOrgCalMstDtlBean2.getTxtSlabBeginMonth())) if (Integer.parseInt(oHrmOrgCalMstDtlBean2.getTxtSlabBeginMonth()) != Integer.parseInt(oHrmOrgCalMstHdrBean.getStartMonth())) { arylstParam = new ArrayList(); arylstParam.add(""); arylstParam.add(new Integer(1)); arylstList.add(new EnrgiseMessageKeyException("hrm.HrmCalendarMaster.slabBeginMonthValidation1", arylstParam)); } while (itrBean.hasNext()) { HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean = arylstDetailBeanArray.get(count); int duration = Integer.parseInt(oHrmOrgCalMstDtlBean.getTxtDuration()); int startMonth = Integer.parseInt(oHrmOrgCalMstDtlBean.getTxtSlabBeginMonth()); newStartMonth = startMonth + duration; if (newStartMonth > 12) newStartMonth -= 12; if (count < arylstDetailBeanArray.size() - 1) { count++; HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean1 = arylstDetailBeanArray.get(count); if (newStartMonth != Integer.parseInt(oHrmOrgCalMstDtlBean1.getTxtSlabBeginMonth())) if (arylstList.isEmpty()) { arylstParam = new ArrayList(); arylstParam.add(""); arylstParam.add(new Integer(count)); arylstList.add(new EnrgiseMessageKeyException("hrm.HrmCalendarMaster.slabBeginMonthValidation", arylstParam)); } } else { reportError(arylstList); } itrBean.next(); } reportError(arylstList); } public void initializeBOImpl() { this.headerTable = "HRM_CALENDAR_MST"; } public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException { String returnString = null; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = new DBUtilitiesBean(); DateUtility d = new DateUtility(); HrmOrgCalMstHdrBean oHrmOrgCalMstHdrBean = (HrmOrgCalMstHdrBean)oBaseHeaderBean; if (ScreenMode.equalsIgnoreCase("N")) { arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, "i")); arylstParam.add(new DBObject(2, 1, 12, this.oUserInfo.getSiteId())); arylstParam.add(new DBObject(3, 1, 12, oHrmOrgCalMstHdrBean.getCalendarType())); arylstParam.add(new DBObject(4, 1, 12, oHrmOrgCalMstHdrBean.getStartMonth())); arylstParam.add(new DBObject(5, 1, 12, oHrmOrgCalMstHdrBean.getDuration())); arylstParam.add(new DBObject(6, 1, 12, this.oUserInfo.getUserTypeId())); arylstParam.add(new DBObject(7, 1, 12, this.oUserInfo.getSiteId())); arylstParam.add(new DBObject(8, 1, 12, null)); arylstParam.add(new DBObject(9, 2, 12)); arylstParam.add(new DBObject(10, 2, 12)); arylstParam.add(new DBObject(11, 2, 12)); arylstParam.add(new DBObject(12, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMORGCALENDARMST.proc_UpsertHrCalendarHdr(?,?,?,?,?,?,?,?,?,?,?,?)"); 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, this.oUserInfo.getSiteId())); arylstParam.add(new DBObject(3, 1, 12, oHrmOrgCalMstHdrBean.getCalendarType())); arylstParam.add(new DBObject(4, 1, 12, oHrmOrgCalMstHdrBean.getStartMonth())); arylstParam.add(new DBObject(5, 1, 12, oHrmOrgCalMstHdrBean.getDuration())); arylstParam.add(new DBObject(6, 1, 12, this.oUserInfo.getUserTypeId())); arylstParam.add(new DBObject(7, 1, 12, this.oUserInfo.getSiteId())); arylstParam.add(new DBObject(8, 1, 12, oHrmOrgCalMstHdrBean.getHeaderPrimaryKey())); arylstParam.add(new DBObject(9, 2, 12)); arylstParam.add(new DBObject(10, 2, 12)); arylstParam.add(new DBObject(11, 2, 12)); arylstParam.add(new DBObject(12, 2, 4)); ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMORGCALENDARMST.proc_UpsertHrCalendarHdr(?,?,?,?,?,?,?,?,?,?,?,?)"); DBObject oOutObject = arylstOutArray.get(0); returnString = (String)oOutObject.getObject(); } return returnString; } public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException { if (sScreenName.equalsIgnoreCase("HrmOrgCalMst")) saveHrmCalendarDetail(sHeaderPrimaryKey, arylstDetailBeanArray); } private void saveHrmCalendarDetail(String sHeaderPrimaryKey, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException { boolean bInsert = false; boolean bUpdate = false; boolean bDelete = false; ArrayList arylstParam = new ArrayList(); DBUtilitiesBean oBean = null; DBUtilitiesBean oBean1 = null; Iterator itrBean = arylstDetailBeanArray.iterator(); while (itrBean.hasNext()) { HrmOrgCalMstDtlBean oHrmOrgCalMstDtlBean = itrBean.next(); System.out.println(oHrmOrgCalMstDtlBean.getStatus()); if (oHrmOrgCalMstDtlBean.getStatus().equals("N")) { if (!bInsert) { oBean = new DBUtilitiesBean(); oBean.createBatch("HRMORGCALENDARMST.proc_UpsertHrCalendarDtl(?,?,?,?,?,?,?,?,?)"); bInsert = true; } arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, "I")); arylstParam.add(new DBObject(2, 1, 12, null)); arylstParam.add(new DBObject(3, 1, 12, sHeaderPrimaryKey)); arylstParam.add(new DBObject(4, 1, 12, "200")); arylstParam.add(new DBObject(5, 1, 12, oHrmOrgCalMstDtlBean.getTxtSlabNumber())); arylstParam.add(new DBObject(6, 1, 12, oHrmOrgCalMstDtlBean.getTxtSlabBeginMonth())); arylstParam.add(new DBObject(7, 1, 12, oHrmOrgCalMstDtlBean.getTxtDuration())); arylstParam.add(new DBObject(8, 1, 12, this.oUserInfo.getUserTypeId())); arylstParam.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(arylstParam); continue; } if (oHrmOrgCalMstDtlBean.getStatus().equals("U")) { if (!bUpdate) { oBean = new DBUtilitiesBean(); oBean.createBatch("HRMORGCALENDARMST.proc_UpsertHrCalendarDtl(?,?,?,?,?,?,?,?,?)"); bUpdate = true; } arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, "U")); arylstParam.add(new DBObject(2, 1, 12, oHrmOrgCalMstDtlBean.getDetailId())); arylstParam.add(new DBObject(3, 1, 12, sHeaderPrimaryKey)); arylstParam.add(new DBObject(4, 1, 12, "200")); arylstParam.add(new DBObject(5, 1, 12, oHrmOrgCalMstDtlBean.getTxtSlabNumber())); arylstParam.add(new DBObject(6, 1, 12, oHrmOrgCalMstDtlBean.getTxtSlabBeginMonth())); arylstParam.add(new DBObject(7, 1, 12, oHrmOrgCalMstDtlBean.getTxtDuration())); arylstParam.add(new DBObject(8, 1, 12, this.oUserInfo.getUserTypeId())); arylstParam.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId())); oBean.addToBatch(arylstParam); continue; } if (oHrmOrgCalMstDtlBean.getStatus().equals("D")) { if (!bDelete) { oBean1 = new DBUtilitiesBean(); oBean1.createBatch("HRMORGCALENDARMST.proc_DeleteCalMstDtl(?)"); bDelete = true; } arylstParam = new ArrayList(); arylstParam.add(new DBObject(1, 1, 12, oHrmOrgCalMstDtlBean.getDetailId())); oBean1.addToBatch(arylstParam); } } if (bInsert) oBean.executeBatch(); if (bUpdate) oBean.executeBatch(); if (bDelete) oBean1.executeBatch(); } }