package WEB-INF.classes.wenrgise.hrms.businessdelegate;

import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
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.HrmAdvSettleHeadsDtlBean;
import wenrgise.hrms.bean.HrmAdvSettleHeadsHdrBean;
import wenrgise.hrms.businessdelegate.HrmBaseBD;
import wenrgise.hrms.ejb.facade.HrmFacade;
import wenrgise.hrms.ejb.facade.HrmFacadeHome;
import wenrgise.hrms.vo.HrmAdvSettleHeadsQVO;

public class HrmAdvSettleHeadsBD extends HrmBaseBD {
  public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public ArrayList getHeaderRecordImpl(BaseQueryVO oQueryVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public RecordMetaInfo getTotalDetailRecordCountImpl(BaseQueryVO oBaseQueryVO, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmFacade oHrmFacade = (HrmFacade)getModuleFacade();
      return oHrmFacade.getHrAdvSettleHeadsDetailMetaInfo((HrmAdvSettleHeadsQVO)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 {
      HrmFacade oHrmFacade = (HrmFacade)getModuleFacade();
      return oHrmFacade.getHrAdvSettleHeadsDetail((HrmAdvSettleHeadsQVO)oBaseQueryVO, lAbsoluteStart, lAbsoluteEnd);
    } 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 getInsertDataImpl(BaseQueryVO oQueryVO) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return "Only Implementation";
  }
  
  public Map getDisabledFieldsImpl(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    HashMap oHashMap = new HashMap();
    ArrayList arylstEnableList = new ArrayList();
    ArrayList arylstDisableList = new ArrayList();
    ArrayList oList = oThisPageVO.getODetailList();
    HrmAdvSettleHeadsHdrBean oHrmAdvSettleHeadsHdrBean = (HrmAdvSettleHeadsHdrBean)oThisPageVO.getOHeaderBean();
    Iterator oIt = oList.iterator();
    HrmAdvSettleHeadsDtlBean oHrmAdvSettleHeadsDtlBean = null;
    while (oIt.hasNext()) {
      oHrmAdvSettleHeadsDtlBean = oIt.next();
      if (oHrmAdvSettleHeadsDtlBean.getTxtSettleStatus() == null || oHrmAdvSettleHeadsDtlBean.getTxtSettleStatus().equalsIgnoreCase("N")) {
        arylstEnableList.add("txtAmount");
        continue;
      } 
      if (oHrmAdvSettleHeadsDtlBean.getTxtSettleStatus().equalsIgnoreCase("A") || oHrmAdvSettleHeadsDtlBean.getTxtSettleStatus().equalsIgnoreCase("P") || oHrmAdvSettleHeadsDtlBean.getTxtSettleStatus().equalsIgnoreCase("R"))
        arylstDisableList.add("txtAmount"); 
    } 
    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("");
  }
  
  public String saveImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmFacadeHome oHome = (HrmFacadeHome)ServiceLocator.getLocator().getService("HrmFacade");
      HrmFacade oHrmFacade = oHome.create();
      return oHrmFacade.saveHrmAdvSettleHds(oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo);
    } catch (CreateException oCrtExcep) {
      throw new EnrgiseSystemException(oCrtExcep);
    } 
  }
}
