package wenrgise.hrms.ejb.business;

import java.lang.reflect.Array;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.bean.LOVBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseMessageKeyException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.DateUtility;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.MessageKey;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.vo.BaseDetailVO;
import wenrgise.common.vo.BaseHeaderVO;
import wenrgise.common.vo.LovQueryVO;
import wenrgise.common.vo.LovVO;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.hrms.bean.HrmRecAdvtMtnDtlBean;
import wenrgise.hrms.bean.HrmRecAdvtMtnHdrBean;
import wenrgise.hrms.vo.HrmRecAdvtMtnQVO;

public class HrmRecAdvtMtnBO extends HrmBaseBO {
  public HrmRecAdvtMtnBO() {}
  
  public HrmRecAdvtMtnBO(UserInfo oUserinfo) {
    super(oUserinfo);
  }
  
  public RecordMetaInfo getHrmRecAdvtHdrMetaInfo(HrmRecAdvtMtnQVO oHrmRecAdvtMtnQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, oHrmRecAdvtMtnQVO.getHeaderPrimaryKey()));
    oParameters.add(new DBObject(2, 2, -5));
    oParameters.add(new DBObject(3, 2, 93));
    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, "HRMRECADVTMTN.proc_HrAdvtCount(?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTimeObject = oOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    DBObject oTotalRecord = oOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrmRecAdvtInfo(HrmRecAdvtMtnQVO oHrmRecAdvtMtnQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    ArrayList oHeaderList = null;
    if (oHrmRecAdvtMtnQVO == null)
      oHrmRecAdvtMtnQVO = new HrmRecAdvtMtnQVO(); 
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, -5, new Long(lStartPosition)));
    oParameters.add(new DBObject(2, 1, -5, new Long(lLastPosition)));
    oParameters.add(new DBObject(3, 1, 12, oHrmRecAdvtMtnQVO.getHeaderPrimaryKey()));
    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, "HRMRECADVTMTN.proc_HrAdvtHdrInfo(?,?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    if (oList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator oIt = oList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        oHeaderList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean = new HrmRecAdvtMtnHdrBean();
      oHrmRecAdvtMtnHdrBean.setHeaderPrimaryKey(oRow.get("ID").getString());
      oHrmRecAdvtMtnHdrBean.setReferenceNo(oRow.get("ref_no").getString());
      oHrmRecAdvtMtnHdrBean.setEntryMode(oRow.get("entry_mode").getString());
      oHrmRecAdvtMtnHdrBean.setReferenceDate(EnrgiseUtil.convertToString(oRow.get("referencedate").getDate()));
      oHrmRecAdvtMtnHdrBean.setMediaType(oRow.get("media_type").getString());
      oHrmRecAdvtMtnHdrBean.setMediaName(oRow.get("media_name").getString());
      oHrmRecAdvtMtnHdrBean.setDescription(oRow.get("description").getString());
      oHrmRecAdvtMtnHdrBean.setMinWrittenScoreA(oRow.get("min_written_mrks").getString());
      oHrmRecAdvtMtnHdrBean.setMinWrittenScoreB(oRow.get("MIN_GD_MRKS").getString());
      oHrmRecAdvtMtnHdrBean.setMinInterviewScore(oRow.get("min_interview_mrks").getString());
      oHrmRecAdvtMtnHdrBean.setMinInterviewScore2(oRow.get("min_interview_marks_2").getString());
      oHrmRecAdvtMtnHdrBean.setMinInterviewScore3(oRow.get("min_interview_marks_3").getString());
      oHrmRecAdvtMtnHdrBean.setMinTotalScore(oRow.get("min_total_mrks").getString());
      oHrmRecAdvtMtnHdrBean.setVenue(oRow.get("venue").getString());
      oHrmRecAdvtMtnHdrBean.setTime(oRow.get("time").getString());
      oHrmRecAdvtMtnHdrBean.setDate(EnrgiseUtil.convertToString(oRow.get("walk_in_date").getDate()));
      oHrmRecAdvtMtnHdrBean.setLastDate(EnrgiseUtil.convertToString(oRow.get("last_date").getDate()));
      oHeaderList.add(oHrmRecAdvtMtnHdrBean);
    } 
    return oHeaderList;
  }
  
  public RecordMetaInfo getHrmRecAdvtDtlMetaInfo(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, lPrimaryKey));
    oParameters.add(new DBObject(2, 2, -5));
    oParameters.add(new DBObject(3, 2, 93));
    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, "HRMRECADVTMTN.proc_HrAdvtDtlCount(?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTotalRecord = oOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    DBObject oTimeObject = oOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrmRecAdvtDetailInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList oHrmPosKPAPtsDetail = null;
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, -5, 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, "HRMRECADVTMTN.proc_GetHrmAdvtDtlInfo(?,?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    if (oList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator oIt = oList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        oHrmPosKPAPtsDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean = new HrmRecAdvtMtnDtlBean();
      oHrmRecAdvtMtnDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmRecAdvtMtnDtlBean.setTxtGradeId(oRow.get("grade_id").getString());
      oHrmRecAdvtMtnDtlBean.setTxtGrade(oRow.get("grade").getString());
      oHrmRecAdvtMtnDtlBean.setTxtDesignationId(oRow.get("designation_ID").getString());
      oHrmRecAdvtMtnDtlBean.setTxtDesignation(oRow.get("designation").getString());
      oHrmRecAdvtMtnDtlBean.setTxtApplicantCategoryId(oRow.get("applicant_cat_id").getString());
      oHrmRecAdvtMtnDtlBean.setTxtApplicantCategory(oRow.get("acatcode").getString());
      oHrmRecAdvtMtnDtlBean.setTxtReservationCategoryId(oRow.get("rsvcat_type_id").getString());
      oHrmRecAdvtMtnDtlBean.setTxtReservationCategory(oRow.get("RES_CAT_CODE").getString());
      oHrmRecAdvtMtnDtlBean.setTxtTotalVacancy(oRow.get("total_vacancy").getString());
      oHrmRecAdvtMtnDtlBean.setTxtSex(oRow.get("sex_code").getString());
      oHrmRecAdvtMtnDtlBean.setTxtMinimumAge(oRow.get("min_age").getString());
      oHrmRecAdvtMtnDtlBean.setTxtMaximumAge(oRow.get("max_age").getString());
      oHrmRecAdvtMtnDtlBean.setTxtMaxAgeOnDate(EnrgiseUtil.convertToString(oRow.get("max_age_on_date").getDate()));
      oHrmRecAdvtMtnDtlBean.setTxtAmount(oRow.get("app_amt").getString());
      oHrmPosKPAPtsDetail.add(oHrmRecAdvtMtnDtlBean);
    } 
    return oHrmPosKPAPtsDetail;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "hrm_advt_hdr";
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    saveAdvtDtl(sHeaderPrimaryKey, oDetailBeanArray);
  }
  
  private void saveAdvtDtl(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bDelete = false;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean = oIt.next();
      if (oHrmRecAdvtMtnDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMRECADVTMTN.proc_UpsertHrmAdvtDtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, "N"));
        oParameters.add(new DBObject(2, 1, 12, null));
        oParameters.add(new DBObject(3, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtMinimumAge()));
        oParameters.add(new DBObject(4, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtMaximumAge()));
        oParameters.add(new DBObject(5, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtSex()));
        oParameters.add(new DBObject(6, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtTotalVacancy()));
        oParameters.add(new DBObject(7, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtAmount()));
        oParameters.add(new DBObject(8, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtApplicantCategoryId()));
        oParameters.add(new DBObject(9, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtGradeId()));
        oParameters.add(new DBObject(10, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtReservationCategoryId()));
        oParameters.add(new DBObject(11, 1, 12, sHeaderPrimaryKey));
        oParameters.add(new DBObject(12, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtDesignationId()));
        oParameters.add(new DBObject(13, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnDtlBean.getTxtMaxAgeOnDate())));
        oParameters.add(new DBObject(14, 1, 12, this.oUserInfo.getSiteId()));
        oParameters.add(new DBObject(15, 1, 12, this.oUserInfo.getUserTypeId()));
        oParameters.add(new DBObject(16, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(oParameters);
        continue;
      } 
      if (oHrmRecAdvtMtnDtlBean.getStatus().equals("U")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMRECADVTMTN.proc_UpsertHrmAdvtDtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, "U"));
        oParameters.add(new DBObject(2, 1, 12, oHrmRecAdvtMtnDtlBean.getDetailId()));
        oParameters.add(new DBObject(3, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtMinimumAge()));
        oParameters.add(new DBObject(4, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtMaximumAge()));
        oParameters.add(new DBObject(5, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtSex()));
        oParameters.add(new DBObject(6, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtTotalVacancy()));
        oParameters.add(new DBObject(7, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtAmount()));
        oParameters.add(new DBObject(8, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtApplicantCategoryId()));
        oParameters.add(new DBObject(9, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtGradeId()));
        oParameters.add(new DBObject(10, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtReservationCategoryId()));
        oParameters.add(new DBObject(11, 1, 12, sHeaderPrimaryKey));
        oParameters.add(new DBObject(12, 1, 12, oHrmRecAdvtMtnDtlBean.getTxtDesignationId()));
        oParameters.add(new DBObject(13, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnDtlBean.getTxtMaxAgeOnDate())));
        oParameters.add(new DBObject(14, 1, 12, this.oUserInfo.getSiteId()));
        oParameters.add(new DBObject(15, 1, 12, this.oUserInfo.getUserTypeId()));
        oParameters.add(new DBObject(16, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(oParameters);
        continue;
      } 
      if (oHrmRecAdvtMtnDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("HRMRECADVTMTN.proc_DeleteHrmAdvtDtl(?)");
          bDelete = true;
        } 
        oParameters = new ArrayList();
        oParameters.add(new DBObject(1, 1, 12, oHrmRecAdvtMtnDtlBean.getDetailId()));
        oBean1.addToBatch(oParameters);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {}
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return new String();
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    if (bHeaderDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        checkMandatoryHeader((HrmRecAdvtMtnHdrBean)oBaseHeaderBean);  
    if (bDetailDataChanged)
      if (sScreenName.equalsIgnoreCase("HrmRecAdvtMtn")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        int rowCount = 1;
        while (oIt1.hasNext()) {
          HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean = oIt1.next();
          if (!oHrmRecAdvtMtnDtlBean.getStatus().equalsIgnoreCase("D")) {
            checkMandatoryDtls(oHrmRecAdvtMtnDtlBean, rowCount);
            checkforNumericfields(oHrmRecAdvtMtnDtlBean, rowCount);
            rowCount++;
          } 
        } 
      }  
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean = (HrmRecAdvtMtnHdrBean)oBaseHeaderBean;
    if (ScreenMode.equalsIgnoreCase("N")) {
      oParameters = new ArrayList();
      oParameters.add(new DBObject(1, 1, 12, "N"));
      oParameters.add(new DBObject(2, 1, 12, null));
      oParameters.add(new DBObject(3, 1, 12, oHrmRecAdvtMtnHdrBean.getReferenceNo()));
      oParameters.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnHdrBean.getReferenceDate())));
      oParameters.add(new DBObject(5, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnHdrBean.getLastDate())));
      oParameters.add(new DBObject(6, 1, 12, oHrmRecAdvtMtnHdrBean.getMediaType()));
      oParameters.add(new DBObject(7, 1, 12, oHrmRecAdvtMtnHdrBean.getMediaName()));
      oParameters.add(new DBObject(8, 1, 12, oHrmRecAdvtMtnHdrBean.getDescription()));
      oParameters.add(new DBObject(9, 1, 12, oHrmRecAdvtMtnHdrBean.getEntryMode()));
      oParameters.add(new DBObject(10, 1, 12, oHrmRecAdvtMtnHdrBean.getMinInterviewScore()));
      oParameters.add(new DBObject(11, 1, 12, oHrmRecAdvtMtnHdrBean.getMinWrittenScoreA()));
      oParameters.add(new DBObject(12, 1, 12, oHrmRecAdvtMtnHdrBean.getMinWrittenScoreB()));
      oParameters.add(new DBObject(13, 1, 12, oHrmRecAdvtMtnHdrBean.getMinTotalScore()));
      oParameters.add(new DBObject(14, 1, 12, oHrmRecAdvtMtnHdrBean.getMinInterviewScore2()));
      oParameters.add(new DBObject(15, 1, 12, oHrmRecAdvtMtnHdrBean.getMinInterviewScore3()));
      oParameters.add(new DBObject(16, 1, 12, oHrmRecAdvtMtnHdrBean.getVenue()));
      oParameters.add(new DBObject(17, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnHdrBean.getDate())));
      oParameters.add(new DBObject(18, 1, 12, oHrmRecAdvtMtnHdrBean.getTime()));
      oParameters.add(new DBObject(19, 1, 12, this.oUserInfo.getSiteId()));
      oParameters.add(new DBObject(20, 1, 12, this.oUserInfo.getUserTypeId()));
      oParameters.add(new DBObject(21, 1, 12, this.oUserInfo.getSiteId()));
      oParameters.add(new DBObject(22, 2, 12));
      oParameters.add(new DBObject(23, 2, 12));
      oParameters.add(new DBObject(24, 2, 12));
      oParameters.add(new DBObject(25, 2, 4));
      ArrayList oOutArray = oBean.callProc(oParameters, "HRMRECADVTMTN.proc_UpsertHrmAdvtHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = oOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      oParameters = new ArrayList();
      oParameters.add(new DBObject(1, 1, 12, "U"));
      oParameters.add(new DBObject(2, 1, 12, oHrmRecAdvtMtnHdrBean.getHeaderPrimaryKey()));
      oParameters.add(new DBObject(3, 1, 12, oHrmRecAdvtMtnHdrBean.getReferenceNo()));
      oParameters.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnHdrBean.getReferenceDate())));
      oParameters.add(new DBObject(5, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnHdrBean.getLastDate())));
      oParameters.add(new DBObject(6, 1, 12, oHrmRecAdvtMtnHdrBean.getMediaType()));
      oParameters.add(new DBObject(7, 1, 12, oHrmRecAdvtMtnHdrBean.getMediaName()));
      oParameters.add(new DBObject(8, 1, 12, oHrmRecAdvtMtnHdrBean.getDescription()));
      oParameters.add(new DBObject(9, 1, 12, oHrmRecAdvtMtnHdrBean.getEntryMode()));
      oParameters.add(new DBObject(10, 1, 12, oHrmRecAdvtMtnHdrBean.getMinInterviewScore()));
      oParameters.add(new DBObject(11, 1, 12, oHrmRecAdvtMtnHdrBean.getMinWrittenScoreA()));
      oParameters.add(new DBObject(12, 1, 12, oHrmRecAdvtMtnHdrBean.getMinWrittenScoreB()));
      oParameters.add(new DBObject(13, 1, 12, oHrmRecAdvtMtnHdrBean.getMinTotalScore()));
      oParameters.add(new DBObject(14, 1, 12, oHrmRecAdvtMtnHdrBean.getMinInterviewScore2()));
      oParameters.add(new DBObject(15, 1, 12, oHrmRecAdvtMtnHdrBean.getMinInterviewScore3()));
      oParameters.add(new DBObject(16, 1, 12, oHrmRecAdvtMtnHdrBean.getVenue()));
      oParameters.add(new DBObject(17, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRecAdvtMtnHdrBean.getDate())));
      oParameters.add(new DBObject(18, 1, 12, oHrmRecAdvtMtnHdrBean.getTime()));
      oParameters.add(new DBObject(19, 1, 12, this.oUserInfo.getSiteId()));
      oParameters.add(new DBObject(20, 1, 12, this.oUserInfo.getUserTypeId()));
      oParameters.add(new DBObject(21, 1, 12, this.oUserInfo.getSiteId()));
      oParameters.add(new DBObject(22, 2, 12));
      oParameters.add(new DBObject(23, 2, 12));
      oParameters.add(new DBObject(24, 2, 12));
      oParameters.add(new DBObject(25, 2, 4));
      ArrayList oOutArray = oBean.callProc(oParameters, "HRMRECADVTMTN.proc_UpsertHrmAdvtHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = oOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } else if (ScreenMode.equalsIgnoreCase("D")) {
      oParameters = new ArrayList();
      oParameters.add(new DBObject(1, 1, 12, oHrmRecAdvtMtnHdrBean.getHeaderPrimaryKey()));
      oParameters.add(new DBObject(2, 2, 12));
      oParameters.add(new DBObject(3, 2, 12));
      oParameters.add(new DBObject(4, 2, 4));
      ArrayList oOutArray = oBean.callProc(oParameters, "HRMRECADVTMTN.proc_DeleteHrmAdvtHdr(?,?,?,?)");
      DBObject oOutObject = oOutArray.get(0);
      returnString = null;
    } 
    return returnString;
  }
  
  public void deleteDetailRecords(String sPrimkey) throws EnrgiseApplicationException, EnrgiseSystemException {
    if (getHrmRecAdvtDtlMetaInfo(sPrimkey).getRecordCount() > 0L) {
      ArrayList oDetailArray = getHrmRecAdvtDetailInfo(sPrimkey, 1L, getHrmRecAdvtDtlMetaInfo(sPrimkey).getRecordCount());
      if (oDetailArray.size() > 0) {
        int rowCount = 0;
        Iterator oIt = oDetailArray.iterator();
        while (oIt.hasNext()) {
          HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean = oIt.next();
          findChildRecord(oHrmRecAdvtMtnDtlBean, rowCount);
          findQualChildRecord(oHrmRecAdvtMtnDtlBean, rowCount);
          findLocationChildRecord(oHrmRecAdvtMtnDtlBean, rowCount);
          findLanguageChildRecord(oHrmRecAdvtMtnDtlBean, rowCount);
          findSkillChildRecord(oHrmRecAdvtMtnDtlBean, rowCount);
          findWorkChildRecord(oHrmRecAdvtMtnDtlBean, rowCount);
          oHrmRecAdvtMtnDtlBean.setStatus("D");
        } 
        saveAdvtDtl(sPrimkey, oDetailArray);
      } 
    } 
  }
  
  public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean = (HrmRecAdvtMtnHdrBean)oBaseHeaderBean;
    if (bHeaderDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D")) {
        checkUniqueHeader((HrmRecAdvtMtnHdrBean)oBaseHeaderBean);
        checkScore((HrmRecAdvtMtnHdrBean)oBaseHeaderBean);
        checkDates((HrmRecAdvtMtnHdrBean)oBaseHeaderBean);
      }  
    if (bDetailDataChanged) {
      if (sScreenName.equalsIgnoreCase("HrmRecAdvtMtn")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        exclusiveItemMatGrp(oDetailBeanArray, oErrorList);
        int rowcount = 1;
        while (oIt1.hasNext()) {
          HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean = oIt1.next();
          if (!oHrmRecAdvtMtnDtlBean.getStatus().equalsIgnoreCase("D"))
            continue; 
          findChildRecord(oHrmRecAdvtMtnDtlBean, rowcount);
          findQualChildRecord(oHrmRecAdvtMtnDtlBean, rowcount);
          findLocationChildRecord(oHrmRecAdvtMtnDtlBean, rowcount);
          findLanguageChildRecord(oHrmRecAdvtMtnDtlBean, rowcount);
          findSkillChildRecord(oHrmRecAdvtMtnDtlBean, rowcount);
          findWorkChildRecord(oHrmRecAdvtMtnDtlBean, rowcount);
          rowcount++;
        } 
      } 
      reportError(oErrorList);
    } 
  }
  
  public LovVO getClassDataLOV(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    LovVO oLovVO = new LovVO();
    ArrayList oList = null;
    Iterator oIt = null;
    String code = oLovQueryVO.getProperty("code");
    String sQuery = "Select clsd.ID,  clsd.NAME from HRM_CLASS_DTL clsd, HRM_CLASS_MST clsm where clsd.CLS_MST_ID = clsm.ID and clsm.CODE =";
    sQuery = String.valueOf(sQuery).concat(String.valueOf(code));
    if (EnrgiseUtil.checkString(oLovQueryVO.getSearchField1()))
      sQuery = String.valueOf(String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" And upper(clsd.NAME) LIKE upper('%"))).concat(String.valueOf(oLovQueryVO.getSearchField1()))).concat(String.valueOf("%') ")); 
    oBean = new DBUtilitiesBean();
    oList = new ArrayList();
    oList = oBean.executeQuery(sQuery);
    oIt = oList.iterator();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("");
    oHeaderList.add("hrm.HrmAdvertiesmentMaintenance.description");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    while (oIt.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getRefNoLOV(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    LovVO oLovVO = new LovVO();
    ArrayList oList = null;
    Iterator oIt = null;
    String sQuery = "select distinct advh.id,advh.ref_no from hrm_advt_hdr advh where 1=1";
    if (EnrgiseUtil.checkString(oLovQueryVO.getSearchField1()))
      sQuery = String.valueOf(String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and upper(advh.ref_no) LIKE upper('%"))).concat(String.valueOf(oLovQueryVO.getSearchField1()))).concat(String.valueOf("%') ")); 
    oBean = new DBUtilitiesBean();
    oList = new ArrayList();
    oList = oBean.executeQuery(sQuery);
    oIt = oList.iterator();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("");
    oHeaderList.add("hrm.HrmAdvertiesmentMaintenance.referenceNo");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    while (oIt.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("ref_no").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getEntryModeLOV(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    LovVO oLovVO = new LovVO();
    ArrayList oList = null;
    Iterator oIt = null;
    String sQuery = "Select  Global_Code_Desc,Global_Code from GEN_GLOBAL_CODES Where Global_Code_type= 103";
    if (EnrgiseUtil.checkString(oLovQueryVO.getSearchField1()))
      sQuery = String.valueOf(String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and upper(Global_Code_Desc) LIKE upper('%"))).concat(String.valueOf(oLovQueryVO.getSearchField1()))).concat(String.valueOf("%') ")); 
    oBean = new DBUtilitiesBean();
    oList = new ArrayList();
    oList = oBean.executeQuery(sQuery);
    oIt = oList.iterator();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("hrm.HrmAdvertiesmentMaintenance.entryMode");
    oHeaderList.add("");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    oLovVO.setVisibilityList(arylstVisibility);
    while (oIt.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("Global_Code_Desc").getString());
      oLOVBean.setDetailField2(oRow.get("Global_Code").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getPositionCodeLOV(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    QueryRow oRow = null;
    LovVO oLovVO = new LovVO();
    ArrayList oList = null;
    Iterator oIt = null;
    String sQuery = "SELECT A.ID, A.DESCRIPTION,  B.ID as desigid, B.name as PositionDesc  FROM HRM_POS_INF_HDR A, HRM_CLASS_DTL B  WHERE   A.DESIGNATION_ID=B.ID(+)";
    if (EnrgiseUtil.checkString(oLovQueryVO.getSearchField1()))
      sQuery = String.valueOf(String.valueOf(String.valueOf(sQuery).concat(String.valueOf(" and upper(DESCRIPTION) LIKE upper('%"))).concat(String.valueOf(oLovQueryVO.getSearchField1()))).concat(String.valueOf("%') ")); 
    oBean = new DBUtilitiesBean();
    oList = new ArrayList();
    oList = oBean.executeQuery(sQuery);
    oIt = oList.iterator();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("");
    oHeaderList.add("hrm.HrmAdvertiesmentMaintenance.forPosition");
    oHeaderList.add("");
    oHeaderList.add("hrm.HrmAdvertiesmentMaintenance.description");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    while (oIt.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("DESCRIPTION").getString());
      oLOVBean.setDetailField3(oRow.get("desigid").getString());
      oLOVBean.setDetailField4(oRow.get("PositionDesc").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  private void checkforNumericfields(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrList = new ArrayList();
    if (!EnrgiseUtil.checkNumber(oHrmRecAdvtMtnDtlBean.getTxtAmount(), 14, 2, "P")) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.amount");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oParam.add(new Integer(rowCount));
      oErrList.add(new EnrgiseMessageKeyException("hrm.advt.detail.nonnumeric", oParam));
    } 
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMinimumAge()) && EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMaximumAge()))
      if (Integer.parseInt(oHrmRecAdvtMtnDtlBean.getTxtMinimumAge()) > Integer.parseInt(oHrmRecAdvtMtnDtlBean.getTxtMaximumAge())) {
        ArrayList oParam = new ArrayList();
        oParam.add(new Integer(rowCount));
        throw new EnrgiseApplicationException("hrm.advt.detail.errorinage", oParam, "E");
      }  
    reportError(oErrList);
  }
  
  private void checkMandatoryHeader(HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oList = new ArrayList();
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getReferenceNo())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.referenceNo");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParam, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMediaType())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.mediaType");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParam, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getLastDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.lastDate");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParam, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getReferenceDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.referenceDate");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParam, "E"));
    } 
    reportError(oList);
  }
  
  private void checkMandatoryDtls(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseSystemException, EnrgiseApplicationException {
    ArrayList oErrorList = new ArrayList();
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtGrade())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.grade");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oParam.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParam, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtSex())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.sex");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oParam.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParam, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtReservationCategory())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAdvertiesmentMaintenance.reservationCategory");
      ArrayList oParam = new ArrayList();
      oParam.add(oMessageKey);
      oParam.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParam, "E"));
    } 
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMinimumAge()))
      if (Integer.parseInt(oHrmRecAdvtMtnDtlBean.getTxtMinimumAge()) < 21) {
        ArrayList oParam = new ArrayList();
        oParam.add(new Integer(rowCount));
        throw new EnrgiseApplicationException("hrm.advt.minage", oParam, "E");
      }  
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMaxAgeOnDate()))
      if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMaximumAge())) {
        ArrayList oParam = new ArrayList();
        oParam.add(new Integer(rowCount));
        throw new EnrgiseApplicationException("hrm.advt.maxage", oParam, "E");
      }  
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMaximumAge()))
      if (!EnrgiseUtil.checkString(oHrmRecAdvtMtnDtlBean.getTxtMaxAgeOnDate())) {
        ArrayList oParam = new ArrayList();
        oParam.add(new Integer(rowCount));
        throw new EnrgiseApplicationException("hrm.advt.maxageDate", oParam, "E");
      }  
    reportError(oErrorList);
  }
  
  private void checkUniqueHeader(HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(String.valueOf(" Select id as ID from HRM_ADVT_HDR where REF_NO='").concat(String.valueOf(oHrmRecAdvtMtnHdrBean.getReferenceNo()))).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(oHrmRecAdvtMtnHdrBean.getHeaderPrimaryKey()))
        throw new EnrgiseApplicationException("hrm.advt.header.uniqueConstraintViolated", "M"); 
    } 
  }
  
  private void checkDates(HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    DateFormat oDateFormat = null;
    int i = EnrgiseUtil.compareDates(oDateFormat, oHrmRecAdvtMtnHdrBean.getLastDate(), oHrmRecAdvtMtnHdrBean.getReferenceDate());
    System.out.println(oHrmRecAdvtMtnHdrBean.getLastDate());
    System.out.println(i);
    if (i < 0)
      throw new EnrgiseApplicationException("hrm.advt.header.date", "E"); 
  }
  
  private void findChildRecord(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(" select id  from hrm_advt_appl_dtl where ADT_DT_ID=").concat(String.valueOf(oHrmRecAdvtMtnDtlBean.getDetailId()));
    System.out.println(sQuery);
    int count = 1;
    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(oHrmRecAdvtMtnDtlBean.getDetailId())) {
        ArrayList oParam = new ArrayList();
        throw new EnrgiseApplicationException("hrm.advt.detail.childRecordFound", oParam, "E");
      } 
    } 
    count++;
  }
  
  private void findQualChildRecord(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    int count = 1;
    String sQuery = String.valueOf(" select ADT_DT_ID from hrm_advt_qual_dtl where ADT_DT_ID=").concat(String.valueOf(oHrmRecAdvtMtnDtlBean.getDetailId()));
    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("ADT_DT_ID").getString().equalsIgnoreCase(oHrmRecAdvtMtnDtlBean.getDetailId())) {
        ArrayList oParam = new ArrayList();
        throw new EnrgiseApplicationException("hrm.advt.detail.attrChildRecordFound", oParam, "E");
      } 
    } 
    count++;
  }
  
  private void findLocationChildRecord(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(" select ADT_DT_ID from hrm_advt_loc_dtl where ADT_DT_ID=").concat(String.valueOf(oHrmRecAdvtMtnDtlBean.getDetailId()));
    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("ADT_DT_ID").getString().equalsIgnoreCase(oHrmRecAdvtMtnDtlBean.getDetailId())) {
        ArrayList oParam = new ArrayList();
        throw new EnrgiseApplicationException("hrm.advt.detail.attrChildRecordFound", oParam, "E");
      } 
    } 
  }
  
  private void exclusiveItemMatGrp(ArrayList oDetailBeanArray, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    String[] sArgs = (String[])Array.newInstance(Class.forName("java.lang.String"), 2);
    sArgs[0] = "txtDesignationId";
    sArgs[1] = "txtReservationCategoryId";
    Iterator oIt1 = oDetailBeanArray.iterator();
    EnrgiseUtil.checkDuplicate(oDetailBeanArray, sArgs, "hrm.advt.detail.exclusive", oErrorList);
  }
  
  private void findLanguageChildRecord(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(" select ADT_DT_ID from hrm_advt_lang_rqmt_dtl where ADT_DT_ID=").concat(String.valueOf(oHrmRecAdvtMtnDtlBean.getDetailId()));
    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("ADT_DT_ID").getString().equalsIgnoreCase(oHrmRecAdvtMtnDtlBean.getDetailId())) {
        ArrayList oParam = new ArrayList();
        throw new EnrgiseApplicationException("hrm.advt.detail.attrChildRecordFound", oParam, "E");
      } 
    } 
  }
  
  private void findSkillChildRecord(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(" select ADT_DT_ID from hrm_advt_skills where ADT_DT_ID=").concat(String.valueOf(oHrmRecAdvtMtnDtlBean.getDetailId()));
    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("ADT_DT_ID").getString().equalsIgnoreCase(oHrmRecAdvtMtnDtlBean.getDetailId())) {
        ArrayList oParam = new ArrayList();
        throw new EnrgiseApplicationException("hrm.advt.detail.attrChildRecordFound", oParam, "E");
      } 
    } 
  }
  
  private void findWorkChildRecord(HrmRecAdvtMtnDtlBean oHrmRecAdvtMtnDtlBean, int rowCount) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(" select ADT_DT_ID from hrm_advt_work_exp where ADT_DT_ID=").concat(String.valueOf(oHrmRecAdvtMtnDtlBean.getDetailId()));
    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("ADT_DT_ID").getString().equalsIgnoreCase(oHrmRecAdvtMtnDtlBean.getDetailId())) {
        ArrayList oParam = new ArrayList();
        throw new EnrgiseApplicationException("hrm.advt.detail.attrChildRecordFound", oParam, "E");
      } 
    } 
  }
  
  private void checkScore(HrmRecAdvtMtnHdrBean oHrmRecAdvtMtnHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    int writtenScore = 0;
    int gdScore = 0;
    int intScore = 0;
    int totalScore = 0;
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinWrittenScoreA()))
      writtenScore = Integer.parseInt(oHrmRecAdvtMtnHdrBean.getMinWrittenScoreA()); 
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinWrittenScoreB()))
      gdScore = Integer.parseInt(oHrmRecAdvtMtnHdrBean.getMinWrittenScoreB()); 
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinInterviewScore()))
      intScore = Integer.parseInt(oHrmRecAdvtMtnHdrBean.getMinInterviewScore()); 
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinTotalScore()))
      totalScore = Integer.parseInt(oHrmRecAdvtMtnHdrBean.getMinTotalScore()); 
    if (EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinTotalScore()))
      if (EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinWrittenScoreA()) || EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinWrittenScoreB()) || EnrgiseUtil.checkString(oHrmRecAdvtMtnHdrBean.getMinInterviewScore()))
        if (totalScore < writtenScore + gdScore + intScore)
          throw new EnrgiseApplicationException("hrm.advt.hdr.totalScore", "E");   
  }
}
