package wenrgise.hrms.ejb.business;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.bean.LOVBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseMessageKeyException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.MessageKey;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.vo.LovQueryVO;
import wenrgise.common.vo.LovVO;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.hrms.bean.HrmPrmViewAssDtlBean;

public class HrmPrmViewAssBO extends HrmBaseBO {
  public HrmPrmViewAssBO() {}
  
  public HrmPrmViewAssBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getPrmViewAssDetailMetaInfo(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, "HRMPRMVIEWASS.proc_ViewAssDtlCount(?,?,?,?,?,?)");
    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 getPrmViewAssDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    QueryRow oRow = null;
    ArrayList oList = null;
    Iterator oIt = null;
    ArrayList oLocVavancyDetail = new ArrayList();
    ArrayList oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, new Long(lDetailFirstPosition)));
    oParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
    oParameters.add(new DBObject(3, 1, 12, lPrimaryKey));
    oParameters.add(new DBObject(4, 2, -10));
    oParameters.add(new DBObject(5, 2, 12));
    oParameters.add(new DBObject(6, 2, 12));
    oParameters.add(new DBObject(7, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMPRMVIEWASS.proc_ViewAssDetail(?,?,?,?,?,?,?)");
    oList = (ArrayList)((DBObject)oOutArray.get(0)).getObject();
    oIt = oList.iterator();
    while (oIt.hasNext()) {
      oRow = oIt.next();
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = new HrmPrmViewAssDtlBean();
      oHrmPrmViewAssDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmPrmViewAssDtlBean.setEmployeeId(oRow.get("empId").getString());
      oHrmPrmViewAssDtlBean.setPositionId(oRow.get("designation_id").getString());
      oHrmPrmViewAssDtlBean.setHdnPrevDtlId(oRow.get("prom_ntcdt_id").getString());
      oHrmPrmViewAssDtlBean.setHeaderPositionId(oRow.get("PosInfoHdrId").getString());
      oHrmPrmViewAssDtlBean.setTxtEmpNo(oRow.get("EMP_NO").getString());
      oHrmPrmViewAssDtlBean.setTxtEmpName(oRow.get("EMPNAME").getString());
      oHrmPrmViewAssDtlBean.setTxtFromPosCode(oRow.get("designation").getString());
      oHrmPrmViewAssDtlBean.setScaleId(oRow.get("scale_id").getString());
      oHrmPrmViewAssDtlBean.setTxtScale(oRow.get("Scale").getString());
      oHrmPrmViewAssDtlBean.setTxtSrvYrs(oRow.get("YEAR_SERVICE").getString());
      oHrmPrmViewAssDtlBean.setTxtCurrSrvYrs(oRow.get("YEAR_CUR_POST").getString());
      oHrmPrmViewAssDtlBean.setTxtSrvYrsPoints(oRow.get("YEAR_SERVICE_POINTS").getString());
      oHrmPrmViewAssDtlBean.setTxtAvgAparPts(oRow.get("AVG_APAR_RATING").getString());
      oHrmPrmViewAssDtlBean.setTxtAparPts(oRow.get("APAR_POINT").getString());
      oHrmPrmViewAssDtlBean.setTxtWrittenTestMarks(oRow.get("WRITTEN_TEST_MARKS").getString());
      oHrmPrmViewAssDtlBean.setTxtWrittenTestPts(oRow.get("WRITTEN_TEST_POINTS").getString());
      oHrmPrmViewAssDtlBean.setTxtGDMarks(oRow.get("GD_MARKS").getString());
      oHrmPrmViewAssDtlBean.setTxtGDPts(oRow.get("GD_POINTS").getString());
      oHrmPrmViewAssDtlBean.setTxtInterviewMarks(oRow.get("INTERVIEW_MARKS").getString());
      oHrmPrmViewAssDtlBean.setTxtInterviewPts(oRow.get("INTERVIEW_POINTS").getString());
      oHrmPrmViewAssDtlBean.setTxtTotalPtsAwarded(oRow.get("AVERAGE_POINTS").getString());
      String prmFlag = oRow.get("PROMOTION_FLAG").getString();
      if (EnrgiseUtil.checkString(prmFlag)) {
        boolean promotion;
        prmFlag = prmFlag.trim();
        if (prmFlag.equalsIgnoreCase("Y")) {
          promotion = true;
        } else {
          promotion = false;
        } 
        oHrmPrmViewAssDtlBean.setTxtEligProm(promotion);
      } 
      oHrmPrmViewAssDtlBean.setStatus("Q");
      oLocVavancyDetail.add(oHrmPrmViewAssDtlBean);
    } 
    return oLocVavancyDetail;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "hrm_asst_promot";
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    System.out.println("Update ille!");
  }
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return "saveNewHeaderImpl ille!";
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String param1) throws EnrgiseSystemException {
    return "saveHeaderImpl toBeDone";
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    saveViewAssDetails(oDetailBeanArray);
  }
  
  private void saveViewAssDetails(ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {
    boolean bUpsert = false;
    boolean bDelete = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    Iterator itrBean = arylstDetailBeanArray.iterator();
    while (itrBean.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = itrBean.next();
      if (oHrmPrmViewAssDtlBean.getStatus().equals("N")) {
        if (!bUpsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMPRMVIEWASS.proc_UpsertViewAssDtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpsert = 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, oHrmPrmViewAssDtlBean.getEmployeeId()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmPrmViewAssDtlBean.getHdnPrevDtlId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmPrmViewAssDtlBean.getPositionId()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmPrmViewAssDtlBean.getTxtSrvYrs()));
        arylstParam.add(new DBObject(7, 1, 12, oHrmPrmViewAssDtlBean.getTxtCurrSrvYrs()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmPrmViewAssDtlBean.getTxtSrvYrsPoints()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmPrmViewAssDtlBean.getTxtAvgAparPts()));
        arylstParam.add(new DBObject(10, 1, 12, oHrmPrmViewAssDtlBean.getTxtAparPts()));
        arylstParam.add(new DBObject(11, 1, 12, oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()));
        arylstParam.add(new DBObject(12, 1, 12, oHrmPrmViewAssDtlBean.getTxtGDMarks()));
        arylstParam.add(new DBObject(13, 1, 12, oHrmPrmViewAssDtlBean.getTxtInterviewMarks()));
        arylstParam.add(new DBObject(14, 1, 12, oHrmPrmViewAssDtlBean.getTxtTotalPtsAwarded()));
        arylstParam.add(new DBObject(15, 1, 12, oHrmPrmViewAssDtlBean.getHdnPromEligibility()));
        arylstParam.add(new DBObject(16, 1, 12, oHrmPrmViewAssDtlBean.getScaleId()));
        arylstParam.add(new DBObject(17, 1, 12, oHrmPrmViewAssDtlBean.getHeaderPositionId()));
        arylstParam.add(new DBObject(18, 1, 12, this.oUserInfo.getUserId()));
        arylstParam.add(new DBObject(19, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
        continue;
      } 
      if (oHrmPrmViewAssDtlBean.getStatus().equals("U")) {
        if (!bUpsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMPRMVIEWASS.proc_UpsertViewAssDtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpsert = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "U"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmPrmViewAssDtlBean.getDetailId()));
        arylstParam.add(new DBObject(3, 1, 12, oHrmPrmViewAssDtlBean.getEmployeeId()));
        arylstParam.add(new DBObject(4, 1, 12, oHrmPrmViewAssDtlBean.getHdnPrevDtlId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmPrmViewAssDtlBean.getPositionId()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmPrmViewAssDtlBean.getTxtSrvYrs()));
        arylstParam.add(new DBObject(7, 1, 12, oHrmPrmViewAssDtlBean.getTxtCurrSrvYrs()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmPrmViewAssDtlBean.getTxtSrvYrsPoints()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmPrmViewAssDtlBean.getTxtAvgAparPts()));
        arylstParam.add(new DBObject(10, 1, 12, oHrmPrmViewAssDtlBean.getTxtAparPts()));
        arylstParam.add(new DBObject(11, 1, 12, oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()));
        arylstParam.add(new DBObject(12, 1, 12, oHrmPrmViewAssDtlBean.getTxtGDMarks()));
        arylstParam.add(new DBObject(13, 1, 12, oHrmPrmViewAssDtlBean.getTxtInterviewMarks()));
        arylstParam.add(new DBObject(14, 1, 12, oHrmPrmViewAssDtlBean.getTxtTotalPtsAwarded()));
        arylstParam.add(new DBObject(15, 1, 12, oHrmPrmViewAssDtlBean.getHdnPromEligibility()));
        arylstParam.add(new DBObject(16, 1, 12, oHrmPrmViewAssDtlBean.getScaleId()));
        arylstParam.add(new DBObject(17, 1, 12, oHrmPrmViewAssDtlBean.getHeaderPositionId()));
        arylstParam.add(new DBObject(18, 1, 12, this.oUserInfo.getUserId()));
        arylstParam.add(new DBObject(19, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
        continue;
      } 
      if (oHrmPrmViewAssDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("HRMPRMVIEWASS.proc_DeletePrmViewAssDtl(?)");
          bDelete = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, oHrmPrmViewAssDtlBean.getDetailId()));
        oBean1.addToBatch(arylstParam);
      } 
    } 
    if (bUpsert)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
  }
  
  public LovVO getPrmViewAssSiteCodeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmPrmGenAss.siteCode");
    arylstHeaderList.add("hrm.HrmPrmGenAss.siteDesc");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = 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(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    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, "HRMORGSETUPLOV.proc_GetSiteCodeLOV(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getPrmViewAssNoticeCodeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmPrmViewAss.prmNo");
    arylstHeaderList.add("hrm.HrmPrmViewAss.noticeDesc");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = 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(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    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, "HRMPRMVIEWASS.proc_GetNoticeNoLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("notice_no").getString());
      oLOVBean.setDetailField3(oRow.get("description").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getPrmViewAssPromotionCodeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmPrmViewAss.toPosition");
    arylstHeaderList.add("hrm.HrmPrmViewAss.posDesc");
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = 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(); 
    String sNoticeNo = oLovQueryVO.getProperty("NoticeNo");
    System.out.println(sNoticeNo);
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParam.add(new DBObject(3, 1, 12, sNoticeNo));
    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, "HRMPRMVIEWASS.proc_GetPromotionNoLOVdata(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("NtcDtlId").getString());
      oLOVBean.setDetailField2(oRow.get("id").getString());
      oLOVBean.setDetailField3(oRow.get("CODE").getString());
      oLOVBean.setDetailField4(oRow.get("Description").getString());
      oLOVBean.setDetailField5(oRow.get("HIERARCHY").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getPrmEmployeeNoLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmPrmViewAss.empNo");
    arylstHeaderList.add("hrm.HrmPrmViewAss.empName");
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmPrmViewAss.fromPosCode");
    arylstHeaderList.add("hrm.HrmPrmViewAss.scale");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = 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(); 
    String sHeirarchy = oLovQueryVO.getProperty("Heirarchy");
    System.out.println(sHeirarchy);
    String sntcDtlId = oLovQueryVO.getProperty("ntcDtlId");
    System.out.println(sntcDtlId);
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParam.add(new DBObject(3, 1, 12, sHeirarchy));
    arylstParam.add(new DBObject(4, 1, 12, sntcDtlId));
    arylstParam.add(new DBObject(5, 2, -10));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMPRMVIEWASS.proc_GetEmployeeNoLOVdata(?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("emp_no").getString());
      oLOVBean.setDetailField3(oRow.get("EMPNAME").getString());
      oLOVBean.setDetailField4(oRow.get("desgnId").getString());
      oLOVBean.setDetailField5(oRow.get("ScaleId").getString());
      oLOVBean.setDetailField6(oRow.get("Designation").getString());
      oLOVBean.setDetailField7(oRow.get("Scale").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getPrmViewAssPosCodeLOVData(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("hrm.HrmAdvertisementAttribute.id");
    arylstHeaderList.add("hrm.HrmPrmViewAss.fromPosCode");
    arylstHeaderList.add("hrm.HrmPrmViewAss.posDesc");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = 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(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    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, "HRMPRMVIEWASS.proc_GetPromotionNoLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("Description").getString());
      oLOVBean.setDetailField4(oRow.get("SCALE").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    if (bDetailDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D")) {
        Iterator oIt1 = arylstDetailBeanArray.iterator();
        int rowCount = 1;
        while (oIt1.hasNext()) {
          HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
          if (!oHrmPrmViewAssDtlBean.getStatus().equalsIgnoreCase("D"))
            checkMandatoryAssessmentDtls(oHrmPrmViewAssDtlBean, rowCount, oErrorList); 
          rowCount++;
        } 
      }  
    reportError(oErrorList);
  }
  
  private void checkMandatoryAssessmentDtls(HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean, int rowCount, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {}
  
  public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    if (bDetailDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        EnrgiseUtil.checkDuplicate(oDetailBeanArray, "txtEmpNo", "hrm.HrmPrmViewAss.empNo", oErrorList, true);
        checkToPositionTest(oDetailBeanArray, oErrorList);
        checkFirstNumericAssessmentDtl(oDetailBeanArray, oErrorList);
        checkNumericAssessmentDtl(oDetailBeanArray, oErrorList);
        checkWrittenMarksPoints(oDetailBeanArray, oErrorList);
        checkGDMarksPoints(oDetailBeanArray, oErrorList);
        checkInterviewMarksPoints(oDetailBeanArray, oErrorList);
      }  
    reportError(oErrorList);
  }
  
  private void checkUniqueAssessmentDtl(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(" Select id as ID from HRM_PROM_assesment where E_PER_DTL_ID= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getEmployeeId()))).concat(String.valueOf("' and prom_ntcdt_id='"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getHdnPrevDtlId()))).concat(String.valueOf("'"));
      System.out.println(sQuery);
      DBUtilitiesBean oBean = new DBUtilitiesBean();
      ArrayList oList = oBean.executeQuery(sQuery);
      Iterator oIt = oList.iterator();
      if (oIt.hasNext()) {
        QueryRow oRow = oIt.next();
        if (!oRow.get("ID").getString().equalsIgnoreCase(oHrmPrmViewAssDtlBean.getDetailId())) {
          ArrayList oParams = new ArrayList();
          MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.empNo");
          oParams.add(oMessageKey);
          oParams.add(new Integer(count));
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.uniqueKeyViolated", oParams, "E"));
        } 
      } 
      count++;
    } 
  }
  
  private void checkToPositionTest(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtInterviewMarks()) || EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()) || EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtGDMarks())) {
        String sQuery = String.valueOf(String.valueOf(" select hpsh.id from hrm_prom_scr_hdr  hpsh where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList oList = oBean.executeQuery(sQuery);
        if (oList.size() == 0) {
          ArrayList oParams = new ArrayList();
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.detail.prmViewAssToPosition", oParams, "E"));
        } 
      } 
      count++;
    } 
  }
  
  private void checkWrittenMarksPoints(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks())) {
        String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(" select hpsd.id from hrm_prom_scr_hdr  hpsh,hrm_prom_scr_dtl hpsd where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("' and  hpsh.exam_type='W' and  hpsd.prom_scrhdr_id=hpsh.id  and  hpsd.score_from <= '"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()))).concat(String.valueOf("' and  hpsd.score_to >= '"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()))).concat(String.valueOf("'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList oList = oBean.executeQuery(sQuery);
        if (oList.size() == 0) {
          ArrayList oParams = new ArrayList();
          oParams.add(new Integer(count));
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.detail.prmViewAssWritten", oParams, "E"));
        } 
      } 
      count++;
    } 
  }
  
  private void checkGDMarksPoints(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtGDMarks())) {
        String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(" select hpsd.id from hrm_prom_scr_hdr  hpsh,hrm_prom_scr_dtl hpsd where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("' and  hpsh.exam_type='G' and  hpsd.prom_scrhdr_id=hpsh.id  and  hpsd.score_from <= '"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getTxtGDMarks()))).concat(String.valueOf("' and  hpsd.score_to >= '"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getTxtGDMarks()))).concat(String.valueOf("'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList oList = oBean.executeQuery(sQuery);
        if (oList.size() == 0) {
          ArrayList oParams = new ArrayList();
          oParams.add(new Integer(count));
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.detail.prmViewAssGD", oParams, "E"));
        } 
      } 
      count++;
    } 
  }
  
  private void checkInterviewMarksPoints(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtInterviewMarks())) {
        String sQuery = String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(" select hpsd.id from hrm_prom_scr_hdr  hpsh,hrm_prom_scr_dtl hpsd where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("' and  hpsh.exam_type='I' and  hpsd.prom_scrhdr_id=hpsh.id  and  hpsd.score_from <= '"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getTxtInterviewMarks()))).concat(String.valueOf("' and  hpsd.score_to >= '"))).concat(String.valueOf(oHrmPrmViewAssDtlBean.getTxtInterviewMarks()))).concat(String.valueOf("'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList oList = oBean.executeQuery(sQuery);
        if (oList.size() == 0) {
          ArrayList oParams = new ArrayList();
          oParams.add(new Integer(count));
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.detail.prmViewAssInterview", oParams, "E"));
        } 
      } 
      count++;
    } 
  }
  
  private void checkNumericAssessmentDtl(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks())) {
        String sQuery = String.valueOf(String.valueOf(" select hpsh.max_score as  Maxmarks from hrm_prom_scr_hdr  hpsh where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("' and  hpsh.exam_type='W'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        QueryRow oRow = null;
        ArrayList oList = oBean.executeQuery(sQuery);
        Iterator oIt = oList.iterator();
        if (oIt.hasNext()) {
          oRow = oIt.next();
          String maxMarks = oRow.get("Maxmarks").getString();
          if (Double.parseDouble(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()) > Double.parseDouble(maxMarks)) {
            ArrayList oParams = new ArrayList();
            MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.writtenTestMarks");
            oParams.add(oMessageKey);
            oParams.add(new Integer(count));
            oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.viewAssdetail.invalidWrittenMarks", oParams, "E"));
          } 
        } 
      } 
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtGDMarks())) {
        String sQuery = String.valueOf(String.valueOf(" select hpsh.max_score as  Maxmarks from hrm_prom_scr_hdr  hpsh where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("' and  hpsh.exam_type='G'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList oList = oBean.executeQuery(sQuery);
        Iterator oIt = oList.iterator();
        if (oIt.hasNext()) {
          QueryRow oRow = oIt.next();
          if (Double.parseDouble(oHrmPrmViewAssDtlBean.getTxtGDMarks()) > Double.parseDouble(oRow.get("Maxmarks").getString())) {
            ArrayList oParams = new ArrayList();
            MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.GDMarks");
            oParams.add(oMessageKey);
            oParams.add(new Integer(count));
            oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.viewAssdetail.invalidGDMarks", oParams, "E"));
          } 
        } 
      } 
      if (EnrgiseUtil.checkString(oHrmPrmViewAssDtlBean.getTxtInterviewMarks())) {
        String sQuery = String.valueOf(String.valueOf(" select hpsh.max_score as  Maxmarks from hrm_prom_scr_hdr  hpsh where  hpsh.pos_inf_hdr_id= '").concat(String.valueOf(oHrmPrmViewAssDtlBean.getHeaderPositionId()))).concat(String.valueOf("' and  hpsh.exam_type='I'  "));
        System.out.println(sQuery);
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        ArrayList oList = oBean.executeQuery(sQuery);
        Iterator oIt = oList.iterator();
        if (oIt.hasNext()) {
          QueryRow oRow = oIt.next();
          if (Double.parseDouble(oHrmPrmViewAssDtlBean.getTxtInterviewMarks()) > Double.parseDouble(oRow.get("Maxmarks").getString())) {
            ArrayList oParams = new ArrayList();
            MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.interviewMarks");
            oParams.add(oMessageKey);
            oParams.add(new Integer(count));
            oErrorList.add(new EnrgiseMessageKeyException("wenrgise.hrms.viewAssdetail.invalidInterviewMarks", oParams, "E"));
          } 
        } 
      } 
      count++;
    } 
  }
  
  private void checkFirstNumericAssessmentDtl(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    int count = 1;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmPrmViewAssDtlBean oHrmPrmViewAssDtlBean = oIt1.next();
      if (!oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks().equalsIgnoreCase("")) {
        MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.writtenTestMarks");
        ArrayList oParam = new ArrayList();
        oParam.add(oMessageKey);
        oParam.add(new Integer(count));
        if (!EnrgiseUtil.checkNumber(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks(), 2, 2, "P")) {
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.invalidNumber", oParam));
        } else if (Double.parseDouble(oHrmPrmViewAssDtlBean.getTxtWrittenTestMarks()) <= false) {
          oErrorList.add(new EnrgiseMessageKeyException("hrm.recadvattrwork.numberZero", oParam));
        } 
      } 
      if (!oHrmPrmViewAssDtlBean.getTxtGDMarks().equalsIgnoreCase("")) {
        MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.GDMarks");
        ArrayList oParam = new ArrayList();
        oParam.add(oMessageKey);
        oParam.add(new Integer(count));
        if (!EnrgiseUtil.checkNumber(oHrmPrmViewAssDtlBean.getTxtGDMarks(), 2, 2, "P")) {
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.invalidNumber", oParam));
        } else if (Double.parseDouble(oHrmPrmViewAssDtlBean.getTxtGDMarks()) <= false) {
          oErrorList.add(new EnrgiseMessageKeyException("hrm.recadvattrwork.numberZero", oParam));
        } 
      } 
      if (!oHrmPrmViewAssDtlBean.getTxtInterviewMarks().equalsIgnoreCase("")) {
        MessageKey oMessageKey = new MessageKey("hrm.HrmPrmViewAss.interviewMarks");
        ArrayList oParam = new ArrayList();
        oParam.add(oMessageKey);
        oParam.add(new Integer(count));
        if (!EnrgiseUtil.checkNumber(oHrmPrmViewAssDtlBean.getTxtInterviewMarks(), 2, 2, "P")) {
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.invalidNumber", oParam));
        } else if (Double.parseDouble(oHrmPrmViewAssDtlBean.getTxtInterviewMarks()) <= false) {
          oErrorList.add(new EnrgiseMessageKeyException("hrm.recadvattrwork.numberZero", oParam));
        } 
      } 
      count++;
    } 
  }
  
  public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
}
