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.HrmAttWorkGroupDayOffHdrBean;
import wenrgise.hrms.ejb.facade.HrmSecondFacade;
import wenrgise.hrms.ejb.facade.HrmSecondFacadeHome;
import wenrgise.hrms.vo.HrmAttWorkGroupDayOffQVO;

public class HrmAttWorkGroupDayOffBD extends HrmBaseBD {
  public RecordMetaInfo getTotalDetailRecordCountImpl(BaseQueryVO oBaseQueryVO, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmSecondFacade oHrmSecondFacade = (HrmSecondFacade)getModuleFacade("SecHRMS");
      return oHrmSecondFacade.getHrmAttWorkGroupDayOffDtlMetaInfo((HrmAttWorkGroupDayOffQVO)oBaseQueryVO);
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  public ArrayList getDetailRecordImpl(BaseQueryVO oBaseQueryVO, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmSecondFacade oHrmSecondFacade = (HrmSecondFacade)getModuleFacade("SecHRMS");
      if (sScreenName.equalsIgnoreCase("HrmAttWorkGroupDayOff"))
        return oHrmSecondFacade.getHrmAttWorkGroupDayOffDetailInfo((HrmAttWorkGroupDayOffQVO)oBaseQueryVO, lAbsoluteStart, lAbsoluteEnd); 
      return null;
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  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 {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oHrmSecondFacade = oHome.create();
      return oHrmSecondFacade.saveHrmAttWorkGroupDayOffData(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 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 RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    RecordMetaInfo oRecordMetaInfo = null;
    return oRecordMetaInfo;
  }
  
  public ArrayList getHeaderRecordImpl(BaseQueryVO oQueryVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oRet = null;
    return oRet;
  }
  
  public Map getDisabledFieldsImpl(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    HashMap oHashMap = new HashMap();
    ArrayList arylstEnableList = new ArrayList();
    ArrayList arylstDisableList = new ArrayList();
    HrmAttWorkGroupDayOffHdrBean oHrmAttWorkGroupDayOffHdrBean = (HrmAttWorkGroupDayOffHdrBean)oThisPageVO.getOHeaderBean();
    if (oThisPageVO.getScreenMode().equalsIgnoreCase("Q")) {
      arylstDisableList.add("butExecute");
      if (EnrgiseUtil.checkString(oHrmAttWorkGroupDayOffHdrBean.getSiteCode()) && EnrgiseUtil.checkString(oHrmAttWorkGroupDayOffHdrBean.getWorkGroupCode()))
        arylstEnableList.add("butGetDetail"); 
    } 
    if (EnrgiseUtil.checkString(oHrmAttWorkGroupDayOffHdrBean.getSiteCode())) {
      arylstEnableList.add("butWrkGrpCode");
      arylstDisableList.add("butSiteCode");
    } else {
      arylstDisableList.add("butWrkGrpCode");
    } 
    if (oThisPageVO.getScreenMode().equals("N"))
      if (EnrgiseUtil.checkString(oHrmAttWorkGroupDayOffHdrBean.getSiteCode()) && EnrgiseUtil.checkString(oHrmAttWorkGroupDayOffHdrBean.getWorkGroupCode()))
        arylstEnableList.add("butAddRow");  
    if (oThisPageVO.getScreenMode().equalsIgnoreCase("U"))
      arylstEnableList.add("butSave"); 
    oHashMap.put("D", arylstDisableList);
    oHashMap.put("E", arylstEnableList);
    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("");
  }
}
