package wenrgise.hrms.ejb.business;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
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.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.hrms.bean.HrmAttEmpShiftDtlBean;
import wenrgise.hrms.bean.HrmAttEmpShiftHdrBean;
import wenrgise.hrms.vo.HrmAttEmpShiftQVO;

public class HrmAttEmpShiftBO extends HrmBaseBO {
  public HrmAttEmpShiftBO() {}
  
  public HrmAttEmpShiftBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrAttEmpShiftDetailMetaInfo(HrmAttEmpShiftQVO oHrmAttEmpShiftQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    if (EnrgiseUtil.checkString(oHrmAttEmpShiftQVO.getHeaderPrimaryKey())) {
      String[] sPrimaryKey = oHrmAttEmpShiftQVO.getHeaderPrimaryKey().split(",");
      System.out.println(sPrimaryKey[0]);
      System.out.println(sPrimaryKey[1]);
      oHrmAttEmpShiftQVO.setEmployeeNo(sPrimaryKey[0]);
      oHrmAttEmpShiftQVO.setEmployeeName(sPrimaryKey[1]);
    } 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, oHrmAttEmpShiftQVO.getEmployeeNo()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmAttEmpShiftQVO.getStartDate()));
    arylstParam.add(new DBObject(3, 1, 12, oHrmAttEmpShiftQVO.getEndDate()));
    arylstParam.add(new DBObject(4, 2, -5));
    arylstParam.add(new DBObject(5, 2, 93));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMATTEMPSHIFT.proc_HrAttEmpShiftDtlCount(?,?,?,?,?,?,?,?)");
    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 getHrAttEmpShiftDetail(HrmAttEmpShiftQVO oHrmAttEmpShiftQVO, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    if (EnrgiseUtil.checkString(oHrmAttEmpShiftQVO.getHeaderPrimaryKey())) {
      String[] sPrimaryKey = oHrmAttEmpShiftQVO.getHeaderPrimaryKey().split(",");
      System.out.println(sPrimaryKey[0]);
      System.out.println(sPrimaryKey[1]);
      oHrmAttEmpShiftQVO.setEmployeeNo(sPrimaryKey[0]);
      oHrmAttEmpShiftQVO.setEmployeeName(sPrimaryKey[1]);
    } 
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator itrBean = null;
    ArrayList arylstAttWorkGroupDayoffDetail = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
    arylstParam.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
    arylstParam.add(new DBObject(3, 1, 12, oHrmAttEmpShiftQVO.getEmployeeNo()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmAttEmpShiftQVO.getStartDate()));
    arylstParam.add(new DBObject(5, 1, 12, oHrmAttEmpShiftQVO.getEndDate()));
    arylstParam.add(new DBObject(6, 2, -10));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 12));
    arylstParam.add(new DBObject(9, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMATTEMPSHIFT.proc_HrAttEmpShiftDtl(?,?,?,?,?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    count = 0;
    itrBean = arylstList.iterator();
    while (itrBean.hasNext()) {
      if (count == 0)
        arylstAttWorkGroupDayoffDetail = new ArrayList(); 
      count++;
      oRow = itrBean.next();
      HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean = new HrmAttEmpShiftDtlBean();
      oHrmAttEmpShiftDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAttEmpShiftDtlBean.setShiftBeginDate(EnrgiseUtil.convertToString(oRow.get("SHIFT_START_DATE").getDate()));
      oHrmAttEmpShiftDtlBean.setShiftEndDate(EnrgiseUtil.convertToString(oRow.get("SHIFT_END_DATE").getDate()));
      oHrmAttEmpShiftDtlBean.setShiftCode(oRow.get("CODE").getString());
      oHrmAttEmpShiftDtlBean.setShiftId(oRow.get("SHFT_MST_ID").getString());
      arylstAttWorkGroupDayoffDetail.add(oHrmAttEmpShiftDtlBean);
    } 
    return arylstAttWorkGroupDayoffDetail;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_EMP_SHIFT_DTL";
  }
  
  public void saveDetailImpl(BaseHeaderBean oBaseHeaderBean, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmAttEmpShift"))
      saveHrmAttEmpShiftDetail(oBaseHeaderBean, oDetailBeanArray); 
  }
  
  public String saveHrmAttEmpShiftDetail(BaseHeaderBean oBaseHeaderBean, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    HrmAttEmpShiftHdrBean oHrmAttEmpShiftHdrBean = (HrmAttEmpShiftHdrBean)oBaseHeaderBean;
    Iterator itrBean = arylstDetailBeanArray.iterator();
    while (itrBean.hasNext()) {
      HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean = itrBean.next();
      if (oHrmAttEmpShiftDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMATTEMPSHIFT.proc_UpsertAttEmpShiftDtl(?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "N"));
        arylstParameters.add(new DBObject(2, 1, 12, oHrmAttEmpShiftHdrBean.getEmpNoId()));
        arylstParameters.add(new DBObject(3, 1, 12, null));
        arylstParameters.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttEmpShiftDtlBean.getShiftBeginDate())));
        arylstParameters.add(new DBObject(5, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttEmpShiftDtlBean.getShiftEndDate())));
        arylstParameters.add(new DBObject(6, 1, 12, oHrmAttEmpShiftDtlBean.getShiftId()));
        arylstParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getUserId()));
        arylstParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmAttEmpShiftDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMATTEMPSHIFT.proc_UpsertAttEmpShiftDtl(?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "U"));
        arylstParameters.add(new DBObject(2, 1, 12, oHrmAttEmpShiftHdrBean.getEmpNoId()));
        arylstParameters.add(new DBObject(3, 1, 12, oHrmAttEmpShiftDtlBean.getDetailId()));
        arylstParameters.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttEmpShiftDtlBean.getShiftBeginDate())));
        arylstParameters.add(new DBObject(5, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttEmpShiftDtlBean.getShiftEndDate())));
        arylstParameters.add(new DBObject(6, 1, 12, oHrmAttEmpShiftDtlBean.getShiftId()));
        arylstParameters.add(new DBObject(7, 1, 12, this.oUserInfo.getUserId()));
        arylstParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmAttEmpShiftDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("HRMATTEMPSHIFT.proc_DelEmpShift(?)");
          bDelete = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, oHrmAttEmpShiftDtlBean.getDetailId()));
        oBean1.addToBatch(arylstParameters);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bUpdate)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
    return String.valueOf(String.valueOf(oHrmAttEmpShiftHdrBean.getEmployeeNo()).concat(String.valueOf(","))).concat(String.valueOf(oHrmAttEmpShiftHdrBean.getEmployeeName()));
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {}
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return new String();
  }
  
  public void saveDetailImpl(String param1, String param2, ArrayList param3) {}
  
  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) {
      HrmAttEmpShiftHdrBean oHrmAttEmpShiftHdrBean = (HrmAttEmpShiftHdrBean)oBaseHeaderBean;
      checkMandatoryHeader(oHrmAttEmpShiftHdrBean, oErrorList);
    } 
    if (bDetailDataChanged)
      if (sScreenName.equalsIgnoreCase("HrmAttEmpShift")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        int rowCount = 1;
        while (oIt1.hasNext()) {
          HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean = oIt1.next();
          if (!oHrmAttEmpShiftDtlBean.getStatus().equalsIgnoreCase("D"))
            checkMandatoryDtls(oHrmAttEmpShiftDtlBean, rowCount, oErrorList); 
          rowCount++;
        } 
      }  
    reportError(oErrorList);
  }
  
  private void checkMandatoryHeader(HrmAttEmpShiftHdrBean oHrmAttEmpShiftHdrBean, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    if (!EnrgiseUtil.checkString(oHrmAttEmpShiftHdrBean.getEmployeeNo())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttEmpShift.employeeNo");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
  }
  
  private void checkMandatoryDtls(HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean, int rowCount, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftBeginDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttEmpShift.shiftBeginDate");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttEmpShift.shiftCode");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
  }
  
  private void checkMandatory(HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean, int iCount, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftBeginDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttEmpShift.shiftBeginDate");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttEmpShift.shiftCode");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    reportError(oErrorList);
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String param1) throws EnrgiseSystemException {
    return new String();
  }
  
  public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oList = new ArrayList();
    if (bDetailDataChanged)
      if (sScreenName.equalsIgnoreCase("HrmAttEmpShift")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        int n = oDetailBeanArray.size();
        int rowCount = 0;
        while (oIt1.hasNext()) {
          System.out.println(rowCount);
          HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean = oIt1.next();
          if (!oHrmAttEmpShiftDtlBean.getStatus().equalsIgnoreCase("D")) {
            if (!EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftEndDate()))
              if (rowCount < n - 1) {
                HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean1 = oDetailBeanArray.get(rowCount + 1);
                if (EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean1.getShiftBeginDate()))
                  oList.add(new EnrgiseApplicationException("wenrgise.hrms.att.Enddate.value")); 
              }  
            if (EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftBeginDate()))
              if (rowCount > 0 && rowCount < n) {
                HrmAttEmpShiftDtlBean oHrmAttEmpShiftDtlBean1 = oDetailBeanArray.get(rowCount - 1);
                if (EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean1.getShiftEndDate())) {
                  DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
                  int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmAttEmpShiftDtlBean.getShiftBeginDate(), oHrmAttEmpShiftDtlBean1.getShiftEndDate());
                  if (dateFlag == -1 && dateFlag != -2)
                    oList.add(new EnrgiseApplicationException("wenrgise.hrms.att.BeginDate.value")); 
                } 
              }  
            if (EnrgiseUtil.checkString(oHrmAttEmpShiftDtlBean.getShiftEndDate())) {
              DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
              int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmAttEmpShiftDtlBean.getShiftEndDate(), oHrmAttEmpShiftDtlBean.getShiftBeginDate());
              if (dateFlag == -1 && dateFlag != -2)
                oList.add(new EnrgiseApplicationException("wenrgise.hrms.attEmp.corresdate.value")); 
            } 
            rowCount++;
            continue;
          } 
          if (oHrmAttEmpShiftDtlBean.getStatus().equalsIgnoreCase("D")) {
            HrmAttEmpShiftHdrBean oHrmAttEmpShiftHdrBean = (HrmAttEmpShiftHdrBean)oBaseHeaderBean;
            DBUtilitiesBean oBean = new DBUtilitiesBean();
            ArrayList arylstParam = new ArrayList();
            arylstParam.add(new DBObject(1, 1, 12, oHrmAttEmpShiftHdrBean.getEmpNoId()));
            arylstParam.add(new DBObject(2, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttEmpShiftDtlBean.getShiftBeginDate())));
            arylstParam.add(new DBObject(3, 2, -5));
            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, "HRMATTEMPSHIFT.procGetShiftRstInfo(?,?,?,?,?,?)");
            RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
            DBObject oTotalRecord = arylstOutArray.get(0);
            oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
            if (oRecordMetaInfo.getRecordCount() > 0L)
              oList.add(new EnrgiseApplicationException("wenrgise.hrms.att.rst.value")); 
          } 
        } 
        reportError(oList);
      }  
  }
  
  public LovVO getHrmAttESEmpNoLOVdataNmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("empNoId");
    oHeaderList.add("hrm.HrmAttEmpShift.employeeNo");
    oHeaderList.add("hrm.HrmAttEmpShift.employeeName");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null) {
      sQuerySearch1 = oLovQueryVO.getSearchField1();
      System.out.println(sQuerySearch1);
    } 
    if (oLovQueryVO.getSearchField2() != null) {
      sQuerySearch2 = oLovQueryVO.getSearchField2();
      System.out.println(sQuerySearch2);
    } 
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    oParameters.add(new DBObject(3, 2, -10));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 12));
    oParameters.add(new DBObject(6, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMATTEMPSHIFT.proc_GetAttEmpNoLovNmode(?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = oList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("EMP_NO").getString());
      oLOVBean.setDetailField3(oRow.get("EMPNAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getHrmAttESEmpNoLOVdataQmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("empNoId");
    oHeaderList.add("hrm.HrmAttEmpShift.employeeNo");
    oHeaderList.add("hrm.HrmAttEmpShift.employeeName");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null) {
      sQuerySearch1 = oLovQueryVO.getSearchField1();
      System.out.println(sQuerySearch1);
    } 
    if (oLovQueryVO.getSearchField2() != null) {
      sQuerySearch2 = oLovQueryVO.getSearchField2();
      System.out.println(sQuerySearch2);
    } 
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    oParameters.add(new DBObject(3, 2, -10));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 12));
    oParameters.add(new DBObject(6, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMATTEMPSHIFT.proc_GetAttEmpNoLovQmode(?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = oList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("EMP_NO").getString());
      oLOVBean.setDetailField3(oRow.get("EMPNAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getHrmAttESShiftCodeLOVdataNmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("shiftId");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.shiftCode");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList oParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null) {
      sQuerySearch1 = oLovQueryVO.getSearchField1();
      System.out.println(sQuerySearch1);
    } 
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(2, 2, -10));
    oParameters.add(new DBObject(3, 2, 12));
    oParameters.add(new DBObject(4, 2, 12));
    oParameters.add(new DBObject(5, 2, 4));
    ArrayList oOutArray = oBean.callProc(oParameters, "HRMATTEMPSHIFT.proc_GetShiftCodeLovN(?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = oList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        oList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("CODE").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
}
