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.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.HrmRecApplnMtnHdrBean;
import wenrgise.hrms.businessdelegate.HrmBaseBD;
import wenrgise.hrms.ejb.facade.HrmSecondFacade;
import wenrgise.hrms.ejb.facade.HrmSecondFacadeHome;
import wenrgise.hrms.vo.HrmRecApplnMtnQVO;

public class HrmRecApplnMtnBD extends HrmBaseBD {
  public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oHrmSecondFacade = oHome.create();
      return oHrmSecondFacade.getHrmRecApplnMtnHdrMetaInfo((HrmRecApplnMtnQVO)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 {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oHrmSecondFacade = oHome.create();
      ArrayList oHeaderList = oHrmSecondFacade.getHrmRecApplnMtnHeaderInfo((HrmRecApplnMtnQVO)oQueryVO, lStartPosition, lLastPosition);
      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 {
    try {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oHrmSecondFacade = oHome.create();
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnAddDtl"))
        return oHrmSecondFacade.getHrmRecApplnAddDtlMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnLangDtl"))
        return oHrmSecondFacade.getHrmRecApplnLangDtlMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnEduDtl"))
        return oHrmSecondFacade.getHrmRecApplnEduDtlMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnExpDtl"))
        return oHrmSecondFacade.getHrmRecApplnExpDtlMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnResultDtl"))
        return oHrmSecondFacade.getHrmRecApplnResultDtlMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnOtherDtl"))
        return oHrmSecondFacade.getHrmRecApplnOtherDtlMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnRef"))
        return oHrmSecondFacade.getHrmRecApplnRefMetaInfo(lPrimaryKey); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnTrngDtls"))
        return oHrmSecondFacade.getHrmRecApplnTrngDtlsMetaInfo(lPrimaryKey); 
      RecordMetaInfo obj = new RecordMetaInfo();
      return obj;
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  public ArrayList getDetailRecordImpl(String lPrimaryKey, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oHrmSecondFacade = oHome.create();
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnAddDtl"))
        return oHrmSecondFacade.getHrmRecApplnAddDtl(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnLangDtl"))
        return oHrmSecondFacade.getHrmRecApplnLangDtl(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnEduDtl"))
        return oHrmSecondFacade.getHrmRecApplnEduDtl(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnExpDtl"))
        return oHrmSecondFacade.getHrmRecApplnExpDtl(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnResultDtl"))
        return oHrmSecondFacade.getHrmRecApplnResultDtl(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnOtherDtl"))
        return oHrmSecondFacade.getHrmRecApplnOtherDtl(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnRef"))
        return oHrmSecondFacade.getHrmRecApplnRef(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnTrngDtls"))
        return oHrmSecondFacade.getHrmRecApplnTrngDtls(lPrimaryKey, lAbsoluteStart, lAbsoluteEnd); 
      ArrayList obj = new ArrayList();
      return obj;
    } 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 {
    System.out.println(String.valueOf("header when picked=").concat(String.valueOf(oWhenPicked)));
    System.out.println(String.valueOf("Detail when picked=").concat(String.valueOf(oDetailPicked)));
    oWhenPicked = oDetailPicked;
    System.out.println(oWhenPicked);
    System.out.println(oDetailPicked);
    try {
      HrmSecondFacadeHome oHome = (HrmSecondFacadeHome)ServiceLocator.getLocator().getService("HrmSecondFacade");
      HrmSecondFacade oHrmSecondFacade = oHome.create();
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnAddDtl"))
        return oHrmSecondFacade.saveHrmRecApplnAddDtl((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnExpDtl"))
        return oHrmSecondFacade.saveHrmRecApplnExpDtl((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnEduDtl"))
        return oHrmSecondFacade.saveHrmRecApplnEduDtl((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnLangDtl"))
        return oHrmSecondFacade.saveHrmRecApplnLangDtl((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnOtherDtl"))
        return oHrmSecondFacade.saveHrmRecApplnOtherDtl((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnResultDtl"))
        return oHrmSecondFacade.saveHrmRecApplnResultDtl((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnRef"))
        return oHrmSecondFacade.saveHrmRecApplnRef((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
      if (sScreenName.equalsIgnoreCase("HrmRecApplnMtnTrngDtls"))
        return oHrmSecondFacade.saveHrmRecApplnTrngDtls((HrmRecApplnMtnHdrBean)oBaseHeaderBean, oWhenPicked, sScreenName, sScreenMode, bHeaderDataChanged, oDetailBeanArray, bDetailDataChanged, oDetailPicked, this.oUserInfo); 
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
    return null;
  }
  
  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 arylstEnab = new ArrayList();
    ArrayList arylstDisab = new ArrayList();
    HrmRecApplnMtnHdrBean oHrmRecApplnMtnHdrBean = (HrmRecApplnMtnHdrBean)oThisPageVO.getOHeaderBean();
    if (oThisPageVO.getScreenMode().equals("Q")) {
      arylstDisab.add("applicationNo");
      arylstDisab.add("butApplicationDate");
      arylstDisab.add("butApplicationDate");
      arylstDisab.add("butReferenceNo");
      arylstDisab.add("applicantFirstName");
      arylstDisab.add("applicantMiddleName");
      arylstDisab.add("applicantLastName");
      arylstDisab.add("butApplForDesignation");
      arylstDisab.add("rollNo");
      if (oThisPageVO.getScreenName().equals("HrmRecApplnMtnAddDtl")) {
        arylstDisab.add("guardianName");
        arylstDisab.add("butDateOfBirth");
        arylstDisab.add("placeOfBirth");
        arylstDisab.add("butNationality");
        arylstDisab.add("butMaritalStatus");
        arylstDisab.add("sex");
        arylstDisab.add("relatedToEmp");
        arylstDisab.add("butMotherTongue");
        arylstDisab.add("butRelatedEmp");
        arylstDisab.add("butReligion");
        arylstDisab.add("handicappedFlag");
        arylstDisab.add("healthRecord");
        arylstDisab.add("bloodGroup");
        arylstDisab.add("appliedEarlier");
        arylstDisab.add("mail");
        arylstDisab.add("butReservationCategory");
        arylstDisab.add("prevEmpFlag");
        arylstDisab.add("prevEmpDtls");
        arylstDisab.add("hobbies");
        arylstDisab.add("grossExpected");
        arylstDisab.add("addlInfo");
        arylstDisab.add("butPresCountry");
        arylstDisab.add("butPresState");
        arylstDisab.add("presCity");
        arylstDisab.add("presAddress");
        arylstDisab.add("presPin");
        arylstDisab.add("presPhone");
        arylstDisab.add("butPermCountry");
        arylstDisab.add("butPermState");
        arylstDisab.add("permAddress");
        arylstDisab.add("permCity");
        arylstDisab.add("permAddress");
        arylstDisab.add("permPin");
        arylstDisab.add("permPhone");
        arylstDisab.add("passportNo");
        arylstDisab.add("placeOfIssue");
        arylstDisab.add("butExpiryDate");
        arylstDisab.add("butIssueDate");
        arylstDisab.add("butSubmissionDate");
        arylstDisab.add("chequeNo");
        arylstDisab.add("submittedAmount");
        arylstDisab.add("submissionDate");
        arylstDisab.add("arrestedBefore");
        arylstDisab.add("imprisonedBefore");
        arylstDisab.add("reasons");
        arylstDisab.add("prosecutedBefore");
        arylstDisab.add("finedByCourt");
      } 
    } 
    if (oThisPageVO.getScreenMode().equals("N")) {
      arylstEnab.add("applicationNo");
      arylstDisab.add("butApplicationNo");
      arylstEnab.add("butApplicationDate");
      arylstEnab.add("butReferenceNo");
      arylstEnab.add("applicantFirstName");
      arylstEnab.add("applicantMiddleName");
      arylstEnab.add("applicantLastName");
      arylstDisab.add("rollNo");
      if (!EnrgiseUtil.checkString(oHrmRecApplnMtnHdrBean.getReferenceNo())) {
        arylstDisab.add("butApplForDesignation");
      } else {
        arylstEnab.add("butApplForDesignation");
      } 
      if (oThisPageVO.getScreenName().equals("HrmRecApplnMtnAddDtl")) {
        arylstEnab.add("guardianName");
        arylstEnab.add("butDateOfBirth");
        arylstEnab.add("placeOfBirth");
        arylstEnab.add("butNationality");
        arylstEnab.add("butMaritalStatus");
        arylstEnab.add("sex");
        arylstEnab.add("relatedToEmp");
        arylstEnab.add("butMotherTongue");
        arylstEnab.add("butRelatedEmp");
        arylstEnab.add("butReligion");
        arylstEnab.add("handicappedFlag");
        arylstEnab.add("healthRecord");
        arylstEnab.add("bloodGroup");
        arylstEnab.add("appliedEarlier");
        arylstEnab.add("mail");
        arylstEnab.add("butReservationCategory");
        arylstEnab.add("prevEmpFlag");
        arylstEnab.add("prevEmpDtls");
        arylstEnab.add("hobbies");
        arylstEnab.add("grossExpected");
        arylstEnab.add("addlInfo");
        arylstEnab.add("butPresCountry");
        arylstEnab.add("butPresState");
        arylstEnab.add("presCity");
        arylstEnab.add("presAddress");
        arylstEnab.add("presPin");
        arylstEnab.add("presPhone");
        arylstEnab.add("butPermCountry");
        arylstEnab.add("butPermState");
        arylstEnab.add("permAddress");
        arylstEnab.add("permCity");
        arylstEnab.add("permAddress");
        arylstEnab.add("permPin");
        arylstEnab.add("permPhone");
        arylstEnab.add("passportNo");
        arylstEnab.add("placeOfIssue");
        arylstEnab.add("butExpiryDate");
        arylstEnab.add("butIssueDate");
        arylstEnab.add("butSubmissionDate");
        arylstEnab.add("chequeNo");
        arylstEnab.add("submittedAmount");
        arylstEnab.add("submissionDate");
        arylstEnab.add("arrestedBefore");
        arylstEnab.add("imprisonedBefore");
        arylstEnab.add("reasons");
        arylstEnab.add("prosecutedBefore");
        arylstEnab.add("finedByCourt");
      } 
    } 
    if (oThisPageVO.getScreenMode().equals("U")) {
      arylstDisab.add("applicationNo");
      arylstDisab.add("butApplicationNo");
      arylstDisab.add("butApplicationDate");
      arylstDisab.add("butReferenceNo");
      arylstEnab.add("applicantFirstName");
      arylstEnab.add("applicantMiddleName");
      arylstEnab.add("applicantLastName");
      arylstDisab.add("rollNo");
      arylstDisab.add("butApplForDesignation");
      if (oThisPageVO.getScreenName().equals("HrmRecApplnMtnAddDtl"))
        if (oThisPageVO.getODetailList() != null) {
          arylstEnab.add("guardianName");
          arylstEnab.add("butDateOfBirth");
          arylstEnab.add("placeOfBirth");
          arylstEnab.add("butNationality");
          arylstEnab.add("butMaritalStatus");
          arylstEnab.add("sex");
          arylstEnab.add("relatedToEmp");
          arylstEnab.add("butMotherTongue");
          arylstEnab.add("butRelatedEmp");
          arylstEnab.add("butReligion");
          arylstEnab.add("handicappedFlag");
          arylstEnab.add("healthRecord");
          arylstEnab.add("bloodGroup");
          arylstEnab.add("appliedEarlier");
          arylstEnab.add("mail");
          arylstEnab.add("butReservationCategory");
          arylstEnab.add("prevEmpFlag");
          arylstEnab.add("prevEmpDtls");
          arylstEnab.add("hobbies");
          arylstEnab.add("grossExpected");
          arylstEnab.add("addlInfo");
          arylstEnab.add("butPresCountry");
          arylstEnab.add("butPresState");
          arylstEnab.add("presCity");
          arylstEnab.add("presAddress");
          arylstEnab.add("presPin");
          arylstEnab.add("presPhone");
          arylstEnab.add("butPermCountry");
          arylstEnab.add("butPermState");
          arylstEnab.add("permAddress");
          arylstEnab.add("permCity");
          arylstEnab.add("permAddress");
          arylstEnab.add("permPin");
          arylstEnab.add("permPhone");
          arylstEnab.add("passportNo");
          arylstEnab.add("placeOfIssue");
          arylstEnab.add("butExpiryDate");
          arylstEnab.add("butIssueDate");
          arylstEnab.add("butSubmissionDate");
          arylstEnab.add("chequeNo");
          arylstEnab.add("submittedAmount");
          arylstEnab.add("submissionDate");
          arylstEnab.add("arrestedBefore");
          arylstEnab.add("imprisonedBefore");
          arylstEnab.add("reasons");
          arylstEnab.add("prosecutedBefore");
          arylstEnab.add("finedByCourt");
        } else {
          arylstDisab.add("guardianName");
          arylstDisab.add("butDateOfBirth");
          arylstDisab.add("placeOfBirth");
          arylstDisab.add("butNationality");
          arylstDisab.add("butMaritalStatus");
          arylstDisab.add("sex");
          arylstDisab.add("relatedToEmp");
          arylstDisab.add("butMotherTongue");
          arylstDisab.add("butRelatedEmp");
          arylstDisab.add("butReligion");
          arylstDisab.add("handicappedFlag");
          arylstDisab.add("healthRecord");
          arylstDisab.add("bloodGroup");
          arylstDisab.add("appliedEarlier");
          arylstDisab.add("mail");
          arylstDisab.add("butReservationCategory");
          arylstDisab.add("prevEmpFlag");
          arylstDisab.add("prevEmpDtls");
          arylstDisab.add("hobbies");
          arylstDisab.add("grossExpected");
          arylstDisab.add("addlInfo");
          arylstDisab.add("butPresCountry");
          arylstDisab.add("butPresState");
          arylstDisab.add("presCity");
          arylstDisab.add("presAddress");
          arylstDisab.add("presPin");
          arylstDisab.add("presPhone");
          arylstDisab.add("butPermCountry");
          arylstDisab.add("butPermState");
          arylstDisab.add("permAddress");
          arylstDisab.add("permCity");
          arylstDisab.add("permAddress");
          arylstDisab.add("permPin");
          arylstDisab.add("permPhone");
          arylstDisab.add("passportNo");
          arylstDisab.add("placeOfIssue");
          arylstDisab.add("butExpiryDate");
          arylstDisab.add("butIssueDate");
          arylstDisab.add("butSubmissionDate");
          arylstDisab.add("chequeNo");
          arylstDisab.add("submittedAmount");
          arylstDisab.add("submissionDate");
          arylstDisab.add("arrestedBefore");
          arylstDisab.add("imprisonedBefore");
          arylstDisab.add("reasons");
          arylstDisab.add("prosecutedBefore");
          arylstDisab.add("finedByCourt");
        }  
    } 
    oHashMap.put("E", arylstEnab);
    oHashMap.put("D", arylstDisab);
    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("");
  }
}
