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.ServiceLocator;
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.HrmAprslEmpDtlsBean;
import wenrgise.hrms.bean.HrmAprslEmployeeBean;
import wenrgise.hrms.bean.HrmAprslGoalsDtlBean;
import wenrgise.hrms.bean.HrmAprslHdrBean;
import wenrgise.hrms.bean.HrmAprslKPADtlBean;
import wenrgise.hrms.bean.HrmAprslTrngReqDtlBean;
import wenrgise.hrms.ejb.facade.HrmFacade;
import wenrgise.hrms.ejb.facade.HrmFacadeHome;
import wenrgise.hrms.vo.HrmAprslQVO;
import wenrgise.workflow.bean.WflAuthorizationBean;
import wenrgise.workflow.bean.WflWorkListInfoBean;
import wenrgise.workflow.core.WflDocumentInfo;
import wenrgise.workflow.core.WflResource;
import wenrgise.workflow.core.WflSite;
import wenrgise.workflow.core.WflStatus;
import wenrgise.workflow.core.impl.WflDocumentInfoImpl;
import wenrgise.workflow.core.impl.WflResourceImpl;
import wenrgise.workflow.core.impl.WflSiteImpl;
import wenrgise.workflow.ejb.facade.WorkFlowFacade;
import wenrgise.workflow.ejb.facade.WorkFlowFacadeHome;

public class HrmAprslBO extends HrmBaseBO {
  public HrmAprslBO() {}
  
