Commit 7550cfb7 authored by dpawar's avatar dpawar

add rollback


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96171 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 60c20519
......@@ -8,11 +8,15 @@ package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import java.sql.*;
import javax.ejb.*;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import javax.ejb.Stateless;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.fin.adv.JvConfirm;
import ibase.webitm.ejb.dis.DistCommon;
......@@ -21,8 +25,8 @@ import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.*;
@Stateless
......@@ -60,24 +64,22 @@ public String confirm(String tranId,String xtraParams,String forcedFlag) throws
FinCommon finCommon = null;
GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean isLocalConn = false;
boolean isLocalConn = false;
if(conn==null){
isLocalConn = true;
}
try
{
finCommon = new FinCommon();
genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
if(isLocalConn){
if(conn == null){
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
isLocalConn = true;
}
sql =" select confirmed,site_code from MISC_VOUCHER where tran_id = ?";
sql =" select confirmed,site_code from MISC_VOUCHER where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
......@@ -111,23 +113,34 @@ public String confirm(String tranId,String xtraParams,String forcedFlag) throws
System.out.println("Exception ::"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
try{
conn.rollback();
}
catch(Exception e1){
System.out.println("Exception while rollbacking222.......");
}
throw new ITMException(e);
}
finally
{
System.out.println("IN fINALLY MiscValConf confirm MATHOD333@#......>>["+isLocalConn+"]");
System.out.println("IN fINALLY MiscValConf confirm errString@#......>>["+errString+"]");
try
{
if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("CONFSUCCES") > -1)
{
if(isLocalConn)
if(isLocalConn){
System.out.println("Transaction commited111.............from MiscValConf");
conn.commit();
}
}
else
{
if(isLocalConn)
{
System.out.println("CONNECTION Rollbacking......................................");
conn.rollback();
System.out.println("CONNECTION Rollback......................................");
}
}
if(rs != null)
......
......@@ -55,6 +55,7 @@ UtilMethods utilMethods = UtilMethods.getInstance();
Random rnd = new Random();
ArrayList<String> miscVoucherTranID=new ArrayList<String>();
String tranIDG="";
boolean isError=false;
public String getTranIDG() {
return tranIDG;
}
......@@ -88,6 +89,7 @@ public String confirm(String tranId, String xtraParams, String forcedFlag) throw
public String confirmMiscVchEmp(String tranId,String xtraParams,String forcedFlag) throws ITMException
{
isError=false;
String retString = "";
String sql = "";
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Root>\r\n");
......@@ -103,6 +105,7 @@ public String confirmMiscVchEmp(String tranId,String xtraParams,String forcedFla
System.out.println("Confirm Action Called:::");
String confirmed = "";
String approverCode = "";
try
{
itmdbAccess = new ITMDBAccessEJB();
......@@ -188,9 +191,17 @@ public String confirmMiscVchEmp(String tranId,String xtraParams,String forcedFla
catch( Exception e)
{
e.printStackTrace();
System.out.println("confirmMiscVchEmp.......Rollback due to Exception");
try{
conn.rollback();
}
catch(Exception e1){
System.out.println("Exception while rollbacking.......");
}
throw new ITMException(e);
}
finally{
System.out.println("in finally123.......................................");
try{
if(rs!=null){
rs.close();
......@@ -199,6 +210,9 @@ public String confirmMiscVchEmp(String tranId,String xtraParams,String forcedFla
if(pstmt!=null){
pstmt.close();
pstmt=null;
}
if(isError){
conn.rollback();
}
if(conn !=null){
conn.close();
......@@ -451,7 +465,7 @@ private String generateMiscVoucher(String tranId, String xtraParams, String forc
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
miscVchTranId = arrayForTranId[1].substring(0,endIndex);
System.out.println("miscVchTranId1234567@@@------>>>["+miscVchTranId+"]");
System.out.println("miscVchTranId123@@@------>>>["+miscVchTranId+"]");
if(miscVchTranId != null && miscVchTranId.trim().length() > 0)
{
MiscValConf MiscValConfObj=new MiscValConf(); //VTSUCC1
......@@ -460,6 +474,7 @@ private String generateMiscVoucher(String tranId, String xtraParams, String forc
//errorStringMisc=confirmMiscVoucher("misc_voucher",miscVchTranId,xtraParams,forcedFlag,conn);
System.out.println("111Return String from confirmMiscVoucher confirm---->["+errorStringMisc+"]");
if(!(errorStringMisc.indexOf("CONFSUCCES") > -1 || errorStringMisc.indexOf("VTSUCC1") > -1 )){
System.out.println("not CONFSUCCES..................123DDD");
conn.rollback();
return errorStringMisc;
}
......@@ -477,7 +492,7 @@ private String generateMiscVoucher(String tranId, String xtraParams, String forc
} //end while
if((errorStringMisc.indexOf("CONFSUCCES") > -1 || errorStringMisc.indexOf("VTSUCC1") > -1 )){
conn.commit();
//conn.commit();
String str=generateAutoPayment(miscVoucherTranID, payMode,siteCode,currCode,tranType,conn);
System.out.println("after generateAutoPayment12355-->["+str+"]");
if (str.indexOf("Success") > -1)
......@@ -494,10 +509,17 @@ private String generateMiscVoucher(String tranId, String xtraParams, String forc
}
catch(Exception e)
{
System.out.println("Exception : MiscVchEmpICConf : CONFIRM :" +e.getMessage());
System.out.println("Exception : MiscVchEmpICConf123 : CONFIRM :" +e.getMessage());
e.printStackTrace();
return "Error";
// throw new ITMException(e);
isError=true;
try{
conn.rollback();
}
catch(Exception e1){
System.out.println("Exception while rollbacking111.......");
}
throw new ITMException(e);
}
return retSting;
}
......@@ -525,13 +547,13 @@ public String saveData(String siteCode,String xmlString, Connection conn) throws
catch(ITMException itme)
{
System.out.println("ITMException : saveData :==>");
itme.printStackTrace();
itme.printStackTrace();
throw itme;
}
catch(Exception e)
{
System.out.println("Exception : saveData :==>");
e.printStackTrace();
e.printStackTrace();
throw new ITMException(e);
}
return retString;
......@@ -701,6 +723,7 @@ private String generateAutoPayment(ArrayList<String> miscTranID,String payMode,S
xmlStringBuff.append("<diff_amt__exch><![CDATA[0]]></diff_amt__exch>");
xmlStringBuff.append("<acct_code__ap><![CDATA["+acctCodeL+"]]></acct_code__ap>");
xmlStringBuff.append("<cctr_code__ap><![CDATA["+cctrCodeL+"]]></cctr_code__ap>");
xmlStringBuff.append("<vouch_date><![CDATA["+tranDate+"]]></vouch_date>"); //vouch date
EmpstanCode= checkNull(getStationEmployeeCode(conn,refNo));
String [] code= EmpstanCode.split(",");
System.out.println("Code Length----->>["+code.length+"]");
......@@ -810,6 +833,7 @@ private String generateAutoPayment(ArrayList<String> miscTranID,String payMode,S
xmlStringBuff.append("<diff_amt__exch><![CDATA[0]]></diff_amt__exch>");
xmlStringBuff.append("<acct_code__ap><![CDATA["+acctCodeL+"]]></acct_code__ap>");
xmlStringBuff.append("<cctr_code__ap><![CDATA["+cctrCodeL+"]]></cctr_code__ap>");
xmlStringBuff.append("<vouch_date><![CDATA["+tranDate+"]]></vouch_date>"); //vouch date
EmpstanCode= checkNull(getStationEmployeeCode(conn,refNo));
String [] code= EmpstanCode.split(",");
System.out.println("Code Length----->>["+code.length+"]");
......@@ -894,6 +918,15 @@ private String generateAutoPayment(ArrayList<String> miscTranID,String payMode,S
{
System.out.println("Exception in generateAutoPayment method........");
e.printStackTrace();
try{
conn.rollback();
throw new ITMException(e);
}
catch(Exception e1){
System.out.println("Exception while rollbacking222.......");
}
return "Error";
}
return retString;
......@@ -939,6 +972,12 @@ public String getMessagesId(String errMag){
catch (Exception e){
System.out.println("Exception in getMessagesId method....");
e.printStackTrace();
try{
throw new ITMException(e);
}
catch(Exception e1){
System.out.println("Exception while rollbacking222.......");
}
return "Error";
}
......@@ -989,7 +1028,15 @@ public String getStationEmployeeCode(Connection conn,String vouchNo)
}
catch(Exception e)
{
isError=true;
e.printStackTrace();
try{
conn.rollback();
throw new ITMException(e);
}
catch(Exception e1){
System.out.println("Exception while rollbacking222.......");
}
}
return EmployeeCode+","+stanCode;
}
......
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