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.RecordMetaInfo;
import wenrgise.common.vo.BaseQueryVO;
import wenrgise.common.vo.ThisPageVO;
import wenrgise.ejb.common.utility.ServiceLocator;
import wenrgise.hrms.bean.HrmAprslStartOrderHdrBean;
import wenrgise.hrms.ejb.facade.HrmThirdFacade;
import wenrgise.hrms.ejb.facade.HrmThirdFacadeHome;
import wenrgise.hrms.vo.HrmAprslStartOrderQVO;

public class HrmAprslStartOrderBD extends HrmBaseBD {
  public boolean updateHeaderRecordImpl(BaseHeaderBean oBaseHeaderBean) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return true;
  }
  
  public String getInsertDataImpl(BaseQueryVO oQueryVO) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public RecordMetaInfo getTotalDetailRecordCountImpl(String lPrimaryKey, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public ArrayList getDetailRecordImpl(String lPrimaryKey, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmThirdFacade oHrmThirdFacade = (HrmThirdFacade)getModuleFacade("ThirdHRMS");
      return oHrmThirdFacade.getHrmAprslStOrderMetaInfo((HrmAprslStartOrderQVO)oQueryVO);
    } 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 {
      HrmThirdFacade oHrmThirdFacade = (HrmThirdFacade)getModuleFacade("ThirdHRMS");
      ArrayList oHeaderList = oHrmThirdFacade.getHrmAprslStOrderInfo((HrmAprslStartOrderQVO)oQueryVO, lStartPosition, lLastPosition);
      return oHeaderList;
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  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();
      String sHeaderPrimaryKey = oHrmThirdFacade.saveHrmAprslStOrder((HrmAprslStartOrderHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo);
      return sHeaderPrimaryKey;
    } catch (CreateException oCrtExcep) {
      throw new EnrgiseSystemException(oCrtExcep);
    } 
  }
  
  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 null;
  }
  
  public Map getDisabledFieldsImpl(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    HashMap oHashMap = new HashMap();
    ArrayList oEnableList = new ArrayList();
    ArrayList oDisableList = new ArrayList();
    ArrayList oDetailList = oThisPageVO.getODetailList();
    BaseHeaderBean oBaseHeaderBean = oThisPageVO.getOHeaderBean();
    HrmAprslStartOrderHdrBean oHrmAprslStartOrderHdrBean = (HrmAprslStartOrderHdrBean)oBaseHeaderBean;
    if (!oThisPageVO.getScreenMode().equalsIgnoreCase("Q")) {
      oDisableList.add("butStOrderNo");
      oEnableList.add("butAprslStDate");
      oEnableList.add("butAprslEndDate");
      oEnableList.add("butPeriodEndDate");
      oEnableList.add("butPeriodStDate");
    } 
    if (oThisPageVO.getScreenMode().equalsIgnoreCase("Q")) {
      oEnableList.add("butStOrderNo");
      oDisableList.add("butAprslStDate");
      oDisableList.add("butAprslEndDate");
      oDisableList.add("butPeriodEndDate");
      oDisableList.add("butPeriodStDate");
    } 
    oHashMap.put("D", oDisableList);
    return oHashMap;
  }
}
