Commit 4dd16e8c authored by sghate's avatar sghate

Shital : Done changes on StatusChangeIC and StatusChangeConfirm Master Component.

StatusChangeConfirm.java
StatusChangeConfirmLocal.java
StatusChangeConfirmRemote.java
StatusChangeIC.java
StatusChangeLocal.java
StatusChangeRemote.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@207309 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8bbb7708
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
public class StatusChangeConfirm extends ActionHandlerEJB implements StatusChangeConfirmLocal, StatusChangeConfirmRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
AdmCommon admCommon = new AdmCommon();
UtilMethods utilMethod = new UtilMethods();
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "";
Connection conn = null;
boolean isError = false;
try
{
conn = getConnection();
retString = gbfPostLogic(tranId,xtraParams,forcedFlag,conn);
System.out.println("returning String from StatusChangeConfirm :confirm():==>[" + retString + "]");
if(retString == null || retString.trim().length() == 0)
{
isError = false;
retString = itmDBAccessEJB.getErrorString("", "VTINVCONF3", "", "", conn);
return retString;
}
else
{
isError = true;
}
}
catch(Exception e)
{
System.out.println("Exception :StatusChangeConfirm :confirm() :" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(isError)
{
conn.rollback();
System.out.println("Connection rollback");
}
else
{
conn.commit();
System.out.println("Connection committed");
}
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
@Override
public String gbfPostLogic(String tranId, String xtraParams, String forcedFlag,Connection conn) throws ITMException
{
String lsEmpCode = "";
String lsTranIdArg = "";
String lsKey1 = "";
Timestamp ldTranDate = null;
String lsTranId = "";
String lsRemarks = "";
int liCnt = 0;
String sql = "";
String refSer = "";
String objSignTrans = "";
String wfPrcStatus = "";
String empStatuschg = "";
String errString = "";
int cnt = 0;
SimpleDateFormat sdf = null;
String userId = "";
String loginEmpCode = "";
String runMode = "";
String chgTerm = "";
String termId = "" , confirm = "",tranDateStr ="";
ArrayList tranIdList = new ArrayList();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("Inside Post Logic Method..!!!!");
sdf =new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
loginEmpCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
runMode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "runMode"));
System.out.println("userId["+userId+"]\t chgTerm["+chgTerm+"]\t loginEmpCode["+loginEmpCode+"]\t runMode["+runMode+"]");
tranIdList = GenericUtility.getInstance().getTokenList(tranId, ":");
System.out.println("tranIdList:::::::::::"+tranIdList);
lsEmpCode = (String) tranIdList.get(0);
tranDateStr = (String) tranIdList.get(1);
System.out.println("empCode:::::::::"+lsEmpCode);
System.out.println("tranIdStr:::::::::"+tranDateStr);
if(tranDateStr != null && tranDateStr.trim().length() > 0)
{
ldTranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(tranDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()));
}
sql = "select case when confirm is null then 'N' else confirm end as confirm ,"
+ " tran_id ,"
+ " remarks "
+ " from "
+ " emp_statuschg "
+ " where "
+ " emp_code = ? "
+ "and tran_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsEmpCode);
pstmt.setTimestamp(2, ldTranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
confirm = checkNull(rs.getString("confirm"));
tranId = checkNull(rs.getString("tran_id"));
lsRemarks = checkNull(rs.getString("remarks"));
}
System.out.println("confirm:["+confirm+"]\t tranId:["+tranId+"]\t lsRemarks:["+lsRemarks+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("N".equalsIgnoreCase(confirm))
{
errString = gbfStatusChg(lsEmpCode , ldTranDate , "Y" ,xtraParams, conn);
System.out.println("lsErrcode :: "+ errString);
if(errString != null && errString.trim().length() > 0)
{
//errString = itmDBAccessEJB.getErrorString("", errString, userId, "", conn);
return errString;
}
}
else if("X".equalsIgnoreCase(confirm))
{
errString = itmDBAccessEJB.getErrorString("", "VTEMPSTS02", userId, "", conn);
return errString;
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VTMCONF1", userId, "", conn);
return errString;
}
if(errString == null || errString.trim().length() == 0)
{
if(tranId != null && tranId.trim().length() > 0)
{
liCnt = 0;
sql = "select count(1) as li_cnt "
+ "from wf_prc_status "
+ "where "
+ "ref_ser = 'TPCEMP' "
+ "and ref_id = ? "
+ "and process_status < 3";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(liCnt > 0)
{
liCnt = 0;
sql = "select count(1) as li_cnt "
+ "from obj_sign_trans "
+ "where ref_ser = 'TPCEMP' "
+ "and ref_id = ? "
+ "and sign_status = 'U'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(liCnt > 0)
{
liCnt = 0;
sql = "update obj_sign_trans "
+ "set sign_status = 'S', "
+ "sign_remarks = 'Approved from ERP' "
+ "where "
+ "ref_ser = 'TPCEMP' "
+ "and ref_id = ? "
+ "and sign_status = 'U'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
if(cnt > 0)
{
System.out.println("Data Updated in obj_sign_trans table..");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
errString = itmDBAccessEJB.getErrorString("", "DS000", userId, "", conn);
}
}
else
{
errString = itmDBAccessEJB.getErrorString("", "DS000", userId, "", conn);
}
sql = "update wf_prc_status "
+ "set "
+ "process_status = 3, "
+ "STATUS_REMARKS = 'Approved from ERP' "
+ "where ref_ser = 'TPCEMP' "
+ "and ref_id = ? "
+ "and process_status < 3";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
int cnt1 = pstmt.executeUpdate();
if(cnt1 > 0)
{
System.out.println("Data Updated in wf_prc_status table..");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(lsRemarks == null || lsRemarks.trim().length() == 0)
{
lsRemarks = "";
}
else
{
lsRemarks = lsRemarks.trim();
}
lsRemarks = "Approved from ERP."+ lsRemarks;
if(lsRemarks != null && lsRemarks.length() > 1500)
{
lsRemarks = utilMethod.mid(lsRemarks, 1, 1500);
sql = "update emp_statuschg "
+ "set remarks = ? "
+ "where "
+ "emp_code = ? "
+ "and tran_date = ? "
+ "and tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsRemarks);
pstmt.setString(2, lsEmpCode);
pstmt.setTimestamp(3, ldTranDate);
pstmt.setString(4, tranId);
cnt = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
/* if(errString == null || errString.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VTMCONF2", userId, "", conn);
return errString;
}*/
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e1)
{
e1.printStackTrace();
throw new ITMException(e1);
}
}
return errString;
}
private String gbfStatusChg(String empCode, Timestamp tranDate, String as_ediopt , String xtraParams, Connection conn) throws RemoteException,ITMException
{
String lsEmpAprv = "";
String lsEligibleOt = "";
Timestamp mduedtchg = null;
Timestamp mduedt = null;
Timestamp meffdate = null;
Timestamp ldConf = null;
Timestamp ldConfDate = null;
int mmonth = 0;
int mVal = 0;
int mextprd = 0;
int liProbprd = 0;
double lcNoticePrd = 0.0;
String lsConfFlag = "";
String sql = "";
String mexten = "";
String mstatus = "";
String lsGrade = "";
String lsCadre = "";
String lsDesign = "";
String lsDesignation = "";
String empCodeAprv = "";
String lsErrcode = "";
String probation = "";
int cnt = 0;
int trainingPrd = 0;
SimpleDateFormat sdf = null;
String userId = "";
String loginEmpCode = "";
String runMode = "";
String chgTerm = "";
String termId = "";
UtilMethods utilmethod = new UtilMethods();
java.sql.Timestamp ldToday = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
ldToday = utilMethod.dateTime(utilMethod.today() , utilMethod.stringToTime("00:00"));
termId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
sql = "select "
+ "extend ,"
+ "status_type ,"
+ "date__due_chg ,"
+ "months_extend ,"
+ "notice_prd ,"
+ "date__effchg ,"
+ "grade_n , "
+ "cadre_n , "
+ "design_code_n , "
+ "designation_n , "
+ "emp_code__aprv , "
+ "conf_date , "
+ "eligible_ot ,"
+ "case when confirm is null then 'N' else confirm end as confirm "
+ "from emp_statuschg "
+ "where "
+ "emp_code = ? "
+ "and tran_date= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
mexten = rs.getString("extend");
mstatus = rs.getString("status_type");
mduedtchg = rs.getTimestamp("date__due_chg");
mmonth = rs.getInt("months_extend");
lcNoticePrd = rs.getDouble("notice_prd");
meffdate = rs.getTimestamp("date__effchg");
lsGrade = rs.getString("grade_n");
lsCadre = rs.getString("cadre_n");
lsDesign = rs.getString("design_code_n");
lsDesignation = rs.getString("designation_n");
lsEmpAprv = rs.getString("emp_code__aprv");
ldConfDate = rs.getTimestamp("conf_date");
lsEligibleOt = rs.getString("eligible_ot");
lsConfFlag = rs.getString("confirm");
}
System.out.println("extend["+mexten+"]\t status_type["+mstatus+"]\t date__due_chg["+mduedtchg+"]\t months_extend["+mmonth+"]\t "
+ "notice_prd["+lcNoticePrd+"]\t date__effchg ["+meffdate+"]\t grade_n["+lsGrade+"]\t "
+ "cadre_n["+lsCadre+"]\t design_code_n["+lsDesign+"]\t designation_n["+lsDesignation+"]\t "
+ "emp_code__aprv["+lsEmpAprv+"]\t conf_date["+ldConfDate+"]\t eligible_ot["+lsEligibleOt+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("X".equalsIgnoreCase(lsConfFlag))
{
lsErrcode = itmDBAccessEJB.getErrorString("", "VTEMPSTS02", userId, "", conn);
return lsErrcode;
}
System.out.println("mexten::::"+mexten);
if("N".equalsIgnoreCase(mexten))
{
System.out.println("mstatus::::"+mstatus);
if("P".equalsIgnoreCase(mstatus))
{
sql = "select probation_prd as li_probprd "
+ "from "
+ "employee "
+ "where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
liProbprd = rs.getInt("li_probprd");
}
System.out.println("liProbprd11"+liProbprd);
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
ldConf = utilmethod.AddMonths(meffdate, liProbprd);
System.out.println("ldConf :: ["+ldConf+"]");
sql = "UPDATE employee "
+ "set probation = 'Y', "
+ "probation_date = ? ,"
+ "notice_prd = ? ,"
+ "date_conf = ? ,"
+ "grade = ? , "
+ "cadre = ? ,"
+ "design_code = ? ,"
+ "designation = ? ,"
+ "chg_date = ? ,"
+ "chg_user = ? ,"
+ "chg_term = ? ,"
+ "eligible_ot = ? "
+ "where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,meffdate);
pstmt.setDouble(2,lcNoticePrd);
pstmt.setTimestamp(3,ldConfDate);
pstmt.setString(4,lsGrade);
pstmt.setString(5,lsCadre);
pstmt.setString(6,lsDesign);
pstmt.setString(7,lsDesignation);
pstmt.setTimestamp(8,ldToday);
pstmt.setString(9,userId);
pstmt.setString(10,termId);
pstmt.setString(11,lsEligibleOt);
pstmt.setString(12,empCode);
cnt = pstmt.executeUpdate();
System.out.println("cnt::::::::::"+cnt);
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("liProbprd222222"+liProbprd);
if (liProbprd == 0)
{
sql = "update employee "
+ "set "
+ "confirmed = 'Y', "
+ "grade = ? , "
+ "cadre = ? , "
+ "design_code = ? ,"
+ "designation = ? , "
+ "notice_prd = ? , "
+ "chg_date= ? , "
+ "chg_user = ? ,"
+ "chg_term = ? ,"
+ "eligible_ot = ? "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsGrade);
pstmt.setString(2,lsCadre);
pstmt.setString(3,lsDesign);
pstmt.setString(4,lsDesignation);
pstmt.setDouble(5,lcNoticePrd);
pstmt.setTimestamp(6,ldToday);
pstmt.setString(7,userId);
pstmt.setString(8,termId);
pstmt.setString(9,lsEligibleOt);
pstmt.setString(10,empCode);
cnt = pstmt.executeUpdate();
if(cnt > 0)
{
System.out.println("Data Updated for employee");
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
System.out.println("mstatus:::::::"+mstatus);
if("C".equalsIgnoreCase(mstatus))
{
sql = "UPDATE employee "
+ "set "
+ "confirmed = 'Y',"
+ "date_conf = ? ,"
+ "notice_prd = ? ,"
+ "grade = ? ,"
+ "cadre = ? ,"
+ "design_code = ? ,"
+ "designation = ? ,"
+ "chg_date= ? ,"
+ "chg_user = ? ,"
+ "chg_term = ? ,"
+ "eligible_ot = ? "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,meffdate);
pstmt.setDouble(2,lcNoticePrd);
pstmt.setString(3,lsGrade);
pstmt.setString(4,lsCadre);
pstmt.setString(5,lsDesign);
pstmt.setString(6,lsDesignation);
pstmt.setTimestamp(7,ldToday);
pstmt.setString(8,userId);
pstmt.setString(9,termId);
pstmt.setString(10,lsEligibleOt);
pstmt.setString(11,empCode);
cnt = pstmt.executeUpdate();
System.out.println("cnt********"+cnt);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
else
{
System.out.println("mexten:::"+mexten);
if("Y".equalsIgnoreCase(mexten))
{
sql = "update "
+ "emp_statuschg "
+ "set date__effchg = ? "
+ "where "
+ "emp_code = ? "
+ "and tran_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,mduedtchg);
pstmt.setString(2,empCode);
pstmt.setTimestamp(3,tranDate);
int cnt3 = pstmt.executeUpdate();
System.out.println("cnt333333333"+cnt3);
if(cnt3 > 0)
{
System.out.println("Data Updated for emp_statuschg");
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("mstatus888"+mstatus);
if("P".equalsIgnoreCase(mstatus))
{
mduedt = utilmethod.AddMonths(mduedtchg, mmonth);
System.out.println("mduedt is ["+mduedt+"]");
sql = "select "
+ "training_prd, "
+ "date_conf "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mVal = rs.getInt("training_prd");
ldConf = rs.getTimestamp("date_conf");
}
System.out.println("mVal ["+mVal+"] \t ldConf ["+ldConf+"]");
if(rs != null)
{
rs.close();
rs.next();
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
mextprd = mmonth + mVal;
ldConf = utilmethod.AddMonths(ldConf, mmonth);
System.out.println("mextprd ["+mextprd+"] \t ldConf ["+ldConf+"]");
sql = "Update "
+ "employee "
+ "set "
+ "probation_date = ? ,"
+ "training_prd = ? , "
+ "grade = ? ,"
+ "cadre = ?"
+ "design_code = ? ,"
+ "designation = ? ,"
+ "notice_prd = ? ,"
+ "chg_date= ? ,"
+ "chg_user = ? ,"
+ "chg_term = ? ,"
+ "eligible_ot = ? "
+ "Where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,mduedt);
pstmt.setInt(2,mextprd);
pstmt.setString(3,lsGrade);
pstmt.setString(4,lsCadre);
pstmt.setString(5,lsDesign);
pstmt.setString(6,lsDesignation);
pstmt.setDouble(7,lcNoticePrd);
pstmt.setTimestamp(8,ldToday);
pstmt.setString(9,userId);
pstmt.setString(10,termId);
pstmt.setString(11,lsEligibleOt);
pstmt.setString(12,empCode);
int cnt4 = pstmt.executeUpdate();
System.out.println("cnt4"+cnt4);
if(cnt4 > 0)
{
System.out.println("Data Updated for emp_statuschg");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
System.out.println("mstatus-----"+mstatus);
if("C".equalsIgnoreCase(mstatus))
{
mduedt = utilmethod.AddMonths(mduedtchg, mmonth);
System.out.println("mduedt-----"+mduedt);
sql = "select "
+ "probation_prd "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mVal = rs.getInt("probation_prd");
}
System.out.println("mVal:::::"+mVal);
if(rs != null)
{
rs.close();
rs.next();
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
mextprd = mmonth + mVal;
System.out.println("mextprd ::: ["+mextprd+"]");
sql = "Update "
+ "employee "
+ "set "
+ "date_conf = ? , "
+ "probation_prd = ? ,"
+ "grade = ? ,"
+ "cadre = ? ,"
+ "design_code = ? ,"
+ "designation = ? , "
+ "notice_prd = ? ,"
+ "chg_date= ? ,"
+ "chg_user = ? , "
+ "chg_term = ? ,"
+ "eligible_ot = ? "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,mduedt);
pstmt.setInt(2,mextprd);
pstmt.setString(3,lsGrade);
pstmt.setString(4,lsCadre);
pstmt.setString(5,lsDesign);
pstmt.setString(6,lsDesignation);
pstmt.setDouble(7,lcNoticePrd);
pstmt.setTimestamp(8,ldToday);
pstmt.setString(9,userId);
pstmt.setString(10,termId);
pstmt.setString(11,lsEligibleOt);
pstmt.setString(12,empCode);
int cnt5 = pstmt.executeUpdate();
System.out.println("cnt5"+cnt5);
if(cnt5 > 0)
{
System.out.println("Data Updated for employee");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
sql = "update "
+ "emp_statuschg "
+ "set "
+ "confirm = 'Y' , "
+ "conf_date = ? , "
+ "emp_code__aprv = ? "
+ "where "
+ "emp_code = ? "
+ "and "
+ "tran_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,ldConfDate);
pstmt.setString(2,lsEmpAprv);
pstmt.setString(3,empCode);
pstmt.setTimestamp(4,tranDate);
int cnt6 = pstmt.executeUpdate();
System.out.println("cnt6"+cnt6);
if(cnt6 > 0)
{
System.out.println("Data Updated for emp_statuschg");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return lsErrcode;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
public interface StatusChangeConfirmLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag)throws RemoteException,ITMException;
public String gbfPostLogic(String tranId, String xtraParams, String forcedFlag,Connection conn) throws ITMException;
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
public interface StatusChangeConfirmRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag)throws RemoteException,ITMException;
public String gbfPostLogic(String tranId, String xtraParams, String forcedFlag,Connection conn) throws ITMException;
}
package ibase.webitm.ejb.adm;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.rmi.RemoteException;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
public class StatusChangeIC extends ValidatorEJB //implements StatusChangeLocal,StatusChangeRemote
{
ITMDBAccessEJB itmDbAcess = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
AdmCommon adm = new AdmCommon();
FinCommon finCommon = new FinCommon();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
System.out.println("Print dom>>>> " + dom);
}
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println("ErrString :" + errString);
}
catch (Exception e)
{
System.out.println("Exception :StatusChangeIC :wfValData(String xmlString):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
NodeList parentNodeList = null;
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
int childNodeListLength = 0;
NodeList childNodeList = null;
String sql = "";
int cnt = 0;
int counter;
int noOfChilds = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer errStringXml = null;
String errString = "";
String userId = "";
int currentFormNo = 0;
Connection conn = null;
Timestamp dateEff = null;
Timestamp dateDue = null;
String empCode = "";
String errCode = "";
String dateDueChgStr = "";
String lsEmpcodeO = "";
String tranDateStr = "";
String lsSite = "";
String ldTrandateOStr = "";
int liCnt = 0 , lcMonths = 0;
String lsConfStatus = "";
String lsProbStatus = "";
String lsStatusType = "";
String lsStatusTypeX = "";
String loginSite = "";
String dateEffchgStr = "";
String confirmed = "";
String extend = "";
String lcMonthsStr = "";
String empCodeAprv = "";
String designCode = "";
String status = "";
String cadreCode = "";
String gradeCode = "";
String reasonCode = "";
String statusType = "";
int monthsExtend = 0;
String monthsExtend1 = "";
int noticePrd = 0;
String lcNoticePrd = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Timestamp dateEffchg = null , tranDate = null , ldTrandateO = null , ldStatusDateX = null , ldProbDate = null ,
ldConfDate = null , reliveDate = null;
try
{
conn = getConnection();
errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSite");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
if (childNode.getNodeType() != Node.ELEMENT_NODE)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("childNodeName.editFlag." + childNodeName + "@V@ Edit flag :-" + editFlag);
if("date__effchg".equalsIgnoreCase(childNodeName))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code",dom));
dateEffchgStr = checkNull(genericUtility.getColumnValue("date__effchg",dom));
System.out.println("dateEffchgStr::::::::::::::::"+dateEffchgStr);
System.out.println("empCode::::::::::::::::"+empCode);
if(dateEffchgStr != null && dateEffchgStr.trim().length() > 0)
{
dateEffchg = Timestamp.valueOf(genericUtility.getValidDateString(dateEffchgStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(dateEffchgStr == null || dateEffchgStr.trim().length() == 0 )
{
errList.add("VTEMPSTS04"); //Effective date is blank, please specify effective date
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " select pay_site as ls_site from employee where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
lsSite = checkNull(rs.getString("ls_site"));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(dateEffchgStr != null && dateEffchgStr.trim().length() > 0)
{
errCode = checkNull(finCommon.nfCheckPeriod("ADM", dateEffchg, lsSite, conn));
}
if(errCode != null && errCode.trim().length() > 0)
{
if("VTPRD2".equalsIgnoreCase(errCode))
{
errList.add("VTPRDTEMP1");//This is a temporary error for status change
errFields.add(childNodeName.toLowerCase());
}
else if("VTPRDADM".equalsIgnoreCase(errCode))
{
errList.add("VTPRDTEMP2");//Period status not defined for Admin
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("emp_code".equalsIgnoreCase(childNodeName))
{
System.out.println("empCode:::::::::"+empCode);
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
lsEmpcodeO = checkNull(genericUtility.getColumnValue("emp_code_orig", dom));
dateEffchgStr = checkNull(genericUtility.getColumnValue("date__effchg", dom));
tranDateStr = checkNull(genericUtility.getColumnValue("tran_date", dom));
ldTrandateOStr = checkNull(genericUtility.getColumnValue("tran_date_orig", dom));
if(dateEffchgStr != null && dateEffchgStr.trim().length() > 0)
{
dateEffchg = Timestamp.valueOf(genericUtility.getValidDateString(dateEffchgStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(tranDateStr != null && tranDateStr.trim().length() > 0)
{
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(ldTrandateOStr != null && ldTrandateOStr.trim().length() > 0)
{
ldTrandateO = Timestamp.valueOf(genericUtility.getValidDateString(ldTrandateOStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
System.out.println("dateEffchgStr:::::::::"+dateEffchgStr);
System.out.println("tranDateStr:::::::::"+tranDateStr);
System.out.println("ldTrandateOStr:::::::::"+ldTrandateOStr);
if(empCode == null || empCode.trim().length() == 0)
{
errList.add("VTEMPSTS05");//Employee code is blank, please specify employee code
errFields.add(childNodeName.toLowerCase());
}
else
{
liCnt = 0;
sql = "select confirmed, "
+ "probation, "
+ "probation_date, "
+ "date_conf, "
+ "1 as li_cnt "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
lsConfStatus = checkNull(rs.getString("confirmed"));
lsProbStatus = checkNull(rs.getString("probation"));
ldProbDate = rs.getTimestamp("probation_date");
ldConfDate = rs.getTimestamp("date_conf");
liCnt = rs.getInt("li_cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(liCnt == 0)
{
errList.add("VTEMPSTS03");//Employee code entered does not existing in master, please enter valid employee code
errFields.add(childNodeName.toLowerCase());
}
else
{
liCnt = 0;
if("A".equalsIgnoreCase(editFlag))
{
sql = "select count(*) as li_cnt "
+ "from "
+ "emp_statuschg "
+ "where "
+ "emp_code = ? "
+ "and "
+ "case when confirm is null then 'N' else confirm end <> 'X' "
+ "and "
+ "tran_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(liCnt > 0)
{
errList.add("VTEMPSTS08");
errFields.add(childNodeName.toLowerCase());
}
}
else
{
liCnt = 0;
sql = "select count(*) as li_cnt "
+ "from "
+ "emp_statuschg "
+ "where "
+ "emp_code = ? "
+ "and case when confirm is null then 'N' else confirm end <> 'X' "
+ "and tran_date = ? "
+ "and (emp_code <> ? or tran_date <> ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, tranDate);
pstmt.setString(3, lsEmpcodeO);
pstmt.setTimestamp(4, ldTrandateO);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
System.out.println("liCnt:::::::::"+liCnt);
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(liCnt > 0)
{
errList.add("VTEMPSTS08");
errFields.add(childNodeName.toLowerCase());
}
else
{
if("A".equalsIgnoreCase(editFlag))
{
liCnt = 0;
sql = "select count(*) as li_cnt "
+ "from "
+ "emp_statuschg "
+ "where "
+ "emp_code = ? "
+ "and case when confirm is null then 'N' else confirm end = 'N' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
liCnt = 0;
sql = "select count(*) as li_cnt "
+ "from "
+ "emp_statuschg "
+ "where "
+ "emp_code = ? "
+ "and case when confirm is null then 'N' else confirm end = 'N' "
+ "and (emp_code <> ? or tran_date <> ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, lsEmpcodeO);
pstmt.setTimestamp(3, ldTrandateO);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(liCnt > 0)
{
errList.add("VTEMPSTS09");
errFields.add(childNodeName.toLowerCase());
}
else
{
lsStatusType = checkNull(genericUtility.getColumnValue("status_type", dom));
if("N".equalsIgnoreCase(lsProbStatus))
{
lsStatusTypeX = "P";
ldStatusDateX = ldProbDate;
}
else
{
if("Y".equalsIgnoreCase(lsProbStatus) && "N".equalsIgnoreCase(lsConfStatus))
{
lsStatusTypeX = "C";
ldStatusDateX = ldConfDate;
}
}
}
if(!lsStatusTypeX.equalsIgnoreCase(lsStatusType))
{
errList.add("VTEMPSTS10");
errFields.add(childNodeName.toLowerCase());
}
else
{
if("A".equalsIgnoreCase(editFlag))
{
liCnt = 0;
sql = "select count(*) as li_cnt "
+ "from "
+ "emp_statuschg "
+ "where "
+ "emp_code = ? "
+ "and "
+ "tran_date >= ? "
+ "and case when confirm is null then 'N' else confirm end <> 'X'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
liCnt = 0;
sql = "select count(*) as li_cnt "
+ "from "
+ "emp_statuschg "
+ "where emp_code = ? "
+ "and tran_date >= ? "
+ "and case when confirm is null then 'N' else confirm end <> 'X' "
+ "and (emp_code <> ? or tran_date <> ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, tranDate);
pstmt.setString(3, lsEmpcodeO);
pstmt.setTimestamp(4, ldTrandateO);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("li_cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(liCnt == 0)
{
sql = "select "
+ "emp_site as ls_site "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
lsSite = rs.getString("ls_site");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(lsSite != null && lsSite.trim().length() > 0)
{
errCode = adm.gbfEmp(empCode, dateEffchg, lsSite, loginSite, conn);
System.out.println("error Code is ====" + errCode);
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
sql = "select "
+ "confirmed "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = rs.getString("confirmed");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("Y".equalsIgnoreCase(confirmed))
{
errList.add("VMEMP3");
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errList.add("VDEMP1");
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
}
}
else if("extend".equalsIgnoreCase(childNodeName))
{
extend = checkNull(genericUtility.getColumnValue("extend", dom));
dateEffchgStr = checkNull(genericUtility.getColumnValue("date__effchg", dom));
dateDueChgStr = checkNull(genericUtility.getColumnValue("date__due_chg", dom));
if(dateEffchgStr != null && dateEffchgStr.trim().length() > 0)
{
dateEffchg = Timestamp.valueOf(genericUtility.getValidDateString(dateEffchgStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(dateDueChgStr != null && dateDueChgStr.trim().length() > 0)
{
dateDue = Timestamp.valueOf(genericUtility.getValidDateString(dateDueChgStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if("N".equalsIgnoreCase(extend))
{
if((dateEffchg != null && dateDue != null) && dateEffchg.before(dateDue))
{
errList.add("VMDATE20");//effective date can not be prior to due date
errFields.add(childNodeName.toLowerCase());
}
else if("Y".equalsIgnoreCase(extend))
{
lcMonthsStr = checkNull(genericUtility.getColumnValue("months_extend", dom));
try
{
lcMonths = Integer.parseInt(lcMonthsStr);
}
catch(Exception e)
{
lcMonths = 0;
}
if(lcMonths <= 0)
{
errList.add("VTEXT");//Extend Months cannot be zero or negative
errFields.add(childNodeName.toLowerCase());
}
}
}
}
else if("emp_code__aprv".equalsIgnoreCase(childNodeName))
{
empCodeAprv = checkNull(genericUtility.getColumnValue("emp_code__aprv", dom));
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
if(empCodeAprv != null && empCodeAprv.trim().length() > 0)
{
sql = "select count(*) as cnt , "
+ "RELIEVE_DATE "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ? group by RELIEVE_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
reliveDate = rs.getTimestamp("RELIEVE_DATE");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if((cnt == 0))
{
errList.add("VMEMP1");
errFields.add(childNodeName.toLowerCase());
}
if(reliveDate != null)
{
errList.add("VMEMPV");
errFields.add(childNodeName.toLowerCase());
}
if(empCodeAprv.equalsIgnoreCase(empCode))
{
errList.add("VMEMP4");
errFields.add(childNodeName.toLowerCase());
}
}
else if("design_code".equalsIgnoreCase(childNodeName))
{
designCode = checkNull(genericUtility.getColumnValue("design_code", dom));
if(designCode == null || designCode.trim().length() == 0)
{
errList.add("VMDESIGN2");
errFields.add(childNodeName.toLowerCase());
}
else
{
cnt = 0;
sql = "select count(*) as cnt "
+ "from "
+ "designation "
+ "where "
+ "design_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, designCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errList.add("VMDESIGN");
errFields.add(childNodeName.toLowerCase());
}
}
sql = "select "
+ "status "
+ "from "
+ "designation "
+ "where "
+ "design_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, designCode);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString("status");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(!"A".equalsIgnoreCase(status))
{
errList.add("VTDGINAC");
errFields.add(childNodeName.toLowerCase());
}
}
else if("cadre_code".equalsIgnoreCase(childNodeName))
{
cnt = 0;
cadreCode = checkNull(genericUtility.getColumnValue("cadre_code", dom));
sql = "select "
+ "count(*) as cnt "
+ "from "
+ "cadre "
+ "where "
+ "cadre_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cadreCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errList.add("VMCAD1");//err = "Invalid cadre code, not defined in master"
errFields.add(childNodeName.toLowerCase());
}
}
else if("grade_code".equalsIgnoreCase(childNodeName))
{
cnt = 0;
gradeCode = checkNull(genericUtility.getColumnValue("grade_code", dom));
sql = "select "
+ "count(*) as cnt "
+ "from "
+ "grade "
+ "where "
+ "grade_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, gradeCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errList.add("VMGRA1");//err = "Invalid grade code, not defined in master"
errFields.add(childNodeName.toLowerCase());
}
}
else if("reason_code".equalsIgnoreCase(childNodeName))
{
cnt = 0;
reasonCode = checkNull(genericUtility.getColumnValue("reason_code", dom));
if(reasonCode == null || reasonCode.trim().length() == 0)
{
errList.add("VTEMPSTS06");
errFields.add(childNodeName.toLowerCase());
}
else
{
cnt = 0;
statusType = checkNull(genericUtility.getColumnValue("status_type", dom));
extend = checkNull(genericUtility.getColumnValue("extend", dom));
sql = "select count(1) as cnt "
+ "from "
+ "gencodes "
+ "where "
+ "fld_name = 'REASON_CODE' "
+ "and "
+ "mod_name in ('W_EMP_STATUS') "
+ "and case when active is null then 'Y' else active end = 'Y' "
+ "and fld_value = ? and udf_str1 = ? and udf_str2 = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statusType);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errList.add("VTEMPSTS07");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("notice_prd".equalsIgnoreCase(childNodeName))
{
lcNoticePrd = genericUtility.getColumnValue("notice_prd", dom);
try
{
noticePrd = Integer.parseInt(lcNoticePrd);
}
catch(Exception e)
{
errList.add("VTEMPSTS13");// Please enter proper value
errFields.add(childNodeName.toLowerCase());
}
if(noticePrd < 0)
{
errList.add("VTEMPSTS11");
errFields.add(childNodeName.toLowerCase());
}
}
else if("months_extend".equalsIgnoreCase(childNodeName))
{
monthsExtend1 = genericUtility.getColumnValue("months_extend", dom);
System.out.println("months_extend :: ["+monthsExtend1+"]");
try
{
monthsExtend = Integer.parseInt(monthsExtend1);
}
catch(Exception e)
{
errList.add("VTEMPSTS13");// Please enter proper value
errFields.add(childNodeName.toLowerCase());
}
}
if(monthsExtend < 0)
{
errList.add("VTEMPSTS12");
errFields.add(childNodeName.toLowerCase());
}
}
}
}
System.out.println("errStringXml.toString()---1= "+errStringXml.toString());
if (errList != null && errList.size() > 0)
{
System.out.println("errList==[" + errList + "]");
int errListSize = errList.size();
System.out.println("errListSize:::::::[" + errListSize + "]");
System.out.println("in error::::::::::");
for (int i = 0; i < errListSize; i++)
{
System.out.println("in error For:::::::::::::::");
errCode = (String) errList.get(i);
String errFldName = (String) errFields.get(i);
System.out.println("errCode .........." + errCode);
errString = itmDbAcess.getErrorString(errFldName, errCode, userId, "", conn);
System.out.println("errString is : ::::>>>> " + errString);
String msgType = errorType(conn, errCode);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
}
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errFields.clear();
}
errStringXml.append("</Errors></Root>\r\n");
System.out.println("errStringXml.toString()---2= "+errStringXml.toString());
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
E12GenericUtility genericUtility = null;
try
{
genericUtility = new E12GenericUtility();
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
System.out.println("returning from StatusChangeIC itemChanged ===" + valueXmlString);
}
catch (Exception e)
{
System.out.println("Exception :StatusChangeIC :itemChanged(String,String):" + e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,String editFlag, String xtraParams)throws java.rmi.RemoteException, ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String colName = "";
colName = currentColumn;
String sql = "";
int currentFormNo = 0;
String empCode = "" , monthsExtend = "";
String empLname = "";
String empFname = "";
String confirmed = "";
String probation = "";
String noticePrd = "";
Timestamp dateJoin = null;
String grade = "";
String cadre = "";
String designCode = "";
String designation = "";
String lsEmpFnameLong = "";
String lsEmpLnameLong = "";
String lcNoticePrd = "";
String lsGrade = "";
String lsCadre = "";
String lsDesignCode = "";
String lsDesignation = "";
String lsEligibleOt = "";
String tranDate = "";
String extend = "";
String gradeCode = "";
String cadreCode = "";
String reasonCode = "";
String probationDateStr = "";
String dateConfStr = "";
String ldJoinDateStr = "";
StringBuffer valueXmlString = null;
SimpleDateFormat sdf = null;
try
{
conn = getConnection();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>");
valueXmlString.append(editFlag).append("</editFlag>\r\n</Header>\r\n");
System.out.println("current form no: " + currentFormNo);
switch(currentFormNo)
{
case 1:
{
valueXmlString.append("<Detail1>\r\n");
if("itm_default".equalsIgnoreCase(currentColumn))
{
monthsExtend = checkNull(genericUtility.getColumnValue("months_extend", dom));
System.out.println("months_extend :: ["+monthsExtend+"]");
valueXmlString.append("<extend>").append("<![CDATA[N]]>").append("</extend>");
valueXmlString.append("<tran_date><![CDATA[").append(sdf.format(new java.util.Date())).append("]]></tran_date>\r\n");
valueXmlString.append("<months_extend protect='1'>").append("<![CDATA[" + monthsExtend + "]]>").append("</months_extend>\r\n");
valueXmlString.append("<confirm>").append("<![CDATA[N]]>").append("</confirm>");
valueXmlString.append("<notice_prd>").append("<![CDATA[0]]>").append("</notice_prd>");
}
else if("emp_code".equalsIgnoreCase(currentColumn))
{
empCode = genericUtility.getColumnValue("emp_code", dom);
System.out.println("::::::::::inside emp_code ITEMCHANGED::::::::"+empCode);
sql = "select "
+ "emp_lname ,"
+ "emp_fname ,"
+ "confirmed ,"
+ "probation ,"
+ "probation_date ,"
+ "date_conf ,"
+ "notice_prd , "
+ "date_join ,"
+ "grade ,"
+ "cadre ,"
+ "design_code ,"
+ "designation , "
+ "case when eligible_ot is null then 'N' else eligible_ot end , "
+ "emp_fname_long , "
+ "emp_lname_long "
+ "from "
+ "employee "
+ "where "
+ "emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
empLname = checkNull(rs.getString("emp_lname"));
empFname = checkNull(rs.getString("emp_fname"));
confirmed = checkNull(rs.getString("confirmed"));
probation = checkNull(rs.getString("probation"));
probationDateStr = rs.getString("probation_date");
dateConfStr = rs.getString("date_conf");
lcNoticePrd = checkNull(rs.getString("notice_prd"));
ldJoinDateStr = rs.getString("date_join");
lsGrade = checkNull(rs.getString("grade"));
lsCadre = checkNull(rs.getString("cadre"));
lsDesignCode = checkNull(rs.getString("design_code"));
lsDesignation = checkNull(rs.getString("designation"));
//lsEligibleOt = checkNull(rs.getString("eligible_ot"));
lsEmpFnameLong = checkNull(rs.getString("emp_fname_long"));
lsEmpLnameLong = checkNull(rs.getString("emp_lname_long"));
}
System.out.println("empLname:::"+empLname);
System.out.println("empFname:::"+empFname);
System.out.println("confirmed:::"+confirmed);
System.out.println("probation:::"+probation);
System.out.println("probationDateStr:::"+probationDateStr);
System.out.println("dateConfStr:::"+dateConfStr);
System.out.println("lcNoticePrd:::"+lcNoticePrd);
System.out.println("ldJoinDateStr:::"+ldJoinDateStr);
System.out.println("lsGrade:::"+lsGrade);
System.out.println("lsCadre:::"+lsCadre);
System.out.println("lsDesignCode:::"+lsDesignCode);
System.out.println("lsDesignation:::"+lsDesignation);
System.out.println("lsEmpFnameLong:::"+lsEmpFnameLong);
System.out.println("lsEmpLnameLong:::"+lsEmpLnameLong);
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(lsEmpFnameLong != null && lsEmpFnameLong.trim().length() > 0)
{
empFname = lsEmpFnameLong;
}
if(lsEmpLnameLong != null && lsEmpLnameLong.trim().length() > 0)
{
empLname = lsEmpLnameLong;
}
System.out.println("probationDateStr:["+probationDateStr+"] \t dateConfStr["+dateConfStr+"] \t ldJoinDateStr["+ldJoinDateStr+"]");
if(probationDateStr != null && probationDateStr.trim().length() > 0)
{
probationDateStr = genericUtility.getValidDateString(probationDateStr,"yyyy-MM-dd", genericUtility.getApplDateFormat());
}
else
{
probationDateStr = "";
}
if(dateConfStr != null && dateConfStr.trim().length() > 0)
{
//dateConfStr = sdf.format(dateConfStr);
dateConfStr = genericUtility.getValidDateString(dateConfStr,"yyyy-MM-dd", genericUtility.getApplDateFormat());
//Timestamp.valueOf(genericUtility.getValidDateString(dateConfStr, genericUtility.getDBDateFormat() , genericUtility.getApplDateFormat()) + " 00:00:00.0");
}
else
{
dateConfStr = "";
}
if(ldJoinDateStr != null && ldJoinDateStr.trim().length() > 0)
{
//ldJoinDateStr = sdf.format(ldJoinDateStr);
ldJoinDateStr = genericUtility.getValidDateString(ldJoinDateStr,"yyyy-MM-dd", genericUtility.getApplDateFormat());
//Timestamp.valueOf(genericUtility.getValidDateString(ldJoinDateStr, genericUtility.getDBDateFormat() , genericUtility.getApplDateFormat()) + " 00:00:00.0");
}
else
{
ldJoinDateStr = "";
}
valueXmlString.append("<employee_date_join>").append("<![CDATA[" + ldJoinDateStr + "]]>").append("</employee_date_join>");
valueXmlString.append("<emp_lname>").append("<![CDATA[" + empLname + "]]>").append("</emp_lname>");
valueXmlString.append("<emp_fname>").append("<![CDATA[" + empFname + "]]>").append("</emp_fname>");
valueXmlString.append("<notice_prd>").append("<![CDATA[" + lcNoticePrd + "]]>").append("</notice_prd>");
valueXmlString.append("<grade_o>").append("<![CDATA[" + lsGrade + "]]>").append("</grade_o>");
valueXmlString.append("<cadre_o>").append("<![CDATA[" + lsCadre + "]]>").append("</cadre_o>");
valueXmlString.append("<design_code_o>").append("<![CDATA[" + lsDesignCode + "]]>").append("</design_code_o>");
valueXmlString.append("<designation_o>").append("<![CDATA[" + lsDesignation + "]]>").append("</designation_o>");
valueXmlString.append("<grade_code>").append("<![CDATA[" + lsGrade + "]]>").append("</grade_code>");
valueXmlString.append("<cadre_code>").append("<![CDATA[" + lsCadre + "]]>").append("</cadre_code>");
valueXmlString.append("<design_code>").append("<![CDATA[" + lsDesignCode + "]]>").append("</design_code>");
valueXmlString.append("<designation>").append("<![CDATA[" + lsDesignation + "]]>").append("</designation>");
if(lsEligibleOt == null || lsEligibleOt.trim().length() == 0)
{
lsEligibleOt = "N";
}
valueXmlString.append("<eligible_ot_o>").append("<![CDATA[" + lsEligibleOt + "]]>").append("</eligible_ot_o>");
valueXmlString.append("<eligible_ot>").append("<![CDATA[" + lsEligibleOt + "]]>").append("</eligible_ot>");
if("N".equalsIgnoreCase(probation))
{
valueXmlString.append("<status_type>").append("<![CDATA[P]]>").append("</status_type>");
valueXmlString.append("<date__due_chg>").append("<![CDATA[" + probationDateStr + "]]>").append("</date__due_chg>");
valueXmlString.append("<date__effchg>").append("<![CDATA[" + probationDateStr + "]]>").append("</date__effchg>");
}
else
{
if("Y".equalsIgnoreCase(probation) && "N".equalsIgnoreCase(confirmed))
{
valueXmlString.append("<status_type>").append("<![CDATA[C]]>").append("</status_type>");
valueXmlString.append("<date__due_chg>").append("<![CDATA[" + dateConfStr + "]]>").append("</date__due_chg>");
valueXmlString.append("<date__effchg>").append("<![CDATA[" + dateConfStr + "]]>").append("</date__effchg>");
}
System.out.println("dateConfStr111111111"+dateConfStr);
}
if("A".equalsIgnoreCase(editFlag))
{
valueXmlString.append("<emp_code_orig>").append("<![CDATA[" + empCode + "]]>").append("</emp_code_orig>");
}
}
else if("tran_date".equalsIgnoreCase(currentColumn))
{
if("A".equalsIgnoreCase(editFlag))
{
tranDate = checkNull(genericUtility.getColumnValue("tran_date", dom));
valueXmlString.append("<tran_date_orig>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date_orig>");
}
}
else if("extend".equalsIgnoreCase(currentColumn))
{
extend = checkNull(genericUtility.getColumnValue("extend", dom));
monthsExtend = checkNull(genericUtility.getColumnValue("months_extend", dom));
if("N".equalsIgnoreCase(extend))
{
valueXmlString.append("<months_extend>").append("<![CDATA[0]]>").append("</months_extend>");
valueXmlString.append("<months_extend protect=\"1\"><![CDATA[").append(monthsExtend).append("]]></months_extend>\r\n");
}
else
{
valueXmlString.append("<months_extend protect=\"0\"><![CDATA[").append(monthsExtend).append("]]></months_extend>\r\n");
}
}
else if("grade_code".equalsIgnoreCase(currentColumn))
{
gradeCode = checkNull(genericUtility.getColumnValue("grade_code", dom));
sql = "select "
+ "cadre_code "
+ "from "
+ "grade "
+ "where "
+ "grade_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, gradeCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cadreCode = rs.getString("cadre_code");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<cadre_code>").append("<![CDATA[" + cadreCode + "]]>").append("</cadre_code>");
}
else if("design_code".equalsIgnoreCase(currentColumn))
{
designCode = checkNull(genericUtility.getColumnValue("design_code", dom));
sql = "select "
+ "designation "
+ "from "
+ "designation "
+ "where "
+ "design_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, designCode);
rs = pstmt.executeQuery();
if(rs.next())
{
designation = rs.getString("designation");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<designation>").append("<![CDATA[" + designation + "]]>").append("</designation>");
}
else if("reason_code".equalsIgnoreCase(currentColumn))
{
String reasonCodeDescr = "";
reasonCode = checkNull(genericUtility.getColumnValue("reason_code", dom));
if(reasonCode == null || reasonCode.trim().length() == 0)
{
reasonCode = "";
}
sql = "select "
+ "descr from gencodes "
+ "where fld_name = 'REASON_CODE' "
+ "and mod_name in ('W_EMP_STATUS') "
+ "and case when active is null then 'Y' else active end = 'Y' "
+ "and fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, designCode);
rs = pstmt.executeQuery();
if(rs.next())
{
reasonCodeDescr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<reason_code_descr>").append("<![CDATA[" + reasonCodeDescr + "]]>").append("</reason_code_descr>");
}
}
valueXmlString.append("</Detail1>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :GradeSiteLveTbl [itemChanged(String xmlString)] : ==>\n" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception d)
{
System.out.println("Exception ::"+d);
d.printStackTrace();
throw new ITMException(d);
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
if (conn == null)
{
System.out.println("Connection is null");
}
else
{
System.out.println("Connection is not null");
}
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
public interface StatusChangeLocal extends ValidatorLocal
{
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException,ITMException ;
public String wfValData(Document dom, Document dom1, Document dom2,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException;
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
public interface StatusChangeRemote extends ValidatorRemote
{
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException,ITMException ;
public String wfValData(Document dom, Document dom1, Document dom2,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment