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

public class HrmAttEmployeeShiftRosterBD extends HrmBaseBD {
  public RecordMetaInfo getTotalDetailRecordCountImpl(BaseQueryVO oBaseQueryVO, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oEmpShiftRosterFacade = oHome.create();
      return oEmpShiftRosterFacade.getAttEmpshiftRosterDetailMetaInfo((HrmAttEmpShiftRosterQVO)oBaseQueryVO);
    } catch (RemoteException oRe) {
      System.out.println(oRe.getMessage());
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      System.out.println(oCrt.getMessage());
      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("HrmAttEmpShiftRoster"))
        return oHrmSecondFacade.getAttEmpshiftRosterDetail((HrmAttEmpShiftRosterQVO)oBaseQueryVO, lAbsoluteStart, lAbsoluteEnd); 
      return null;
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  public RecordMetaInfo getTotalDetailRecordCountImpl(String sPrimaryKey, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public ArrayList getDetailRecordImpl(String sPrimaryKey, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public String saveImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public boolean updateHeaderRecordImpl(BaseHeaderBean oBaseHeaderBean) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return true;
  }
  
  public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    return new RecordMetaInfo();
  }
  
  public ArrayList getHeaderRecordImpl(BaseQueryVO oQueryVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return new ArrayList();
  }
  
  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 String getInsertDataImpl(BaseQueryVO oBaseQueryVO) 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();
    oDisableList.add("butExecute");
    oDisableList.add("butDelete");
    oDisableList.add("butAddRow");
    oDisableList.add("butDelRow");
    oDisableList.add("butSave");
    oDisableList.add("butInsert");
    if (oThisPageVO.getScreenMode().equalsIgnoreCase("Q")) {
      oDisableList.add("butAddRow");
      oDisableList.add("butDelRow");
      oEnableList.add("butGetDetail");
    } 
    if (oThisPageVO.getScreenMode().equalsIgnoreCase("U")) {
      oDisableList.add("butAddRow");
      oDisableList.add("butDelRow");
      oDisableList.add("butWorkGrpCode");
      oDisableList.add("butEmpNo");
      oDisableList.add("butSiteId");
      oDisableList.add("butperiodStartDate");
      oDisableList.add("butperiodEndDate");
      oEnableList.add("butQuery");
    } 
    oHashMap.put("D", oDisableList);
    oHashMap.put("E", oEnableList);
    return oHashMap;
  }
}
