Commit 667690c8 authored by arawankar's avatar arawankar

Changes made in below component

1.EmpDetChgCancel
-Change component name to EmpDetChgCanc to EmpChgDetCancel
-Changes error code
-Changes made for rollback.

2.PayrVouch.java
-Changes error code
-Changes made for rollback.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@184908 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 23d9621d
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.utility.ITMException;
@Stateless
public class EmpDetChgCancel extends ActionHandlerEJB implements EmpDetChgCancelLocal,EmpDetChgCancelRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("==========Inside Confirm Method[EmpDetChgCanc]================");
System.out.println("Parameter--tranId--["+tranId+"]--xtraParams--["+xtraParams+"]--forcedFlag--["+forcedFlag+"]");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
String sql = "";
String confirmed = "";
String status = "";
String retString = "";
int updCount = 0;
AppConnectParm appConnect = null;
InitialContext initialCtx = null;
ITMDBAccessLocal itmDBAccess = null;
E12GenericUtility genericUtility = null;
String loginCode = "";
String loginEmpCode = "";
try
{
conn = getConnection();
appConnect = new AppConnectParm();
initialCtx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
genericUtility = new E12GenericUtility();
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loginCode---["+loginCode+"]");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("loginEmpCode---["+loginEmpCode+"]");
String dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Check whether the transaction is confirmed or not
if("oracle".equalsIgnoreCase(dbName))
{
sql = "select confirmed ,status from employee_det_change where tran_id = ? FOR UPDATE NOWAIT";
}
else if ("db2".equalsIgnoreCase(dbName) )
{
sql = "select confirmed ,status from employee_det_change where tran_id = ? for update with RS";
}
else if ("mysql".equalsIgnoreCase(dbName))
{
sql="select confirmed ,status from employee_det_change where tran_id = ? for update";
}
else
{
sql = "select confirmed ,status from employee_det_change where tran_id = ? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
resultSet = pstmt.executeQuery();
if(resultSet.next())
{
confirmed = resultSet.getString("confirmed");
status = resultSet.getString("status");
}
System.out.println("Transaction Confirmed--["+tranId+"]["+confirmed+"]["+status+"]");
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("X".equalsIgnoreCase(status))
{
retString = itmDBAccess.getErrorString( "", "VTCANC2" , loginCode);
return retString;
}
//If transaction in confirmed then unable to cancel the transaction else update the status as "X" in employee_det_change table.
//if("Y".equalsIgnoreCase(confirmed))
else if("C".equalsIgnoreCase(status))
{
retString = itmDBAccess.getErrorString( "", "VTCONF8" , loginCode);
return retString;
}
//else if("N".equalsIgnoreCase(confirmed) || confirmed == null)
else if("E".equalsIgnoreCase(status) || status == null)
{
sql = "";
//sql = "update employee_det_change set status = 'X' where tran_id = ? ";
sql = "update employee_det_change set status = 'X' ,EMP_CODE__APRV = ? ,CONF_DATE = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginEmpCode);
pstmt.setTimestamp(2, new java.sql.Timestamp(new java.util.Date().getTime()));
pstmt.setString(3, tranId);
updCount = pstmt.executeUpdate();
System.out.println("["+updCount+"]of records updated agains tran_id ["+tranId+"]");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
/*else
{
retString = itmDBAccess.getErrorString( "", "VTCANC2" , loginCode);
return retString;
}*/
if(retString == null || retString.trim().length() == 0)
{
conn.commit();
System.out.println("Connection commit................");
retString = itmDBAccess.getErrorString( "", "VTCANC1" , loginCode);
}
else
{
conn.rollback();
System.out.println("Connection rollback................");
}
}
catch(SQLException se)
{
System.out.println("SQL Exception from [EmpDetChgCanc][confirm][" + se.getMessage()+ "]");
se.printStackTrace();
retString = itmDBAccess.getErrorString( "", "DS00000000" , loginCode);
return retString;
}
catch(Exception e)
{
//Modified by Ahmed on 26-APR-2018 to rollback transaction if exception occurs[start]
try
{
if (conn!=null)
{
conn.rollback();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
e.printStackTrace();
//Modified by Ahmed on 26-APR-2018 to rollback transaction if exception occurs[end]
System.out.println("Exception from [EmpDetChgCanc][confirm]["+e.getMessage()+"]");
}
finally
{
try
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Ahmed on 26-APR-2018 to close connection[start]
if (conn!=null)
{
conn.close();
conn = null;
}
//Modified by Ahmed on 26-APR-2018 to close connection[end]
}
catch(Exception e)
{
System.out.println("Exception in connection closing [EmpDetChgCanc][confirm]["+e.getMessage()+"]");
e.printStackTrace();//Modified by Ahmed on 26-APR-2018 to print stack trace if exception occurs
}
}
System.out.println("retString from EmpDetChgCanc---------["+retString+"]");
return retString;
}
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import javax.ejb.Local;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface EmpDetChgCancelLocal extends ActionHandlerLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface EmpDetChgCancelRemote extends ActionHandlerRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
......@@ -4,11 +4,13 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
......@@ -38,7 +40,7 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loinCode---["+loginCode+"]");
System.out.println("loginCode---["+loginCode+"]");
retString = confirm(tranId, xtraParams, forcedFlag, conn);
......@@ -90,8 +92,9 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
e.printStackTrace();
}
}
//return forcedFlag;
return retString;
//Modified by Ahmed on 26-APR-2018 to close connection[end]
return forcedFlag;
}
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
......@@ -104,6 +107,7 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
String retString = "";
int updCount = 0;
String status = "";
String loginEmpCode = "";
E12GenericUtility genericUtility = null;
AppConnectParm appConnect = null;
......@@ -118,10 +122,30 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loinCode---["+loginCode+"]");
System.out.println("loginCode---["+loginCode+"]");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("loginEmpCode---["+loginEmpCode+"]");
String dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Check whether the transaction is confirmed or not
sql = "select confirmed ,status from payr_voucher where tran_id = ?";
if("oracle".equalsIgnoreCase(dbName))
{
sql = "select confirmed ,status from payr_voucher where tran_id = ? FOR UPDATE NOWAIT";
}
else if ("db2".equalsIgnoreCase(dbName) )
{
sql = "select confirmed ,status from payr_voucher where tran_id = ? for update with RS";
}
else if ("mysql".equalsIgnoreCase(dbName))
{
sql="select confirmed ,status from payr_voucher where tran_id = ? for update";
}
else
{
sql = "select confirmed ,status from payr_voucher where tran_id = ? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
resultSet = pstmt.executeQuery();
......@@ -142,20 +166,23 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
pstmt.close();
pstmt = null;
}
if("X".equalsIgnoreCase(status))
//if("X".equalsIgnoreCase(status))
if("X".equalsIgnoreCase(confirmed))
{
retString = itmDBAccess.getErrorString( "", "VTCAN" , loginCode);
retString = itmDBAccess.getErrorString( "", "VTCANC2" , loginCode);
return retString;
}
if("Y".equalsIgnoreCase(confirmed))
{
retString = itmDBAccess.getErrorString( "", "VTCANC8" , loginCode);
retString = itmDBAccess.getErrorString( "", "VTCONF8" , loginCode);
return retString;
}
else if("N".equalsIgnoreCase(confirmed) || confirmed == null)
{
sql = "";
sql = "delete from payr_vouchadv where tran_id = ?";
//Modified by Anjali R. on[11/05/2018][As discussed with vishal sanghavi,Details will not be deleted,this is for tracing purpose][Start]
/*sql = "delete from payr_vouchadv where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
updCount = pstmt.executeUpdate();
......@@ -176,12 +203,15 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
{
pstmt.close();
pstmt = null;
}
}*/
//Modified by Anjali R. on[11/05/2018][As discussed with vishal sanghavi,Details will not be deleted,this is for tracing purpose][End]
sql = "";
sql = "update payr_voucher set status = 'X' where tran_id = ?";
//sql = "update payr_voucher set status = 'X' where tran_id = ?";
sql = "update payr_voucher set CONFIRMED = 'X' ,CONF_DATE = ?,EMP_CODE__APRV = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setTimestamp(1, new java.sql.Timestamp(new java.util.Date().getTime()));
pstmt.setString(2, loginEmpCode );
pstmt.setString(3, tranId);
updCount = pstmt.executeUpdate();
System.out.println("["+updCount+"]Rows Update in payr_vouchdet");
if(pstmt != null)
......@@ -192,10 +222,17 @@ public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemo
}
else
{
retString = itmDBAccess.getErrorString( "", "VTCANC2" , loginCode);
retString = itmDBAccess.getErrorString( "", "VTCANC3" , loginCode);
return retString;
}
}
catch(SQLException se)
{
System.out.println("SQL Exception from [PayrVouchCanc][confirm][" + se.getMessage()+ "]");
se.printStackTrace();
retString = itmDBAccess.getErrorString( "", "DS00000000" , loginCode);
return retString;
}
catch( Exception e )
{
System.out.println("Exception from [PayrVouchCanc][confirm]["+e.getMessage()+"]");
......
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