package wenrgise.hrms.businessdelegate; import java.rmi.RemoteException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.ejb.CreateException; import wenrgise.common.bean.BaseHeaderBean; 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.vo.BaseQueryVO; import wenrgise.common.vo.ThisPageVO; import wenrgise.ejb.common.utility.ServiceLocator; import wenrgise.hrms.bean.HrmAppraisalKPADtlBean; import wenrgise.hrms.bean.HrmAppraisalKPAHdrBean; import wenrgise.hrms.ejb.facade.HrmThirdFacade; import wenrgise.hrms.ejb.facade.HrmThirdFacadeHome; import wenrgise.hrms.vo.HrmAppraisalKPAQVO; public class HrmApprisalKPABD extends HrmBaseBD { public RecordMetaInfo getTotalDetailRecordCountImpl(String sPrimaryKey, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException { try { HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade"); HrmThirdFacade oHrmAppKPAFacade = oHome.create(); if (sScreenName.equals("HrmAppraisalKPA")) return oHrmAppKPAFacade.getHrmAppRaisalKpaDetailMetaInfo(sPrimaryKey); return null; } catch (RemoteException oRe) { System.out.println(oRe.getMessage()); throw new EnrgiseSystemException(oRe); } catch (CreateException oCrt) { System.out.println(oCrt.getMessage()); throw new EnrgiseSystemException(oCrt); } } public ArrayList getDetailRecordImpl(String sPrimaryKey, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { try { HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade"); HrmThirdFacade oHrmAppKPAFacade = oHome.create(); if (sScreenName.equals("HrmAppraisalKPA")) return oHrmAppKPAFacade.getHrmAppRaisalKpaDetail(sPrimaryKey, lAbsoluteStart, lAbsoluteEnd); return null; } catch (RemoteException oRe) { System.out.println(oRe.getMessage()); throw new EnrgiseSystemException(oRe); } catch (CreateException oCrt) { System.out.println(oCrt.getMessage()); throw new EnrgiseSystemException(oCrt); } } public String saveImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { try { HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade"); HrmThirdFacade oHrmAppKPAFacade = oHome.create(); return oHrmAppKPAFacade.saveHrmAppRaisalKpa((HrmAppraisalKPAHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); } catch (RemoteException oRe) { throw new EnrgiseSystemException(oRe); } catch (CreateException oCrt) { throw new EnrgiseSystemException(oCrt); } } public boolean updateHeaderRecordImpl(BaseHeaderBean oBaseHeaderBean) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { return true; } public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException { try { HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade"); HrmThirdFacade oHrmAppKPAFacade = oHome.create(); return oHrmAppKPAFacade.getHrmAppRaisalKpaHeaderMetaInfo((HrmAppraisalKPAQVO)oQueryVO); } catch (RemoteException oRe) { throw new EnrgiseSystemException(oRe); } catch (CreateException oCrt) { throw new EnrgiseSystemException(oCrt); } } public ArrayList getHeaderRecordImpl(BaseQueryVO oQueryVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { try { HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade"); HrmThirdFacade oHrmAppKPAFacade = oHome.create(); ArrayList oHeaderList = oHrmAppKPAFacade.getHrmAppRaisalKpaHeader((HrmAppraisalKPAQVO)oQueryVO, lStartPosition, lLastPosition); return oHeaderList; } catch (RemoteException oRe) { throw new EnrgiseSystemException(oRe); } catch (CreateException oCrt) { throw new EnrgiseSystemException(oCrt); } } public String submitImpl(String sButtonName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { try { String sHeaderPrimaryKey = null; HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade"); HrmThirdFacade oHrmThirdFacade = oHome.create(); if (bHeaderDataChanged || bDetailDataChanged) { MessageKey oMessageKey = new MessageKey("save.before.freeze"); ArrayList oParams = new ArrayList(); throw new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"); } if (sButtonName.equalsIgnoreCase("butFreeze")) sHeaderPrimaryKey = oHrmThirdFacade.getHrmAppRaisalKpaExactWeightage(oBaseHeaderBean.getHeaderPrimaryKey()); return sHeaderPrimaryKey; } catch (RemoteException oRe) { throw new EnrgiseSystemException(oRe); } catch (CreateException oCrt) { throw new EnrgiseSystemException(oCrt); } } public String getInsertDataImpl(BaseQueryVO oBaseQueryVO) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException { return null; } public Map getDisabledFieldsImpl(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException { HashMap oHashMap = new HashMap(); ArrayList arylstEnableList = new ArrayList(); ArrayList arylstDisableList = new ArrayList(); arylstDisableList.add("butDelete"); arylstDisableList.add("butDelRow"); ArrayList oEnableList = new ArrayList(); ArrayList oDetailList = oThisPageVO.getODetailList(); HrmAppraisalKPAHdrBean objHdrBean = (HrmAppraisalKPAHdrBean)oThisPageVO.getOHeaderBean(); if (oThisPageVO.getScreenMode().equalsIgnoreCase("N")) arylstDisableList.add("butKpaGroupCode"); if (oThisPageVO.getScreenMode().equalsIgnoreCase("Q")) { arylstDisableList.add("kpaGroupCode"); arylstDisableList.add("description"); arylstDisableList.add("ratingRequired"); arylstDisableList.add("txtAppraiserType"); } ArrayList arylstList = new ArrayList(); if (EnrgiseUtil.checkString(objHdrBean.getStatusOfHeader())) { if (oDetailList != null && objHdrBean.getStatusOfHeader().equalsIgnoreCase("Freezed")) { Iterator oIt = oDetailList.iterator(); while (oIt.hasNext()) { HrmAppraisalKPADtlBean oHrmAppraisalKPADtlBean = oIt.next(); oHrmAppraisalKPADtlBean.setDisabmandatoryFlag("true"); oHrmAppraisalKPADtlBean.setDisabtxtDescription("true"); oHrmAppraisalKPADtlBean.setDisabtxtKpaCode("true"); oHrmAppraisalKPADtlBean.setDisabtxtSrlNo("true"); oHrmAppraisalKPADtlBean.setDisabtxtWeightage("true"); arylstList.add(oHrmAppraisalKPADtlBean); } oThisPageVO.setODetailList(arylstList); } } else { ArrayList arylstDisabList = new ArrayList(); if (oDetailList != null) { Iterator oIt = oDetailList.iterator(); while (oIt.hasNext()) { HrmAppraisalKPADtlBean oHrmAppraisalKPADtlBean = oIt.next(); if (oHrmAppraisalKPADtlBean.getStatus().equalsIgnoreCase("Q")) { oHrmAppraisalKPADtlBean.setDisabtxtKpaCode("true"); oHrmAppraisalKPADtlBean.setDisabtxtSrlNo("true"); } arylstDisabList.add(oHrmAppraisalKPADtlBean); } } oThisPageVO.setODetailList(arylstDisabList); } if (oDetailList == null) { arylstDisableList.add("butFreeze"); } else if (oDetailList != null) { arylstEnableList.add("butFreeze"); } if (EnrgiseUtil.checkString(objHdrBean.getStatusOfHeader())) { arylstDisableList.add("butFreeze"); arylstDisableList.add("kpaGroupCode"); arylstDisableList.add("butKpaGroupCode"); arylstDisableList.add("description"); arylstDisableList.add("ratingRequired"); arylstDisableList.add("statusOfHeader"); arylstDisableList.add("txtAppraiserType"); } oHashMap.put("D", arylstDisableList); oHashMap.put("E", arylstEnableList); return oHashMap; } }