package wenrgise.hrms.ejb.business;

import java.sql.Timestamp;
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.HrmRoasterEntryDtlBean;
import wenrgise.hrms.bean.HrmRoasterEntryHdrBean;
import wenrgise.hrms.vo.HrmRoasterEntryQVO;

public class HrmRecRoasterEntryBO extends HrmBaseBO {
  public HrmRecRoasterEntryBO() {}
  
  public HrmRecRoasterEntryBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrmRoasterHdrMetaInfo(HrmRoasterEntryQVO oHrmRoasterEntryQVO) 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, oHrmRoasterEntryQVO.getTxtRoasterCode()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmRoasterEntryQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(3, 2, -5));
    arylstParam.add(new DBObject(4, 2, 93));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "hrmrecroaster.proc_hrmrecroastercount(?,?,?,?,?,?,?)");
    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 getHrmRoasterHdrInfo(HrmRoasterEntryQVO oHrmRoasterEntryQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    ArrayList arylstHeaderList = null;
    if (oHrmRoasterEntryQVO == null)
      oHrmRoasterEntryQVO = new HrmRoasterEntryQVO(); 
    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, oHrmRoasterEntryQVO.getTxtRoasterCode()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmRoasterEntryQVO.getHeaderPrimaryKey()));
    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, "hrmrecroaster.proc_hrmrecroasterhdrinfo(?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    if (arylstParam.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstParam.iterator();
    String draft = null;
    while (itrBean.hasNext()) {
      if (count == 0)
        arylstHeaderList = new ArrayList(); 
      count++;
      oRow = (QueryRow)itrBean.next();
      HrmRoasterEntryHdrBean oHrmRoasterEntryHdrBean = new HrmRoasterEntryHdrBean();
      oHrmRoasterEntryHdrBean.setHeaderPrimaryKey(oRow.get("id").getString());
      oHrmRoasterEntryHdrBean.setTxtRoasterCode(oRow.get("roaster_code").getString());
      oHrmRoasterEntryHdrBean.setTxtRoasterDescription(oRow.get("roaster_desc").getString());
      arylstHeaderList.add(oHrmRoasterEntryHdrBean);
    } 
    return arylstHeaderList;
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmRoasterEntryHdrBean oHrmRoasterEntryHdrBean = (HrmRoasterEntryHdrBean)oBaseHeaderBean;
    if (ScreenMode.equalsIgnoreCase("N")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "n"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmRoasterEntryHdrBean.getTxtRoasterCode()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmRoasterEntryHdrBean.getTxtRoasterDescription()));
      arylstParam.add(new DBObject(4, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParam.add(new DBObject(5, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(6, 1, 12, null));
      arylstParam.add(new DBObject(7, 2, 12));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "hrmrecroaster.proc_upserthrmrecroasterhdr(?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "u"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmRoasterEntryHdrBean.getTxtRoasterCode()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmRoasterEntryHdrBean.getTxtRoasterDescription()));
      arylstParam.add(new DBObject(4, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParam.add(new DBObject(5, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmRoasterEntryHdrBean.getHeaderPrimaryKey()));
      arylstParam.add(new DBObject(7, 2, 12));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "hrmrecroaster.proc_upserthrmrecroasterhdr(?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } else if (ScreenMode.equalsIgnoreCase("D")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, oHrmRoasterEntryHdrBean.getHeaderPrimaryKey()));
      arylstParam.add(new DBObject(2, 2, 12));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "hrmrecroaster.proc_deletehrmrecroasterhdr(?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = null;
    } 
    return returnString;
  }
  
  public RecordMetaInfo getHrmRoasterEntryDetailMetaInfo(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, lPrimaryKey));
    arylstParameters.add(new DBObject(2, 2, -5));
    arylstParameters.add(new DBObject(3, 2, 93));
    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, "hrmrecroaster.proc_hrmrecroasterdtlcount(?,?,?,?,?,?)");
    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 getHrmRoasterEntryDetailInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arrHrmRoasterEntryDtl = null;
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
    arylstParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
    arylstParameters.add(new DBObject(3, 1, 12, lPrimaryKey));
    arylstParameters.add(new DBObject(4, 2, -10));
    arylstParameters.add(new DBObject(5, 2, 12));
    arylstParameters.add(new DBObject(6, 2, 12));
    arylstParameters.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "hrmrecroaster.proc_hrmrecroasterdtlinfo(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstList.iterator();
    while (itrBean.hasNext()) {
      if (count == 0)
        arrHrmRoasterEntryDtl = new ArrayList(); 
      count++;
      oRow = itrBean.next();
      HrmRoasterEntryDtlBean oRoasterBean = new HrmRoasterEntryDtlBean();
      oRoasterBean.setDetailId(oRow.get("ID").getString());
      oRoasterBean.setTxtRoasterPoint(oRow.get("roaster_point").getString());
      oRoasterBean.setSocialStatus(oRow.get("CATEGORY_AS_PER_ROASTER_ID").getString());
      oRoasterBean.setTxtCategoryAsPerRoaster(oRow.get("CATEGORY_AS_PER_ROASTER").getString());
      oRoasterBean.setTxtEmployeeNo(oRow.get("emp_no").getString());
      oRoasterBean.setEmpNoId(oRow.get("E_PER_DTL_ID").getString());
      oRoasterBean.setTxtEmployeeName(oRow.get("EMPNAME").getString());
      oRoasterBean.setTxtAppointmentDate(EnrgiseUtil.convertToString(oRow.get("APPOINTMENT_DATE").getDate()));
      oRoasterBean.setTxtDob(EnrgiseUtil.convertToString(oRow.get("DOB").getDate()));
      oRoasterBean.setTxtCategoryId(oRow.get("CATEGORY_ID").getString());
      oRoasterBean.setTxtCategory(oRow.get("CATEGORY").getString());
      oRoasterBean.setEntryMode(oRow.get("ENTRYMODE").getString());
      arrHrmRoasterEntryDtl.add(oRoasterBean);
    } 
    return arrHrmRoasterEntryDtl;
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    System.out.println("Update ille!");
  }
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return "saveNewHeaderImpl ille!";
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_RELA_MST";
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmRoasterEntry"))
      saveHrmRoasterEntryDetail(arylstDetailBeanArray, sHeaderPrimaryKey); 
  }
  
  private void saveHrmRoasterEntryDetail(ArrayList arylstDetailBeanArray, String sHeaderPrimaryKey) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    Iterator itrBean = arylstDetailBeanArray.iterator();
    while (itrBean.hasNext()) {
      HrmRoasterEntryDtlBean oHrmRoasterEntryDtlBean = itrBean.next();
      if (oHrmRoasterEntryDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("hrmrecroaster.proc_upserthrmrecroasterdtl(?,?,?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "N"));
        arylstParameters.add(new DBObject(2, 1, 12, sHeaderPrimaryKey));
        arylstParameters.add(new DBObject(3, 1, 12, oHrmRoasterEntryDtlBean.getTxtRoasterPoint()));
        arylstParameters.add(new DBObject(4, 1, 12, oHrmRoasterEntryDtlBean.getSocialStatus()));
        arylstParameters.add(new DBObject(5, 1, 12, oHrmRoasterEntryDtlBean.getEmpNoId()));
        arylstParameters.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRoasterEntryDtlBean.getTxtAppointmentDate())));
        arylstParameters.add(new DBObject(7, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRoasterEntryDtlBean.getTxtDob())));
        arylstParameters.add(new DBObject(8, 1, 12, oHrmRoasterEntryDtlBean.getTxtCategoryId()));
        arylstParameters.add(new DBObject(9, 1, 12, oHrmRoasterEntryDtlBean.getEntryMode()));
        arylstParameters.add(new DBObject(10, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParameters.add(new DBObject(11, 1, 12, this.oUserInfo.getSiteId()));
        arylstParameters.add(new DBObject(12, 1, 12, null));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmRoasterEntryDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("hrmrecroaster.proc_upserthrmrecroasterdtl(?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "U"));
        arylstParameters.add(new DBObject(2, 1, 12, sHeaderPrimaryKey));
        arylstParameters.add(new DBObject(3, 1, 12, oHrmRoasterEntryDtlBean.getTxtRoasterPoint()));
        arylstParameters.add(new DBObject(4, 1, 12, oHrmRoasterEntryDtlBean.getSocialStatus()));
        arylstParameters.add(new DBObject(5, 1, 12, oHrmRoasterEntryDtlBean.getEmpNoId()));
        arylstParameters.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRoasterEntryDtlBean.getTxtAppointmentDate())));
        arylstParameters.add(new DBObject(7, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmRoasterEntryDtlBean.getTxtDob())));
        arylstParameters.add(new DBObject(8, 1, 12, oHrmRoasterEntryDtlBean.getTxtCategoryId()));
        arylstParameters.add(new DBObject(9, 1, 12, oHrmRoasterEntryDtlBean.getEntryMode()));
        arylstParameters.add(new DBObject(10, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParameters.add(new DBObject(11, 1, 12, this.oUserInfo.getSiteId()));
        arylstParameters.add(new DBObject(12, 1, 12, oHrmRoasterEntryDtlBean.getDetailId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmRoasterEntryDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("hrmrecroaster.proc_deletehrmrecroasterdtl(?)");
          bDelete = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, oHrmRoasterEntryDtlBean.getDetailId()));
        oBean1.addToBatch(arylstParameters);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bUpdate)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {}
  
  private void checkMandatory(HrmRoasterEntryDtlBean oHrmRoasterEntryDtlBean, int iCount, ArrayList arylstErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {}
  
  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 arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {}
  
  private void checkUniqueDtl(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oParams = new ArrayList();
    ArrayList oErrorList = new ArrayList();
    int count = 0;
    Iterator oIt1 = oDetailBeanArray.iterator();
    while (oIt1.hasNext()) {
      HrmRoasterEntryDtlBean oHrmRoasterEntryDtlBean = oIt1.next();
      String sQuery = String.valueOf(String.valueOf(" Select ID from HRM_STAFF_ROASTER_DTL where ROASTER='").concat(String.valueOf(oHrmRoasterEntryDtlBean.getTxtRoasterPoint()))).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(oHrmRoasterEntryDtlBean.getDetailId())) {
          MessageKey oMessageKey = new MessageKey("hrm.HrmRoasterEntry.txtRoasterPoint");
          oParams = new ArrayList();
          oParams.add(oMessageKey);
          oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.uniqueConstraintViolated", oParams, "E"));
        } 
      } 
    } 
    reportError(oErrorList);
  }
  
  public LovVO getRstrSocialStatusLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("ID");
    arylstHeaderList.add("hrm.HrmEmpPersonalDetails.code");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    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, "hrmrecroaster.procGetHrmRstRsvLOVdata(?,?,?,?,?,?)");
    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());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getRstrCodeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("ID");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtRoasterCode");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtRoasterDescription");
    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, "hrmrecroaster.procGetHrmRoasterLOVdata(?,?,?,?,?,?)");
    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("roaster_code").getString());
      oLOVBean.setDetailField3(oRow.get("roaster_desc").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getRoasterEmpDetailsLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("ID");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtCategoryId");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtEmployeeNo");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtEmployeeName");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtAppointmentDate");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtDob");
    arylstHeaderList.add("hrm.HrmRoasterEntry.txtCategory");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    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, "hrmrecroaster.procGetHrmRstEmpLOVdata(?,?,?,?,?,?)");
    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("rvsCategId").getString());
      oLOVBean.setDetailField3(oRow.get("emp_no").getString());
      oLOVBean.setDetailField4(oRow.get("empName").getString());
      oLOVBean.setDetailField5(EnrgiseUtil.convertToString(oRow.get("comp_join_date").getDate()));
      oLOVBean.setDetailField6(EnrgiseUtil.convertToString(oRow.get("dob").getDate()));
      oLOVBean.setDetailField7(oRow.get("rvsCateg").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
}
