package wenrgise.hrms.businessdelegate;

import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.ejb.CreateException;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.vo.BaseQueryVO;
import wenrgise.common.vo.ThisPageVO;
import wenrgise.ejb.common.utility.ServiceLocator;
import wenrgise.hrms.bean.HrmTransferApplicationHdrBean;
import wenrgise.hrms.ejb.facade.HrmThirdFacade;
import wenrgise.hrms.ejb.facade.HrmThirdFacadeHome;
import wenrgise.hrms.vo.HrmATDTransApplQVO;

public class HrmATDTransApplBD extends HrmBaseBD {
  public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade");
      HrmThirdFacade oHrmThirdFacade = oHome.create();
      return oHrmThirdFacade.getHrmEmpTransAppHeaderMetaInfo((HrmATDTransApplQVO)oQueryVO, this.oUserInfo);
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  public ArrayList getHeaderRecordImpl(BaseQueryVO oQueryVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade");
      HrmThirdFacade oHrmThirdFacade = oHome.create();
      ArrayList oHeaderList = oHrmThirdFacade.getHrmEmpTransAppHeader((HrmATDTransApplQVO)oQueryVO, lStartPosition, lLastPosition, this.oUserInfo);
      return oHeaderList;
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  public RecordMetaInfo getTotalDetailRecordCountImpl(String lPrimaryKey, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    RecordMetaInfo oRecordMetaInfo = null;
    return oRecordMetaInfo;
  }
  
  public ArrayList getDetailRecordImpl(String lPrimaryKey, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oRet = null;
    return oRet;
  }
  
  public boolean updateHeaderRecordImpl(BaseHeaderBean oBaseHeaderBean) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return true;
  }
  
  public String saveImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmThirdFacadeHome oHome = (HrmThirdFacadeHome)ServiceLocator.getLocator().getService("HrmThirdFacade");
      HrmThirdFacade oHrmThirdFacade = oHome.create();
      return oHrmThirdFacade.saveHrmTransAppl((HrmTransferApplicationHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo);
    } catch (CreateException oCrtExcep) {
      throw new EnrgiseSystemException(oCrtExcep);
    } 
  }
  
  public String getInsertDataImpl(BaseQueryVO oQueryVO) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return "Only Implementation";
  }
  
  public Map getDisabledFieldsImpl(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    HashMap oHashMap = new HashMap();
    ArrayList arylstEnabledList = new ArrayList();
    ArrayList arylstDisabledList = new ArrayList();
    HrmTransferApplicationHdrBean oHrmTransferApplicationHdrBean = (HrmTransferApplicationHdrBean)oThisPageVO.getOHeaderBean();
    ArrayList oDetailList = oThisPageVO.getODetailList();
    if (oThisPageVO.getScreenMode().equalsIgnoreCase("Q")) {
      arylstDisabledList.add("butToDesignation");
      arylstDisabledList.add("butToWorkGroup");
      arylstEnabledList.add("butEmployeeNo");
    } 
    if (!oHrmTransferApplicationHdrBean.equals(null))
      if (oThisPageVO.getScreenMode().equalsIgnoreCase("N")) {
        arylstEnabledList.add("ofcNoteNo");
        arylstEnabledList.add("butOfcNoteNo");
        arylstEnabledList.add("ofcNoteDate");
        arylstEnabledList.add("butOfcNoteDate");
        arylstEnabledList.add("butEmployeeNo");
        arylstEnabledList.add("butToDesignation");
        arylstEnabledList.add("butToWorkGroup");
        if (EnrgiseUtil.checkString(oHrmTransferApplicationHdrBean.getApplnType()))
          if (oHrmTransferApplicationHdrBean.getApplnType().equalsIgnoreCase("S")) {
            oHrmTransferApplicationHdrBean.setSite1("");
            oHrmTransferApplicationHdrBean.setSite2("");
            oHrmTransferApplicationHdrBean.setSite3("");
            oHrmTransferApplicationHdrBean.setSiteCode1("");
            oHrmTransferApplicationHdrBean.setSiteCode2("");
            oHrmTransferApplicationHdrBean.setSiteCode3("");
            arylstDisabledList.add("siteCode1");
            arylstDisabledList.add("siteCode2");
            arylstDisabledList.add("siteCode3");
            arylstDisabledList.add("site1");
            arylstDisabledList.add("site2");
            arylstDisabledList.add("site3");
            arylstDisabledList.add("butSite1");
            arylstDisabledList.add("butSite2");
            arylstDisabledList.add("butSite3");
          } else if (oHrmTransferApplicationHdrBean.getApplnType().equalsIgnoreCase("L")) {
            arylstEnabledList.add("siteCode1");
            arylstEnabledList.add("siteCode2");
            arylstEnabledList.add("siteCode3");
            arylstEnabledList.add("site1");
            arylstEnabledList.add("site2");
            arylstEnabledList.add("site3");
            arylstEnabledList.add("butSite1");
            arylstEnabledList.add("butSite2");
            arylstEnabledList.add("butSite3");
          }  
      } else if (oThisPageVO.getScreenMode().equalsIgnoreCase("U")) {
        arylstEnabledList.add("ofcNoteNo");
        arylstEnabledList.add("butOfcNoteNo");
        arylstEnabledList.add("ofcNoteDate");
        arylstEnabledList.add("butOfcNoteDate");
        arylstEnabledList.add("butEmployeeNo");
        arylstEnabledList.add("butToDesignation");
        arylstEnabledList.add("butToWorkGroup");
        if (EnrgiseUtil.checkString(oHrmTransferApplicationHdrBean.getApplnType()))
          if (oHrmTransferApplicationHdrBean.getApplnType().equalsIgnoreCase("S")) {
            oHrmTransferApplicationHdrBean.setSite1("");
            oHrmTransferApplicationHdrBean.setSite2("");
            oHrmTransferApplicationHdrBean.setSite3("");
            oHrmTransferApplicationHdrBean.setSiteCode1("");
            oHrmTransferApplicationHdrBean.setSiteCode2("");
            oHrmTransferApplicationHdrBean.setSiteCode3("");
            arylstDisabledList.add("siteCode1");
            arylstDisabledList.add("siteCode2");
            arylstDisabledList.add("siteCode3");
            arylstDisabledList.add("site1");
            arylstDisabledList.add("site2");
            arylstDisabledList.add("site3");
            arylstDisabledList.add("butSite1");
            arylstDisabledList.add("butSite2");
            arylstDisabledList.add("butSite3");
          } else if (oHrmTransferApplicationHdrBean.getApplnType().equalsIgnoreCase("L")) {
            arylstEnabledList.add("siteCode1");
            arylstEnabledList.add("siteCode2");
            arylstEnabledList.add("siteCode3");
            arylstEnabledList.add("site1");
            arylstEnabledList.add("site2");
            arylstEnabledList.add("site3");
            arylstEnabledList.add("butSite1");
            arylstEnabledList.add("butSite2");
            arylstEnabledList.add("butSite3");
          }  
      }  
    oThisPageVO.setOHeaderBean((BaseHeaderBean)oHrmTransferApplicationHdrBean);
    oHashMap.put("D", arylstDisabledList);
    oHashMap.put("E", arylstEnabledList);
    return oHashMap;
  }
  
  public String submitImpl(String sButtonName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return new String();
  }
  
  public void onLoadAction(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException {}
}
