Commit e9872038 authored by vvengurlekar's avatar vvengurlekar

EmpLeaveConf.java - commit statement written outside confirm method

EmpLvePrkBalTrfCanc.java
EmpLvePrkBalTrfConf.java - changes done for emp lve and prk transfer
EmpLvePrkBalTrfIC.java - 


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@188700 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b3ec1f5f
......@@ -3,7 +3,6 @@ package ibase.webitm.ejb.adm;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;//Modified By Hemlata on[20/11/2014] [As per changes in framework to use genericUtility ]
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
......@@ -534,6 +533,7 @@ public class EmpLvePrkBalTrfIC extends ValidatorEJB implements EmpLvePrkBalTrfIC
String siteCodeFrom = "";
String siteCodeTo = "";
java.util.Date joinDate = null ;
Date currentDate = new Date();
String tranMode = "", joinDateStr="", retString = "";
E12GenericUtility genericUtility = new E12GenericUtility();
......@@ -694,7 +694,16 @@ public class EmpLvePrkBalTrfIC extends ValidatorEJB implements EmpLvePrkBalTrfIC
retString = itmDBAccess.getErrorString( "", "VTELPTRF05", userId, "", conn );
return retString;
}
//Added by Varsha V on 16-07-18 for adding condition of relieving date should less than current date
currentDate = new java.util.Date();
System.out.println("currentDate:::["+currentDate+"] relieveDate:::["+relieveDate+"]");
if(relieveDate.after(currentDate))
{
System.out.println("relieveDate is not greater than currentDate ::::");
retString = itmDBAccess.getErrorString( "", "VTELPTRF22", userId, "", conn );
return retString;
}
//Ended by Varsha V on 16-07-18 for adding condition of relieving date should less than current date
sql = "SELECT USR_LEV FROM USERS WHERE CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, loginCode );
......
......@@ -98,6 +98,16 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
try
{
retString = confirm( tranId, xtraParams, forcedFlag, 2, conn);
//Added by varsha V on 03-08-18 for Commit statement
if(retString.contains("VTSUCC1"))
{
conn.commit();
}
else
{
conn.rollback();
}
//Ended by varsha V on 03-08-18 for Commit statement
}
catch(Exception e)
{
......@@ -214,7 +224,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
}
if (errString == null || errString.trim().length() == 0)
{
conn.commit();
//commented commit statement by varsha V on 03-08-18
//conn.commit();
/*Modified by Anjali Rawankar on[22/08/2017][Start]
*[Added for itmDbAccess]*/
//errString = getErrorString( "", "VTSUCC1" , this.userId );
......@@ -225,10 +236,11 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
/*[Added for itmDbAccess]
*Modified by Anjali Rawankar on[22/08/2017][End]*/
}
else
//commented rollback statement by varsha V on 03-08-18
/*else
{
conn.rollback();
}
}*/
}
catch(Exception e)
{
......
......@@ -138,11 +138,14 @@ public class EmpLvePrkBalTrfCanc extends ActionHandlerEJB implements EmpLvePrkBa
}
else
{
sql=" UPDATE EMP_LVEPRKBAL_TRFHDR SET STATUS = ?, STATUS_DATE = ? WHERE TRAN_ID= ? ";
sql=" UPDATE EMP_LVEPRKBAL_TRFHDR SET STATUS = ?, STATUS_DATE = ?, EMP_CODE__CONF = ? WHERE TRAN_ID= ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, "X" );
pstmt.setTimestamp( 2, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString( 3, tranId );
// Added by Varsha V on 16/07/18 for updating EMP_CODE__CONF also
pstmt.setString( 3, userId );
// Ended by Varsha V on 16/07/18 for updating EMP_CODE__CONF also
pstmt.setString( 4, tranId );
pstmt.executeUpdate();
updCnt = pstmt.executeUpdate();
if( updCnt > 0 )
......
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.CallableStatement;
import java.sql.Connection;
......@@ -10,7 +9,6 @@ import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
......@@ -20,15 +18,14 @@ import ibase.utility.BaseException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;//Added by sarita on 20 JULY 18 for [ITMDBAccessEJB]
//import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.adm.AdmCommon;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
/**Author: Umakanta Das
* Desc:
/**
* Author: Umakanta Das Desc:
*
*/
@Stateless
......@@ -38,53 +35,41 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
* @see ActionHandlerEJB#ActionHandlerEJB()
*/
AdmCommon admCommon = new AdmCommon();
public EmpLvePrkBalTrfConf()
{
public EmpLvePrkBalTrfConf() {
super();
}
public String confirm( String tranId, String xtraParams, String forcedFlag ) throws RemoteException, ITMException
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException {
Connection conn = null;
boolean errorFound = false;
String retStr = "";
try
{
try {
conn = getConnection();
System.out.println("tranId:::::["+tranId+"] xtraParams::::: ["+xtraParams+"] forcedFlag::::: ["+forcedFlag+"]");
retStr = confirm( tranId, xtraParams, forcedFlag, conn);
System.out.println("Umakanta::retStr["+retStr+"]");
}
catch (Exception e)
{
System.out.println("tranId:::::[" + tranId + "] xtraParams::::: [" + xtraParams + "] forcedFlag::::: ["
+ forcedFlag + "]");
retStr = confirm(tranId, xtraParams, forcedFlag, conn);
System.out.println("Umakanta::retStr[" + retStr + "]");
} catch (Exception e) {
errorFound = true;
System.out.println("in confirm ["+e.getMessage()+"]" );
System.out.println("in confirm [" + e.getMessage() + "]");
e.printStackTrace();
}
finally
{
try
{
if( conn != null )
{
if( errorFound )
{
} finally {
try {
if (conn != null) {
if (errorFound) {
System.out.println("Rolling Back Changes......");
conn.rollback();
}
else
{
} else {
System.out.println("Commiting Changes......");
conn.commit();
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
} catch (Exception e) {
System.out.println("EmpLvePrkBalTrfConf :confirm :==>\n" + e);
e.printStackTrace();
throw new ITMException(e);
......@@ -94,8 +79,7 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
}
/**
* This method handle the confirmation logic for
* leave confirmation.
* This method handle the confirmation logic for leave confirmation.
*
* @param conn
* @param tranId
......@@ -109,11 +93,12 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
* @throws BaseException
*/
@SuppressWarnings({ "unused", "resource" })
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException
{
String retString = ""; String successString = "";
ResultSet rs = null; ResultSet rs1 = null;
PreparedStatement pStmt = null; PreparedStatement pStmt1 = null; PreparedStatement pStmt2 = null; PreparedStatement pStmt3 = null; PreparedStatement pStmt4 = null; PreparedStatement pStmt5 = null;
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException {
String retString = "";
String successString = "";
ResultSet rs = null;
ResultSet rs1 = null;
PreparedStatement pStmt = null, pStmt1 = null, pStmt2 = null, pStmt3 = null, pStmt4 = null, pStmt5 = null, pStmt6 = null;
CallableStatement callStmt = null;
String sql = "";
Timestamp tranDate = null;
......@@ -128,26 +113,26 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
String empCodeConf = "";
String balCodeAson = "";
String balCode = "";
double lveBalance = 0.0D; double perkBalance = 0.0D;
Timestamp relieveDateTM = null; Timestamp joinDate = null;
double lveBalance = 0.0D;
double perkBalance = 0.0D;
Timestamp relieveDateTM = null;
String periodCode = "";
String chgUser = "";
String chgTerm = "";
String logEmpCode = "";
String keyString = "";
String refSer = "";
String grade = ""; String cadre = ""; String siteCode = ""; String workSite = ""; String paySite = "";
//Added & Commented by sarita to use object of ITMDBAccessEJB,EmpLeaveConf instead ITMDBAccessLocal,EmpLeaveConfLocal on 20 JULY 18.[START]
/* ITMDBAccessLocal itmDBAccess = null;
EmpLeaveConfLocal empLeaveConf = null;*/
String grade = "";
String cadre = "";
String siteCode = "";
String workSite = "";
String paySite = "";
ITMDBAccessEJB itmDBAccess = null;
EmpLeaveConf empLeaveConf = null;
//Added & Commented by sarita to use object of ITMDBAccessEJB,EmpLeaveConf instead ITMDBAccessLocal,EmpLeaveConfLocal on 20 JULY 18.[END]
E12GenericUtility genericUtility = new E12GenericUtility();
boolean successFlag = true;
StringBuffer xmlStringForID = null;
try
{
try {
System.out.println("Inside confirm method of EmpLvePrkBalTrfConf");
//Added & Commented by sarita to create object instead creating lookup for ITMDBAccessEJB on 20 JULY 18 [START]
/* AppConnectParm appConnect = new AppConnectParm();
......@@ -161,35 +146,39 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
java.util.Date currentDate = new java.util.Date();
String currDateStr = sdf.format(currentDate);
System.out.println("currDateStr::::::[" + currDateStr + "]");
Timestamp curDateTm = Timestamp.valueOf(genericUtility.getValidDateTimeString(currDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()));
Timestamp curDateTm = Timestamp.valueOf(genericUtility.getValidDateTimeString(currDateStr,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()));
System.out.println("curDateTm - [" + curDateTm + "]");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if ((chgUser == null) || (chgUser.trim().length() == 0))
{
if ((chgUser == null) || (chgUser.trim().length() == 0)) {
chgUser = "SYSTEM";
}
if ((chgTerm == null) || (chgTerm.trim().length() == 0))
{
if ((chgTerm == null) || (chgTerm.trim().length() == 0)) {
chgTerm = "SYSTEM";
}
String userId = "";
int count = 0; int updCnt = 0; int insrtStatus = 0; int selectCount = 0;
String admEnvReturn = ""; String admParameter = "";
int count = 0;
int updCnt = 0;
int insrtStatus = 0;
int selectCount = 0;
String admEnvReturn = "";
String admParameter = "", statusEmpLeave = "";
Timestamp frDate = null; Timestamp toDate = null; Timestamp expDate = null;
Timestamp frDate = null;
Timestamp toDate = null;
Timestamp expDate = null;
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
sql = " SELECT LEAV.TRAN_DATE, LEAV.TRAN_TYPE, LEAV.TRAN_MODE, LEAV.SITE_CODE__FR , LEAV.SITE_CODE__TO, LEAV.EMP_CODE__FR, LEAV.EMP_CODE__TO, LEAV.STATUS, LEAV.STATUS_DATE, LEAV.EMP_CODE__CONF, LEAV.BALANCE_ASON, EMP.RELIEVE_DATE, EMP.PERIOD_CODE, EMP.RELIEVE_DATE, EMP.DATE_JOIN FROM EMP_LVEPRKBAL_TRFHDR LEAV INNER JOIN EMPLOYEE EMP ON LEAV.EMP_CODE__FR = EMP.EMP_CODE WHERE LEAV.TRAN_ID = ? ";
sql = " SELECT LEAV.TRAN_DATE, LEAV.TRAN_TYPE, LEAV.TRAN_MODE, LEAV.SITE_CODE__FR , LEAV.SITE_CODE__TO, LEAV.EMP_CODE__FR, LEAV.EMP_CODE__TO, LEAV.STATUS, LEAV.STATUS_DATE, LEAV.EMP_CODE__CONF, LEAV.BALANCE_ASON FROM EMP_LVEPRKBAL_TRFHDR LEAV WHERE LEAV.TRAN_ID = ? FOR UPDATE NOWAIT ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
tranDate = rs.getTimestamp("TRAN_DATE");
tranType = checkNull(rs.getString("TRAN_TYPE"));
tranMode = checkNull(rs.getString("TRAN_MODE"));
......@@ -201,31 +190,23 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
statusDate = rs.getDate("STATUS_DATE");
empCodeConf = checkNull(rs.getString("EMP_CODE__CONF"));
balCodeAson = checkNull(rs.getString("BALANCE_ASON"));
relieveDateTM = rs.getTimestamp("RELIEVE_DATE");
joinDate = rs.getTimestamp("DATE_JOIN");
periodCode = checkNull(rs.getString("PERIOD_CODE"));
}
if (rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
String releiveDateStr = genericUtility.getValidDateTimeString(relieveDateTM.toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
System.out.println("releiveDateStr:::::[" + releiveDateStr + "]");
if ("X".equalsIgnoreCase(status))
{
if ("X".equalsIgnoreCase(status)) {
retString = itmDBAccess.getErrorString("", "VTELPTRF16", userId, "", conn);
successFlag = false;
return retString;
}
if ("C".equalsIgnoreCase(status))
{
else if ("C".equalsIgnoreCase(status)) {
retString = itmDBAccess.getErrorString("", "VTELPTRF17", userId, "", conn);
successFlag = false;
return retString;
......@@ -237,49 +218,77 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
rs = pStmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
count = rs.getInt("ROW_CNT");
}
System.out.println("count:::: [" + count + "]");
if (rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if (count <= 0)
{
if (count <= 0) {
retString = itmDBAccess.getErrorString("", "VTELPTRF18", userId, "", conn);
successFlag = false;
return retString;
}
sql = "SELECT RELIEVE_DATE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, empCodeFr);
rs = pStmt.executeQuery();
if (rs.next()) {
relieveDateTM = rs.getTimestamp("RELIEVE_DATE");
}
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
String releiveDateStr = genericUtility.getValidDateTimeString(relieveDateTM.toString(),
genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
System.out.println("releiveDateStr:::::[" + releiveDateStr + "]");
sql = "SELECT CODE FROM PERIOD WHERE ? BETWEEN FR_DATE AND TO_DATE";
pStmt = conn.prepareStatement(sql);
pStmt.setTimestamp(1, relieveDateTM);
rs = pStmt.executeQuery();
if (rs.next()) {
periodCode = checkNull(rs.getString("CODE"));
}
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
sql = "SELECT GRADE, CADRE, EMP_SITE, WORK_SITE, PAY_SITE FROM EMPLOYEE WHERE EMP_CODE = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, empCodeTo);
rs = pStmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
grade = checkNull(rs.getString("GRADE"));
cadre = checkNull(rs.getString("CADRE"));
siteCode = checkNull(rs.getString("EMP_SITE"));
workSite = checkNull(rs.getString("WORK_SITE"));
paySite = checkNull(rs.getString("PAY_SITE"));
}
if (rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
......@@ -287,47 +296,38 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
admParameter = "TRF" + tranType.trim() + "_BLUPD_PROC";
admEnvReturn = this.admCommon.getAdmEnv(siteCode, cadre, grade, admParameter, curDateTm, conn);
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0) || (admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0)
|| (admEnvReturn.equalsIgnoreCase("NULLFOUND"))) {
admEnvReturn = this.admCommon.getEnv("999999", admParameter, conn);
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0) || (admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0)
|| (admEnvReturn.equalsIgnoreCase("NULLFOUND"))) {
admEnvReturn = "";
}
}
System.out.println("admEnvReturn:::::[" + admEnvReturn + "]");
if ("LVE".equalsIgnoreCase(tranType))
{
if ("LVE".equalsIgnoreCase(tranType)) {
sql = " select key_string as keystr, ref_ser as refser from transetup where upper(tran_window) = 'W_EMPLEAVE' ";
}
else
{
} else {
sql = " select key_string as keystr, ref_ser as refser from transetup where upper(tran_window) = 'T_EMP_ADLAPSE'";
}
pStmt = conn.prepareStatement(sql);
rs = pStmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
keyString = checkNull(rs.getString("keystr"));
refSer = checkNull(rs.getString("refSer"));
}
else
{
} else {
successFlag = false;
}
if (rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
System.out.println("keyString[" + keyString + "]============= refSer[" + refSer + "]");
if (!successFlag)
{
if (!successFlag) {
retString = itmDBAccess.getErrorString("", "VTSEQ", userId, "", conn);
return retString;
}
......@@ -335,11 +335,7 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
logEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("Umakanta::loginCode[" + logEmpCode + "]");
if ("LVE".equalsIgnoreCase(tranType))
{
sql = " select sum(bal_days) as baldays from leavebal where emp_code = ? and lve_code = ? and EFF_DATE = ? and UPTO_DATE = ? and EXP_DATE >= ?";
pStmt1 = conn.prepareStatement(sql);
if ("LVE".equalsIgnoreCase(tranType)) {
sql = "INSERT INTO EMPLEAVE ( EMP_CODE, LVE_DATE_FR, LVE_DATE_TO, LVE_CODE, USE_FLAG, ENCH_AMT, NO_DAYS, STATUS_DATE, PRD_CODE, CHG_DATE, CHG_USER, CHG_TERM, APPL_DATE, TRAN_ID, LEAVE_STARTS, LEAVE_ENDS ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ";
......@@ -348,13 +344,15 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
sql = "SELECT count(*) as COUNT FROM EMPLEAVE WHERE TRAN_ID = ?";
pStmt3 = conn.prepareStatement(sql);
sql = " SELECT BALANCE_CODE, FROM_DATE, TO_DATE, SUM(BALANCE) AS BALANCE FROM EMP_LVEPRKBAL_TRFDET WHERE TRAN_ID = ? GROUP BY BALANCE_CODE, FROM_DATE, TO_DATE ORDER BY BALANCE_CODE, FROM_DATE, TO_DATE ";
sql = "SELECT STATUS FROM EMPLEAVE WHERE TRAN_ID = ?";
pStmt4 = conn.prepareStatement(sql);
sql = " SELECT BALANCE_CODE, FROM_DATE, TO_DATE, BALANCE FROM EMP_LVEPRKBAL_TRFDET WHERE TRAN_ID = ? ORDER BY BALANCE_CODE, FROM_DATE, TO_DATE ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
while (rs.next())
{
while (rs.next()) {
balCode = checkNull(rs.getString("BALANCE_CODE"));
lveBalance = rs.getDouble("BALANCE");
frDate = rs.getTimestamp("FROM_DATE");
......@@ -362,36 +360,13 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
double balDays = 0.0D;
pStmt1.setString(1, empCodeFr);
pStmt1.setString(2, balCode);
pStmt1.setTimestamp(3, frDate);
pStmt1.setTimestamp(4, toDate);
pStmt1.setTimestamp(5, relieveDateTM);
rs1 = pStmt1.executeQuery();
if (rs1.next())
{
balDays = rs1.getDouble("baldays");
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
pStmt1.clearParameters();
if (lveBalance > balDays)
{
retString = itmDBAccess.getErrorString("", "VTELPTRF20", userId, "", conn);
successFlag = false;
break;
}
xmlStringForID = new StringBuffer();
xmlStringForID.append("<Root><Detail1><appl_date>" + curDateTm + "</appl_date><lve_code>" + balCode + "</lve_code>" +
"<lve_date_fr>" + releiveDateStr + "</lve_date_fr>" +
"<work_site>" + workSite + "</work_site>" + "</Detail1></Root>");
xmlStringForID.append("<Root><Detail1><appl_date>" + curDateTm + "</appl_date><lve_code>" + balCode
+ "</lve_code>" + "<lve_date_fr>" + releiveDateStr + "</lve_date_fr>" + "<work_site>"
+ workSite + "</work_site>" + "</Detail1></Root>");
System.out.println("xmlStringForID::::[" + xmlStringForID + "]");
TransIDGenerator tg = new TransIDGenerator(xmlStringForID.toString(), "SYSTEM", CommonConstants.DB_NAME);
TransIDGenerator tg = new TransIDGenerator(xmlStringForID.toString(), "SYSTEM",
CommonConstants.DB_NAME);
String tranIdGen = tg.generateTranSeqID(refSer, "", keyString, conn);
System.out.println("Umakanta::uniqueKey[" + tranIdGen + "]");
......@@ -416,83 +391,93 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
System.out.println("insert executed = [" + insrtStatus + "]");
pStmt2.clearParameters();
if (insrtStatus > 0)
{
if (insrtStatus > 0) {
pStmt3.setString(1, tranIdGen);
rs1 = pStmt3.executeQuery();
if (rs1.next())
{
if (rs1.next()) {
selectCount = rs1.getInt("COUNT");
}
if (rs1 != null)
{
if (rs1 != null) {
rs1.close();
rs1 = null;
}
pStmt3.clearParameters();
System.out.println("empLeave.table::selectCount[" + selectCount + "]");
System.out.println("empLeave.table::tranIdGen[" + tranIdGen + "]");
System.out.println("empLeave.table::xtraParams[" + xtraParams + "]");
String confirmStatus = empLeaveConf.confirm(tranIdGen, xtraParams, "Y", conn);
String confirmStatus = empLeaveConf.confirm(tranIdGen, xtraParams, "Y",1, conn);
System.out.println("empLeaveConf.confirm::confirmStatus[" + confirmStatus + "]");
if (selectCount > 0)
if(!confirmStatus.contains("VTSUCC1"))
{
successFlag = false;
retString = confirmStatus;
break;
}
pStmt4.setString(1, tranIdGen);
rs1 = pStmt4.executeQuery();
if (rs1.next()) {
statusEmpLeave = checkNull(rs1.getString("status"));
}
if (rs1 != null) {
rs1.close();
rs1 = null;
}
pStmt4.clearParameters();
System.out.println("empLeave.table::statusEmpLeave[" + statusEmpLeave + "]");
if (statusEmpLeave.equalsIgnoreCase("A")) {
successFlag = true;
successString = confirmStatus;
}
else
{
} else {
retString = confirmStatus;
successFlag = false;
break;
}
}
else
{
System.out.println("::After EmpLeave status successFlag[" + successFlag + "]");
} else {
successFlag = false;
break;
}
}
if (pStmt1 != null)
{
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pStmt1 != null) {
pStmt1.close();
pStmt1 = null;
}
if (pStmt2 != null)
{
if (pStmt2 != null) {
pStmt2.close();
pStmt2 = null;
}
if (pStmt3 != null)
{
if (pStmt3 != null) {
pStmt3.close();
pStmt3 = null;
}
if (rs != null)
{
if (pStmt4 != null) {
pStmt4.close();
pStmt4 = null;
}
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if ((retString != null) && (retString.trim().length() > 0))
{
if ((retString != null) && (retString.trim().length() > 0)) {
System.out.println("retString:::::[ " + retString + " ] ");
successFlag = false;
return retString;
}
if (successFlag)
{
if ((admEnvReturn != null) && (admEnvReturn.trim().length() > 0) && (!admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
try
{
if (successFlag) {
if ((admEnvReturn != null) && (admEnvReturn.trim().length() > 0)
&& (!admEnvReturn.equalsIgnoreCase("NULLFOUND"))) {
try {
System.out.println("Inside callable statement");
String procSql = "{call " + admEnvReturn + "(?,?,?,?,?)}";
callStmt = conn.prepareCall(procSql);
......@@ -503,22 +488,19 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
callStmt.registerOutParameter(5, Types.VARCHAR);
callStmt.executeQuery();
String outParam = callStmt.getString(5);
if (callStmt != null)
{
if (callStmt != null) {
callStmt.close();
callStmt = null;
}
System.out.println("outParam::::["+outParam+"]");
if ((outParam != null) && (outParam.trim().length() > 0))
{
retString = itmDBAccess.getErrorString("", "VTELPTRF53", userId, "", conn);
System.out.println("outParam::::[" + outParam + "]");
if ((outParam != null) && (outParam.trim().length() > 0)) {
// retString = itmDBAccess.getErrorString("", "VTELPTRF53", userId, "", conn);
retString = itmDBAccess.getErrorString("", outParam.trim(), userId, "", conn);
successFlag = false;
}
successFlag = true;
}
catch (SQLException se)
{
} catch (SQLException se) {
se.printStackTrace();
retString = this.admCommon.getErrorMessage(se, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
......@@ -528,19 +510,14 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
}
}
else
{
retString = itmDBAccess.getErrorString("", "VTELPTRF52", userId, "", conn);
} else {
retString = itmDBAccess.getErrorString("", "VTELPTRF24", userId, "", conn);
successFlag = false;
return retString;
}
}
}
else if ("PRK".equalsIgnoreCase(tranType))
{
if (empCodeTo.length() <= 0)
{
} else if ("PRK".equalsIgnoreCase(tranType)) {
if (empCodeTo.length() <= 0) {
retString = itmDBAccess.getErrorString("", "VTELPTRF19", userId, "", conn);
successFlag = false;
return retString;
......@@ -566,6 +543,15 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
pStmt5 = conn.prepareStatement(sql);
// Added by Varsha V on 16-07-18 for updating AMOUNT for emp_code_fr
// Modified by Piyush on 18/07/2018 [Should not update amount]
// sql = "UPDATE ALLOWDEDN_BAL set AMOUNT = AMOUNT - ?, AMT_ADJ = AMT_ADJ + ?,
// AMT_BAL = AMT_BAL - ? WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ?
// AND END_DATE = ?";
sql = "UPDATE ALLOWDEDN_BAL set AMT_ADJ = AMT_ADJ + ?, AMT_BAL = AMT_BAL - ? WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ? AND END_DATE = ?";
pStmt6 = conn.prepareStatement(sql);
// Ended by Varsha V on 16-07-18 for updating AMOUNT for emp_code_fr
String procSql = "{call " + admEnvReturn + "(?,?,?,?,?)}";
callStmt = conn.prepareCall(procSql);
......@@ -575,8 +561,7 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
int ctr = 0;
while (rs.next())
{
while (rs.next()) {
balCode = checkNull(rs.getString("BALANCE_CODE"));
frDate = rs.getTimestamp("FROM_DATE");
toDate = rs.getTimestamp("TO_DATE");
......@@ -584,12 +569,12 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
perkBalance = rs.getDouble("BALANCE");
xmlStringForID = new StringBuffer();
xmlStringForID.append("<Root><Detail1><pay_site>" +
paySite + "</pay_site><site_code>" + siteCode + "</site_code><ad_code>" + balCode + "</ad_code>" +
"<tran_date>" + currDateStr + "</tran_date>" +
"</Detail1></Root>");
xmlStringForID.append("<Root><Detail1><pay_site>" + paySite + "</pay_site><site_code>" + siteCode
+ "</site_code><ad_code>" + balCode + "</ad_code>" + "<tran_date>" + currDateStr
+ "</tran_date>" + "</Detail1></Root>");
System.out.println("xmlStringForID::::[" + xmlStringForID + "]");
TransIDGenerator tg = new TransIDGenerator(xmlStringForID.toString(), "SYSTEM", CommonConstants.DB_NAME);
TransIDGenerator tg = new TransIDGenerator(xmlStringForID.toString(), "SYSTEM",
CommonConstants.DB_NAME);
String tranIdGen = tg.generateTranSeqID(refSer, "", keyString, conn);
System.out.println("Umakanta::uniqueKey[" + tranIdGen + "]");
......@@ -609,12 +594,9 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
insrtStatus = pStmt1.executeUpdate();
System.out.println("insert executed = [" + insrtStatus + "]");
pStmt1.clearParameters();
if (insrtStatus > 0)
{
if (insrtStatus > 0) {
successFlag = true;
}
else
{
} else {
successFlag = false;
break;
}
......@@ -634,35 +616,30 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
insrtStatus = pStmt2.executeUpdate();
System.out.println("insert executed = [" + insrtStatus + "]");
pStmt2.clearParameters();
if (insrtStatus > 0)
{
if (insrtStatus > 0) {
successFlag = true;
}
else
{
} else {
successFlag = false;
break;
}
System.out.println("*************admEnvReturn:::::[" + admEnvReturn + "]");
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0) || (admEnvReturn.equalsIgnoreCase("NULLFOUND")))
{
if ((admEnvReturn == null) || (admEnvReturn.trim().length() == 0)
|| (admEnvReturn.equalsIgnoreCase("NULLFOUND"))) {
insrtStatus = 0;
pStmt3.setString(1, empCodeTo);
pStmt3.setString(2, balCode);
pStmt3.setTimestamp(3, frDate);
pStmt3.setTimestamp(4, toDate);
rs1 = pStmt3.executeQuery();
if (rs1.next())
{
if (rs1.next()) {
insrtStatus = rs1.getInt("COUNT");
}
if (rs1 != null)
{
if (rs1 != null) {
rs1.close();
rs1 = null;
}
pStmt3.clearParameters();
if (insrtStatus > 0)
{
if (insrtStatus > 0) {
pStmt4.setDouble(1, perkBalance);
pStmt4.setDouble(2, perkBalance);
pStmt4.setString(3, empCodeTo);
......@@ -671,18 +648,13 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
pStmt4.setTimestamp(6, toDate);
updCnt = pStmt4.executeUpdate();
pStmt4.clearParameters();
if (updCnt > 0)
{
if (updCnt > 0) {
successFlag = true;
}
else
{
} else {
successFlag = false;
break;
}
}
else
{
} else {
pStmt5.setString(1, empCodeTo);
pStmt5.setString(2, balCode);
pStmt5.setTimestamp(3, frDate);
......@@ -700,23 +672,52 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
updCnt = pStmt5.executeUpdate();
System.out.println("insert executed = [" + updCnt + "]");
pStmt5.clearParameters();
if (updCnt > 0)
{
if (updCnt > 0) {
successFlag = true;
} else {
successFlag = false;
break;
}
else
{
}
// Added by Varsha V on 16-07-18 for updating AMOUNT for emp_code_fr
if (successFlag) {
// Modified by Piyush on 18/07/2018 [Should not update amount].Start
pStmt6.setDouble(1, perkBalance);
pStmt6.setDouble(2, perkBalance);
pStmt6.setString(3, empCodeFr);
pStmt6.setString(4, balCode);
pStmt6.setTimestamp(5, frDate);
pStmt6.setTimestamp(6, toDate);
// Modified by Piyush on 18/07/2018 [Should not update amount].End
updCnt = pStmt6.executeUpdate();
pStmt6.clearParameters();
if (updCnt > 0) {
successFlag = true;
} else {
successFlag = false;
break;
}
}
// Ended by Varsha V on 16-07-18 for updating AMOUNT for emp_code_fr
}
else
{
try
{
// Modified by Piyush on 18/07/2018 [Procedure should be called outside of loop
// as it should happen once only].Start
}
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if ((admEnvReturn != null) && (admEnvReturn.trim().length() > 0)
&& (!admEnvReturn.equalsIgnoreCase("NULLFOUND"))) {
try {
System.out.println("Inside callable statement");
System.out.println("tranId:::["+tranId+"] chgUser:::["+chgUser+"] empCodeTo:::["+empCodeTo+"] chgTerm:::["+chgTerm+"]");
System.out.println("tranId:::[" + tranId + "] chgUser:::[" + chgUser + "] empCodeTo:::["
+ empCodeTo + "] chgTerm:::[" + chgTerm + "]");
callStmt.setString(1, tranId);
callStmt.setString(2, chgUser);
callStmt.setString(3, empCodeTo);
......@@ -724,23 +725,18 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
callStmt.registerOutParameter(5, Types.VARCHAR);
callStmt.executeQuery();
String outParam = callStmt.getString(5);
if (callStmt != null)
{
if (callStmt != null) {
callStmt.close();
callStmt = null;
}
System.out.println("outParam::::["+outParam+"]");
if ((outParam != null) && (outParam.trim().length() > 0))
{
retString = itmDBAccess.getErrorString("", "VTELPTRF53", userId, "", conn);
System.out.println("outParam::::[" + outParam + "]");
if ((outParam != null) && (outParam.trim().length() > 0)) {
retString = itmDBAccess.getErrorString("", outParam.trim(), userId, "", conn);
successFlag = false;
break;
}
} else {
successFlag = true;
}
catch (SQLException se)
{
} catch (SQLException se) {
se.printStackTrace();
retString = this.admCommon.getErrorMessage(se, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
......@@ -750,51 +746,45 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
}
}
}
if (pStmt1 != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pStmt1 != null) {
pStmt1.close();
pStmt1 = null;
}
if (pStmt2 != null)
{
if (pStmt2 != null) {
pStmt2.close();
pStmt2 = null;
}
if (pStmt3 != null)
{
if (pStmt3 != null) {
pStmt3.close();
pStmt3 = null;
}
if (pStmt4 != null)
{
if (pStmt4 != null) {
pStmt4.close();
pStmt4 = null;
}
if (pStmt5 != null)
{
if (pStmt5 != null) {
pStmt5.close();
pStmt5 = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
if (callStmt != null)
{
callStmt.close();
callStmt = null;
}
if (pStmt6 != null) {
pStmt6.close();
pStmt6 = null;
}
if (successFlag)
{
if (successFlag) {
sql = " UPDATE EMP_LVEPRKBAL_TRFHDR SET STATUS = ?, STATUS_DATE = ?, EMP_CODE__CONF = ? WHERE TRAN_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, "C");
......@@ -802,43 +792,33 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
pStmt.setString(3, logEmpCode);
pStmt.setString(4, tranId);
updCnt = pStmt.executeUpdate();
if (updCnt > 0)
{
if (updCnt > 0) {
successString = itmDBAccess.getErrorString("", "VTSUCC1", userId, "", conn);
successFlag = true;
System.out.println("Umakanta::retString::Confirm[" + successString + "]");
return successString;
}
} else {
retString = itmDBAccess.getErrorString("", "VTELPTRF23", userId, "", conn);
successFlag = false;
if (pStmt != null)
{
pStmt.close();
pStmt = null;
}
return retString;
}
}
catch (SQLException se)
{
} catch (SQLException se) {
se.printStackTrace();
successFlag = false;
retString = this.admCommon.getErrorMessage(se, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
return retString;
}
catch (BaseException be)
{
} catch (BaseException be) {
successFlag = false;
retString = this.admCommon.getErrorMessage(be, "");
retString = this.admCommon.getErrorXmlString(this.admCommon, retString, tranId);
System.out.println("errString after getErrorXmlString: " + retString);
return retString;
}
catch (Exception exp)
{
// }
catch (Exception exp) {
System.out.println("Umakanta::Exception[" + exp.getMessage() + "]");
successFlag = false;
......@@ -847,91 +827,63 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
System.out.println("errString after getErrorXmlString: " + retString);
String str1 = retString;
return str1;
}
finally
{
try
{
//Added by sarita on 25 JULY 18 [START]
itmDBAccess = null;
//Added by sarita on 25 JULY 18 [END]
if (successFlag)
{
} finally {
try {
if (conn != null) {
if (successFlag) {
conn.commit();
}
else
{
} else {
conn.rollback();
}
if (conn != null)
{
if (rs1 != null)
{
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (pStmt1 != null)
{
if (pStmt1 != null) {
pStmt1.close();
pStmt1 = null;
}
if (pStmt2 != null)
{
if (pStmt2 != null) {
pStmt2.close();
pStmt2 = null;
}
if (pStmt3 != null)
{
if (pStmt3 != null) {
pStmt3.close();
pStmt3 = null;
}
if (pStmt4 != null)
{
if (pStmt4 != null) {
pStmt4.close();
pStmt4 = null;
}
if (pStmt5 != null)
{
if (pStmt5 != null) {
pStmt5.close();
pStmt5 = null;
}
if (rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
}
}
catch (SQLException e)
{
} catch (SQLException e) {
e.printStackTrace();
}
}
return retString;
}
private InitialContext getInitialContext()throws ITMException
{
private InitialContext getInitialContext() throws ITMException {
InitialContext ctx = null;
try
{
try {
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
} catch (ITMException itme) {
System.out.println("ITMException :[EmpLvePrkBalTrfConf] :getInitialContext :==>");
throw itme;
}
catch(Exception e)
{
} catch (Exception e) {
System.out.println("Exception :[EmpLvePrkBalTrfConf] :getInitialContext :==>");
throw new ITMException(e);
}
......@@ -945,14 +897,10 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
* @return input
*/
@SuppressWarnings("unused")
private String checkNull( String input )
{
if ( input == null )
{
private String checkNull(String input) {
if (input == null) {
input = "";
}
else
{
} else {
input = input.trim();
}
return input;
......@@ -966,45 +914,33 @@ public class EmpLvePrkBalTrfConf extends ActionHandlerEJB implements EmpLvePrkBa
* @return msgType
* @throws ITMException
*/
private String errorType( Connection conn , String errorCode ) throws ITMException
{
private String errorType(Connection conn, String errorCode) throws ITMException {
String msgType = "";
PreparedStatement pstmt = null ;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
try {
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql );
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while( rs.next() )
{
while (rs.next()) {
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if ( rs != null )
{
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if ( pstmt != null )
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
......
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