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.HrmAttWorkGroupShiftDtlBean;
import wenrgise.hrms.bean.HrmAttWorkGroupShiftHdrBean;
import wenrgise.hrms.vo.HrmAttWorkGroupShiftQVO;

public class HrmAttWorkGroupShiftBO extends HrmBaseBO {
  public HrmAttWorkGroupShiftBO() {}
  
  public HrmAttWorkGroupShiftBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrmAttWGShiftDtlMetaInfo(HrmAttWorkGroupShiftQVO oHrmAttWorkGroupShiftQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    if (EnrgiseUtil.checkString(oHrmAttWorkGroupShiftQVO.getHeaderPrimaryKey())) {
      String[] sPrimaryKey = oHrmAttWorkGroupShiftQVO.getHeaderPrimaryKey().split(",");
      System.out.println(sPrimaryKey[0]);
      System.out.println(sPrimaryKey[1]);
      oHrmAttWorkGroupShiftQVO.setWrkGrpCode(sPrimaryKey[0]);
      oHrmAttWorkGroupShiftQVO.setSiteCode(sPrimaryKey[1]);
      oHrmAttWorkGroupShiftQVO.setWorkGroupDescription(sPrimaryKey[2]);
      oHrmAttWorkGroupShiftQVO.setSiteDescription(sPrimaryKey[3]);
    } 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, oHrmAttWorkGroupShiftQVO.getWorkGroupId()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmAttWorkGroupShiftQVO.getSiteId()));
    arylstParam.add(new DBObject(3, 1, 12, oHrmAttWorkGroupShiftQVO.getStartDate()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmAttWorkGroupShiftQVO.getEndDate()));
    arylstParam.add(new DBObject(5, 2, -5));
    arylstParam.add(new DBObject(6, 2, 93));
    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, "HRMATTWRKGRPSHIFT.proc_HrAttWGSDtlCount(?,?,?,?,?,?,?,?,?)");
    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 getHrmAttWGShiftDtlInfo(HrmAttWorkGroupShiftQVO oHrmAttWorkGroupShiftQVO, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    if (EnrgiseUtil.checkString(oHrmAttWorkGroupShiftQVO.getHeaderPrimaryKey())) {
      String[] sPrimaryKey = oHrmAttWorkGroupShiftQVO.getHeaderPrimaryKey().split(",");
      System.out.println(sPrimaryKey[0]);
      System.out.println(sPrimaryKey[1]);
      oHrmAttWorkGroupShiftQVO.setWrkGrpCode(sPrimaryKey[0]);
      oHrmAttWorkGroupShiftQVO.setSiteCode(sPrimaryKey[1]);
      oHrmAttWorkGroupShiftQVO.setWorkGroupDescription(sPrimaryKey[2]);
      oHrmAttWorkGroupShiftQVO.setSiteDescription(sPrimaryKey[3]);
    } 
    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, oHrmAttWorkGroupShiftQVO.getWorkGroupId()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmAttWorkGroupShiftQVO.getSiteId()));
    arylstParam.add(new DBObject(5, 1, 12, oHrmAttWorkGroupShiftQVO.getStartDate()));
    arylstParam.add(new DBObject(6, 1, 12, oHrmAttWorkGroupShiftQVO.getEndDate()));
    arylstParam.add(new DBObject(7, 2, -10));
    arylstParam.add(new DBObject(8, 2, 12));
    arylstParam.add(new DBObject(9, 2, 12));
    arylstParam.add(new DBObject(10, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMATTWRKGRPSHIFT.proc_HrAttWGSDtl(?,?,?,?,?,?,?,?,?,?)");
    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();
      HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean = new HrmAttWorkGroupShiftDtlBean();
      oHrmAttWorkGroupShiftDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmAttWorkGroupShiftDtlBean.setShiftCode(oRow.get("CODE").getString());
      oHrmAttWorkGroupShiftDtlBean.setShiftId(oRow.get("SHFT_MST_ID").getString());
      oHrmAttWorkGroupShiftDtlBean.setShiftBeginDate(EnrgiseUtil.convertToString(oRow.get("SHIFT_BEGIN_DATE").getDate()));
      oHrmAttWorkGroupShiftDtlBean.setShiftEndDate(EnrgiseUtil.convertToString(oRow.get("SHIFT_END_DATE").getDate()));
      arylstAttWorkGroupDayoffDetail.add(oHrmAttWorkGroupShiftDtlBean);
    } 
    return arylstAttWorkGroupDayoffDetail;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_WRKGRP_SHFT_DTL";
  }
  
  public void saveDetailImpl(BaseHeaderBean oBaseHeaderBean, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmAttWorkGroupShift"))
      saveWGSImpl(oBaseHeaderBean, oDetailBeanArray); 
  }
  
  public String saveWGSImpl(BaseHeaderBean oBaseHeaderBean, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    HrmAttWorkGroupShiftHdrBean oHrmAttWorkGroupShiftHdrBean = (HrmAttWorkGroupShiftHdrBean)oBaseHeaderBean;
    Iterator itrBean = oDetailBeanArray.iterator();
    while (itrBean.hasNext()) {
      HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean = itrBean.next();
      if (oHrmAttWorkGroupShiftDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMATTWRKGRPSHIFT.proc_UpsertHrAttEmpShiftDtl(?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "N"));
        arylstParameters.add(new DBObject(2, 1, 12, null));
        arylstParameters.add(new DBObject(3, 1, 12, oHrmAttWorkGroupShiftHdrBean.getWorkGroupId()));
        arylstParameters.add(new DBObject(4, 1, 12, oHrmAttWorkGroupShiftHdrBean.getSiteId()));
        arylstParameters.add(new DBObject(5, 1, 12, oHrmAttWorkGroupShiftDtlBean.getShiftId()));
        arylstParameters.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttWorkGroupShiftDtlBean.getShiftBeginDate())));
        arylstParameters.add(new DBObject(7, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttWorkGroupShiftDtlBean.getShiftEndDate())));
        arylstParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getUserId()));
        arylstParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmAttWorkGroupShiftDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMATTWRKGRPSHIFT.proc_UpsertHrAttEmpShiftDtl(?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "U"));
        arylstParameters.add(new DBObject(2, 1, 12, oHrmAttWorkGroupShiftDtlBean.getDetailId()));
        arylstParameters.add(new DBObject(3, 1, 12, oHrmAttWorkGroupShiftHdrBean.getWorkGroupId()));
        arylstParameters.add(new DBObject(4, 1, 12, oHrmAttWorkGroupShiftHdrBean.getSiteId()));
        arylstParameters.add(new DBObject(5, 1, 12, oHrmAttWorkGroupShiftDtlBean.getShiftId()));
        arylstParameters.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttWorkGroupShiftDtlBean.getShiftBeginDate())));
        arylstParameters.add(new DBObject(7, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttWorkGroupShiftDtlBean.getShiftEndDate())));
        arylstParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getUserId()));
        arylstParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmAttWorkGroupShiftDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("HRMATTWRKGRPSHIFT.proc_DelWrkGrpShift(?)");
          bDelete = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, oHrmAttWorkGroupShiftDtlBean.getDetailId()));
        oBean1.addToBatch(arylstParameters);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bUpdate)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
    return String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf(oHrmAttWorkGroupShiftHdrBean.getWorkGroupCode()).concat(String.valueOf(","))).concat(String.valueOf(oHrmAttWorkGroupShiftHdrBean.getSiteCode()))).concat(String.valueOf(","))).concat(String.valueOf(oHrmAttWorkGroupShiftHdrBean.getWorkGroupDescription()))).concat(String.valueOf(","))).concat(String.valueOf(oHrmAttWorkGroupShiftHdrBean.getSiteDescription()));
  }
  
  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 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((HrmAttWorkGroupShiftHdrBean)oBaseHeaderBean);  
    if (bDetailDataChanged)
      if (sScreenName.equalsIgnoreCase("HrmAttWorkGroupShift")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        int rowCount = 1;
        while (oIt1.hasNext()) {
          HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean = oIt1.next();
          if (!oHrmAttWorkGroupShiftDtlBean.getStatus().equalsIgnoreCase("D"))
            checkMandatoryDtls(oHrmAttWorkGroupShiftDtlBean, rowCount, oErrorList); 
          rowCount++;
        } 
      }  
    reportError(oErrorList);
  }
  
  private void checkMandatoryHeader(HrmAttWorkGroupShiftHdrBean oHrmAttWorkGroupShiftHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException {
    ArrayList oErrorList = new ArrayList();
    ArrayList oParams = new ArrayList();
    if (!EnrgiseUtil.checkString(oHrmAttWorkGroupShiftHdrBean.getWorkGroupCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttWorkGroupShift.workGroupCode");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmAttWorkGroupShiftHdrBean.getSiteCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttWorkGroupShift.siteCode");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    reportError(oErrorList);
  }
  
  private void checkMandatoryDtls(HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean, int rowCount, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmAttWorkGroupShiftDtlBean.getShiftBeginDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttWorkGroupShift.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(oHrmAttWorkGroupShiftDtlBean.getShiftCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmAttWorkGroupShift.shiftCode");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
  }
  
  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("HrmAttWorkGroupShift")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        int n = oDetailBeanArray.size();
        int rowCount = 0;
        while (oIt1.hasNext()) {
          System.out.println(rowCount);
          HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean = oIt1.next();
          if (!oHrmAttWorkGroupShiftDtlBean.getStatus().equalsIgnoreCase("D")) {
            if (!EnrgiseUtil.checkString(oHrmAttWorkGroupShiftDtlBean.getShiftEndDate()))
              if (rowCount < n - 1) {
                HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean1 = oDetailBeanArray.get(rowCount + 1);
                if (EnrgiseUtil.checkString(oHrmAttWorkGroupShiftDtlBean1.getShiftBeginDate()))
                  oList.add(new EnrgiseApplicationException("wenrgise.hrms.att.Enddate.value")); 
              }  
            if (EnrgiseUtil.checkString(oHrmAttWorkGroupShiftDtlBean.getShiftBeginDate()))
              if (rowCount > 0 && rowCount < n) {
                HrmAttWorkGroupShiftDtlBean oHrmAttWorkGroupShiftDtlBean1 = oDetailBeanArray.get(rowCount - 1);
                if (EnrgiseUtil.checkString(oHrmAttWorkGroupShiftDtlBean1.getShiftEndDate())) {
                  DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
                  int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmAttWorkGroupShiftDtlBean.getShiftBeginDate(), oHrmAttWorkGroupShiftDtlBean1.getShiftEndDate());
                  if (dateFlag == -1 && dateFlag != -2)
                    oList.add(new EnrgiseApplicationException("wenrgise.hrms.att.BeginDate.value")); 
                } 
              }  
            if (EnrgiseUtil.checkString(oHrmAttWorkGroupShiftDtlBean.getShiftEndDate())) {
              DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
              int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmAttWorkGroupShiftDtlBean.getShiftEndDate(), oHrmAttWorkGroupShiftDtlBean.getShiftBeginDate());
              if (dateFlag == -1 && dateFlag != -2)
                oList.add(new EnrgiseApplicationException("wenrgise.hrms.attEmp.corresdate.value")); 
            } 
            rowCount++;
            continue;
          } 
          if (oHrmAttWorkGroupShiftDtlBean.getStatus().equalsIgnoreCase("D")) {
            HrmAttWorkGroupShiftHdrBean oHrmAttWorkGroupShiftHdrBean = (HrmAttWorkGroupShiftHdrBean)oBaseHeaderBean;
            DBUtilitiesBean oBean = new DBUtilitiesBean();
            ArrayList arylstParam = new ArrayList();
            arylstParam.add(new DBObject(1, 1, 12, oHrmAttWorkGroupShiftHdrBean.getWorkGroupId()));
            arylstParam.add(new DBObject(2, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmAttWorkGroupShiftDtlBean.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, "HRMATTWRKGRPSHIFT.proc_GetShiftRstInfo(?,?,?,?,?,?)");
            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 void saveDetailImpl(String param1, String param2, ArrayList param3) {}
  
  public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public LovVO getHrmAttWorkGrpCodeLOVdataQmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("workGroupId");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.wrkGrpCode");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.workGroupDescription");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    String siteId = null;
    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);
    } 
    if (oLovQueryVO.getProperty("siteId") != null) {
      siteId = oLovQueryVO.getProperty("siteId");
      System.out.println(siteId);
    } 
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, siteId));
    oParameters.add(new DBObject(2, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(3, 1, 12, sQuerySearch2));
    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, "HRMATTWRKGRPSHIFT.proc_GetAttWrkGrpCodeLovQmode(?,?,?,?,?,?,?)");
    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());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getHrmAttWorkGrpCodeLOVdataNmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("workGroupId");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.wrkGrpCode");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.workGroupDescription");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    String siteId = null;
    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);
    } 
    if (oLovQueryVO.getProperty("siteId") != null) {
      siteId = oLovQueryVO.getProperty("siteId");
      System.out.println(siteId);
    } 
    oParameters = new ArrayList();
    oParameters.add(new DBObject(1, 1, 12, siteId));
    oParameters.add(new DBObject(2, 1, 12, sQuerySearch1));
    oParameters.add(new DBObject(3, 1, 12, sQuerySearch2));
    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, "HRMATTWRKGRPSHIFT.proc_GetAttWrkGrpCodeLovNmode(?,?,?,?,?,?,?)");
    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());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getHrmAttWorkGrpSiteCodeLOVdataQmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("siteId");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.siteCode");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.siteDescription");
    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, "HRMATTWRKGRPSHIFT.proc_GetWrkGrpSiteCodeLovQmode(?,?,?,?,?,?)");
    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());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getHrmAttWorkGrpSiteCodeLOVdataNmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("siteId");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.siteCode");
    oHeaderList.add("hrm.HrmAttWorkGroupShift.siteDescription");
    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, "HRMATTWRKGRPSHIFT.proc_GetWrkGrpSiteCodeLovNmode(?,?,?,?,?,?)");
    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());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
  
  public LovVO getHrmAttWorkGrpShiftCodeLOVdataQmode(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, "HRMATTWRKGRPSHIFT.proc_GetWrkGrpShiftCodeLovN(?,?,?,?,?)");
    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;
  }
}
