package wenrgise.hrms.ejb.business;

import java.sql.Timestamp;
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.HrmOrgSkillMstDtlBean;
import wenrgise.hrms.bean.HrmOrgSkillMstHdrBean;
import wenrgise.hrms.vo.HrmOrgSkillMstQVO;

public class HrmOrgSkillMstBO extends HrmBaseBO {
  public HrmOrgSkillMstBO() {}
  
  public HrmOrgSkillMstBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getHrmSkillHdrMetaInfo(HrmOrgSkillMstQVO oHrmOrgSkillMstQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, oHrmOrgSkillMstQVO.getHeaderPrimaryKey()));
    arylstParameters.add(new DBObject(2, 1, 12, oHrmOrgSkillMstQVO.getSkillTypeCode()));
    arylstParameters.add(new DBObject(3, 2, -5));
    arylstParameters.add(new DBObject(4, 2, 93));
    arylstParameters.add(new DBObject(5, 2, 12));
    arylstParameters.add(new DBObject(6, 2, 12));
    arylstParameters.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSKILLMST.proc_HrSkillHdrCount(?,?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTimeObject = arylstOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    DBObject oTotalRecord = arylstOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrmSkillHeaderInfo(HrmOrgSkillMstQVO oHrmOrgSkillMstQVO, long lStartPosition, long lLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    Timestamp oWhenPicked = null;
    int count = 0;
    BaseHeaderVO oBaseHeaderVO = new BaseHeaderVO();
    ArrayList arylstHeaderList = null;
    if (oHrmOrgSkillMstQVO == null)
      oHrmOrgSkillMstQVO = new HrmOrgSkillMstQVO(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, -5, new Long(lStartPosition)));
    arylstParameters.add(new DBObject(2, 1, -5, new Long(lLastPosition)));
    arylstParameters.add(new DBObject(3, 1, 12, oHrmOrgSkillMstQVO.getHeaderPrimaryKey()));
    arylstParameters.add(new DBObject(4, 1, 12, oHrmOrgSkillMstQVO.getSkillTypeCode()));
    arylstParameters.add(new DBObject(5, 2, -10));
    arylstParameters.add(new DBObject(6, 2, 12));
    arylstParameters.add(new DBObject(7, 2, 12));
    arylstParameters.add(new DBObject(8, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSKILLMST.proc_GetHrSkillHdr(?,?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstList.iterator();
    while (itrBean.hasNext()) {
      if (count == 0)
        arylstHeaderList = new ArrayList(); 
      count++;
      oRow = itrBean.next();
      HrmOrgSkillMstHdrBean oSkillHeader = new HrmOrgSkillMstHdrBean();
      oSkillHeader.setHeaderPrimaryKey(oRow.get("ID").getString());
      oSkillHeader.setSkillTypeCode(oRow.get("CODE").getString());
      oSkillHeader.setSkillTypeName(oRow.get("NAME").getString());
      arylstHeaderList.add(oSkillHeader);
    } 
    return arylstHeaderList;
  }
  
  public RecordMetaInfo getHrmSkillDtlMetaInfo(String lPrimaryKey) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, lPrimaryKey));
    arylstParameters.add(new DBObject(2, 2, -5));
    arylstParameters.add(new DBObject(3, 2, 93));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 12));
    arylstParameters.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSKILLMST.proc_HrSkillDtlCount(?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTotalRecord = arylstOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    DBObject oTimeObject = arylstOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrmSkillDetailInfo(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    BaseDetailVO oBaseDetailVO = null;
    ArrayList arylstHrmSkillDetail = null;
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
    arylstParameters.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
    arylstParameters.add(new DBObject(3, 1, 12, lPrimaryKey));
    arylstParameters.add(new DBObject(4, 2, -10));
    arylstParameters.add(new DBObject(5, 2, 12));
    arylstParameters.add(new DBObject(6, 2, 12));
    arylstParameters.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSKILLMST.proc_GetHrSkillDtl(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    QueryRow oRow = null;
    QueryValue oValue = null;
    HashMap oColumns = null;
    Iterator itrBean = arylstList.iterator();
    while (itrBean.hasNext()) {
      if (count == 0)
        arylstHrmSkillDetail = new ArrayList(); 
      count++;
      oRow = itrBean.next();
      HrmOrgSkillMstDtlBean oSkillDetailBean = new HrmOrgSkillMstDtlBean();
      oSkillDetailBean.setDetailId(oRow.get("ID").getString());
      oSkillDetailBean.setTxtSkillCode(oRow.get("CODE").getString());
      oSkillDetailBean.setTxtSkillName(oRow.get("NAME").getString());
      oSkillDetailBean.setTxtHourlyRate(oRow.get("HOURLY_RATE").getString());
      oSkillDetailBean.setTxtOtRate(oRow.get("OT_RATE").getString());
      arylstHrmSkillDetail.add(oSkillDetailBean);
    } 
    return arylstHrmSkillDetail;
  }
  
  public LovVO getHrmSkillCodeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("Code ID");
    arylstHeaderList.add("hrm.HrmSkillMaster.skillTypeCode");
    arylstHeaderList.add("hrm.HrmSkillMaster.skillTypeName");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParameters = 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(); 
    arylstParameters = new ArrayList();
    arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParameters.add(new DBObject(3, 2, -10));
    arylstParameters.add(new DBObject(4, 2, 12));
    arylstParameters.add(new DBObject(5, 2, 12));
    arylstParameters.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSETUPLOV.proc_GetSkillCodeLOV(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("CODE").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "GEN_SKILL_TYPE_MST";
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmOrgSkillMstHdrBean oHrmOrgSkillMstHdrBean = (HrmOrgSkillMstHdrBean)oBaseHeaderBean;
    if (ScreenMode.equalsIgnoreCase("N")) {
      arylstParameters = new ArrayList();
      arylstParameters.add(new DBObject(1, 1, 12, "i"));
      arylstParameters.add(new DBObject(2, 1, 12, oHrmOrgSkillMstHdrBean.getSkillTypeCode()));
      arylstParameters.add(new DBObject(3, 1, 12, oHrmOrgSkillMstHdrBean.getSkillTypeName()));
      arylstParameters.add(new DBObject(4, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParameters.add(new DBObject(5, 1, 12, this.oUserInfo.getSiteId()));
      arylstParameters.add(new DBObject(6, 1, 12, null));
      arylstParameters.add(new DBObject(7, 2, 12));
      arylstParameters.add(new DBObject(8, 2, 12));
      arylstParameters.add(new DBObject(9, 2, 12));
      arylstParameters.add(new DBObject(10, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSKILLMST.proc_UpsertHrSkillHdr(?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      arylstParameters = new ArrayList();
      arylstParameters.add(new DBObject(1, 1, 12, "u"));
      arylstParameters.add(new DBObject(2, 1, 12, oHrmOrgSkillMstHdrBean.getSkillTypeCode()));
      arylstParameters.add(new DBObject(3, 1, 12, oHrmOrgSkillMstHdrBean.getSkillTypeName()));
      arylstParameters.add(new DBObject(4, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParameters.add(new DBObject(5, 1, 12, this.oUserInfo.getSiteId()));
      arylstParameters.add(new DBObject(6, 1, 12, oHrmOrgSkillMstHdrBean.getHeaderPrimaryKey()));
      arylstParameters.add(new DBObject(7, 2, 12));
      arylstParameters.add(new DBObject(8, 2, 12));
      arylstParameters.add(new DBObject(9, 2, 12));
      arylstParameters.add(new DBObject(10, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMORGSKILLMST.proc_UpsertHrSkillHdr(?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
      System.out.println(returnString);
    } 
    return returnString;
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {
    if (sScreenName.equalsIgnoreCase("HrmOrgSkillMst"))
      saveHrmSkillDetail(sHeaderPrimaryKey, arylstDetailBeanArray); 
  }
  
  private void saveHrmSkillDetail(String sHeaderPrimaryKey, ArrayList arylstDetailBeanArray) throws EnrgiseSystemException {
    boolean bInsert = false;
    boolean bUpdate = false;
    boolean bDelete = false;
    ArrayList arylstParameters = new ArrayList();
    DBUtilitiesBean oBean = null;
    DBUtilitiesBean oBean1 = null;
    Iterator itrBean = arylstDetailBeanArray.iterator();
    while (itrBean.hasNext()) {
      HrmOrgSkillMstDtlBean oHrmOrgSkillMstDtlBean = itrBean.next();
      System.out.println(oHrmOrgSkillMstDtlBean.getStatus());
      if (oHrmOrgSkillMstDtlBean.getStatus().equals("N")) {
        if (!bInsert) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMORGSKILLMST.proc_UpsertHrSkillDtl(?,?,?,?,?,?,?,?,?)");
          bInsert = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "I"));
        arylstParameters.add(new DBObject(2, 1, 12, null));
        arylstParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
        arylstParameters.add(new DBObject(4, 1, 12, oHrmOrgSkillMstDtlBean.getTxtSkillCode()));
        arylstParameters.add(new DBObject(5, 1, 12, oHrmOrgSkillMstDtlBean.getTxtSkillName()));
        arylstParameters.add(new DBObject(6, 1, 12, oHrmOrgSkillMstDtlBean.getTxtHourlyRate()));
        arylstParameters.add(new DBObject(7, 1, 12, oHrmOrgSkillMstDtlBean.getTxtOtRate()));
        arylstParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmOrgSkillMstDtlBean.getStatus().equals("U")) {
        if (!bUpdate) {
          oBean = new DBUtilitiesBean();
          oBean.createBatch("HRMORGSKILLMST.proc_UpsertHrSkillDtl(?,?,?,?,?,?,?,?,?)");
          bUpdate = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, "U"));
        arylstParameters.add(new DBObject(2, 1, 12, oHrmOrgSkillMstDtlBean.getDetailId()));
        arylstParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
        arylstParameters.add(new DBObject(4, 1, 12, oHrmOrgSkillMstDtlBean.getTxtSkillCode()));
        arylstParameters.add(new DBObject(5, 1, 12, oHrmOrgSkillMstDtlBean.getTxtSkillName()));
        arylstParameters.add(new DBObject(6, 1, 12, oHrmOrgSkillMstDtlBean.getTxtHourlyRate()));
        arylstParameters.add(new DBObject(7, 1, 12, oHrmOrgSkillMstDtlBean.getTxtOtRate()));
        arylstParameters.add(new DBObject(8, 1, 12, this.oUserInfo.getUserTypeId()));
        arylstParameters.add(new DBObject(9, 1, 12, this.oUserInfo.getSiteId()));
        oBean.addToBatch(arylstParameters);
        continue;
      } 
      if (oHrmOrgSkillMstDtlBean.getStatus().equals("D")) {
        if (!bDelete) {
          oBean1 = new DBUtilitiesBean();
          oBean1.createBatch("HRMORGSKILLMST.proc_DeleteSkillMstCalDtl(?)");
          bDelete = true;
        } 
        arylstParameters = new ArrayList();
        arylstParameters.add(new DBObject(1, 1, 12, oHrmOrgSkillMstDtlBean.getDetailId()));
        oBean1.addToBatch(arylstParameters);
      } 
    } 
    if (bInsert)
      oBean.executeBatch(); 
    if (bUpdate)
      oBean.executeBatch(); 
    if (bDelete)
      oBean1.executeBatch(); 
  }
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    System.out.println("Update ille!");
  }
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return "saveNewHeaderImpl ille!";
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstErrorList = new ArrayList();
    if (bHeaderDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        checkMandatoryHeader((HrmOrgSkillMstHdrBean)oBaseHeaderBean);  
    if (bDetailDataChanged)
      if (sScreenName.equalsIgnoreCase("HrmOrgSkillMst")) {
        Iterator itrBean1 = arylstDetailBeanArray.iterator();
        int iCount = 1;
        while (itrBean1.hasNext()) {
          HrmOrgSkillMstDtlBean oHrmOrgSkillMstDtlBean = itrBean1.next();
          if (!oHrmOrgSkillMstDtlBean.getStatus().equalsIgnoreCase("D"))
            checkMandatory(oHrmOrgSkillMstDtlBean, iCount, arylstErrorList); 
          iCount++;
        } 
      }  
    reportError(arylstErrorList);
  }
  
  private void checkMandatory(HrmOrgSkillMstDtlBean oHrmOrgSkillMstDtlBean, int iCount, ArrayList arylstErrorList) throws EnrgiseSystemException, EnrgiseApplicationException {
    if (!EnrgiseUtil.checkString(oHrmOrgSkillMstDtlBean.getTxtSkillCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmSkillMaster.txtSkillCode");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmOrgSkillMstDtlBean.getTxtSkillName())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmSkillMaster.txtSkillName");
      ArrayList oParams = new ArrayList();
      oParams.add(oMessageKey);
      oParams.add(new Integer(iCount));
      arylstErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
    } 
    reportError(arylstErrorList);
  }
  
  private void checkMandatoryHeader(HrmOrgSkillMstHdrBean oHrmOrgSkillMstHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException {
    ArrayList oErrorList = new ArrayList();
    ArrayList oParams = new ArrayList();
    if (!EnrgiseUtil.checkString(oHrmOrgSkillMstHdrBean.getSkillTypeCode())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmSkillMaster.skillTypeCode");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
    } 
    if (!EnrgiseUtil.checkString(oHrmOrgSkillMstHdrBean.getSkillTypeName())) {
      MessageKey oMessageKey = new MessageKey("hrm.HrmSkillMaster.skillTypeName");
      oParams = new ArrayList();
      oParams.add(oMessageKey);
      oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.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 arylstDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstErrorList = new ArrayList();
    HrmOrgSkillMstHdrBean oHrmOrgSkillMstHdrBean = (HrmOrgSkillMstHdrBean)oBaseHeaderBean;
    if (bHeaderDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        checkUniqueHeader((HrmOrgSkillMstHdrBean)oBaseHeaderBean);  
    if (bDetailDataChanged)
      if (!sScreenMode.equalsIgnoreCase("D"))
        if (sScreenName.equalsIgnoreCase("HrmOrgSkillMst")) {
          EnrgiseUtil.checkDuplicate(arylstDetailBeanArray, "txtSkillCode", "hrm.HrmSkillMaster.txtSkillCode", arylstErrorList, true);
          EnrgiseUtil.checkDuplicate(arylstDetailBeanArray, "txtSkillName", "hrm.HrmSkillMaster.txtSkillName", arylstErrorList, true);
        }   
    reportError(arylstErrorList);
  }
  
  public void checkRefferenceKey(String sSkillHeaderId) throws EnrgiseApplicationException, EnrgiseSystemException {
    System.out.println("To be added");
  }
  
  private void checkUniqueHeader(HrmOrgSkillMstHdrBean oHrmOrgSkillMstHdrBean) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstList1 = new ArrayList();
    ArrayList arylstParam = new ArrayList();
    String sQuery = String.valueOf(String.valueOf(" Select ID as ID from GEN_SKILL_TYPE_MST where CODE='").concat(String.valueOf(oHrmOrgSkillMstHdrBean.getSkillTypeCode()))).concat(String.valueOf("'"));
    System.out.println(sQuery);
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    ArrayList arylstList = oBean.executeQuery(sQuery);
    Iterator itrBean = arylstList.iterator();
    if (itrBean.hasNext()) {
      QueryRow oRow = itrBean.next();
      if (!oRow.get("ID").getString().equalsIgnoreCase(oHrmOrgSkillMstHdrBean.getHeaderPrimaryKey())) {
        arylstParam = new ArrayList();
        arylstParam.add("");
        arylstParam.add(new Integer(0));
        arylstList1.add(new EnrgiseMessageKeyException("wenrgise.common.uniqueConstraintViolated", arylstParam));
      } 
    } 
    reportError(arylstList1);
  }
}
