package wenrgise.hrms.ejb.business;

import java.rmi.RemoteException;
import java.sql.Timestamp;
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.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseMessageKeyException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.DateUtility;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.MessageKey;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.utility.WorkFlowServiceLocator;
import wenrgise.common.vo.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.HrmAprslSpcTmplDtlBean;
import wenrgise.hrms.bean.HrmAprslSpcTmplEmpEligDtlBean;
import wenrgise.hrms.bean.HrmAprslSpcTmplGoalDtlBean;
import wenrgise.hrms.bean.HrmAprslSpcTmplHdrBean;
import wenrgise.hrms.vo.HrmAprslSpcTmplQVO;
import wenrgise.workflow.bean.WflAuthorizationBean;
import wenrgise.workflow.core.WflDocumentInfo;
import wenrgise.workflow.core.WflResource;
import wenrgise.workflow.core.WflSite;
import wenrgise.workflow.core.WflStatus;
import wenrgise.workflow.core.impl.WflDocumentInfoImpl;
import wenrgise.workflow.core.impl.WflResourceImpl;
import wenrgise.workflow.core.impl.WflSiteImpl;
import wenrgise.workflow.ejb.facade.WorkFlowFacade;
import wenrgise.workflow.ejb.facade.WorkFlowFacadeHome;

public class HrmAprslSpcTmplBO extends HrmBaseBO {
  public HrmAprslSpcTmplBO() {}
  
  public HrmAprslSpcTmplBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_APRSL_SPECIFIC_TMPL";
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    System.out.println("Update ille!");
  }
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return "";
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    if (sScreenName.equals("HrmAprslSpcTmplGoals"))
      saveGoalDetailData(sHeaderPrimaryKey, oDetailBeanArray); 
    if (sScreenName.equals("HrmAprslSpcTmpl"))
      saveKPADetailData(sHeaderPrimaryKey, oDetailBeanArray); 
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean = (HrmAprslSpcTmplHdrBean)oBaseHeaderBean;
    if (ScreenMode.equalsIgnoreCase("N")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "N"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmAprslSpcTmplHdrBean.getTemplateNameId()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmAprslSpcTmplHdrBean.getSplTemplateName()));
      arylstParam.add(new DBObject(4, 1, 12, oHrmAprslSpcTmplHdrBean.getSiteId()));
      arylstParam.add(new DBObject(5, 1, 12, oHrmAprslSpcTmplHdrBean.getDeptId()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmAprslSpcTmplHdrBean.getClassHdrId()));
      arylstParam.add(new DBObject(7, 1, 12, oHrmAprslSpcTmplHdrBean.getClassDtlId()));
      arylstParam.add(new DBObject(8, 1, 12, oHrmAprslSpcTmplHdrBean.getEmpId()));
      arylstParam.add(new DBObject(9, 1, 12, oHrmAprslSpcTmplHdrBean.getStOrderId()));
      arylstParam.add(new DBObject(10, 1, 12, this.oUserInfo.getUserId()));
      arylstParam.add(new DBObject(11, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(12, 2, 12));
      arylstParam.add(new DBObject(13, 2, 12));
      arylstParam.add(new DBObject(14, 2, 12));
      arylstParam.add(new DBObject(15, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSLSPCTMPL.procUpsertHrAprslSpcTmplHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } else if (ScreenMode.equalsIgnoreCase("U")) {
    
    } 
    saveKPADetailPart(returnString);
    saveEmpEligDetailPart(returnString);
    return returnString;
  }
  
  public void saveKPADetailPart(String sHeaderPrimaryKey) throws EnrgiseSystemException {
    ArrayList oDetailBeanArray = new ArrayList();
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey));
    oParameters.add(new DBObject(2, 1, 12, this.oUserInfo.getUserId()));
    oParameters.add(new DBObject(3, 1, 12, this.oUserInfo.getSiteId()));
    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, "HRMAPRSLSPCTMPL.procGetHrAprslSpcTmplKPAInfo(?,?,?,?,?,?)");
  }
  
  public void saveEmpEligDetailPart(String sHeaderPrimaryKey) throws EnrgiseSystemException {
    ArrayList oDetailBeanArray = new ArrayList();
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sHeaderPrimaryKey));
    oParameters.add(new DBObject(2, 1, 12, this.oUserInfo.getUserId()));
    oParameters.add(new DBObject(3, 1, 12, this.oUserInfo.getSiteId()));
    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, "HRMAPRSLSPCTMPL.procSaveSpcTmplEmpEligInfo(?,?,?,?,?,?)");
  }
  
  public void saveGoalDetailData(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBeanInsert = null;
    DBUtilitiesBean oBeanDelete = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslSpcTmplGoalDtlBean oHrmAprslSpcTmplGoalDtlBean = oIt.next();
      if (oHrmAprslSpcTmplGoalDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBeanInsert = new DBUtilitiesBean();
          oBeanInsert.createBatch("HRMAPRSLSPCTMPL.procUpsertHrTmplAprslGoal(?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, new String("N")));
        oParameters.add(new DBObject(2, 1, 12, new String("888")));
        oParameters.add(new DBObject(3, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtSrlNo())));
        oParameters.add(new DBObject(4, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtSectionId())));
        oParameters.add(new DBObject(5, 1, 12, sHeaderPrimaryKey));
        oParameters.add(new DBObject(6, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtMesr())));
        oParameters.add(new DBObject(7, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtGoalsDesc())));
        oParameters.add(new DBObject(8, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtWtg())));
        oParameters.add(new DBObject(9, 1, 12, new String(this.oUserInfo.getUserId())));
        oParameters.add(new DBObject(10, 1, 12, new String(this.oUserInfo.getSiteId())));
        oBeanInsert.addToBatch(oParameters);
        continue;
      } 
      if (oHrmAprslSpcTmplGoalDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMAPRSLSPCTMPL.procUpsertHrTmplAprslGoal(?,?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, new String("U")));
        oParameters.add(new DBObject(2, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getDetailId())));
        oParameters.add(new DBObject(3, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtSrlNo())));
        oParameters.add(new DBObject(4, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtSectionId())));
        oParameters.add(new DBObject(5, 1, 12, sHeaderPrimaryKey));
        oParameters.add(new DBObject(6, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtMesr())));
        oParameters.add(new DBObject(7, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtGoalsDesc())));
        oParameters.add(new DBObject(8, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getTxtWtg())));
        oParameters.add(new DBObject(9, 1, 12, new String(this.oUserInfo.getUserId())));
        oParameters.add(new DBObject(10, 1, 12, new String(this.oUserInfo.getSiteId())));
        oBean.addToBatch(oParameters);
        continue;
      } 
      if (oHrmAprslSpcTmplGoalDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBeanDelete = new DBUtilitiesBean();
          oBeanDelete.createBatch("HRMAPRSLSPCTMPL.proc_DeleteAprslTmplGoal(?)");
          bDelete = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, new String(oHrmAprslSpcTmplGoalDtlBean.getDetailId())));
        oBeanDelete.addToBatch(oParameters);
      } 
    } 
    try {
      if (bInsert)
        oBeanInsert.executeBatch(); 
      if (bUpdate)
        oBean.executeBatch(); 
      if (bDelete)
        oBeanDelete.executeBatch(); 
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } 
  }
  
  public void saveKPADetailData(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bDelete = false;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBeanDelete = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslSpcTmplDtlBean oHrmAprslSpcTmplDtlBean = oIt.next();
      if (oHrmAprslSpcTmplDtlBean.getStatus().equals("D") && oHrmAprslSpcTmplDtlBean.getTxtFlag().equalsIgnoreCase("off")) {
        if (!bDelete) {
          oBeanDelete = new DBUtilitiesBean();
          oBeanDelete.createBatch("HRMAPRSLSPCTMPL.proc_DeleteAprslTmplKPADtl(?)");
          bDelete = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, new String(oHrmAprslSpcTmplDtlBean.getDetailId())));
        oBeanDelete.addToBatch(oParameters);
      } 
    } 
    try {
      if (bDelete)
        oBeanDelete.executeBatch(); 
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } 
  }
  
  public RecordMetaInfo getHrmAprslSpcTmpHdrMetaInfo(HrmAprslSpcTmplQVO oHrmAprslSpcTmplQVO) 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, oHrmAprslSpcTmplQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmAprslSpcTmplQVO.getTemplateNameId()));
    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, "HRMAPRSLSPCTMPL.procHrAprslSpcTmplHdrCount(?,?,?,?,?,?,?)");
    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 getHrmAprslSpcTmpHeaderInfo(HrmAprslSpcTmplQVO oHrmAprslSpcTmplQVO, 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 (oHrmAprslSpcTmplQVO == null)
      oHrmAprslSpcTmplQVO = new HrmAprslSpcTmplQVO(); 
    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, oHrmAprslSpcTmplQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmAprslSpcTmplQVO.getTemplateNameId()));
    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, "HRMAPRSLSPCTMPL.procHrAprslSpcTmplHdr(?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstHeaderList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean = new HrmAprslSpcTmplHdrBean();
      oHrmAprslSpcTmplHdrBean.setHeaderPrimaryKey(oRow.get("ID").getString());
      oHrmAprslSpcTmplHdrBean.setSplTemplateName(oRow.get("SPECIFIC_TEMPLATE_NAME").getString());
      oHrmAprslSpcTmplHdrBean.setTemplateName(oRow.get("TEMPLATE_NAME").getString());
      oHrmAprslSpcTmplHdrBean.setTemplateNameId(oRow.get("TMPL_HDR_ID").getString());
      oHrmAprslSpcTmplHdrBean.setStOrderId(oRow.get("APRSL_START_ORDER_ID").getString());
      oHrmAprslSpcTmplHdrBean.setStOrderNo(oRow.get("START_ORDER_NO").getString());
      oHrmAprslSpcTmplHdrBean.setDeptId(oRow.get("WRKGRP_ID").getString());
      oHrmAprslSpcTmplHdrBean.setDeptCode(oRow.get("DEPT_CODE").getString());
      oHrmAprslSpcTmplHdrBean.setDeptDesc(oRow.get("DEPT_NAME").getString());
      oHrmAprslSpcTmplHdrBean.setEmpId(oRow.get("E_PER_DTL_ID").getString());
      oHrmAprslSpcTmplHdrBean.setEmpNo(oRow.get("EMP_NO").getString());
      oHrmAprslSpcTmplHdrBean.setEmpName(oRow.get("EMPNAME").getString());
      oHrmAprslSpcTmplHdrBean.setFromDate(EnrgiseUtil.convertToString(oRow.get("PERIOD_START_DATE").getDate()));
      oHrmAprslSpcTmplHdrBean.setToDate(EnrgiseUtil.convertToString(oRow.get("PERIOD_END_DATE").getDate()));
      oHrmAprslSpcTmplHdrBean.setSiteId(oRow.get("SITE_ID").getString());
      oHrmAprslSpcTmplHdrBean.setSiteCode(oRow.get("SITE_CODE").getString());
      oHrmAprslSpcTmplHdrBean.setSiteDesc(oRow.get("SITE_NAME").getString());
      oHrmAprslSpcTmplHdrBean.setClassHdrId(oRow.get("CLS_HDR_ID").getString());
      oHrmAprslSpcTmplHdrBean.setClassHdr(oRow.get("CLS_HDR_CODE").getString());
      oHrmAprslSpcTmplHdrBean.setClassHdrDesc(oRow.get("CLS_HDR_NAME").getString());
      oHrmAprslSpcTmplHdrBean.setClassDtlId(oRow.get("CLS_DTL_ID").getString());
      oHrmAprslSpcTmplHdrBean.setClassDtl(oRow.get("CLS_DTL_CODE").getString());
      oHrmAprslSpcTmplHdrBean.setClassDtlDesc(oRow.get("CLS_DTL_NAME").getString());
      arylstHeaderList.add(oHrmAprslSpcTmplHdrBean);
    } 
    return arylstHeaderList;
  }
  
  public RecordMetaInfo getHrmAprslSpcTmpKPADtlMetaInfo(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, "HRMAPRSLSPCTMPL.proc_GetHrAprslSpcTmplKPACount(?,?,?,?,?,?)");
    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 getHrmAprslSpcTmpKPADetailInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arylstHrmTempSecDetail = 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, "HRMAPRSLSPCTMPL.procHrAprslSpcTmplKPADtlInfo(?,?,?,?,?,?,?)");
    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 oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstHrmTempSecDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslSpcTmplDtlBean oHrmAprslSpcTmplDtlBean = new HrmAprslSpcTmplDtlBean();
      oHrmAprslSpcTmplDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAprslSpcTmplDtlBean.setTxtKPAGrId(oRow.get("APRSL_KPA_GRP_ID").getString());
      oHrmAprslSpcTmplDtlBean.setTxtKpaGrCode(oRow.get("KPA_GRP_CODE").getString());
      oHrmAprslSpcTmplDtlBean.setTxtKpaGrDesc(oRow.get("KPA_GRP_DESC").getString());
      oHrmAprslSpcTmplDtlBean.setTxtKPAId(oRow.get("kpa_dtl_id").getString());
      oHrmAprslSpcTmplDtlBean.setTxtKpaCode(oRow.get("KPA_CODE").getString());
      oHrmAprslSpcTmplDtlBean.setTxtKpaDesc(oRow.get("KPA_DESC").getString());
      String selectFlag = oRow.get("mandatory_flag").getString();
      if (selectFlag.equalsIgnoreCase("null")) {
        selectFlag = "off";
      } else {
        if (selectFlag.equalsIgnoreCase("Y"))
          selectFlag = "on"; 
        if (selectFlag.equalsIgnoreCase("N"))
          selectFlag = "off"; 
      } 
      oHrmAprslSpcTmplDtlBean.setTxtFlag(selectFlag);
      arylstHrmTempSecDetail.add(oHrmAprslSpcTmplDtlBean);
    } 
    return arylstHrmTempSecDetail;
  }
  
  public RecordMetaInfo getHrmAprslSpcTmpGoalsDtlMetaInfo(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, "HRMAPRSLSPCTMPL.proc_GetHrAprslTmplGoalCount(?,?,?,?,?,?)");
    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 getHrmAprslSpcTmpGoalsDetailInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arylstHrmTempSecDetail = 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, "HRMAPRSLSPCTMPL.procHrAprslTmplGoalDtlInfo(?,?,?,?,?,?,?)");
    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 oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstHrmTempSecDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslSpcTmplGoalDtlBean oHrmAprslSpcTmplGoalDtlBean = new HrmAprslSpcTmplGoalDtlBean();
      oHrmAprslSpcTmplGoalDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtSrlNo(oRow.get("srl_no").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtSection(oRow.get("sec_code").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtSectionId(oRow.get("tmpl_sec_id").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtParentSection(oRow.get("PARENT_SEC_CODE").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtGoalsDesc(oRow.get("goal_desc").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtMesr(oRow.get("measure").getString());
      oHrmAprslSpcTmplGoalDtlBean.setTxtWtg(oRow.get("weightage").getString());
      oHrmAprslSpcTmplGoalDtlBean.setDisabtxtGoalsDesc("true");
      oHrmAprslSpcTmplGoalDtlBean.setDisabtxtSection("true");
      oHrmAprslSpcTmplGoalDtlBean.setDisabtxtMesr("true");
      arylstHrmTempSecDetail.add(oHrmAprslSpcTmplGoalDtlBean);
    } 
    return arylstHrmTempSecDetail;
  }
  
  public RecordMetaInfo getHrmAprslSpcTmpEligDtlMetaInfo(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, "HRMAPRSLSPCTMPL.procGetAprslSpcTmplEligConut(?,?,?,?,?,?)");
    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 getHrmAprslSpcTmpEligDetailInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arylstHrmTempSecDetail = 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, "HRMAPRSLSPCTMPL.procGetAprslSpcTmplEmpEligInfo(?,?,?,?,?,?,?)");
    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 oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstHrmTempSecDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslSpcTmplEmpEligDtlBean oHrmAprslSpcTmplEmpEligDtlBean = new HrmAprslSpcTmplEmpEligDtlBean();
      oHrmAprslSpcTmplEmpEligDtlBean.setDetailId(oRow.get("SPC_TMPL_ID").getString());
      oHrmAprslSpcTmplEmpEligDtlBean.setTxtEmpNo(oRow.get("emp_no").getString());
      oHrmAprslSpcTmplEmpEligDtlBean.setTxtEmpName(oRow.get("name").getString());
      oHrmAprslSpcTmplEmpEligDtlBean.setTxtEmpId(oRow.get("E_PER_DTL_ID").getString());
      arylstHrmTempSecDetail.add(oHrmAprslSpcTmplEmpEligDtlBean);
    } 
    return arylstHrmTempSecDetail;
  }
  
  public LovVO getTemplateData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("SelectID");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.templateName");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new String(oLovQueryVO.getSearchField1())));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_TemplateLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("TEMPLATE_NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getQueryTemplateData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("SelectID");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.templateName");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new String(oLovQueryVO.getSearchField1())));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_TemplateLOVQ(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("TEMPLATE_NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getQuerySpcTemplateData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("SelectID");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.splTemplateName");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new String(oLovQueryVO.getSearchField1())));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_TemplateLOVQ(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("TEMPLATE_NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getTempSectionData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("SelectID");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.Section");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.parentSection");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new String(oLovQueryVO.getSearchField1())));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_TempSectionLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("SEC_CODE").getString());
      oLOVBean.setDetailField3(oRow.get("PARENTCODE").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getClsMstData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("SelectOptionID");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classHeaderCode");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classHeaderDesc");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new String(oLovQueryVO.getSearchField1())));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSTRULE.proc_ClsMstLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("code").getString());
      oLOVBean.setDetailField3(oRow.get("name").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getClsDtlData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("OptionDetailID");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classDetailCode");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classDetailDesc");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    String sID = oLovQueryVO.getProperty("SelOpt");
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sID));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSTRULE.proc_ClsDtlLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getClsMstDataQ(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("SelectOptionID");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classHeaderCode");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classHeaderDesc");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new String(oLovQueryVO.getSearchField1())));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSTRULE.proc_ClsMstLOVQ(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("code").getString());
      oLOVBean.setDetailField3(oRow.get("name").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getClsDtlDataQ(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("OptionDetailID");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classDetailCode");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.classDetailDesc");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    String sID = oLovQueryVO.getProperty("SelOpt");
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sID));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSTRULE.proc_ClsDtlLOVQ(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getSpcEmployeeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("empId");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.employeeNo");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.employeeName");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getSearchField1()));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_EmployeeLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("Name").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getQueryEmployeeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("empId");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.employeeNo");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.employeeName");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getSearchField1()));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSTRULE.proc_QueryEmployeeLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("Name").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getQueryStOrdLOVData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("codeID");
    arylstHeaderNames.add("hrm.HrmAprslStartRule.aprslStartOrderNo");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.fromDate");
    arylstHeaderNames.add("hrm.ApprslSpcTemp.toDate");
    oLovVO.setHeaderList(arylstHeaderNames);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getSearchField1()));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_QueryStOrdLOV(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("START_ORDER_NO").getString());
      oLOVBean.setDetailField3(EnrgiseUtil.convertToString(oRow.get("PERIOD_START_DATE").getDate()));
      oLOVBean.setDetailField4(EnrgiseUtil.convertToString(oRow.get("PERIOD_END_DATE").getDate()));
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getQueryWrkGrpLOVData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("Code ID");
    arylstHeaderList.add("hrm.HrmWorkGroup.code");
    arylstHeaderList.add("hrm.HrmWorkGroup.name");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getSearchField1()));
    oParameters.add(new DBObject(2, 1, 12, oLovQueryVO.getSearchField2()));
    oParameters.add(new DBObject(3, 2, -10));
    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, "HRMAPRSLSTRULE.proc_QueryWrkGrpLOV(?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getQuerySiteCodeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("Code ID");
    arylstHeaderList.add("hrm.HrmWorkGroup.code");
    arylstHeaderList.add("hrm.HrmWorkGroup.name");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getSearchField1()));
    oParameters.add(new DBObject(2, 1, 12, oLovQueryVO.getSearchField2()));
    oParameters.add(new DBObject(3, 2, -10));
    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, "HRMAPRSLSTRULE.proc_QuerySiteIDLOV(?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList 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("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public String rejectHrmAprslSpcTmp(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    ArrayList arylstList = new ArrayList();
    ArrayList arylstParam = new ArrayList();
    HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean = (HrmAprslSpcTmplHdrBean)oBaseHeaderBean;
    String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
    WflStatus status = null;
    status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Reject", (String)null);
    if (status.getStatus().equalsIgnoreCase("Rejected"))
      approveSpcTmpl(oBaseHeaderBean, "R"); 
    return oBaseHeaderBean.getHeaderPrimaryKey();
  }
  
  public String approveHrmAprslSpcTmp(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    if (sScreenName.equals("HrmAprslSpcTmplGoals")) {
      ArrayList oErrorList = new ArrayList();
      checkWeightageValidation(oBaseHeaderBean.getHeaderPrimaryKey(), oErrorList);
      reportError(oErrorList);
    } 
    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"))
      approveSpcTmpl(oBaseHeaderBean, "A"); 
    return oBaseHeaderBean.getHeaderPrimaryKey();
  }
  
  private void checkWeightageValidation(String sHeaderPrimKey, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    int count = 0;
    String sSecCode = "";
    String sWtg = "";
    String sCnt = "";
    long lWeightage = 0L;
    long lCount = 0L;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sHeaderPrimKey));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_ProperWtg(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = oList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = iter.next();
      sSecCode = oRow.get("sec_code").getString();
      sWtg = oRow.get("totWtg").getString();
      sCnt = oRow.get("totCnt").getString();
      lWeightage = Long.parseLong(sWtg);
      lCount = Long.parseLong(sCnt);
      if (lWeightage == 0L) {
        lWeightage = 100L / lCount;
        sWtg = String.valueOf(lWeightage);
        oParameters = new ArrayList();
        oBean = new DBUtilitiesBean();
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, sWtg));
        oParameters.add(new DBObject(2, 1, 12, sSecCode));
        oParameters.add(new DBObject(3, 2, 12));
        oParameters.add(new DBObject(4, 2, 12));
        oParameters.add(new DBObject(5, 2, 4));
        oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_UpdateWtg(?,?,?,?,?)");
      } 
      oParameters = new ArrayList();
      long lNoNull = 0L;
      oBean = new DBUtilitiesBean();
      oParameters = new ArrayList();
      oParameters.add(new DBObject(1, 1, 12, sSecCode));
      oParameters.add(new DBObject(2, 2, -5));
      oParameters.add(new DBObject(3, 2, 12));
      oParameters.add(new DBObject(4, 2, 12));
      oParameters.add(new DBObject(5, 2, 4));
      oOutArray = oBean.callProc(oParameters, "HRMAPRSLSPCTMPL.proc_getNullCount(?,?,?,?,?)");
      oOutObject = oOutArray.get(0);
      lNoNull = ((Long)oOutObject.getObject()).longValue();
      if (lNoNull > 0L) {
        ArrayList oParams = new ArrayList();
        oParams.add(new String(sSecCode));
        oErrorList.add(new EnrgiseMessageKeyException("hrms.spcaprsl.wt.null", oParams, "E"));
      } 
      if (lWeightage < 100L && lWeightage > 0L) {
        ArrayList oParams = new ArrayList();
        oParams.add(new String(sSecCode));
        oErrorList.add(new EnrgiseMessageKeyException("hrms.spcaprsl.wt.less", oParams, "E"));
      } 
      if (lWeightage > 100L) {
        ArrayList oParams = new ArrayList();
        oParams.add(new String(sSecCode));
        oErrorList.add(new EnrgiseMessageKeyException("hrms.spcaprsl.wt.greater", oParams, "E"));
      } 
    } 
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oList = new ArrayList();
    checkMandatoryHdr((HrmAprslSpcTmplHdrBean)oBaseHeaderBean, oList);
    if (sScreenName.equals("HrmAprslSpcTmplGoals"))
      if (bDetailDataChanged) {
        Iterator oIt1 = arylstDetailBeanArray.iterator();
        int rowCount = 1;
        while (oIt1.hasNext()) {
          HrmAprslSpcTmplGoalDtlBean oHrmAprslSpcTmplGoalDtlBean = oIt1.next();
          if (!oHrmAprslSpcTmplGoalDtlBean.getStatus().equalsIgnoreCase("D"))
            checkMandatoryDtls(oHrmAprslSpcTmplGoalDtlBean, rowCount, oList); 
          rowCount++;
        } 
      }  
    reportError(oList);
  }
  
  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 oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oList = new ArrayList();
    if (sScreenMode.equalsIgnoreCase("N"))
      checkUniqueTemp((HrmAprslSpcTmplHdrBean)oBaseHeaderBean, oList); 
    if (sScreenName.equals("HrmAprslSpcTmpl"))
      if (bDetailDataChanged) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        int rowCount = 1;
        while (oIt1.hasNext()) {
          HrmAprslSpcTmplDtlBean oHrmAprslSpcTmplDtlBean = oIt1.next();
          if (oHrmAprslSpcTmplDtlBean.getStatus().equalsIgnoreCase("D"))
            if (oHrmAprslSpcTmplDtlBean.getTxtFlag().equalsIgnoreCase("on")) {
              ArrayList oParams = new ArrayList();
              oParams.add(new Integer(rowCount));
              oList.add(new EnrgiseMessageKeyException("hrms.spcaprsl.kpa.special", oParams, "E"));
            }  
          rowCount++;
        } 
      }  
    reportError(oList);
  }
  
  private void checkMandatoryHdr(HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getStOrderNo())) {
      MessageKey oMessageKey = new MessageKey("hrm.ApprslSpcTemp.stOrderNo");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getSplTemplateName())) {
      MessageKey oMessageKey = new MessageKey("hrm.ApprslSpcTemp.splTemplateName");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getTemplateName())) {
      MessageKey oMessageKey = new MessageKey("hrm.ApprslSpcTemp.templateName");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getEmpNo()))
      if (EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getDeptCode()) || EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getSiteCode()) || EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getClassHdr()) || EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getClassDtl())) {
        MessageKey eMessageKey = new MessageKey("hrm.HrmAprslStartRule.employeeNo");
        MessageKey wMessageKey = new MessageKey("hrm.ApprslSpcTemp.deptCode");
        MessageKey sMessageKey = new MessageKey("hrm.HrmAprslStartRule.siteCode");
        MessageKey chMessageKey = new MessageKey("hrm.HrmAprslStartRule.classHeaderCode");
        MessageKey cdMessageKey = new MessageKey("hrm.HrmAprslStartRule.classDetailCode");
        ArrayList oParams = new ArrayList();
        oParams.add(eMessageKey);
        oParams.add(wMessageKey);
        oParams.add(sMessageKey);
        oParams.add(chMessageKey);
        oParams.add(cdMessageKey);
        oErrorList.add(new EnrgiseMessageKeyException("hrm.aprsl.rule.header.mandatoryFieldMissing", oParams, "E"));
      }  
    if (EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getDeptCode()))
      if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getSiteCode())) {
        MessageKey oMessageKey = new MessageKey("hrm.HrmAprslStartRule.siteCode");
        ArrayList oParams = new ArrayList();
        oParams.add(oMessageKey);
        oErrorList.add(new EnrgiseMessageKeyException("hrm.StRule.SiteCode.mandatoryFieldMissing", oParams, "E"));
      }  
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getEmpNo()) && !EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getDeptCode()) && !EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getSiteCode()) && !EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getClassHdr()) && !EnrgiseUtil.checkString(oHrmAprslSpcTmplHdrBean.getClassDtl())) {
      MessageKey eMessageKey = new MessageKey("hrm.HrmAprslStartRule.employeeNo");
      MessageKey wMessageKey = new MessageKey("hrm.ApprslSpcTemp.deptCode");
      MessageKey sMessageKey = new MessageKey("hrm.HrmAprslStartRule.siteCode");
      MessageKey chMessageKey = new MessageKey("hrm.HrmAprslStartRule.classHeaderCode");
      MessageKey cdMessageKey = new MessageKey("hrm.HrmAprslStartRule.classDetailCode");
      ArrayList oParams = new ArrayList();
      oParams.add(eMessageKey);
      oParams.add(wMessageKey);
      oParams.add(sMessageKey);
      oParams.add(chMessageKey);
      oParams.add(cdMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("hrm.aprsl.StRule.all.header.mandatoryFieldMissing", oParams, "E"));
    } 
  }
  
  private void checkMandatoryDtls(HrmAprslSpcTmplGoalDtlBean oHrmAprslSpcTmplGoalDtlBean, int rowCount, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplGoalDtlBean.getTxtSrlNo())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmHrmAppraisalKPA.txtSrlNo");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplGoalDtlBean.getTxtSection())) {
      MessageKey oMessageKey = new MessageKey("hrm.ApprslSpcTemp.Section");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplGoalDtlBean.getTxtGoalsDesc())) {
      MessageKey oMessageKey = new MessageKey("hrm.ApprslSpcTemp.goalsDesc");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAprslSpcTmplGoalDtlBean.getTxtMesr())) {
      MessageKey oMessageKey = new MessageKey("hrm.ApprslSpcTemp.txtMesr");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
  }
  
  private void checkUniqueTemp(HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    long lNoTmpl = 0L;
    oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oHrmAprslSpcTmplHdrBean.getSplTemplateName()));
    oParameters.add(new DBObject(2, 1, 12, oHrmAprslSpcTmplHdrBean.getStOrderId()));
    oParameters.add(new DBObject(3, 2, -5));
    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, "HRMAPRSLSPCTMPL.proc_getTempNameCount(?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    lNoTmpl = ((Long)oOutObject.getObject()).longValue();
    if (lNoTmpl > 0L) {
      ArrayList oParams = new ArrayList();
      oErrorList.add(new EnrgiseMessageKeyException("hrm.SpcTemp.Unique.Data", oParams, "E"));
    } 
  }
  
  public WflStatus callWorkFlow(BaseHeaderBean oBaseHeaderBean, ArrayList arylstDetailBeanArray, String activity, String initiatedFlag) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      WorkFlowFacadeHome oHome = (WorkFlowFacadeHome)WorkFlowServiceLocator.getLocator().getService("WorkFlowFacade");
      WorkFlowFacade workFlowFacade = oHome.create();
      HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean = (HrmAprslSpcTmplHdrBean)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(oHrmAprslSpcTmplHdrBean.getHeaderPrimaryKey());
      wflDocumentInfoImpl.setDocumentType("Appraisal");
      wflDocumentInfoImpl.setInitiatedFlag(initiatedFlag);
      String documentTypeId = workFlowFacade.getDocumentTypeId("AppraisalSpcTmpl");
      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("Spec Temp Appraisal No : ").concat(String.valueOf(oHrmAprslSpcTmplHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for approval")));
        wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for approval: Spec Temp Appraisal No:").concat(String.valueOf(oHrmAprslSpcTmplHdrBean.getHeaderPrimaryKey())));
      } else if (!activity.equalsIgnoreCase("Approve")) {
        wflDocumentInfoImpl.setDocumentNumber(String.valueOf(String.valueOf("Spec Temp Appraisal No : ").concat(String.valueOf(oHrmAprslSpcTmplHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for rejection")));
        wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for rejection:Spec Temp Appraisal No:").concat(String.valueOf(oHrmAprslSpcTmplHdrBean.getHeaderPrimaryKey())));
      } 
      wflDocumentInfoImpl.setModuleId("8");
      wflDocumentInfoImpl.setCreator((WflResource)wflResourceImpl);
      wflDocumentInfoImpl.setRequesterAction(activityId);
      HashMap oProp = new HashMap();
      oProp.put("1", "1");
      wflDocumentInfoImpl.setDocumentAttributes(oProp);
      WflAuthorizationBean wflAuthBean = workFlowFacade.canDo((WflDocumentInfo)wflDocumentInfoImpl);
      if (EnrgiseUtil.checkString(wflAuthBean.getErrorCode()))
        throw new EnrgiseApplicationException(wflAuthBean.getErrorCode()); 
      if (!wflAuthBean.isAuthStatus())
        throw new EnrgiseApplicationException("wenrgise.workflow.submit.notauthorized"); 
      WflStatus wflStatus = workFlowFacade.process((WflDocumentInfo)wflDocumentInfoImpl);
      if (wflStatus.getStatus().equals("Error"))
        throw new EnrgiseSystemException(); 
      workFlowFacade.remove();
      return wflStatus;
    } catch (RemoteException oRtEx) {
      throw new EnrgiseSystemException("wenrgise.workflow.connect", oRtEx);
    } catch (CreateException oCx) {
      throw new EnrgiseSystemException("wenrgise.workflow.connect", oCx);
    } catch (RemoveException oRx) {
      throw new EnrgiseSystemException("wenrgise.workflow.connect", oRx);
    } 
  }
  
  private void approveSpcTmpl(BaseHeaderBean oBaseHeaderBean, String sFlag) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = null;
    HrmAprslSpcTmplHdrBean oHrmAprslSpcTmplHdrBean = (HrmAprslSpcTmplHdrBean)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, sFlag));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstPK = oBean.callProc(arylstParameters, "HRMAPRSLSPCTMPL.proc_UpsertApproveSpcTmpl(?,?,?,?,?)");
  }
}
