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.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.HrmTransferApplicationHdrBean;
import wenrgise.hrms.vo.HrmATDTransApplQVO;

public class HrmATDTransApplBO extends HrmBaseBO {
  public HrmATDTransApplBO() {}
  
  public HrmATDTransApplBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrmEmpTransAppHdrMetaInfo(HrmATDTransApplQVO oHrmATDTransApplQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oHrmATDTransApplQVO.getHeaderPrimaryKey()));
    arylstParameters.add(new DBObject(2, 1, 12, oHrmATDTransApplQVO.getEmployeeNoId()));
    arylstParameters.add(new DBObject(3, 1, 12, oHrmATDTransApplQVO.getApplnNo()));
    arylstParameters.add(new DBObject(4, 2, -5));
    arylstParameters.add(new DBObject(5, 2, 93));
    arylstParameters.add(new DBObject(6, 2, 12));
    arylstParameters.add(new DBObject(7, 2, 12));
    arylstParameters.add(new DBObject(8, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRANSAPP.proc_GetHrEmpTransAppHdrCount(?,?,?,?,?,?,?,?)");
    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 getHrmEmpTransAppHeaderInfo(HrmATDTransApplQVO oHrmATDTransApplQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    ArrayList oHeaderList = null;
    if (oHrmATDTransApplQVO == null)
      oHrmATDTransApplQVO = new HrmATDTransApplQVO(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, -5, new Long(lStartPosition)));
    arylstParameters.add(new DBObject(2, 1, -5, new Long(lLastPosition)));
    arylstParameters.add(new DBObject(3, 1, 12, oHrmATDTransApplQVO.getHeaderPrimaryKey()));
    arylstParameters.add(new DBObject(4, 1, 12, oHrmATDTransApplQVO.getEmployeeNoId()));
    arylstParameters.add(new DBObject(5, 1, 12, oHrmATDTransApplQVO.getApplnNo()));
    arylstParameters.add(new DBObject(6, 2, -10));
    arylstParameters.add(new DBObject(7, 2, 12));
    arylstParameters.add(new DBObject(8, 2, 12));
    arylstParameters.add(new DBObject(9, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRANSAPP.proc_GetHrEmpTransAppHdr(?,?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        oHeaderList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmTransferApplicationHdrBean oTransAppHeader = new HrmTransferApplicationHdrBean();
      oTransAppHeader.setHeaderPrimaryKey(oRow.get("ID").getString());
      oTransAppHeader.setApplnNo(oRow.get("APPLICATION_NO").getString());
      oTransAppHeader.setSelfOffice(oRow.get("SELF_OFFICE_FLAG").getString());
      oTransAppHeader.setEmployeeNo(oRow.get("EMP_NO").getString());
      oTransAppHeader.setOfcNoteNo(oRow.get("OFFICE_NOTE_NO").getString());
      oTransAppHeader.setApplnDate(EnrgiseUtil.convertToString(oRow.get("APPLICATION_DATE").getDate()));
      oTransAppHeader.setOfcNoteDate(EnrgiseUtil.convertToString(oRow.get("OFFICE_ORDER_DATE").getDate()));
      oTransAppHeader.setSite1(oRow.get("NAME1").getString());
      oTransAppHeader.setSite2(oRow.get("NAME2").getString());
      oTransAppHeader.setSite3(oRow.get("NAME3").getString());
      oTransAppHeader.setReason(oRow.get("REASON").getString());
      oTransAppHeader.setEmpName(oRow.get("EMPNAME").getString());
      oTransAppHeader.setEmployeeNoId(oRow.get("EMP_ID").getString());
      oTransAppHeader.setSiteId(oRow.get("SITEID").getString());
      oTransAppHeader.setSite1Id(oRow.get("SITE1ID").getString());
      oTransAppHeader.setSite2Id(oRow.get("SITE2ID").getString());
      oTransAppHeader.setSite3Id(oRow.get("SITE3ID").getString());
      oTransAppHeader.setFromWorkGroup(oRow.get("FROM_WRKGRP_NAME").getString());
      oTransAppHeader.setToWorkGroupCode(oRow.get("TO_WRKGRP_CODE").getString());
      oTransAppHeader.setToWorkGroup(oRow.get("TO_WRKGRP_NAME").getString());
      oTransAppHeader.setApplnType(oRow.get("TRANS_APP_TYPE").getString());
      oTransAppHeader.setFromSite(oRow.get("FROM_SITE_NAME").getString());
      oTransAppHeader.setFromDesignation(oRow.get("FROM_DESIG").getString());
      oTransAppHeader.setToDesignationId(oRow.get("TO_DESIG_ID").getString());
      oTransAppHeader.setToDesignation(oRow.get("TO_DESIGNATION").getString());
      oTransAppHeader.setSiteCode1(oRow.get("CODE1").getString());
      oTransAppHeader.setSiteCode2(oRow.get("CODE2").getString());
      oTransAppHeader.setSiteCode3(oRow.get("CODE3").getString());
      oHeaderList.add(oTransAppHeader);
    } 
    return oHeaderList;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_EMP_TRANS_APPL";
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {}
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {}
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) 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 LovVO getHrmTrnApplnNoLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmTransferApplcn.applnNo");
    oHeaderList.add("hrm.HrmTransferApplcn.employeeNo");
    oHeaderList.add("hrm.HrmTransferApplcn.employeeName");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    String sQuerySearch2 = null;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 2, -10));
    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, "HRMTRNSFRLOV.proc_GetHrmTrnsfrApplnLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("APPLICATION_NO").getString());
      oLOVBean.setDetailField3(oRow.get("EMP_NO").getString());
      oLOVBean.setDetailField4(oRow.get("EMPNAME").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnOfcNoteNoLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmTransferApplcn.ofcNoteNo");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnsfrOfcLOVdata(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("OFFICE_NOTE_NO").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnDesignationLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmTransferApplcn.toDesignation");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    ArrayList arylstList = null;
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    String transType = null;
    String wrkGrp = null;
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 2, -10));
    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, "HRMTRNSFRLOV.proc_GetHrmTrnsDesigLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("NAME").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnWorkgroupLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmTransferApplcn.toWorkGroupCode");
    oHeaderList.add("hrm.HrmTransferApplcn.toWorkGroup");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = new ArrayList();
    ArrayList arylstList = null;
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    String transType = null;
    String wrkGrp = null;
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 1, 12, wrkGrp));
    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, "HRMTRNSFRLOV.proc_gethrmtrnsworkgrplov1data(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = 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());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnEmpNoLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmTransferApplcn.employeeNo");
    oHeaderList.add("hrm.HrmTransferApplcn.employeeName");
    oHeaderList.add("hrm.HrmTransferApplcn.fromDesignation");
    oHeaderList.add("hrm.HrmTransferApplcn.siteName");
    oHeaderList.add("siteId");
    oHeaderList.add("fromDesignationId");
    oHeaderList.add("hrm.HrmTransferApplcn.fromWorkGroup");
    oHeaderList.add("fromWorkGroupId");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = 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(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 2, -10));
    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, "HRMTRNSFRLOV.proc_GetHrmTrnsEmpNoLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = 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());
      oLOVBean.setDetailField4(oRow.get("FROM_DESIGNATION").getString());
      oLOVBean.setDetailField5(oRow.get("FROM_SITE_NAME").getString());
      oLOVBean.setDetailField6(oRow.get("FROM_SITE_ID").getString());
      oLOVBean.setDetailField7(oRow.get("FROM_DESIG_ID").getString());
      oLOVBean.setDetailField8(oRow.get("FROM_WorkGrp").getString());
      oLOVBean.setDetailField9(oRow.get("FROM_WorkGrp_id").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnEmpNoInsLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("ID");
    oHeaderList.add("hrm.HrmTransferApplcn.employeeNo");
    oHeaderList.add("hrm.HrmTransferApplcn.employeeName");
    oHeaderList.add("hrm.HrmTransferApplcn.fromDesignation");
    oHeaderList.add("hrm.HrmTransferApplcn.siteName");
    oHeaderList.add("siteId");
    oHeaderList.add("fromDesignationId");
    oHeaderList.add("hrm.HrmTransferApplcn.fromWorkGroup");
    oHeaderList.add("fromWorkGroupId");
    oLovVO.setHeaderList(oHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("H");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = 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(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 2, -10));
    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, "HRMTRNSFRLOV.proc_GetHrmTrnsEmpNoInsLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = 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());
      oLOVBean.setDetailField4(oRow.get("FROM_DESIGNATION").getString());
      oLOVBean.setDetailField5(oRow.get("FROM_SITE_NAME").getString());
      oLOVBean.setDetailField6(oRow.get("FROM_SITE_ID").getString());
      oLOVBean.setDetailField7(oRow.get("FROM_DESIG_ID").getString());
      oLOVBean.setDetailField8(oRow.get("FROM_WorkGrp").getString());
      oLOVBean.setDetailField9(oRow.get("FROM_WorkGrp_id").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnSite1LOVdata(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("site1 Id");
    oHeaderList.add("hrm.HrmTransferApplcn.siteCode");
    oHeaderList.add("hrm.HrmTransferApplcn.siteName");
    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 arylstParameters = 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);
    } 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 1, 12, siteId));
    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, "HRMTRNSFRLOV.proc_GetHrmTrnsfrSite1LOVdata(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = 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());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnSite2LOVdata(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("site2 Id");
    oHeaderList.add("hrm.HrmTransferApplcn.siteCode");
    oHeaderList.add("hrm.HrmTransferApplcn.siteName");
    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;
    String site1Id = null;
    ArrayList arylstParameters = 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);
    } 
    if (oLovQueryVO.getProperty("site1Id") != null) {
      site1Id = oLovQueryVO.getProperty("site1Id");
      System.out.println(site1Id);
    } 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 1, 12, siteId));
    arylstParameters.add(new DBObject(4, 1, 12, site1Id));
    arylstParameters.add(new DBObject(5, 2, -10));
    arylstParameters.add(new DBObject(6, 2, 12));
    arylstParameters.add(new DBObject(7, 2, 12));
    arylstParameters.add(new DBObject(8, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnsfrSite2LOVdata(?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = 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());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmTrnSite3LOVdata(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList oHeaderList = new ArrayList();
    oHeaderList.add("site3 Id");
    oHeaderList.add("hrm.HrmTransferApplcn.siteCode");
    oHeaderList.add("hrm.HrmTransferApplcn.siteName");
    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;
    String site1Id = null;
    String site2Id = null;
    ArrayList arylstParameters = 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);
    } 
    if (oLovQueryVO.getProperty("site1Id") != null) {
      site1Id = oLovQueryVO.getProperty("site1Id");
      System.out.println(site1Id);
    } 
    if (oLovQueryVO.getProperty("site2Id") != null) {
      site2Id = oLovQueryVO.getProperty("site2Id");
      System.out.println(site2Id);
    } 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 1, 12, siteId));
    arylstParameters.add(new DBObject(4, 1, 12, site1Id));
    arylstParameters.add(new DBObject(5, 1, 12, site2Id));
    arylstParameters.add(new DBObject(6, 2, -10));
    arylstParameters.add(new DBObject(7, 2, 12));
    arylstParameters.add(new DBObject(8, 2, 12));
    arylstParameters.add(new DBObject(9, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnsfrSite3LOVdata(?,?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = 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());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmCommonBO oBO = new HrmCommonBO();
    HrmTransferApplicationHdrBean oHrmTransApplHdrBean = (HrmTransferApplicationHdrBean)oBaseHeaderBean;
    if (EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteCode1())) {
      String site1Id = oBO.getRefList1("GEN_SITE_MST", "CODE", oHrmTransApplHdrBean.getSiteCode1(), "ID");
      oHrmTransApplHdrBean.setSite1Id(site1Id);
    } 
    if (EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteCode2())) {
      String site2Id = oBO.getRefList1("GEN_SITE_MST", "CODE", oHrmTransApplHdrBean.getSiteCode2(), "ID");
      oHrmTransApplHdrBean.setSite2Id(site2Id);
    } 
    if (EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteCode3())) {
      String site3Id = oBO.getRefList1("GEN_SITE_MST", "CODE", oHrmTransApplHdrBean.getSiteCode3(), "ID");
      oHrmTransApplHdrBean.setSite3Id(site3Id);
    } 
    if (ScreenMode.equalsIgnoreCase("N")) {
      arylstParameters = new ArrayList();
      arylstParameters.add(new DBObject(1, 1, 12, "N"));
      arylstParameters.add(new DBObject(2, 1, 12, oHrmTransApplHdrBean.getEmployeeNoId()));
      arylstParameters.add(new DBObject(3, 1, 12, oHrmTransApplHdrBean.getApplnNo()));
      arylstParameters.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransApplHdrBean.getApplnDate())));
      arylstParameters.add(new DBObject(5, 1, 12, oHrmTransApplHdrBean.getOfcNoteNo()));
      arylstParameters.add(new DBObject(6, 1, 12, oHrmTransApplHdrBean.getSite1Id()));
      arylstParameters.add(new DBObject(7, 1, 12, oHrmTransApplHdrBean.getSite2Id()));
      arylstParameters.add(new DBObject(8, 1, 12, oHrmTransApplHdrBean.getSite3Id()));
      arylstParameters.add(new DBObject(9, 1, 12, oHrmTransApplHdrBean.getReason()));
      arylstParameters.add(new DBObject(10, 1, 12, "A"));
      arylstParameters.add(new DBObject(11, 1, 12, oHrmTransApplHdrBean.getApplnType()));
      arylstParameters.add(new DBObject(12, 1, 12, oHrmTransApplHdrBean.getSiteId()));
      arylstParameters.add(new DBObject(13, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransApplHdrBean.getOfcNoteDate())));
      arylstParameters.add(new DBObject(14, 1, 12, oHrmTransApplHdrBean.getToDesignationId()));
      arylstParameters.add(new DBObject(15, 1, 12, oHrmTransApplHdrBean.getFromDesignationId()));
      arylstParameters.add(new DBObject(16, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParameters.add(new DBObject(17, 1, 12, this.oUserInfo.getSiteId()));
      arylstParameters.add(new DBObject(18, 1, 12, null));
      arylstParameters.add(new DBObject(19, 1, 12, oHrmTransApplHdrBean.getSelfOffice()));
      arylstParameters.add(new DBObject(20, 1, 12, oHrmTransApplHdrBean.getFromWorkGroupId()));
      arylstParameters.add(new DBObject(21, 1, 12, oHrmTransApplHdrBean.getToWorkGroupId()));
      arylstParameters.add(new DBObject(22, 2, 12));
      arylstParameters.add(new DBObject(23, 2, 12));
      arylstParameters.add(new DBObject(24, 2, 12));
      arylstParameters.add(new DBObject(25, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRANSAPP.proc_UpsertHrEmpTransAppHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      arylstParameters = new ArrayList();
      arylstParameters.add(new DBObject(1, 1, 12, "U"));
      arylstParameters.add(new DBObject(2, 1, 12, oHrmTransApplHdrBean.getEmployeeNoId()));
      arylstParameters.add(new DBObject(3, 1, 12, oHrmTransApplHdrBean.getApplnNo()));
      arylstParameters.add(new DBObject(4, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransApplHdrBean.getApplnDate())));
      arylstParameters.add(new DBObject(5, 1, 12, oHrmTransApplHdrBean.getOfcNoteNo()));
      arylstParameters.add(new DBObject(6, 1, 12, oHrmTransApplHdrBean.getSite1Id()));
      arylstParameters.add(new DBObject(7, 1, 12, oHrmTransApplHdrBean.getSite2Id()));
      arylstParameters.add(new DBObject(8, 1, 12, oHrmTransApplHdrBean.getSite3Id()));
      arylstParameters.add(new DBObject(9, 1, 12, oHrmTransApplHdrBean.getReason()));
      arylstParameters.add(new DBObject(10, 1, 12, oHrmTransApplHdrBean.getTrnsStatus()));
      arylstParameters.add(new DBObject(11, 1, 12, oHrmTransApplHdrBean.getApplnType()));
      arylstParameters.add(new DBObject(12, 1, 12, oHrmTransApplHdrBean.getSiteId()));
      arylstParameters.add(new DBObject(13, 1, 93, EnrgiseUtil.convertToSqlDate(oHrmTransApplHdrBean.getOfcNoteDate())));
      arylstParameters.add(new DBObject(14, 1, 12, oHrmTransApplHdrBean.getToDesignationId()));
      arylstParameters.add(new DBObject(15, 1, 12, oHrmTransApplHdrBean.getFromDesignationId()));
      arylstParameters.add(new DBObject(16, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParameters.add(new DBObject(17, 1, 12, this.oUserInfo.getSiteId()));
      arylstParameters.add(new DBObject(18, 1, 12, null));
      arylstParameters.add(new DBObject(19, 1, 12, oHrmTransApplHdrBean.getSelfOffice()));
      arylstParameters.add(new DBObject(20, 1, 12, oHrmTransApplHdrBean.getFromWorkGroupId()));
      arylstParameters.add(new DBObject(21, 1, 12, oHrmTransApplHdrBean.getToWorkGroupId()));
      arylstParameters.add(new DBObject(22, 2, 12));
      arylstParameters.add(new DBObject(23, 2, 12));
      arylstParameters.add(new DBObject(24, 2, 12));
      arylstParameters.add(new DBObject(25, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRANSAPP.proc_UpsertHrEmpTransAppHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } else if (ScreenMode.equalsIgnoreCase("D")) {
      arylstParameters.add(new DBObject(1, 1, 12, oHrmTransApplHdrBean.getHeaderPrimaryKey()));
      arylstParameters.add(new DBObject(2, 2, 12));
      arylstParameters.add(new DBObject(3, 2, 12));
      arylstParameters.add(new DBObject(4, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRANSAPP.proc_DeleteHrmEmpTransApplHdr(?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = null;
    } 
    return returnString;
  }
  
  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((HrmTransferApplicationHdrBean)oBaseHeaderBean);
        checkHeaderFields((HrmTransferApplicationHdrBean)oBaseHeaderBean);
      }  
    reportError(oErrorList);
  }
  
  private void checkMandatoryHeader(HrmTransferApplicationHdrBean oHrmTransApplHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException {
    ArrayList oErrorList = new ArrayList();
    ArrayList oParams = new ArrayList();
    if (!EnrgiseUtil.checkString(oHrmTransApplHdrBean.getApplnNo())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmTransferApplcn.applnNo");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmTransApplHdrBean.getApplnDate())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmTransferApplcn.applnDate");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmTransApplHdrBean.getApplnType())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmTransferApplcn.applnType");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmTransApplHdrBean.getReason())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmTransferApplcn.reason");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmTransApplHdrBean.getEmployeeNo())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmTransferApplcn.employeeNo");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    reportError(oErrorList);
  }
  
  private void checkHeaderFields(HrmTransferApplicationHdrBean oHrmTransApplHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException {
    ArrayList arylstList1 = new ArrayList();
    if (oHrmTransApplHdrBean.getApplnType().equalsIgnoreCase("S")) {
      if (EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSite1Id()) || EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSite2Id()) || EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSite3Id()))
        arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransApp.sectional.value")); 
      if (oHrmTransApplHdrBean.getFromDesignation().equals(oHrmTransApplHdrBean.getToDesignation()))
        arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransApp.designation.value")); 
    } 
    if (oHrmTransApplHdrBean.getApplnType().equalsIgnoreCase("L")) {
      if (!EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteId()) || !EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteCode1()))
        arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransApp.site.value")); 
      if (oHrmTransApplHdrBean.getSiteId().equals(oHrmTransApplHdrBean.getSite1Id()) || oHrmTransApplHdrBean.getSite1Id().equals(oHrmTransApplHdrBean.getSite2Id()) || oHrmTransApplHdrBean.getSiteId().equals(oHrmTransApplHdrBean.getSite3Id()))
        arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransApp.fromSite.value")); 
      if (EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteCode2()))
        if (oHrmTransApplHdrBean.getSiteCode1().equals(oHrmTransApplHdrBean.getSiteCode2()) || oHrmTransApplHdrBean.getSiteCode2().equals(oHrmTransApplHdrBean.getSiteCode3()))
          arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransApp.toSite.value"));  
      if (EnrgiseUtil.checkString(oHrmTransApplHdrBean.getSiteCode3()))
        if (oHrmTransApplHdrBean.getSiteCode1().equals(oHrmTransApplHdrBean.getSiteCode3()) || oHrmTransApplHdrBean.getSiteCode2().equals(oHrmTransApplHdrBean.getSiteCode3()))
          arylstList1.add(new EnrgiseApplicationException("wenrgise.empTransApp.toSite.value"));  
    } 
    reportError(arylstList1);
  }
  
  public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    HrmTransferApplicationHdrBean oHrmTransferApplicationHdrBean = (HrmTransferApplicationHdrBean)oBaseHeaderBean;
    if (bHeaderDataChanged) {
      if (!sScreenMode.equalsIgnoreCase("D")) {
        checkUniqueHeader((HrmTransferApplicationHdrBean)oBaseHeaderBean);
        checkDatesConstraint((HrmTransferApplicationHdrBean)oBaseHeaderBean, oErrorList);
      } 
      if (sScreenMode.equalsIgnoreCase("D")) {
        HrmCommonBO oCommonBO = new HrmCommonBO();
        String sRefId = oCommonBO.getRefList("HRM_EMP_TRANS_ORDER_DTL", "TRANS_APPL_ID ", oHrmTransferApplicationHdrBean.getHeaderPrimaryKey(), "ID");
        if (EnrgiseUtil.checkString(sRefId))
          oErrorList.add(new EnrgiseApplicationException("wenrgise.common.deletion")); 
        if (!oHrmTransferApplicationHdrBean.getTrnsStatus().equalsIgnoreCase("N"))
          if (oErrorList.isEmpty())
            oErrorList.add(new EnrgiseApplicationException("wenrgise.common.deletion.rejected"));  
      } 
    } 
    reportError(oErrorList);
  }
  
  private void checkUniqueHeader(HrmTransferApplicationHdrBean oHrmTransApplHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    String sQuery = String.valueOf(String.valueOf(" Select ID as ID from hrm_emp_trans_appl where application_no= '").concat(String.valueOf(oHrmTransApplHdrBean.getApplnNo()))).concat(String.valueOf("'"));
    System.out.println(sQuery);
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    ArrayList arylstList = oBean.executeQuery(sQuery);
    ArrayList arylstParam = new ArrayList();
    Iterator oIt = arylstList.iterator();
    if (oIt.hasNext()) {
      QueryRow oRow = oIt.next();
      if (!oRow.get("ID").getString().equalsIgnoreCase(oHrmTransApplHdrBean.getHeaderPrimaryKey()))
        throw new EnrgiseApplicationException("wenrgise.common.header.uniqueConstraintViolated", "M"); 
    } 
  }
  
  private void checkDatesConstraint(HrmTransferApplicationHdrBean oHrmTransferApplicationHdrBean, ArrayList oErrorList) throws EnrgiseApplicationException, EnrgiseSystemException {
    DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
    if (EnrgiseUtil.checkString(oHrmTransferApplicationHdrBean.getOfcNoteDate())) {
      int dateFlag = EnrgiseUtil.compareDates(dateFormat, oHrmTransferApplicationHdrBean.getOfcNoteDate(), oHrmTransferApplicationHdrBean.getApplnDate());
      if (dateFlag == -1 && dateFlag != -2)
        oErrorList.add(new EnrgiseApplicationException("wenrgise.empTransApp.dateConstraintViolated")); 
    } 
    if (EnrgiseUtil.checkString(oHrmTransferApplicationHdrBean.getApplnDate())) {
      int dateFlag1 = EnrgiseUtil.compareDates(dateFormat, EnrgiseUtil.convertToString(EnrgiseUtil.getSysDate()), oHrmTransferApplicationHdrBean.getApplnDate());
      if (dateFlag1 == -1 && dateFlag1 != -2)
        oErrorList.add(new EnrgiseApplicationException("wenrgise.empTransApp.dateConstraintViolated3")); 
    } 
    if (EnrgiseUtil.checkString(oHrmTransferApplicationHdrBean.getOfcNoteDate())) {
      int dateFlag2 = EnrgiseUtil.compareDates(dateFormat, EnrgiseUtil.convertToString(EnrgiseUtil.getSysDate()), oHrmTransferApplicationHdrBean.getOfcNoteDate());
      if (dateFlag2 == -1 && dateFlag2 != -2)
        oErrorList.add(new EnrgiseApplicationException("wenrgise.empTransApp.dateConstraintViolated2")); 
    } 
  }
  
  public String getHrEmpInfo(String sEmpId) throws EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    String sStatus = null;
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sEmpId));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnsfrAppEmpdata(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      oRow = oIt.next();
      sStatus = oRow.get("APPROVED_FLAG").getString();
    } 
    return sStatus;
  }
  
  public String getHrEmpOrderInfo(String sEmpId) throws EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    String sStatus = null;
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sEmpId));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmTrnsfrAppEmpOrddata(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      oRow = oIt.next();
      sStatus = oRow.get("APPROVED_FLAG").getString();
    } 
    return sStatus;
  }
  
  public String getHrEmpOrderChInfo(String sEmpId) throws EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    String sStatus = null;
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sEmpId));
    arylstParameters.add(new DBObject(2, 2, -10));
    arylstParameters.add(new DBObject(3, 2, 12));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNSFRLOV.proc_GetHrmEmpOrdChdata(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator oIt = arylstList.iterator();
    while (oIt.hasNext()) {
      oRow = oIt.next();
      sStatus = oRow.get("ID").getString();
    } 
    return sStatus;
  }
}