  public HrmAprslBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public WflWorkListInfoBean getLevel(String sWorkListId) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmFacadeHome oHome = (HrmFacadeHome)ServiceLocator.getLocator().getService("HrmFacade");
      HrmFacade oHrmFacade = oHome.create();
      return oHrmFacade.getWorkListInfo(sWorkListId);
    } catch (CreateException oCrtExcep) {
      throw new EnrgiseSystemException(oCrtExcep);
    } catch (RemoteException oRemExcep) {
      throw new EnrgiseSystemException(oRemExcep);
    } 
  }
  
  public RecordMetaInfo getHrmAprslKPADtlMetaInfo(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, "HRMAPRSL.proc_GetHrEmpAprslKPADtlCount(?,?,?,?,?,?)");
    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 getHrAprslKPADetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator oIt = null;
    ArrayList arylstAprslKPADetail = 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, "HRMAPRSL.procHrEmpAprslKPADtlInfo(?,?,?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    count = 0;
    oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstAprslKPADetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslKPADtlBean oHrmAprslKPADtlBean = new HrmAprslKPADtlBean();
      oHrmAprslKPADtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAprslKPADtlBean.setTxtKPADesc(oRow.get("KPA_DESC").getString());
      oHrmAprslKPADtlBean.setTxtKPACode(oRow.get("KPA_GROUP_DESC").getString());
      oHrmAprslKPADtlBean.setTxtTmplKPADtlId(oRow.get("TMPL_KPA_DTL_ID").getString());
      oHrmAprslKPADtlBean.setTxtKPADtlId(oRow.get("KPA_DTL_ID").getString());
      oHrmAprslKPADtlBean.setTxtKpaRatingReq(oRow.get("rating_required").getString());
      oHrmAprslKPADtlBean.setTxtKpaAprslType(oRow.get("appraiser_type").getString());
      oHrmAprslKPADtlBean.setTxtLevelAprl0(oRow.get("aprsl_lvl0").getString());
      oHrmAprslKPADtlBean.setTxtLevelAprl1(oRow.get("aprsl_lvl1").getString());
      oHrmAprslKPADtlBean.setTxtLevelAprl2(oRow.get("aprsl_lvl2").getString());
      oHrmAprslKPADtlBean.setTxtLevelAprl3(oRow.get("aprsl_lvl3").getString());
      oHrmAprslKPADtlBean.setTxtLevelAprl4(oRow.get("aprsl_lvl4").getString());
      oHrmAprslKPADtlBean.setTxtLevelAprl5(oRow.get("aprsl_lvl5").getString());
      oHrmAprslKPADtlBean.setTxtLevelRating0(oRow.get("rating_lvl0").getString());
      oHrmAprslKPADtlBean.setTxtLevelRating1(oRow.get("rating_lvl1").getString());
      oHrmAprslKPADtlBean.setTxtLevelRating2(oRow.get("rating_lvl2").getString());
      oHrmAprslKPADtlBean.setTxtLevelRating3(oRow.get("rating_lvl3").getString());
      oHrmAprslKPADtlBean.setTxtLevelRating4(oRow.get("rating_lvl4").getString());
      oHrmAprslKPADtlBean.setTxtLevelRating5(oRow.get("rating_lvl5").getString());
      oHrmAprslKPADtlBean.setTxtEmpAprsKPAlHdrId(oRow.get("emp_aprsl_id").getString());
      arylstAprslKPADetail.add(oHrmAprslKPADtlBean);
    } 
    return arylstAprslKPADetail;
  }
  
  public RecordMetaInfo getHrmAprslGoalsDtlMetaInfo(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, "HRMAPRSL.proc_GetHrEmpAprslGoalDtlCount(?,?,?,?,?,?)");
    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 getHrAprslGoalsDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator oIt = null;
    ArrayList arylstAprslGoalsDetail = 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, "HRMAPRSL.procHrEmpAprslGoalDtlInfo(?,?,?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    count = 0;
    oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstAprslGoalsDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslGoalsDtlBean oHrmAprslGoalsDtlBean = new HrmAprslGoalsDtlBean();
      oHrmAprslGoalsDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAprslGoalsDtlBean.setTxtTmplGoalId(oRow.get("TMPL_GOAL_ID").getString());
      oHrmAprslGoalsDtlBean.setTxtTmplSecId(oRow.get("tmpl_sec_id").getString());
      oHrmAprslGoalsDtlBean.setTxtParentSecId(oRow.get("parent_sec_id").getString());
      oHrmAprslGoalsDtlBean.setTxtGoalDesc(oRow.get("goal_desc").getString());
      oHrmAprslGoalsDtlBean.setTxtSection(oRow.get("sec_code").getString());
      oHrmAprslGoalsDtlBean.setTxtParentSec(oRow.get("PARENT_SEC_CODE").getString());
      oHrmAprslGoalsDtlBean.setTxtSecRatingReq(oRow.get("rating_required").getString());
      oHrmAprslGoalsDtlBean.setTxtSecAprslType(oRow.get("appraiser_typ_flag").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelAprl0g(oRow.get("aprsl_lvl0").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelAprl1g(oRow.get("aprsl_lvl1").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelAprl2g(oRow.get("aprsl_lvl2").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelAprl3g(oRow.get("aprsl_lvl3").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelAprl4g(oRow.get("aprsl_lvl4").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelAprl5g(oRow.get("aprsl_lvl5").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelRating0g(oRow.get("rating_lvl0").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelRating1g(oRow.get("rating_lvl1").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelRating2g(oRow.get("rating_lvl2").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelRating3g(oRow.get("rating_lvl3").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelRating4g(oRow.get("rating_lvl4").getString());
      oHrmAprslGoalsDtlBean.setTxtLevelRating5g(oRow.get("rating_lvl5").getString());
      oHrmAprslGoalsDtlBean.setTxtEmpAprslHdrId(oRow.get("emp_aprsl_id").getString());
      arylstAprslGoalsDetail.add(oHrmAprslGoalsDtlBean);
    } 
    return arylstAprslGoalsDetail;
  }
  
  public RecordMetaInfo getHrmAprslTrngReqDtlMetaInfo(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, "HRMAPRSL.procHrEmpAprslTrngReqDtlCount(?,?,?,?,?,?)");
    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 getHrAprslTrngReqDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator oIt = null;
    ArrayList arylstAprslTrngReqDetail = 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, "HRMAPRSL.procHrEmpAprslTrngReqDtlInfo(?,?,?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    count = 0;
    oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstAprslTrngReqDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslTrngReqDtlBean oHrmAprslTrngReqDtlBean = new HrmAprslTrngReqDtlBean();
      oHrmAprslTrngReqDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAprslTrngReqDtlBean.setTxtDateSubmitted(EnrgiseUtil.convertToString(oRow.get("date_submitted").getDate()));
      oHrmAprslTrngReqDtlBean.setTxtCourseName(oRow.get("CRS_NAME").getString());
      oHrmAprslTrngReqDtlBean.setTxtTrngCal(oRow.get("CAL_NAME").getString());
      oHrmAprslTrngReqDtlBean.setTxtInstName(oRow.get("inst_name").getString());
      oHrmAprslTrngReqDtlBean.setTxtStartDate(EnrgiseUtil.convertToString(oRow.get("start_date").getDate()));
      oHrmAprslTrngReqDtlBean.setTxtEndDate(EnrgiseUtil.convertToString(oRow.get("end_date").getDate()));
      oHrmAprslTrngReqDtlBean.setTxtNature(oRow.get("nature").getString());
      oHrmAprslTrngReqDtlBean.setTxtPurpose(oRow.get("purpose").getString());
      oHrmAprslTrngReqDtlBean.setTxtRecommender(oRow.get("REC_NAME").getString());
      oHrmAprslTrngReqDtlBean.setTxtAppStatus(oRow.get("approved_flag").getString());
      oHrmAprslTrngReqDtlBean.setTxtRemarks(oRow.get("rejection_remark").getString());
      arylstAprslTrngReqDetail.add(oHrmAprslTrngReqDtlBean);
    } 
    return arylstAprslTrngReqDetail;
  }
  
  public String getSpcTmplInfo(String sEmpId, String sStartOrderId) throws EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sSpcTmplId = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sEmpId));
    arylstParam.add(new DBObject(2, 1, 12, sStartOrderId));
    arylstParam.add(new DBObject(3, 2, -10));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procGetHrEmpAprslSpcTmplInfo(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sSpcTmplId = oRow.get("SP_TMPL_ID").getString();
    } 
    return sSpcTmplId;
  }
  
  public ArrayList getHrAprslKPADtlIdInfo(String sEmpAprslHdrId) throws EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arylstTmplKPADtlId = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sEmpAprslHdrId));
    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, "HRMAPRSL.procGetHrEmpAprslKPADtlInfo(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0)
      arylstTmplKPADtlId = new ArrayList(); 
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      if (count == 0)
        arylstTmplKPADtlId = new ArrayList(); 
      count++;
      oRow = (QueryRow)itrBean.next();
      HrmAprslKPADtlBean oHrmAprslKPADtlBean = new HrmAprslKPADtlBean();
      oHrmAprslKPADtlBean.setTxtTmplKPADtlId(oRow.get("TMPL_KPA_DTL_ID").getString());
      arylstTmplKPADtlId.add(oHrmAprslKPADtlBean);
    } 
    return arylstTmplKPADtlId;
  }
  
  public ArrayList getHrAprslGoalsDtlIdInfo(String sEmpAprslHdrId) throws EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arylstTmplGoalsDtlId = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sEmpAprslHdrId));
    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, "HRMAPRSL.procGetHrEmpAprslGoalDtlInfo(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0)
      arylstTmplGoalsDtlId = new ArrayList(); 
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      if (count == 0)
        arylstTmplGoalsDtlId = new ArrayList(); 
      count++;
      oRow = (QueryRow)itrBean.next();
      HrmAprslGoalsDtlBean oHrmAprslGoalsDtlBean = new HrmAprslGoalsDtlBean();
      oHrmAprslGoalsDtlBean.setTxtTmplGoalId(oRow.get("TMPL_GOAL_ID").getString());
      arylstTmplGoalsDtlId.add(oHrmAprslGoalsDtlBean);
    } 
    return arylstTmplGoalsDtlId;
  }
  
  public void insertEmpAprslKPA(String sEmpAprslHdrId) throws EnrgiseSystemException {
    boolean bInsert = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    ArrayList oDetailBeanArray = getHrAprslKPADtlIdInfo(sEmpAprslHdrId);
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslKPADtlBean oHrmAprslKPADtlBean = oIt.next();
      String sTmplKPADtlId = oHrmAprslKPADtlBean.getTxtTmplKPADtlId();
      if (!bInsert) {
        oBean = new DBUtilitiesBean();
        oBean.createBatch("HRMAPRSL.procUpsertHrEmpAprslKPADtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        bInsert = true;
      } 
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "N"));
      arylstParam.add(new DBObject(2, 1, 12, null));
      arylstParam.add(new DBObject(3, 1, 12, sEmpAprslHdrId));
      arylstParam.add(new DBObject(4, 1, 12, sTmplKPADtlId));
      arylstParam.add(new DBObject(5, 1, 12, null));
      arylstParam.add(new DBObject(6, 1, 12, null));
      arylstParam.add(new DBObject(7, 1, 12, null));
      arylstParam.add(new DBObject(8, 1, 12, null));
      arylstParam.add(new DBObject(9, 1, 12, null));
      arylstParam.add(new DBObject(10, 1, 12, null));
      arylstParam.add(new DBObject(11, 1, 12, null));
      arylstParam.add(new DBObject(12, 1, 12, null));
      arylstParam.add(new DBObject(13, 1, 12, null));
      arylstParam.add(new DBObject(14, 1, 12, null));
      arylstParam.add(new DBObject(15, 1, 12, null));
      arylstParam.add(new DBObject(16, 1, 12, null));
      arylstParam.add(new DBObject(17, 1, 12, this.oUserInfo.getUserId()));
      arylstParam.add(new DBObject(18, 1, 12, this.oUserInfo.getSiteId()));
      oBean.addToBatch(arylstParam);
    } 
    if (bInsert)
      oBean.executeBatch(); 
  }
  
  public void insertEmpAprslGoals(String sEmpAprslHdrId) throws EnrgiseSystemException {
    boolean bInsert = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    ArrayList oDetailBeanArray = getHrAprslGoalsDtlIdInfo(sEmpAprslHdrId);
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslGoalsDtlBean oHrmAprslGoalsDtlBean = oIt.next();
      String sTmplGoalsDtlId = oHrmAprslGoalsDtlBean.getTxtTmplGoalId();
      if (!bInsert) {
        oBean = new DBUtilitiesBean();
        oBean.createBatch("HRMAPRSL.procUpsertHrEmpAprslGoalDtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        bInsert = true;
      } 
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "N"));
      arylstParam.add(new DBObject(2, 1, 12, null));
      arylstParam.add(new DBObject(3, 1, 12, sEmpAprslHdrId));
      arylstParam.add(new DBObject(4, 1, 12, sTmplGoalsDtlId));
      arylstParam.add(new DBObject(5, 1, 12, null));
      arylstParam.add(new DBObject(6, 1, 12, null));
      arylstParam.add(new DBObject(7, 1, 12, null));
      arylstParam.add(new DBObject(8, 1, 12, null));
      arylstParam.add(new DBObject(9, 1, 12, null));
      arylstParam.add(new DBObject(10, 1, 12, null));
      arylstParam.add(new DBObject(11, 1, 12, null));
      arylstParam.add(new DBObject(12, 1, 12, null));
      arylstParam.add(new DBObject(13, 1, 12, null));
      arylstParam.add(new DBObject(14, 1, 12, null));
      arylstParam.add(new DBObject(15, 1, 12, null));
      arylstParam.add(new DBObject(16, 1, 12, null));
      arylstParam.add(new DBObject(17, 1, 12, this.oUserInfo.getUserId()));
      arylstParam.add(new DBObject(18, 1, 12, this.oUserInfo.getSiteId()));
      oBean.addToBatch(arylstParam);
    } 
    if (bInsert)
      oBean.executeBatch(); 
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    String SAppraiserType = null;
    HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)oBaseHeaderBean;
    String sSpcTmplId = getSpcTmplInfo(oHrmAprslHdrBean.getEmpId(), oHrmAprslHdrBean.getStartOrderId());
    if (ScreenMode.equalsIgnoreCase("N")) {
      if (EnrgiseUtil.checkString(oHrmAprslHdrBean.getAprslLevel())) {
        if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("0"))
          SAppraiserType = "0"; 
      } else {
        SAppraiserType = "0";
      } 
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "N"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmAprslHdrBean.getEmpId()));
      arylstParam.add(new DBObject(3, 1, 12, sSpcTmplId));
      arylstParam.add(new DBObject(4, 1, 12, SAppraiserType));
      arylstParam.add(new DBObject(5, 1, 12, oHrmAprslHdrBean.getRating0()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmAprslHdrBean.getRating1()));
      arylstParam.add(new DBObject(7, 1, 12, oHrmAprslHdrBean.getRating2()));
      arylstParam.add(new DBObject(8, 1, 12, oHrmAprslHdrBean.getRating3()));
      arylstParam.add(new DBObject(9, 1, 12, oHrmAprslHdrBean.getRating4()));
      arylstParam.add(new DBObject(10, 1, 12, oHrmAprslHdrBean.getRating5()));
      arylstParam.add(new DBObject(11, 1, 12, this.oUserInfo.getUserId()));
      arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(13, 1, 12, null));
      arylstParam.add(new DBObject(14, 2, 12));
      arylstParam.add(new DBObject(15, 2, 12));
      arylstParam.add(new DBObject(16, 2, 12));
      arylstParam.add(new DBObject(17, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procUpsertHrEmpAprslHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
      insertEmpAprslKPA(returnString);
      insertEmpAprslGoals(returnString);
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "U"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmAprslHdrBean.getEmpId()));
      arylstParam.add(new DBObject(3, 1, 12, sSpcTmplId));
      arylstParam.add(new DBObject(4, 1, 12, SAppraiserType));
      arylstParam.add(new DBObject(5, 1, 12, oHrmAprslHdrBean.getRating0()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmAprslHdrBean.getRating1()));
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("2")) {
        arylstParam.add(new DBObject(7, 1, 12, oHrmAprslHdrBean.getFinalRating()));
      } else {
        arylstParam.add(new DBObject(7, 1, 12, oHrmAprslHdrBean.getRating2()));
      } 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("3")) {
        arylstParam.add(new DBObject(8, 1, 12, oHrmAprslHdrBean.getFinalRating()));
      } else {
        arylstParam.add(new DBObject(8, 1, 12, oHrmAprslHdrBean.getRating3()));
      } 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("4")) {
        arylstParam.add(new DBObject(9, 1, 12, oHrmAprslHdrBean.getFinalRating()));
      } else {
        arylstParam.add(new DBObject(9, 1, 12, oHrmAprslHdrBean.getRating4()));
      } 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("5")) {
        arylstParam.add(new DBObject(10, 1, 12, oHrmAprslHdrBean.getFinalRating()));
      } else {
        arylstParam.add(new DBObject(10, 1, 12, oHrmAprslHdrBean.getRating5()));
      } 
      arylstParam.add(new DBObject(11, 1, 12, this.oUserInfo.getUserId()));
      arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(13, 1, 12, oHrmAprslHdrBean.getHeaderPrimaryKey()));
      arylstParam.add(new DBObject(14, 2, 12));
      arylstParam.add(new DBObject(15, 2, 12));
      arylstParam.add(new DBObject(16, 2, 12));
      arylstParam.add(new DBObject(17, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procUpsertHrEmpAprslHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } 
    return returnString;
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmAprslKPA")) {
      saveHrmEmpAprslKPA(sHeaderPrimaryKey, oDetailBeanArray);
    } else if (sScreenName.equalsIgnoreCase("HrmAprslGoals")) {
      saveHrmEmpAprslGoals(sHeaderPrimaryKey, oDetailBeanArray);
    } else if (sScreenName.equalsIgnoreCase("HrmAprslTrngReq")) {
      saveHrmEmpAprslTrngReq(sHeaderPrimaryKey, oDetailBeanArray);
    } else if (sScreenName.equalsIgnoreCase("HrmAprslEmployee")) {
      saveHrmEmpAprslDtl(sHeaderPrimaryKey, oDetailBeanArray);
    } 
  }
  
  private void saveHrmEmpAprslKPA(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bUpdate = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslKPADtlBean oHrmAprslKPADtlBean = oIt.next();
      if (oHrmAprslKPADtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMAPRSL.procUpsertHrEmpAprslKPADtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "U"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmAprslKPADtlBean.getDetailId()));
        arylstParam.add(new DBObject(3, 1, 12, oHrmAprslKPADtlBean.getTxtEmpAprsKPAlHdrId()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmAprslKPADtlBean.getTxtTmplKPADtlId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmAprslKPADtlBean.getTxtLevelRating0()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmAprslKPADtlBean.getTxtLevelRating1()));
        arylstParam.add(new DBObject(7, 1, 12, oHrmAprslKPADtlBean.getTxtLevelRating2()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmAprslKPADtlBean.getTxtLevelRating3()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmAprslKPADtlBean.getTxtLevelRating4()));
        arylstParam.add(new DBObject(10, 1, 12, oHrmAprslKPADtlBean.getTxtLevelRating5()));
        arylstParam.add(new DBObject(11, 1, 12, oHrmAprslKPADtlBean.getTxtLevelAprl0()));
        arylstParam.add(new DBObject(12, 1, 12, oHrmAprslKPADtlBean.getTxtLevelAprl1()));
        arylstParam.add(new DBObject(13, 1, 12, oHrmAprslKPADtlBean.getTxtLevelAprl2()));
        arylstParam.add(new DBObject(14, 1, 12, oHrmAprslKPADtlBean.getTxtLevelAprl3()));
        arylstParam.add(new DBObject(15, 1, 12, oHrmAprslKPADtlBean.getTxtLevelAprl4()));
        arylstParam.add(new DBObject(16, 1, 12, oHrmAprslKPADtlBean.getTxtLevelAprl5()));
        arylstParam.add(new DBObject(17, 1, 12, this.oUserInfo.getUserId()));
        arylstParam.add(new DBObject(18, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
      } 
    } 
    if (bUpdate)
      oBean.executeBatch(); 
  }
  
  private void saveHrmEmpAprslGoals(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bUpdate = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslGoalsDtlBean oHrmAprslGoalsDtlBean = oIt.next();
      if (oHrmAprslGoalsDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMAPRSL.procUpsertHrEmpAprslGoalDtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "U"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmAprslGoalsDtlBean.getDetailId()));
        arylstParam.add(new DBObject(3, 1, 12, oHrmAprslGoalsDtlBean.getTxtEmpAprslHdrId()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmAprslGoalsDtlBean.getTxtTmplGoalId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelRating0g()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelRating1g()));
        arylstParam.add(new DBObject(7, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelRating2g()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelRating3g()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelRating4g()));
        arylstParam.add(new DBObject(10, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelRating5g()));
        arylstParam.add(new DBObject(11, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelAprl0g()));
        arylstParam.add(new DBObject(12, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelAprl1g()));
        arylstParam.add(new DBObject(13, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelAprl2g()));
        arylstParam.add(new DBObject(14, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelAprl3g()));
        arylstParam.add(new DBObject(15, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelAprl4g()));
        arylstParam.add(new DBObject(16, 1, 12, oHrmAprslGoalsDtlBean.getTxtLevelAprl5g()));
        arylstParam.add(new DBObject(17, 1, 12, this.oUserInfo.getUserId()));
        arylstParam.add(new DBObject(18, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
      } 
    } 
    if (bUpdate)
      oBean.executeBatch(); 
  }
  
  private void saveHrmEmpAprslTrngReq(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslTrngReqDtlBean oHrmAprslTrngReqDtlBean = oIt.next();
      if (oHrmAprslTrngReqDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMAPRSL.procUpsertHrTrngReq(?,?,?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "N"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmAprslTrngReqDtlBean.getTxtNature()));
        arylstParam.add(new DBObject(3, 1, 12, oHrmAprslTrngReqDtlBean.getTxtPurpose()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmAprslTrngReqDtlBean.getTxtRecId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmAprslTrngReqDtlBean.getTxtRemarks()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmAprslTrngReqDtlBean.getTxtLevel().equalsIgnoreCase("0") ? "N" : "A"));
        arylstParam.add(new DBObject(7, 1, 12, oHrmAprslTrngReqDtlBean.getTxtEmpId()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmAprslTrngReqDtlBean.getTxtCalId()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmAprslTrngReqDtlBean.getTxtCrsId()));
        arylstParam.add(new DBObject(10, 1, 12, sHeaderPrimaryKey));
        arylstParam.add(new DBObject(11, 1, 12, this.oUserInfo.getUserId()));
        arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
  }
  
  public LovVO getHrmAprslStartOrderLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("startOrderId");
    oHeaderList.add("hrm.EmpAprsl.stOrderNo");
    oHeaderList.add("hrm.EmpAprsl.fromDate");
    oHeaderList.add("hrm.EmpAprsl.toDate");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSLLOV.proc_GetAprslStartOrderLOV(?,?,?,?,?)");
    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("START_ORDER_NO").getString());
      oLOVBean.setDetailField3(EnrgiseUtil.convertToString(oRow.get("PERIOD_START_DATE").getDate()));
      oLOVBean.setDetailField4(EnrgiseUtil.convertToString(oRow.get("PERIOD_END_DATE").getDate()));
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmAprslRatingLevel0LOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.EmpAprsl.RatingFrom");
    oHeaderList.add("hrm.EmpAprsl.RatingTo");
    oHeaderList.add("hrm.EmpAprsl.RatingDesc");
    oHeaderList.add("hrm.EmpAprsl.levelRating0");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    System.out.println(oLovQueryVO.getProperty("headerPrimaryKey"));
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getProperty("headerPrimaryKey")));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSL.proc_HrRatingHelpLov(?,?,?,?,?)");
    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("RATING_FROM").getString());
      oLOVBean.setDetailField2(oRow.get("RATING_TO").getString());
      oLOVBean.setDetailField3(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField4(oRow.get("NUMERIC_EQ").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmAprslRatingLevel1LOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.EmpAprsl.RatingFrom");
    oHeaderList.add("hrm.EmpAprsl.RatingTo");
    oHeaderList.add("hrm.EmpAprsl.RatingDesc");
    oHeaderList.add("hrm.EmpAprsl.levelRating1");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getProperty("headerPrimaryKey")));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSL.proc_HrRatingHelpLov(?,?,?,?,?)");
    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("RATING_FROM").getString());
      oLOVBean.setDetailField2(oRow.get("RATING_TO").getString());
      oLOVBean.setDetailField3(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField4(oRow.get("NUMERIC_EQ").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmAprslRatingLevel2LOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.EmpAprsl.RatingFrom");
    oHeaderList.add("hrm.EmpAprsl.RatingTo");
    oHeaderList.add("hrm.EmpAprsl.RatingDesc");
    oHeaderList.add("hrm.EmpAprsl.levelRating2");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getProperty("headerPrimaryKey")));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSL.proc_HrRatingHelpLov(?,?,?,?,?)");
    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("RATING_FROM").getString());
      oLOVBean.setDetailField2(oRow.get("RATING_TO").getString());
      oLOVBean.setDetailField3(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField4(oRow.get("NUMERIC_EQ").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmAprslRatingLevel3LOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.EmpAprsl.RatingFrom");
    oHeaderList.add("hrm.EmpAprsl.RatingTo");
    oHeaderList.add("hrm.EmpAprsl.RatingDesc");
    oHeaderList.add("hrm.EmpAprsl.levelRating3");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getProperty("headerPrimaryKey")));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSL.proc_HrRatingHelpLov(?,?,?,?,?)");
    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("RATING_FROM").getString());
      oLOVBean.setDetailField2(oRow.get("RATING_TO").getString());
      oLOVBean.setDetailField3(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField4(oRow.get("NUMERIC_EQ").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmAprslRatingLevel4LOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.EmpAprsl.RatingFrom");
    oHeaderList.add("hrm.EmpAprsl.RatingTo");
    oHeaderList.add("hrm.EmpAprsl.RatingDesc");
    oHeaderList.add("hrm.EmpAprsl.levelRating4");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getProperty("headerPrimaryKey")));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSL.proc_HrRatingHelpLov(?,?,?,?,?)");
    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("RATING_FROM").getString());
      oLOVBean.setDetailField2(oRow.get("RATING_TO").getString());
      oLOVBean.setDetailField3(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField4(oRow.get("NUMERIC_EQ").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmAprslRatingLevel5LOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.EmpAprsl.RatingFrom");
    oHeaderList.add("hrm.EmpAprsl.RatingTo");
    oHeaderList.add("hrm.EmpAprsl.RatingDesc");
    oHeaderList.add("hrm.EmpAprsl.levelRating5");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oLovQueryVO.getProperty("headerPrimaryKey")));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSL.proc_HrRatingHelpLov(?,?,?,?,?)");
    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("RATING_FROM").getString());
      oLOVBean.setDetailField2(oRow.get("RATING_TO").getString());
      oLOVBean.setDetailField3(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField4(oRow.get("NUMERIC_EQ").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_EMP_APRSL_HDR";
  }
  
  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();
    HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)oBaseHeaderBean;
    if (bDetailDataChanged) {
      if (sScreenName.equalsIgnoreCase("HrmAprslKPA")) {
        Iterator itrBean1 = arylstDetailBeanArray.iterator();
        int iCount = 1;
        while (itrBean1.hasNext()) {
          HrmAprslKPADtlBean oHrmAprslKPADtlBean = itrBean1.next();
          if (!oHrmAprslKPADtlBean.getStatus().equalsIgnoreCase("D")) {
            if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("0"))
              if (!EnrgiseUtil.checkString(oHrmAprslKPADtlBean.getTxtLevelRating0())) {
                MessageKey oMessageKey = new MessageKey("hrm.EmpAprsl.levelRating0");
                ArrayList oParams = new ArrayList();
                oParams.add(oMessageKey);
                oParams.add(new Integer(iCount));
                arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
              }  
            if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("1"))
              if (!EnrgiseUtil.checkString(oHrmAprslKPADtlBean.getTxtLevelRating1())) {
                MessageKey oMessageKey = new MessageKey("hrm.EmpAprsl.levelRating1");
                ArrayList oParams = new ArrayList();
                oParams.add(oMessageKey);
                oParams.add(new Integer(iCount));
                arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
              }  
          } 
          iCount++;
        } 
      } 
      if (sScreenName.equalsIgnoreCase("HrmAprslGoals")) {
        Iterator itrBean1 = arylstDetailBeanArray.iterator();
        int iCount = 1;
        while (itrBean1.hasNext()) {
          HrmAprslGoalsDtlBean oHrmAprslGoalsDtlBean = itrBean1.next();
          if (!oHrmAprslGoalsDtlBean.getStatus().equalsIgnoreCase("D")) {
            if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("0"))
              if (!EnrgiseUtil.checkString(oHrmAprslGoalsDtlBean.getTxtLevelRating0g())) {
                MessageKey oMessageKey = new MessageKey("hrm.EmpAprsl.levelRating0");
                ArrayList oParams = new ArrayList();
                oParams.add(oMessageKey);
                oParams.add(new Integer(iCount));
                arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
              }  
            if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("1"))
              if (!EnrgiseUtil.checkString(oHrmAprslGoalsDtlBean.getTxtLevelRating1g())) {
                MessageKey oMessageKey = new MessageKey("hrm.EmpAprsl.levelRating1");
                ArrayList oParams = new ArrayList();
                oParams.add(oMessageKey);
                oParams.add(new Integer(iCount));
                arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
              }  
          } 
          iCount++;
        } 
      } 
      if (sScreenName.equalsIgnoreCase("HrmAprslTrngReq")) {
        Iterator itrBean2 = arylstDetailBeanArray.iterator();
        int iCount = 1;
        while (itrBean2.hasNext()) {
          HrmAprslTrngReqDtlBean oHrmAprslTrngReqDtlBean = itrBean2.next();
          if (!oHrmAprslTrngReqDtlBean.getStatus().equalsIgnoreCase("D"));
        } 
      } 
    } 
    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 param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public LovVO getEmpAprslStOrderLOVQ(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("startOrderId");
    arylstHeaderNames.add("hrm.HrmAprslForm.stOrderNo");
    arylstHeaderNames.add("hrm.EmpAprsl.toDate");
    arylstHeaderNames.add("hrm.EmpAprsl.fromDate");
    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();
    String sQuerySearch1 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sID = oLovQueryVO.getProperty("EmpStOrder");
    System.out.println(sID);
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(2, 1, 12, sID));
    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, "HRMAPRSLLOV.proc_GetEMPAprslStOrderQLOV(?,?,?,?,?,?)");
    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("StartOrder").getString());
      oLOVBean.setDetailField3(EnrgiseUtil.convertToString(oRow.get("StDate").getDate()));
      oLOVBean.setDetailField4(EnrgiseUtil.convertToString(oRow.get("EndDate").getDate()));
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getEmpAprslStOrderLOVI(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderNames = new ArrayList();
    arylstHeaderNames.add("startOrderId");
    arylstHeaderNames.add("hrm.HrmAprslForm.stOrderNo");
    arylstHeaderNames.add("hrm.EmpAprsl.toDate");
    arylstHeaderNames.add("hrm.EmpAprsl.fromDate");
    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();
    String sQuerySearch1 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sID = oLovQueryVO.getProperty("EmpStOrder");
    System.out.println(sID);
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(2, 1, 12, sID));
    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, "HRMAPRSLLOV.proc_GetEMPAprslStOrderILOV(?,?,?,?,?,?)");
    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("StartOrder").getString());
      oLOVBean.setDetailField3(EnrgiseUtil.convertToString(oRow.get("StDate").getDate()));
      oLOVBean.setDetailField4(EnrgiseUtil.convertToString(oRow.get("EndDate").getDate()));
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public String calKpaRating(String sEmpId, String sLevel) throws EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sRating = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sEmpId));
    arylstParam.add(new DBObject(2, 1, 12, sLevel));
    arylstParam.add(new DBObject(3, 2, 12));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procGetKPARatingInfo(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    sRating = oOutObject.getObject().toString();
    return sRating;
  }
  
  public String calGoalRating(String sEmpId, String sLevel) throws EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sRating = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sEmpId));
    arylstParam.add(new DBObject(2, 1, 12, sLevel));
    arylstParam.add(new DBObject(3, 2, 12));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procGetGoalRatingInfo(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    sRating = oOutObject.getObject().toString();
    return sRating;
  }
  
  public String calFinalRating(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)oBaseHeaderBean;
    if (EnrgiseUtil.checkString(oHrmAprslHdrBean.getAprslLevel())) {
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("0") || oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("1")) {
        checkRatingValue(oBaseHeaderBean, sScreenName);
        float kpaRating = Float.parseFloat(calKpaRating(oHrmAprslHdrBean.getEmpId(), oHrmAprslHdrBean.getAprslLevel()));
        float goalRating = Float.parseFloat(calGoalRating(oHrmAprslHdrBean.getEmpId(), oHrmAprslHdrBean.getAprslLevel()));
        String finalRating = String.valueOf((kpaRating + goalRating) / 2);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, oHrmAprslHdrBean.getHeaderPrimaryKey()));
        arylstParam.add(new DBObject(2, 1, 12, oHrmAprslHdrBean.getAprslLevel()));
        arylstParam.add(new DBObject(3, 1, 12, finalRating));
        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, "HRMAPRSL.upEmpAprslHdr(?,?,?,?,?,?)");
        DBObject dBObject = arylstOutArray.get(0);
      } 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("2") || oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("3") || oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("4") || oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("5")) {
        ArrayList arylstList = new ArrayList();
        arylstList.add(new EnrgiseApplicationException("wenrgise.hrms.aprsl.reviewer.rating.value"));
        reportError(arylstList);
      } 
    } 
    return oHrmAprslHdrBean.getHeaderPrimaryKey();
  }
  
  public void checkRatingValue(BaseHeaderBean oBaseHeaderBean, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)oBaseHeaderBean;
    ArrayList oErrorList = new ArrayList();
    String sRatingVal = null;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, oHrmAprslHdrBean.getEmpId()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmAprslHdrBean.getAprslLevel()));
    arylstParam.add(new DBObject(3, 1, 12, "K"));
    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, "HRMAPRSL.checkRatingVal(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    int count = 0;
    while (itrBean.hasNext()) {
      if (count == 0);
      count++;
      oRow = (QueryRow)itrBean.next();
      String sRatingReq = oRow.get("Rating_Required").getString();
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("0"))
        sRatingVal = oRow.get("rating_lvl0").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("1"))
        sRatingVal = oRow.get("rating_lvl1").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("2"))
        sRatingVal = oRow.get("rating_lvl2").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("3"))
        sRatingVal = oRow.get("rating_lvl3").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("4"))
        sRatingVal = oRow.get("rating_lvl4").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("5"))
        sRatingVal = oRow.get("rating_lvl5").getString(); 
      if (sRatingReq.equalsIgnoreCase("Y"))
        if (!EnrgiseUtil.checkString(sRatingVal))
          oErrorList.add(new EnrgiseApplicationException("wenrgise.hrms.aprsl.kpa.rating.value"));  
    } 
    ArrayList arylstParam1 = new ArrayList();
    DBUtilitiesBean oBean1 = new DBUtilitiesBean();
    arylstParam1 = new ArrayList();
    arylstParam1.add(new DBObject(1, 1, 12, oHrmAprslHdrBean.getEmpId()));
    arylstParam1.add(new DBObject(2, 1, 12, oHrmAprslHdrBean.getAprslLevel()));
    arylstParam1.add(new DBObject(3, 1, 12, "G"));
    arylstParam1.add(new DBObject(4, 2, -10));
    arylstParam1.add(new DBObject(5, 2, 12));
    arylstParam1.add(new DBObject(6, 2, 12));
    arylstParam1.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray1 = oBean1.callProc(arylstParam1, "HRMAPRSL.checkRatingVal(?,?,?,?,?,?,?)");
    DBObject oOutObject1 = arylstOutArray1.get(0);
    arylstParam1 = (ArrayList)oOutObject1.getObject();
    if (arylstParam1.size() == 0);
    QueryRow oRow1 = null;
    QueryValue oValue1 = null;
    HashMap oColumns1 = null;
    Iterator itrBean1 = arylstParam1.iterator();
    int count1 = 0;
    while (itrBean1.hasNext()) {
      if (count1 == 0);
      count1++;
      oRow1 = (QueryRow)itrBean1.next();
      String sRatingReq = oRow1.get("Rating_Required").getString();
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("0"))
        sRatingVal = oRow1.get("rating_lvl0").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("1"))
        sRatingVal = oRow1.get("rating_lvl1").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("2"))
        sRatingVal = oRow1.get("rating_lvl2").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("3"))
        sRatingVal = oRow1.get("rating_lvl3").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("4"))
        sRatingVal = oRow1.get("rating_lvl4").getString(); 
      if (oHrmAprslHdrBean.getAprslLevel().equalsIgnoreCase("5"))
        sRatingVal = oRow1.get("rating_lvl5").getString(); 
      if (sRatingReq.equalsIgnoreCase("Y"))
        if (!EnrgiseUtil.checkString(sRatingVal))
          oErrorList.add(new EnrgiseApplicationException("wenrgise.hrms.aprsl.goals.rating.value"));  
    } 
    reportError(oErrorList);
  }
  
  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();
      HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)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(oHrmAprslHdrBean.getHeaderPrimaryKey());
      wflDocumentInfoImpl.setDocumentType("Appraisal");
      wflDocumentInfoImpl.setInitiatedFlag(initiatedFlag);
      String documentTypeId = workFlowFacade.getDocumentTypeId("Appraisal");
      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("Appraisal No:  ").concat(String.valueOf(oHrmAprslHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for approval")));
        wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for approval: Appraisal No:").concat(String.valueOf(oHrmAprslHdrBean.getHeaderPrimaryKey())));
      } else if (!activity.equalsIgnoreCase("Approve")) {
        wflDocumentInfoImpl.setDocumentNumber(String.valueOf(String.valueOf("Appraisal No : ").concat(String.valueOf(oHrmAprslHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf("is pending for rejection")));
        wflDocumentInfoImpl.setDocDesc(String.valueOf("The following document has been pending for rejection:Appraisal No:").concat(String.valueOf(oHrmAprslHdrBean.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 approveEmpAprsl(BaseHeaderBean oBaseHeaderBean, String sFlag) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = null;
    HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)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, "HRMAPRSL.proc_UpsertApproveEmpAprsl(?,?,?,?,?)");
  }
  
  public String rejectEmpAprsl(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();
    HrmAprslHdrBean oHrmAprslHdrBean = (HrmAprslHdrBean)oBaseHeaderBean;
    String sHeaderPrimaryKey = (null != oBaseHeaderBean) ? oBaseHeaderBean.getHeaderPrimaryKey() : "";
    WflStatus status = null;
    status = callWorkFlow(oBaseHeaderBean, arylstDetailBeanArray, "Reject", (String)null);
    if (status.getStatus().equalsIgnoreCase("Rejected"))
      approveEmpAprsl(oBaseHeaderBean, "R"); 
    return sHeaderPrimaryKey;
  }
  
  public String approveEmpAprsl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    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"))
      approveEmpAprsl(oBaseHeaderBean, "A"); 
    return oBaseHeaderBean.getHeaderPrimaryKey();
  }
  
  public String getStaffJoiningDateInfo(String sPrimKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sStaffJoinDate = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    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, "HRMAPRSL.procGetStaffJoiningDate(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sStaffJoinDate = EnrgiseUtil.convertToString(oRow.get("staff_join_date").getDate());
    } 
    return sStaffJoinDate;
  }
  
  public String getOfficerJoiningDateInfo(String sPrimKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sOfficerJoinDate = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    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, "HRMAPRSL.procGetOfficerJoiningDate(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sOfficerJoinDate = EnrgiseUtil.convertToString(oRow.get("officer_join_date").getDate());
    } 
    return sOfficerJoinDate;
  }
  
  public String getPromotedOfficerJoiningDateInfo(String sPrimKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sPromotedOfficerJoinDate = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    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, "HRMAPRSL.procPromotedOfficerJoiningDate(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sPromotedOfficerJoinDate = EnrgiseUtil.convertToString(oRow.get("prom_officer_join_date").getDate());
    } 
    return sPromotedOfficerJoinDate;
  }
  
  public ArrayList getEmpPresentDetail(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator oIt = null;
    ArrayList arylstEmpPresentDetail = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, lPrimaryKey));
    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, "HRMAPRSL.procEmpPresDtls(?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0);
    count = 0;
    oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arylstEmpPresentDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslEmpDtlsBean oHrmAprslEmpDtlsBean = new HrmAprslEmpDtlsBean();
      oHrmAprslEmpDtlsBean.setGrade(oRow.get("present_grade").getString());
      oHrmAprslEmpDtlsBean.setDateofBirth(EnrgiseUtil.convertToString(oRow.get("dob").getDate()));
      oHrmAprslEmpDtlsBean.setDesignation(oRow.get("present_designation").getString());
      oHrmAprslEmpDtlsBean.setPresLoc(oRow.get("present_site_name").getString());
      arylstEmpPresentDetail.add(oHrmAprslEmpDtlsBean);
    } 
    return arylstEmpPresentDetail;
  }
  
  public String getLastPromotionDateInfo(String sPrimKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sLastPromotionDate = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    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, "HRMAPRSL.procLastPromotionDate(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sLastPromotionDate = EnrgiseUtil.convertToString(oRow.get("last_prom_date").getDate());
    } 
    return sLastPromotionDate;
  }
  
  public String getLastPayInfo(String sPrimKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sLastPay = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    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, "HRMAPRSL.procLastPayOnMarch(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sLastPay = oRow.get("net_earning").getString();
    } 
    return sLastPay;
  }
  
  public String getEmpPastRating(String sEmpId, String sPrdStDate, String sPrdEndDate) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sEmpPastRating = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sEmpId));
    arylstParam.add(new DBObject(2, 1, 93, EnrgiseUtil.convertToSqlDate(sPrdStDate)));
    arylstParam.add(new DBObject(3, 1, 93, EnrgiseUtil.convertToSqlDate(sPrdEndDate)));
    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, "HRMAPRSL.procPastRating(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sEmpPastRating = oRow.get("RATING_LVL5").getString();
    } 
    return sEmpPastRating;
  }
  
  public String getEmpQual(String sPrimKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    BaseDetailVO oBaseDetailVO = null;
    String sEmpQual = new String();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    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, "HRMAPRSL.procEmpQual(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    int count = 0;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sEmpQual = String.valueOf(sEmpQual).concat(String.valueOf(oRow.get("name").getString()));
      if (count != arylstParam.size() - 1)
        sEmpQual = String.valueOf(sEmpQual).concat(String.valueOf(", ")); 
      count++;
    } 
    return sEmpQual;
  }
  
  public String getEmpPastTotal(String sPrimKey, String sYYYYMM) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    String sEmpPastTotal = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sPrimKey));
    arylstParam.add(new DBObject(2, 1, 12, sYYYYMM));
    arylstParam.add(new DBObject(3, 2, -10));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procBasicFixedAllowIncrTotal(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0);
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    while (itrBean.hasNext()) {
      oRow = (QueryRow)itrBean.next();
      sEmpPastTotal = oRow.get("total").getString();
    } 
    return sEmpPastTotal;
  }
  
  public LovVO getHrmAprslEmpNoLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("Id");
    oHeaderList.add("hrm.EmpAprsl.empCode");
    oHeaderList.add("hrm.EmpAprsl.empName");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 2, -10));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 12));
    arylstParameters.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMAPRSLLOV.proc_GetApprEmpLOV(?,?,?,?,?,?)");
    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("EMP_NO").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public RecordMetaInfo getHrmAprslEmpDtlMetaInfo(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, "HRMAPRSL.procHrEmpAprslDtlCount(?,?,?,?,?,?)");
    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 getHrAprslEmpPerDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    String empId = null;
    String aprslYear = null;
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator oIt = null;
    ArrayList arrHrmEmpDtl = 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, 1, 12, empId));
    arylstParam.add(new DBObject(5, 1, 12, aprslYear));
    arylstParam.add(new DBObject(6, 2, -10));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 12));
    arylstParam.add(new DBObject(9, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procHrEmpAprslDtl(?,?,?,?,?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    count = 0;
    oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        arrHrmEmpDtl = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslEmployeeBean oHrmAprslEmployeeBean = new HrmAprslEmployeeBean();
      oHrmAprslEmployeeBean.setDetailId(oRow.get("ID").getString());
      oHrmAprslEmployeeBean.setEmpIdDtl(oRow.get("E_PER_DTL_ID").getString());
      oHrmAprslEmployeeBean.setEmpNoDtl(oRow.get("E_PER_DTL_ID").getString());
      oHrmAprslEmployeeBean.setEmpNameDtl(oRow.get("EMPNAME").getString());
      oHrmAprslEmployeeBean.setAprslYearDtl(oRow.get("Aprsl_Year").getString());
      oHrmAprslEmployeeBean.setFinalRatingDtl(oRow.get("final_rating").getString());
      arrHrmEmpDtl.add(oHrmAprslEmployeeBean);
    } 
    return arrHrmEmpDtl;
  }
  
  public RecordMetaInfo getHrmAprslHdrMetaInfo(HrmAprslQVO oHrmAprslQVO) 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, oHrmAprslQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmAprslQVO.getEmployeeId()));
    arylstParam.add(new DBObject(3, 1, 12, oHrmAprslQVO.getAprslYear()));
    arylstParam.add(new DBObject(4, 2, -5));
    arylstParam.add(new DBObject(5, 2, 93));
    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, "HRMAPRSL.procHrEmpAprslHeaderCount(?,?,?,?,?,?,?,?)");
    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 getHrmAprslHeaderInfo(HrmAprslQVO oHrmAprslQVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    ArrayList arylstHeaderList = null;
    if (oHrmAprslQVO == null)
      oHrmAprslQVO = new HrmAprslQVO(); 
    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, oHrmAprslQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmAprslQVO.getEmployeeId()));
    arylstParam.add(new DBObject(5, 1, 12, oHrmAprslQVO.getAprslYear()));
    arylstParam.add(new DBObject(6, 2, -10));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 12));
    arylstParam.add(new DBObject(9, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMAPRSL.procHrEmpAprslHeader(?,?,?,?,?,?,?,?,?)");
    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();
    String sLevel = null;
    while (oIt.hasNext()) {
      if (count == 0)
        arylstHeaderList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmAprslHdrBean oHrmAprslHdrBean = new HrmAprslHdrBean();
      oHrmAprslHdrBean.setHeaderPrimaryKey(oRow.get("E_PER_DTL_ID").getString());
      oHrmAprslHdrBean.setEmpId(oRow.get("E_PER_DTL_ID").getString());
      oHrmAprslHdrBean.setEmpNo(oRow.get("E_PER_DTL_ID").getString());
      oHrmAprslHdrBean.setEmpName(oRow.get("EMPNAME").getString());
      arylstHeaderList.add(oHrmAprslHdrBean);
    } 
    return arylstHeaderList;
  }
  
  private void saveHrmEmpAprslDtl(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslEmployeeBean oHrmAprslEmployeeBean = oIt.next();
      if (oHrmAprslEmployeeBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMAPRSL.procUpsertHrEmpAprsl(?,?,?,?)");
          bInsert = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "N"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmAprslEmployeeBean.getEmpIdDtl()));
        arylstParam.add(new DBObject(3, 1, 12, oHrmAprslEmployeeBean.getAprslYearDtl()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmAprslEmployeeBean.getFinalRatingDtl()));
        oBean.addToBatch(arylstParam);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmAprslEmployeeBean oHrmAprslEmployeeBean = oIt.next();
      if (oHrmAprslEmployeeBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMAPRSL.procUpsertHrEmpAprsl(?,?,?,?)");
          bUpdate = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "U"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmAprslEmployeeBean.getEmpIdDtl()));
        arylstParam.add(new DBObject(3, 1, 12, oHrmAprslEmployeeBean.getAprslYearDtl()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmAprslEmployeeBean.getFinalRatingDtl()));
        oBean.addToBatch(arylstParam);
      } 
    } 
    if (bUpdate)
      oBean.executeBatch(); 
  }
}
