package wenrgise.hrms.ejb.business;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
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.ejb.business.HrmCommonBO;
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.HrmEmpDiscActionDtlBean;
import wenrgise.hrms.bean.HrmEmpDiscActionHdrBean;
import wenrgise.hrms.vo.HrmEmpDiscActionQVO;

public class HrmEmpDiscActionBO extends HrmBaseBO {
  public HrmEmpDiscActionBO() {}
  
  public HrmEmpDiscActionBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrmEmpDiscActionHdrMetaInfo(HrmEmpDiscActionQVO oHrmEmpDiscActionQVO) 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, oHrmEmpDiscActionQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmEmpDiscActionQVO.getEmployeeNo()));
    arylstParam.add(new DBObject(3, 1, 12, oHrmEmpDiscActionQVO.getCaseFlag()));
    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 oOutArray = oBean.callProc(arylstParam, "HRMEMPDISCACTION.procGetEmpDiscActionHdrCount(?,?,?,?,?,?,?,?)");
    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 getHrmEmpDiscActionHdrInfo(HrmEmpDiscActionQVO oHrmEmpDiscActionQVO, 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 oHeaderList = null;
    if (oHrmEmpDiscActionQVO == null)
      oHrmEmpDiscActionQVO = new HrmEmpDiscActionQVO(); 
    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, oHrmEmpDiscActionQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmEmpDiscActionQVO.getEmployeeNo()));
    arylstParam.add(new DBObject(5, 1, 12, oHrmEmpDiscActionQVO.getCaseFlag()));
    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 oOutArray = oBean.callProc(arylstParam, "HRMEMPDISCACTION.procGetEmpDiscActionHdr(?,?,?,?,?,?,?,?,?)");
    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();
      HrmEmpDiscActionHdrBean oEmployeeDependantDetailsHeader = new HrmEmpDiscActionHdrBean();
      oEmployeeDependantDetailsHeader.setHeaderPrimaryKey(oRow.get("ID").getString());
      oEmployeeDependantDetailsHeader.setEmployeeNo(oRow.get("EMP_NO").getString());
      oEmployeeDependantDetailsHeader.setEmployeeName(oRow.get("EMPNAME").getString());
      oHeaderList.add(oEmployeeDependantDetailsHeader);
    } 
    return oHeaderList;
  }
  
  public RecordMetaInfo getHrmEmpDiscActionMetaInfo(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, lPrimaryKey));
    arylstParam.add(new DBObject(2, 2, -5));
    arylstParam.add(new DBObject(3, 2, 93));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList oOutArray = oBean.callProc(arylstParam, "HRMEMPDISCACTION.procHrmEmpDiscActionCount(?,?,?,?,?,?)");
    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 getHrmEmpDiscActionInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList oHrmEmpDiscActionsDetail = 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, lPrimaryKey));
    arylstParam.add(new DBObject(4, 2, -10));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 4));
    ArrayList oOutArray = oBean.callProc(arylstParam, "HRMEMPDISCACTION.procGetHrmEmpDiscActionDtl(?,?,?,?,?,?,?)");
    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)
        oHrmEmpDiscActionsDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmEmpDiscActionDtlBean oEmployeeDependantDetailsDtlBean = new HrmEmpDiscActionDtlBean();
      oEmployeeDependantDetailsDtlBean.setDetailId(oRow.get("ID").getString());
      oEmployeeDependantDetailsDtlBean.setTxtLocationId(oRow.get("SITE_ID").getString());
      oEmployeeDependantDetailsDtlBean.setTxtLocation(oRow.get("NAME").getString());
      oEmployeeDependantDetailsDtlBean.setTxtMisconduct(oRow.get("MISCONDUCT").getString());
      oEmployeeDependantDetailsDtlBean.setTxtFromDate(EnrgiseUtil.convertToString(oRow.get("FROM_DATE").getDate()));
      oEmployeeDependantDetailsDtlBean.setTxtChrgShtDate(EnrgiseUtil.convertToString(oRow.get("TO_DATE").getDate()));
      oEmployeeDependantDetailsDtlBean.setTxtActionTaken(oRow.get("ACTION_TAKEN").getString());
      oEmployeeDependantDetailsDtlBean.setTxtStatus(oRow.get("STATUS").getString());
      oEmployeeDependantDetailsDtlBean.setTxtStatusEffectDate(EnrgiseUtil.convertToString(oRow.get("STATUS_EFFECT_DATE").getDate()));
      oEmployeeDependantDetailsDtlBean.setTxtRemarks(oRow.get("REMARKS").getString());
      oEmployeeDependantDetailsDtlBean.setTxtInqDate(EnrgiseUtil.convertToString(oRow.get("inquiry_date").getDate()));
      oEmployeeDependantDetailsDtlBean.setTxtInqOfficer(oRow.get("inquiry_officer").getString());
      oEmployeeDependantDetailsDtlBean.setTxtActionOfficer(oRow.get("action_auth").getString());
      oEmployeeDependantDetailsDtlBean.setTxtAppealDate(EnrgiseUtil.convertToString(oRow.get("appeal_date").getDate()));
      oHrmEmpDiscActionsDetail.add(oEmployeeDependantDetailsDtlBean);
    } 
    return oHrmEmpDiscActionsDetail;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_EMP_PERS";
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmEmpDiscAction"))
      saveHrmEmpDiscAction(sHeaderPrimaryKey, oDetailBeanArray); 
  }
  
  private void saveHrmEmpDiscAction(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmEmpDiscActionDtlBean oHrmEmpDiscActionDtlBean = oIt.next();
      if (oHrmEmpDiscActionDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMEMPDISCACTION.procUpsertHrmEmpDiscAction(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "I"));
        arylstParam.add(new DBObject(2, 1, 12, null));
        arylstParam.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
        arylstParam.add(new DBObject(4, 1, 12, oHrmEmpDiscActionDtlBean.getTxtLocationId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmEmpDiscActionDtlBean.getTxtMisconduct()));
        arylstParam.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtFromDate())));
        arylstParam.add(new DBObject(7, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtChrgShtDate())));
        arylstParam.add(new DBObject(8, 1, 12, oHrmEmpDiscActionDtlBean.getTxtActionTaken()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmEmpDiscActionDtlBean.getTxtStatus()));
        arylstParam.add(new DBObject(10, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtStatusEffectDate())));
        arylstParam.add(new DBObject(11, 1, 12, oHrmEmpDiscActionDtlBean.getTxtRemarks()));
        arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParam.add(new DBObject(13, 1, 12, this.oUserInfo.getSiteId()));
        arylstParam.add(new DBObject(14, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtInqDate())));
        arylstParam.add(new DBObject(15, 1, 12, oHrmEmpDiscActionDtlBean.getTxtInqOfficer()));
        arylstParam.add(new DBObject(16, 1, 12, oHrmEmpDiscActionDtlBean.getTxtActionOfficer()));
        arylstParam.add(new DBObject(17, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtAppealDate())));
        oBean.addToBatch(arylstParam);
        continue;
      } 
      if (oHrmEmpDiscActionDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMEMPDISCACTION.procUpsertHrmEmpDiscAction(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "U"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmEmpDiscActionDtlBean.getDetailId()));
        arylstParam.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
        arylstParam.add(new DBObject(4, 1, 12, oHrmEmpDiscActionDtlBean.getTxtLocationId()));
        arylstParam.add(new DBObject(5, 1, 12, oHrmEmpDiscActionDtlBean.getTxtMisconduct()));
        arylstParam.add(new DBObject(6, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtFromDate())));
        arylstParam.add(new DBObject(7, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtChrgShtDate())));
        arylstParam.add(new DBObject(8, 1, 12, oHrmEmpDiscActionDtlBean.getTxtActionTaken()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmEmpDiscActionDtlBean.getTxtStatus()));
        arylstParam.add(new DBObject(10, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtStatusEffectDate())));
        arylstParam.add(new DBObject(11, 1, 12, oHrmEmpDiscActionDtlBean.getTxtRemarks()));
        arylstParam.add(new DBObject(12, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParam.add(new DBObject(13, 1, 12, this.oUserInfo.getSiteId()));
        arylstParam.add(new DBObject(14, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtInqDate())));
        arylstParam.add(new DBObject(15, 1, 12, oHrmEmpDiscActionDtlBean.getTxtInqOfficer()));
        arylstParam.add(new DBObject(16, 1, 12, oHrmEmpDiscActionDtlBean.getTxtActionOfficer()));
        arylstParam.add(new DBObject(17, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmEmpDiscActionDtlBean.getTxtAppealDate())));
        oBean.addToBatch(arylstParam);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bUpdate)
      oBean.executeBatch(); 
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {}
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return new String();
  }
  
  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 additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oList = new ArrayList();
    ArrayList arylstErrorList = new ArrayList();
    if (bDetailDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        if (sScreenName.equalsIgnoreCase("HrmEmpDiscAction")) {
          Iterator oIt1 = oDetailBeanArray.iterator();
          int rowCount = 1;
          while (oIt1.hasNext()) {
            HrmEmpDiscActionDtlBean oHrmEmpDiscActionDtlBean = oIt1.next();
            if (!oHrmEmpDiscActionDtlBean.getStatus().equalsIgnoreCase("D"))
              checkMandatoryDiscDtl(oHrmEmpDiscActionDtlBean, rowCount, arylstErrorList); 
            rowCount++;
          } 
        }   
  }
  
  public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    HrmEmpDiscActionHdrBean oHrmEmpDiscActionHdrBean = (HrmEmpDiscActionHdrBean)oBaseHeaderBean;
    ArrayList oList = new ArrayList();
    ArrayList arylstErrorList = new ArrayList();
    if (bDetailDataChanged)
      if (sScreenName.equalsIgnoreCase("HrmEmpDiscAction")) {
        Iterator oIt1 = oDetailBeanArray.iterator();
        while (oIt1.hasNext()) {
          HrmEmpDiscActionDtlBean oHrmEmpDiscActionDtlBean = oIt1.next();
          if (!oHrmEmpDiscActionDtlBean.getStatus().equalsIgnoreCase("D"))
            checkDatesConstraintForDtl(oDetailBeanArray, arylstErrorList); 
        } 
      }  
    reportError(oList);
  }
  
  private void checkDatesConstraintForDtl(ArrayList arylstDetailBeanArray, ArrayList arylstErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    int n = arylstDetailBeanArray.size();
    Iterator itrBean1 = arylstDetailBeanArray.iterator();
    int rowCount = 0;
    while (itrBean1.hasNext()) {
      HrmEmpDiscActionDtlBean oHrmEmpDiscActionDtlBean = itrBean1.next();
      DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
      int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmEmpDiscActionDtlBean.getTxtFromDate(), oHrmEmpDiscActionDtlBean.getTxtToDate());
      if (dateFlag == 1 && dateFlag != -2)
        arylstErrorList.add(new EnrgiseApplicationException("hrm.startEndDate.dateConstraintViolated")); 
    } 
    reportError(arylstErrorList);
  }
  
  private void checkMandatoryDiscDtl(HrmEmpDiscActionDtlBean oHrmEmpDiscActionDtlBean, int iCount, ArrayList arylstErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmEmpDiscActionDtlBean.getTxtLocationId())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmEmpDiscAction.txtLocation");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmEmpDiscActionDtlBean.getTxtFromDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmEmpDiscAction.txtFromDate");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmEmpDiscActionDtlBean.getTxtStatus())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmEmpDiscAction.txtStatus");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
    DateUtility d = new DateUtility();
    System.out.println(d.getSysDate());
    HrmCommonBO oBO = new HrmCommonBO();
    String sysDate = oBO.getddmmmyyyyDateFormat(d.getSysDate());
    int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmEmpDiscActionDtlBean.getTxtFromDate(), sysDate);
    if (dateFlag == 1 && dateFlag != -2)
      arylstErrorList.add(new EnrgiseApplicationException("wenrgise.dateOfMisconduct.dateConstraintViolated")); 
    reportError(arylstErrorList);
  }
  
  public LovVO getHrmEmpDiscActionEmpNoLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    return null;
  }
  
  public LovVO getHrmEmpDiscActionSiteLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmEmpDiscAction.txtLocation");
    oLovVO.setHeaderList(oHeaderList);
    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 oOutArray = oBean.callProc(arylstParam, "HRMEMPDISCACTION.procGetHrmEmpDiscSiteLOVdata(?,?,?,?,?,?)");
    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("NAME").getString());
      oList.add(oLOVBean);
    } 
    oLovVO.setDetailList(oList);
    return oLovVO;
  }
}
