Files
HRMS/hrmsEjb/wenrgise/hrms/ejb/business/HrmTrngInsCrsBO.java
2025-07-28 13:56:49 +05:30

756 lines
36 KiB
Java

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.HrmTrngInsCrsDtlbean;
import wenrgise.hrms.bean.HrmTrngInsCrsHdrBean;
import wenrgise.hrms.vo.HrmTrngInsCrsQVO;
public class HrmTrngInsCrsBO extends HrmBaseBO {
public HrmTrngInsCrsBO() {}
public HrmTrngInsCrsBO(UserInfo oUserInfo) {
super(oUserInfo);
}
public RecordMetaInfo getHrmTrngInsCrsHdrMetaInfo(HrmTrngInsCrsQVO oHrmTrngInsCrsQVO) 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, oHrmTrngInsCrsQVO.getHeaderPrimaryKey()));
arylstParameters.add(new DBObject(2, 1, 12, oHrmTrngInsCrsQVO.getInstituteCode()));
arylstParameters.add(new DBObject(3, 1, 12, oHrmTrngInsCrsQVO.getType()));
arylstParameters.add(new DBObject(4, 2, -5));
arylstParameters.add(new DBObject(5, 2, 93));
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, "HRMTRNGINSCRSDTL.proc_HrTrngInsCrsHdrCount(?,?,?,?,?,?,?,?)");
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 getHrmTrngInsCrsHeaderInfo(HrmTrngInsCrsQVO oHrmTrngInsCrsQVO, 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 (oHrmTrngInsCrsQVO == null)
oHrmTrngInsCrsQVO = new HrmTrngInsCrsQVO();
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, oHrmTrngInsCrsQVO.getHeaderPrimaryKey()));
arylstParameters.add(new DBObject(4, 1, 12, oHrmTrngInsCrsQVO.getInstituteCode()));
arylstParameters.add(new DBObject(5, 1, 12, oHrmTrngInsCrsQVO.getType()));
arylstParameters.add(new DBObject(6, 2, -10));
arylstParameters.add(new DBObject(7, 2, 12));
arylstParameters.add(new DBObject(8, 2, 12));
arylstParameters.add(new DBObject(9, 2, 4));
ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNGINSCRSDTL.proc_GetHrTrngInsCrs(?,?,?,?,?,?,?,?,?)");
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();
HrmTrngInsCrsHdrBean oTrngInsCrsHeader = new HrmTrngInsCrsHdrBean();
oTrngInsCrsHeader.setHeaderPrimaryKey(oRow.get("ID").getString());
oTrngInsCrsHeader.setInstituteCode(oRow.get("INST_CODE").getString());
oTrngInsCrsHeader.setInstituteName(oRow.get("INST_NAME").getString());
oTrngInsCrsHeader.setType(oRow.get("TYPE_TYPE").getString());
oTrngInsCrsHeader.setInCharge(oRow.get("IN_CHARGE").getString());
oTrngInsCrsHeader.setAddress(oRow.get("ADDRESS").getString());
oTrngInsCrsHeader.setPin(oRow.get("PIN").getString());
oTrngInsCrsHeader.setTrgInstCityId(oRow.get("CITY_ID").getString());
oTrngInsCrsHeader.setTrgInstCountryId(oRow.get("COUNTRY_ID").getString());
oTrngInsCrsHeader.setCountry(oRow.get("CON_NAME").getString());
oTrngInsCrsHeader.setCity(oRow.get("CITY_NAME").getString());
oTrngInsCrsHeader.setState(oRow.get("STATE").getString());
oTrngInsCrsHeader.setPhone(oRow.get("PHONE").getString());
oTrngInsCrsHeader.setFax(oRow.get("FAX").getString());
oTrngInsCrsHeader.setEmail(oRow.get("EMAIL").getString());
arylstHeaderList.add(oTrngInsCrsHeader);
}
return arylstHeaderList;
}
public RecordMetaInfo getHrmTrngInsCrsDetailMetaInfo(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, "HRMTRNGINSCRSDTL.proc_HrTrngInsCrsDtlCount(?,?,?,?,?,?)");
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 getHrmTrngInsCrsDetail(String lPrimaryKey, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
ArrayList arylstParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
int count = 0;
BaseDetailVO oBaseDetailVO = null;
ArrayList arylstHrmTrngInsCrsDetail = 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, "HRMTRNGINSCRSDTL.proc_GetTrngInsCrsDtl(?,?,?,?,?,?,?)");
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)
arylstHrmTrngInsCrsDetail = new ArrayList();
count++;
oRow = itrBean.next();
HrmTrngInsCrsDtlbean oTrngInsCrsDetailBean = new HrmTrngInsCrsDtlbean();
oTrngInsCrsDetailBean.setDetailId(oRow.get("Id").getString());
oTrngInsCrsDetailBean.setCourseId(oRow.get("trn_corsms_id").getString());
oTrngInsCrsDetailBean.setTxtCourse(oRow.get("COURSE").getString());
oTrngInsCrsDetailBean.setTxtCourseName(oRow.get("NAME").getString());
arylstHrmTrngInsCrsDetail.add(oTrngInsCrsDetailBean);
}
return arylstHrmTrngInsCrsDetail;
}
public LovVO getHrmTrgInstCodeLOVdataQmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
LovVO oLovVO = new LovVO();
ArrayList arylstHeaderList = new ArrayList();
arylstHeaderList.add("Institute Id");
arylstHeaderList.add("hrm.HrmTrnInCoDtl.instituteCode");
arylstHeaderList.add("hrm.HrmTrnInCoDtl.instituteName");
arylstHeaderList.add("Type");
arylstHeaderList.add("In-Charge");
arylstHeaderList.add("Address");
arylstHeaderList.add("PIN");
arylstHeaderList.add("City");
arylstHeaderList.add("State");
arylstHeaderList.add("Country");
arylstHeaderList.add("Phone");
arylstHeaderList.add("Fax");
arylstHeaderList.add("Email");
arylstHeaderList.add("CityId");
arylstHeaderList.add("CountryId");
oLovVO.setHeaderList(arylstHeaderList);
ArrayList arylstVisibility = new ArrayList();
arylstVisibility.add("H");
arylstVisibility.add("V");
arylstVisibility.add("V");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
arylstVisibility.add("H");
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();
System.out.println(sQuerySearch1);
}
if (oLovQueryVO.getSearchField2() != null) {
sQuerySearch2 = oLovQueryVO.getSearchField2();
System.out.println(sQuerySearch2);
}
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, "HRMTRNGLOV.proc_GetInstCodeQmode(?,?,?,?,?,?)");
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("INST_CODE").getString());
oLOVBean.setDetailField3(oRow.get("INST_NAME").getString());
oLOVBean.setDetailField4(oRow.get("TYPE_TYPE").getString());
oLOVBean.setDetailField5(oRow.get("IN_CHARGE").getString());
oLOVBean.setDetailField6(oRow.get("ADDRESS").getString());
oLOVBean.setDetailField7(oRow.get("COUNTRY_NAME").getString());
oLOVBean.setDetailField8(oRow.get("CITY_NAME").getString());
oLOVBean.setDetailField9(oRow.get("STATE").getString());
oLOVBean.setDetailField10(oRow.get("PIN").getString());
oLOVBean.setDetailField11(oRow.get("PHONE").getString());
oLOVBean.setDetailField12(oRow.get("FAX").getString());
oLOVBean.setDetailField13(oRow.get("EMAIL").getString());
oLOVBean.setDetailField14(oRow.get("CITY_ID").getString());
oLOVBean.setDetailField15(oRow.get("COUNTRY_ID").getString());
arylstList.add(oLOVBean);
}
oLovVO.setDetailList(arylstList);
return oLovVO;
}
public LovVO getHrmTrgCountryCodeLOVdataQmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
LovVO oLovVO = new LovVO();
ArrayList arylstHeaderList = new ArrayList();
arylstHeaderList.add("Country Id");
arylstHeaderList.add("hrm.HrmTrnInCoDtl.country");
oLovVO.setHeaderList(arylstHeaderList);
ArrayList arylstVisibility = new ArrayList();
arylstVisibility.add("H");
arylstVisibility.add("V");
oLovVO.setVisibilityList(arylstVisibility);
int count = 0;
ArrayList arylstParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
String sQuerySearch1 = new String();
if (oLovQueryVO.getSearchField1() != null) {
sQuerySearch1 = oLovQueryVO.getSearchField1();
System.out.println(sQuerySearch1);
}
arylstParameters = new ArrayList();
arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
arylstParameters.add(new DBObject(2, 2, -10));
arylstParameters.add(new DBObject(3, 2, 12));
arylstParameters.add(new DBObject(4, 2, 12));
arylstParameters.add(new DBObject(5, 2, 4));
ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNGLOV.proc_GetTrgCountryLOVQmode(?,?,?,?,?)");
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("COUNTRY_ID").getString());
oLOVBean.setDetailField2(oRow.get("NAME").getString());
arylstList.add(oLOVBean);
}
oLovVO.setDetailList(arylstList);
return oLovVO;
}
public LovVO getHrmTrgCityCodeLOVdataQmode(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
LovVO oLovVO = new LovVO();
ArrayList arylstHeaderList = new ArrayList();
arylstHeaderList.add("City Id");
arylstHeaderList.add("hrm.HrmTrnInCoDtl.city");
oLovVO.setHeaderList(arylstHeaderList);
ArrayList arylstVisibility = new ArrayList();
arylstVisibility.add("H");
arylstVisibility.add("V");
oLovVO.setVisibilityList(arylstVisibility);
int count = 0;
String countryId = null;
ArrayList arylstParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
String sQuerySearch1 = new String();
if (oLovQueryVO.getSearchField1() != null) {
sQuerySearch1 = oLovQueryVO.getSearchField1();
System.out.println(sQuerySearch1);
}
if (oLovQueryVO.getProperty("trgInstCountryId") != null) {
countryId = oLovQueryVO.getProperty("trgInstCountryId");
System.out.println(countryId);
}
arylstParameters = new ArrayList();
arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
arylstParameters.add(new DBObject(2, 1, 12, countryId));
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, "HRMTRNGLOV.proc_GetTrgCityLOVQmode(?,?,?,?,?,?)");
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("CITY_ID").getString());
oLOVBean.setDetailField2(oRow.get("NAME").getString());
arylstList.add(oLOVBean);
}
oLovVO.setDetailList(arylstList);
return oLovVO;
}
public LovVO getHrmTrgCourseLOVData(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
LovVO oLovVO = new LovVO();
ArrayList arylstHeaderList = new ArrayList();
arylstHeaderList.add("Course Id");
arylstHeaderList.add("hrm.HrmTrnInCoDtl.course");
arylstHeaderList.add("hrm.HrmTrnInCoDtl.courseName");
oLovVO.setHeaderList(arylstHeaderList);
ArrayList arylstVisibility = new ArrayList();
arylstVisibility.add("H");
arylstVisibility.add("V");
arylstVisibility.add("V");
oLovVO.setVisibilityList(arylstVisibility);
int count = 0;
String countryId = null;
String calId = null;
ArrayList arylstParameters = new ArrayList();
DBUtilitiesBean oBean = new DBUtilitiesBean();
String sQuerySearch1 = new String();
String sQuerySearch2 = new String();
if (oLovQueryVO.getSearchField1() != null) {
sQuerySearch1 = oLovQueryVO.getSearchField1();
System.out.println(sQuerySearch1);
}
if (oLovQueryVO.getSearchField2() != null) {
sQuerySearch2 = oLovQueryVO.getSearchField2();
System.out.println(sQuerySearch2);
}
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, "HRMTRNGLOV.proc_GetTrgCourseLOV(?,?,?,?,?,?)");
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("COURSE").getString());
oLOVBean.setDetailField3(oRow.get("NAME").getString());
arylstList.add(oLOVBean);
}
oLovVO.setDetailList(arylstList);
return oLovVO;
}
public LovVO getHrmTrngCrsInsNameLOV(LovQueryVO oLovQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
LovVO oLovVO = new LovVO();
ArrayList arylstHeaderNames = new ArrayList();
arylstHeaderNames.add("Course Id");
arylstHeaderNames.add("hrm.HrmFacTrngDtl.calendarName");
arylstHeaderNames.add("hrm.HrmFacTrngDtl.courseName");
arylstHeaderNames.add("hrm.HrmFacTrngDtl.institutionName");
arylstHeaderNames.add("hrm.HrmFacTrngDtl.startDate");
arylstHeaderNames.add("hrm.HrmFacTrngDtl.endDate");
arylstHeaderNames.add("Institute Id");
arylstHeaderNames.add("Status Flag");
oLovVO.setHeaderList(arylstHeaderNames);
ArrayList arylstVisibility = new ArrayList();
arylstVisibility.add("H");
arylstVisibility.add("V");
arylstVisibility.add("V");
arylstVisibility.add("V");
arylstVisibility.add("V");
arylstVisibility.add("V");
arylstVisibility.add("H");
arylstVisibility.add("H");
oLovVO.setVisibilityList(arylstVisibility);
int count = 0;
ArrayList arylstParameters = new ArrayList();
String calId = null;
String sId = null;
String sQuerySearch1 = new String();
String sQuerySearch2 = new String();
if (oLovQueryVO.getSearchField1() != null) {
sQuerySearch1 = oLovQueryVO.getSearchField1();
System.out.println(sQuerySearch1);
}
if (oLovQueryVO.getSearchField2() != null) {
sQuerySearch2 = oLovQueryVO.getSearchField2();
System.out.println(sQuerySearch2);
}
if (oLovQueryVO.getProperty("calId") != null) {
calId = oLovQueryVO.getProperty("calId");
System.out.println(calId);
}
if (oLovQueryVO.getProperty("siteId") != null) {
sId = oLovQueryVO.getProperty("siteId");
System.out.println(sId);
}
DBUtilitiesBean oBean = new DBUtilitiesBean();
arylstParameters = new ArrayList();
arylstParameters.add(new DBObject(1, 1, 12, sQuerySearch1));
arylstParameters.add(new DBObject(2, 1, 12, sQuerySearch2));
arylstParameters.add(new DBObject(3, 1, 12, calId));
arylstParameters.add(new DBObject(4, 1, 12, sId));
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, "HRMTRNGLOV.proc_GetTrngCrsInsLOV(?,?,?,?,?,?,?,?)");
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("CAL_NAME").getString());
oLOVBean.setDetailField3(oRow.get("NAME").getString());
oLOVBean.setDetailField4(oRow.get("INST_NAME").getString());
oLOVBean.setDetailField5(EnrgiseUtil.convertToString(oRow.get("START_DATE").getDate()));
oLOVBean.setDetailField6(EnrgiseUtil.convertToString(oRow.get("END_DATE").getDate()));
oLOVBean.setDetailField7(oRow.get("InstId").getString());
oLOVBean.setDetailField8(oRow.get("STATUS_FLAG").getString());
arylstList.add(oLOVBean);
}
oLovVO.setDetailList(arylstList);
return oLovVO;
}
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 arylstList = new ArrayList();
if (bHeaderDataChanged)
if (!sScreenMode.equalsIgnoreCase("D"))
checkMandatoryHeader((HrmTrngInsCrsHdrBean)oBaseHeaderBean);
if (bDetailDataChanged)
if (!sScreenMode.equalsIgnoreCase("D"))
if (sScreenName.equalsIgnoreCase("HrmTrngInstCourseDtl")) {
Iterator itrBean1 = arylstDetailBeanArray.iterator();
int rowCount = 1;
while (itrBean1.hasNext()) {
HrmTrngInsCrsDtlbean oHrmTrngInsCrsDtlbean = itrBean1.next();
if (!oHrmTrngInsCrsDtlbean.getStatus().equalsIgnoreCase("D")) {
checkMandatoryDtls(oHrmTrngInsCrsDtlbean, rowCount);
EnrgiseUtil.checkDuplicate(arylstDetailBeanArray, "txtCourse", "hrm.HrmTrnInCoDtl.course", arylstList, true);
}
}
rowCount++;
}
}
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 arylstList = new ArrayList();
if (bDetailDataChanged) {
HrmTrngInsCrsHdrBean oHrmTrngInsCrsHdrBean = (HrmTrngInsCrsHdrBean)oBaseHeaderBean;
Iterator itrBean = arylstDetailBeanArray.iterator();
String sHeaderPrimaryKey = oHrmTrngInsCrsHdrBean.getHeaderPrimaryKey();
while (itrBean.hasNext()) {
HrmTrngInsCrsDtlbean oHrmTrngInsCrsDtlbean = itrBean.next();
if (!oHrmTrngInsCrsDtlbean.getStatus().equals("D"))
checkUniqueDtl(sHeaderPrimaryKey, arylstDetailBeanArray);
if (oHrmTrngInsCrsDtlbean.getStatus().equals("D")) {
String sQuery = String.valueOf(String.valueOf(String.valueOf("select count(*) as checkExist from HRM_TRNG_CAL_DTL where trng_instms_id= ").concat(String.valueOf(oHrmTrngInsCrsHdrBean.getHeaderPrimaryKey()))).concat(String.valueOf(" and trng_corsms_id="))).concat(String.valueOf(oHrmTrngInsCrsDtlbean.getCourseId()));
DBUtilitiesBean oBean3 = new DBUtilitiesBean();
ArrayList arylstList1 = oBean3.executeQuery(sQuery);
Iterator itrBean1 = arylstList1.iterator();
String chExist = null;
if (itrBean1.hasNext()) {
QueryRow oRow = itrBean1.next();
chExist = oRow.get("checkExist").getString();
System.out.println(chExist);
}
if (!chExist.equalsIgnoreCase("0"))
arylstList.add(new EnrgiseApplicationException("wenrgise.trngCal.error.empApplied"));
}
}
}
reportError(arylstList);
}
private void checkMandatoryHeader(HrmTrngInsCrsHdrBean oHrmTrngInsCrsHdrBean) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oErrorList = new ArrayList();
ArrayList oParams = new ArrayList();
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsHdrBean.getInstituteCode())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.instituteCode");
oParams = new ArrayList();
oParams.add(oMessageKey);
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
}
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsHdrBean.getInstituteName())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.instituteName");
oParams = new ArrayList();
oParams.add(oMessageKey);
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
}
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsHdrBean.getType())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.type");
oParams = new ArrayList();
oParams.add(oMessageKey);
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
}
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsHdrBean.getAddress())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.address");
oParams = new ArrayList();
oParams.add(oMessageKey);
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
}
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsHdrBean.getCountry())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.country");
oParams = new ArrayList();
oParams.add(oMessageKey);
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
}
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsHdrBean.getPin())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.pin");
oParams = new ArrayList();
oParams.add(oMessageKey);
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.header.mandatoryFieldMissing", oParams, "E"));
}
reportError(oErrorList);
}
private void checkMandatoryDtls(HrmTrngInsCrsDtlbean oHrmTrngInsCrsDtlbean, int rowCount) throws EnrgiseSystemException, EnrgiseApplicationException {
ArrayList oErrorList = new ArrayList();
ArrayList oParams = new ArrayList();
rowCount++;
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsDtlbean.getTxtCourse())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.course");
oParams = new ArrayList();
oParams.add(oMessageKey);
oParams.add(String.valueOf(rowCount));
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
}
if (!EnrgiseUtil.checkString(oHrmTrngInsCrsDtlbean.getTxtCourseName())) {
MessageKey oMessageKey = new MessageKey("hrm.HrmTrnInCoDtl.courseName");
oParams = new ArrayList();
oParams.add(oMessageKey);
oParams.add(String.valueOf(rowCount));
oErrorList.add(new EnrgiseMessageKeyException("wenrgise.common.detail.mandatoryFieldMissing", oParams, "E"));
}
reportError(oErrorList);
}
public void initializeBOImpl() {
this.headerTable = "HRM_TRNG_INST_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();
HrmTrngInsCrsHdrBean oHrmTrngInsCrsHdrBean = (HrmTrngInsCrsHdrBean)oBaseHeaderBean;
if (ScreenMode.equalsIgnoreCase("N")) {
arylstParameters = new ArrayList();
arylstParameters.add(new DBObject(1, 1, 12, "i"));
arylstParameters.add(new DBObject(2, 1, 12, oHrmTrngInsCrsHdrBean.getInstituteCode()));
arylstParameters.add(new DBObject(3, 1, 12, oHrmTrngInsCrsHdrBean.getInstituteName()));
arylstParameters.add(new DBObject(4, 1, 12, oHrmTrngInsCrsHdrBean.getType()));
arylstParameters.add(new DBObject(5, 1, 12, oHrmTrngInsCrsHdrBean.getInCharge()));
arylstParameters.add(new DBObject(6, 1, 12, oHrmTrngInsCrsHdrBean.getAddress()));
arylstParameters.add(new DBObject(7, 1, 12, oHrmTrngInsCrsHdrBean.getTrgInstCountryId()));
arylstParameters.add(new DBObject(8, 1, 12, oHrmTrngInsCrsHdrBean.getTrgInstCityId()));
arylstParameters.add(new DBObject(9, 1, 12, oHrmTrngInsCrsHdrBean.getState()));
arylstParameters.add(new DBObject(10, 1, 12, oHrmTrngInsCrsHdrBean.getPin()));
arylstParameters.add(new DBObject(11, 1, 12, oHrmTrngInsCrsHdrBean.getPhone()));
arylstParameters.add(new DBObject(12, 1, 12, oHrmTrngInsCrsHdrBean.getEmail()));
arylstParameters.add(new DBObject(13, 1, 12, oHrmTrngInsCrsHdrBean.getFax()));
arylstParameters.add(new DBObject(14, 1, 12, "100"));
arylstParameters.add(new DBObject(15, 1, 12, "100"));
arylstParameters.add(new DBObject(16, 1, 12, null));
arylstParameters.add(new DBObject(17, 2, 12));
arylstParameters.add(new DBObject(18, 2, 12));
arylstParameters.add(new DBObject(19, 2, 12));
arylstParameters.add(new DBObject(20, 2, 4));
ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNGINSCRSDTL.proc_UpsertHrTrngInsHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
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, oHrmTrngInsCrsHdrBean.getInstituteCode()));
arylstParameters.add(new DBObject(3, 1, 12, oHrmTrngInsCrsHdrBean.getInstituteName()));
arylstParameters.add(new DBObject(4, 1, 12, oHrmTrngInsCrsHdrBean.getType()));
arylstParameters.add(new DBObject(5, 1, 12, oHrmTrngInsCrsHdrBean.getInCharge()));
arylstParameters.add(new DBObject(6, 1, 12, oHrmTrngInsCrsHdrBean.getAddress()));
arylstParameters.add(new DBObject(7, 1, 12, oHrmTrngInsCrsHdrBean.getTrgInstCountryId()));
arylstParameters.add(new DBObject(8, 1, 12, oHrmTrngInsCrsHdrBean.getTrgInstCityId()));
arylstParameters.add(new DBObject(9, 1, 12, oHrmTrngInsCrsHdrBean.getState()));
arylstParameters.add(new DBObject(10, 1, 12, oHrmTrngInsCrsHdrBean.getPin()));
arylstParameters.add(new DBObject(11, 1, 12, oHrmTrngInsCrsHdrBean.getPhone()));
arylstParameters.add(new DBObject(12, 1, 12, oHrmTrngInsCrsHdrBean.getEmail()));
arylstParameters.add(new DBObject(13, 1, 12, oHrmTrngInsCrsHdrBean.getFax()));
arylstParameters.add(new DBObject(14, 1, 12, "100"));
arylstParameters.add(new DBObject(15, 1, 12, "100"));
arylstParameters.add(new DBObject(16, 1, 12, oHrmTrngInsCrsHdrBean.getHeaderPrimaryKey()));
arylstParameters.add(new DBObject(17, 2, 12));
arylstParameters.add(new DBObject(18, 2, 12));
arylstParameters.add(new DBObject(19, 2, 12));
arylstParameters.add(new DBObject(20, 2, 4));
ArrayList arylstOutArray = oBean.callProc(arylstParameters, "HRMTRNGINSCRSDTL.proc_UpsertHrTrngInsHdr(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
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("HrmTrngInstCourseDtl"))
saveHrmTrngInsDetail(sHeaderPrimaryKey, arylstDetailBeanArray);
}
private void saveHrmTrngInsDetail(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()) {
HrmTrngInsCrsDtlbean oHrmTrngInsCrsDtlbean = itrBean.next();
if (oHrmTrngInsCrsDtlbean.getStatus().equals("N")) {
if (!bInsert) {
oBean = new DBUtilitiesBean();
oBean.createBatch("HRMTRNGINSCRSDTL.proc_UpsertHrTrngInst(?,?,?,?,?,?)");
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, oHrmTrngInsCrsDtlbean.getCourseId()));
arylstParameters.add(new DBObject(5, 1, 12, "200"));
arylstParameters.add(new DBObject(6, 1, 12, "200"));
System.out.println(oHrmTrngInsCrsDtlbean.getTxtCourseName());
oBean.addToBatch(arylstParameters);
continue;
}
if (oHrmTrngInsCrsDtlbean.getStatus().equals("U")) {
if (!bUpdate) {
oBean = new DBUtilitiesBean();
oBean.createBatch("HRMTRNGINSCRSDTL.proc_UpsertHrTrngInst(?,?,?,?,?,?)");
bUpdate = true;
}
arylstParameters = new ArrayList();
arylstParameters.add(new DBObject(1, 1, 12, "U"));
arylstParameters.add(new DBObject(2, 1, 12, oHrmTrngInsCrsDtlbean.getDetailId()));
arylstParameters.add(new DBObject(3, 1, 12, sHeaderPrimaryKey));
arylstParameters.add(new DBObject(4, 1, 12, oHrmTrngInsCrsDtlbean.getCourseId()));
arylstParameters.add(new DBObject(5, 1, 12, "200"));
arylstParameters.add(new DBObject(6, 1, 12, "200"));
oBean.addToBatch(arylstParameters);
continue;
}
if (oHrmTrngInsCrsDtlbean.getStatus().equals("D")) {
if (!bDelete) {
oBean1 = new DBUtilitiesBean();
oBean1.createBatch("HRMTRNGINSCRSDTL.proc_DeleteTrngInstDtl(?)");
bDelete = true;
}
arylstParameters = new ArrayList();
arylstParameters.add(new DBObject(1, 1, 12, oHrmTrngInsCrsDtlbean.getDetailId()));
oBean1.addToBatch(arylstParameters);
}
}
if (bInsert)
oBean.executeBatch();
if (bUpdate)
oBean.executeBatch();
if (bDelete)
oBean1.executeBatch();
}
private void checkUniqueDtl(String sHeaderPrimaryKey, ArrayList arylstDetailBeanArray) throws EnrgiseApplicationException, EnrgiseSystemException {
int count = 0;
Iterator itrBean1 = arylstDetailBeanArray.iterator();
while (itrBean1.hasNext()) {
HrmTrngInsCrsDtlbean oHrmTrngInsCrsDtlbean = itrBean1.next();
String sQuery = String.valueOf(String.valueOf(String.valueOf(" Select a.ID as ID from HRM_TRNG_INST_CRS_MAP a,HRM_TRNG_CRS_MST b where a.trn_corsms_id=b.id and b.course= '").concat(String.valueOf(oHrmTrngInsCrsDtlbean.getTxtCourse()))).concat(String.valueOf("' and a.trn_instms_id ="))).concat(String.valueOf(sHeaderPrimaryKey));
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(oHrmTrngInsCrsDtlbean.getDetailId()))
throw new EnrgiseApplicationException("wenrgise.common.uniqueConstraintViolated", "M");
}
}
}
}