package wenrgise.hrms.ejb.business;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.bean.LOVBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseMessageKeyException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.DateUtility;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.MessageKey;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.vo.BaseDetailVO;
import wenrgise.common.vo.BaseHeaderVO;
import wenrgise.common.vo.LovQueryVO;
import wenrgise.common.vo.LovVO;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.hrms.bean.HrmMediclaimMasterDtlBean;
import wenrgise.hrms.bean.HrmMediclaimMasterHdrBean;
import wenrgise.hrms.vo.HrmMediclaimMasterQVO;

public class HrmMediclaimMasterBO extends HrmBaseBO {
  public HrmMediclaimMasterBO() {}
  
  public HrmMediclaimMasterBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrmMediclaimMasterHeaderMetaInfo(HrmMediclaimMasterQVO oHrmMediclaimMasterQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    String pKey = oHrmMediclaimMasterQVO.getHeaderPrimaryKey();
    String cadreId = oHrmMediclaimMasterQVO.getTxtCadreId();
    String classID = oHrmMediclaimMasterQVO.getTxtClassId();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, oHrmMediclaimMasterQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(2, 1, 12, oHrmMediclaimMasterQVO.getTxtClassId()));
    arylstParam.add(new DBObject(3, 1, 12, oHrmMediclaimMasterQVO.getTxtCadreId()));
    arylstParam.add(new DBObject(4, 2, -5));
    arylstParam.add(new DBObject(5, 2, 93));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 4));
    ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.prochrmedimsthdrcount(?,?,?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTimeObject = oOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    DBObject oTotalRecord = oOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrmMediclaimMasterHeaderInfo(HrmMediclaimMasterQVO oHrmMediclaimMasterQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    String pKey = oHrmMediclaimMasterQVO.getHeaderPrimaryKey();
    String cadreId = oHrmMediclaimMasterQVO.getTxtCadreId();
    String classID = oHrmMediclaimMasterQVO.getTxtClassId();
    ArrayList oHeaderList = null;
    if (oHrmMediclaimMasterQVO == null)
      oHrmMediclaimMasterQVO = new HrmMediclaimMasterQVO(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, -5, new Long(lStartPosition)));
    arylstParam.add(new DBObject(2, 1, -5, new Long(lLastPosition)));
    arylstParam.add(new DBObject(3, 1, 12, oHrmMediclaimMasterQVO.getHeaderPrimaryKey()));
    arylstParam.add(new DBObject(4, 1, 12, oHrmMediclaimMasterQVO.getTxtCadreId()));
    arylstParam.add(new DBObject(5, 1, 12, oHrmMediclaimMasterQVO.getTxtClassId()));
    arylstParam.add(new DBObject(6, 2, -10));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 12));
    arylstParam.add(new DBObject(9, 2, 4));
    ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.procgethrmedimsthdr(?,?,?,?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    if (oList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator oIt = oList.iterator();
    while (oIt.hasNext()) {
      boolean all;
      if (count == 0)
        oHeaderList = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmMediclaimMasterHdrBean oHrmMediclaimMasterHdrBean = new HrmMediclaimMasterHdrBean();
      oHrmMediclaimMasterHdrBean.setHeaderPrimaryKey(oRow.get("ID").getString());
      oHrmMediclaimMasterHdrBean.setClaimCode(oRow.get("CLAIM_CODE").getString());
      oHrmMediclaimMasterHdrBean.setTxtClassId(oRow.get("CLASS_ID").getString());
      oHrmMediclaimMasterHdrBean.setTxtCadreId(oRow.get("CADRE_ID").getString());
      oHrmMediclaimMasterHdrBean.setTxtClass(oRow.get("CLASS").getString());
      oHrmMediclaimMasterHdrBean.setCadre(oRow.get("CADRE").getString());
      oHrmMediclaimMasterHdrBean.setAllEmployeeApplicable(oRow.get("ALL_FLAG").getString());
      String allFlag = oRow.get("ALL_FLAG").getString();
      allFlag = allFlag.trim();
      if (allFlag.equalsIgnoreCase("on")) {
        all = true;
      } else {
        all = false;
      } 
      oHrmMediclaimMasterHdrBean.setAllEmp(all);
      oHrmMediclaimMasterHdrBean.setDependents(oRow.get("DEPENDENTS").getString());
      oHeaderList.add(oHrmMediclaimMasterHdrBean);
    } 
    return oHeaderList;
  }
  
  public RecordMetaInfo getHrmMediclaimMasterDetailMetaInfo(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, lPrimaryKey));
    arylstParam.add(new DBObject(2, 2, -5));
    arylstParam.add(new DBObject(3, 2, 93));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.prochrmedimstdtlcount(?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTotalRecord = oOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    DBObject oTimeObject = oOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrmMediclaimMasterDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList oHrmMediMstDetail = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
    arylstParam.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
    arylstParam.add(new DBObject(3, 1, 12, lPrimaryKey));
    arylstParam.add(new DBObject(4, 2, -10));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 4));
    ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.procgethrmedimstdtl(?,?,?,?,?,?,?)");
    DBObject oOutObject = oOutArray.get(0);
    ArrayList oList = (ArrayList)oOutObject.getObject();
    if (oList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
    Iterator oIt = oList.iterator();
    while (oIt.hasNext()) {
      if (count == 0)
        oHrmMediMstDetail = new ArrayList(); 
      count++;
      oRow = oIt.next();
      HrmMediclaimMasterDtlBean oHrmMediclaimMasterDtlBean = new HrmMediclaimMasterDtlBean();
      oHrmMediclaimMasterDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmMediclaimMasterDtlBean.setCoverName(oRow.get("COVER_NAME").getString());
      oHrmMediclaimMasterDtlBean.setSumInsured(oRow.get("SUM_INSURED").getString());
      oHrmMediclaimMasterDtlBean.setSalaryUnit(oRow.get("SAL_LIMIT").getString());
      oHrmMediclaimMasterDtlBean.setPremium(oRow.get("PREMIUM").getString());
      oHrmMediclaimMasterDtlBean.setAgeFrom(oRow.get("AGE_FROM").getString());
      oHrmMediclaimMasterDtlBean.setAgeTo(oRow.get("AGE_TO").getString());
      oHrmMediclaimMasterDtlBean.setAicContribution(oRow.get("AIC_CONTR").getString());
      oHrmMediclaimMasterDtlBean.setDocumentRequired(oRow.get("DOC_REQ").getString());
      oHrmMediMstDetail.add(oHrmMediclaimMasterDtlBean);
    } 
    return oHrmMediMstDetail;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_MDCLAIM_MST";
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmMediclaimMasterHdrBean oHrmMediclaimMasterHdrBean = (HrmMediclaimMasterHdrBean)oBaseHeaderBean;
    String taxReb = null;
    String priTaxReb = null;
    String settAuto = null;
    if (ScreenMode.equalsIgnoreCase("N")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "N"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmMediclaimMasterHdrBean.getClaimCode()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmMediclaimMasterHdrBean.getTxtClassId()));
      arylstParam.add(new DBObject(4, 1, 12, oHrmMediclaimMasterHdrBean.getTxtCadreId()));
      arylstParam.add(new DBObject(5, 1, 12, oHrmMediclaimMasterHdrBean.getAllEmployeeApplicable()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmMediclaimMasterHdrBean.getDependents()));
      arylstParam.add(new DBObject(7, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParam.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(9, 1, 12, null));
      arylstParam.add(new DBObject(10, 2, 12));
      arylstParam.add(new DBObject(11, 2, 12));
      arylstParam.add(new DBObject(12, 2, 12));
      arylstParam.add(new DBObject(13, 2, 4));
      ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.procupserthrmedimsthdr(?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = oOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "U"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmMediclaimMasterHdrBean.getClaimCode()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmMediclaimMasterHdrBean.getTxtClassId()));
      arylstParam.add(new DBObject(4, 1, 12, oHrmMediclaimMasterHdrBean.getTxtCadreId()));
      arylstParam.add(new DBObject(5, 1, 12, oHrmMediclaimMasterHdrBean.getAllEmployeeApplicable()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmMediclaimMasterHdrBean.getDependents()));
      arylstParam.add(new DBObject(7, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParam.add(new DBObject(8, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(9, 1, 12, oHrmMediclaimMasterHdrBean.getHeaderPrimaryKey()));
      arylstParam.add(new DBObject(10, 2, 12));
      arylstParam.add(new DBObject(11, 2, 12));
      arylstParam.add(new DBObject(12, 2, 12));
      arylstParam.add(new DBObject(13, 2, 4));
      ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.procupserthrmedimsthdr(?,?,?,?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = oOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } else if (ScreenMode.equalsIgnoreCase("D")) {
      arylstParam.add(new DBObject(1, 1, 12, oHrmMediclaimMasterHdrBean.getHeaderPrimaryKey()));
      arylstParam.add(new DBObject(2, 2, 12));
      arylstParam.add(new DBObject(3, 2, 12));
      arylstParam.add(new DBObject(4, 2, 4));
      ArrayList oOutArray = oBean.callProc(arylstParam, "HRMMEDIMST.procdeletehrmmedimsthdr(?,?,?,?)");
      DBObject oOutObject = oOutArray.get(0);
      returnString = null;
    } 
    return returnString;
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmMediclaimMaster"))
      saveHrmMediMstDetail(sHeaderPrimaryKey, oDetailBeanArray); 
  }
  
  private void saveHrmMediMstDetail(String sHeaderPrimaryKey, ArrayList oDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    String applToEmp = null;
    Iterator oIt = oDetailBeanArray.iterator();
    while (oIt.hasNext()) {
      HrmMediclaimMasterDtlBean oHrmMediclaimMasterDtlBean = oIt.next();
      if (oHrmMediclaimMasterDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMMEDIMST.procupserthrmedimstdtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "N"));
        arylstParam.add(new DBObject(2, 1, 12, null));
        arylstParam.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
        arylstParam.add(new DBObject(4, 1, 12, "200"));
        arylstParam.add(new DBObject(5, 1, 12, oHrmMediclaimMasterDtlBean.getCoverName()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmMediclaimMasterDtlBean.getSumInsured()));
        arylstParam.add(new DBObject(7, 1, 12, oHrmMediclaimMasterDtlBean.getSalaryUnit()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmMediclaimMasterDtlBean.getPremium()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmMediclaimMasterDtlBean.getAgeFrom()));
        arylstParam.add(new DBObject(10, 1, 12, oHrmMediclaimMasterDtlBean.getAgeTo()));
        arylstParam.add(new DBObject(11, 1, 12, oHrmMediclaimMasterDtlBean.getAicContribution()));
        arylstParam.add(new DBObject(12, 1, 12, oHrmMediclaimMasterDtlBean.getDocumentRequired()));
        arylstParam.add(new DBObject(13, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParam.add(new DBObject(14, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
        continue;
      } 
      if (oHrmMediclaimMasterDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMMEDIMST.procupserthrmedimstdtl(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, "U"));
        arylstParam.add(new DBObject(2, 1, 12, oHrmMediclaimMasterDtlBean.getDetailId()));
        arylstParam.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
        arylstParam.add(new DBObject(4, 1, 12, "200"));
        arylstParam.add(new DBObject(5, 1, 12, oHrmMediclaimMasterDtlBean.getCoverName()));
        arylstParam.add(new DBObject(6, 1, 12, oHrmMediclaimMasterDtlBean.getSumInsured()));
        arylstParam.add(new DBObject(7, 1, 12, oHrmMediclaimMasterDtlBean.getSalaryUnit()));
        arylstParam.add(new DBObject(8, 1, 12, oHrmMediclaimMasterDtlBean.getPremium()));
        arylstParam.add(new DBObject(9, 1, 12, oHrmMediclaimMasterDtlBean.getAgeFrom()));
        arylstParam.add(new DBObject(10, 1, 12, oHrmMediclaimMasterDtlBean.getAgeTo()));
        arylstParam.add(new DBObject(11, 1, 12, oHrmMediclaimMasterDtlBean.getAicContribution()));
        arylstParam.add(new DBObject(12, 1, 12, oHrmMediclaimMasterDtlBean.getDocumentRequired()));
        arylstParam.add(new DBObject(13, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParam.add(new DBObject(14, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParam);
        continue;
      } 
      if (oHrmMediclaimMasterDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("HRMMEDIMST.procdeletemedimstdtl(?)");
          bDelete = true;
        } 
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, oHrmMediclaimMasterDtlBean.getDetailId()));
        oBean1.addToBatch(arylstParam);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bUpdate)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {}
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return new String();
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    HrmMediclaimMasterHdrBean oHrmMediclaimMasterHdrBean = (HrmMediclaimMasterHdrBean)oBaseHeaderBean;
    if (bHeaderDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        checkMandatoryHeader((HrmMediclaimMasterHdrBean)oBaseHeaderBean);  
    if (bDetailDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        if (sScreenName.equalsIgnoreCase("HrmMediclaimMaster")) {
          Iterator oIt1 = oDetailBeanArray.iterator();
          int rowCount = 1;
          while (oIt1.hasNext()) {
            HrmMediclaimMasterDtlBean oHrmMediclaimMasterDtlBean = oIt1.next();
            if (!oHrmMediclaimMasterDtlBean.getStatus().equalsIgnoreCase("D"))
              checkMandatoryDtls(oHrmMediclaimMasterDtlBean, rowCount, oErrorList); 
            rowCount++;
          } 
        }   
    reportError(oErrorList);
  }
  
  private void checkMandatoryHeader(HrmMediclaimMasterHdrBean oHrmMediclaimMasterHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oErrorList = new ArrayList();
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterHdrBean.getClaimCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.claimCode");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterHdrBean.getTxtClass())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.txtClass");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterHdrBean.getCadre())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.cadre");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterHdrBean.getDependents())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.dependents");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    reportError(oErrorList);
  }
  
  private void checkMandatoryDtls(HrmMediclaimMasterDtlBean oHrmMediclaimMasterDtlBean, int rowCount, ArrayList oErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getCoverName())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.coverName");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getSumInsured())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.sumInsured");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getSumInsured())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.sumInsured");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getSalaryUnit())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.salaryUnit");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getPremium())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.premium");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getAgeFrom())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.ageFrom");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getAgeTo())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.ageTo");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getAicContribution())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.aicContribution");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmMediclaimMasterDtlBean.getDocumentRequired())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmMediclaimMaster.documentRequired");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(rowCount));
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    reportError(oErrorList);
  }
  
  public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public void additionalBusinessValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {}
  
  public LovVO getHrmMediClassLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("txtClassId");
    arylstHeaderList.add("hrm.HrmMediclaimMaster.txtClass");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 2, -10));
    arylstParam.add(new DBObject(3, 2, 12));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMADVMST.proc_getClassLovData(?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("NAME").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
  
  public LovVO getHrmMediCadreLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("txtClassId");
    arylstHeaderList.add("hrm.HrmMediclaimMaster.txtClass");
    arylstHeaderList.add("hrm.HrmMediclaimMaster.cadre");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParam.add(new DBObject(3, 2, -10));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMADVMST.proc_getCadreLovData(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    arylstParam = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstParam.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstParam = new ArrayList(); 
      count++;
      oRow = (QueryRow)iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("NAME").getString());
      oLOVBean.setDetailField3(oRow.get("CODE").getString());
      arylstParam.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstParam);
    return oLovVO;
  }
}
