Commit 4148d968 authored by caluka's avatar caluka

Travel,NotTravel and open functionality added [D16ASUN014]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101401 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 82d49cf5
...@@ -174,6 +174,448 @@ public class EmpTravelInfoConf extends ActionHandlerEJB implements EmpTravelInfo ...@@ -174,6 +174,448 @@ public class EmpTravelInfoConf extends ActionHandlerEJB implements EmpTravelInfo
{ {
pstmt.close();pstmt = null; pstmt.close();pstmt = null;
} }
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{System.out.println("Exception : "+e);e.printStackTrace();}
}
return retString ;
}
public String travel( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException
{
String retString = "";
String sql = "";
int count=0,upd=0,travelCount=0;
ResultSet rs = null;
PreparedStatement pstmt = null;
ibase.utility.E12GenericUtility genericUtility= null;
ITMDBAccessEJB itmDBAccess = null;
Connection conn = null;
try
{
genericUtility = new ibase.utility.E12GenericUtility();
itmDBAccess = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
//connStatus = true;
String userId="",empCode="",status="";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); System.out.println("--login code--"+userId);
sql = " select status from emp_travel_info where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString("status");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if("X".equalsIgnoreCase(status))
{ System.out.println("Travel information Cancelled");
retString = itmDBAccess.getErrorString("","VTNOTCONF3","");
return retString;
}else if("R".equalsIgnoreCase(status))
{ System.out.println("Travel information not Traveled");
retString = itmDBAccess.getErrorString("","VTTRVFAIL","");
return retString;
}
else
{
sql = " select count(*) from emp_travel_info where tran_id = ? and (case when confirmed is null then 'N' else confirmed end = 'Y') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(count > 0 )
{
sql = " select count(*) from emp_travel_info where tran_id = ? " +
" and (case when confirmed is null then 'N' else confirmed end = 'Y') " +
" and (case when status is null then 'N' else status end = 'T') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
travelCount = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(travelCount > 0 )
{
System.out.println("The transaction already Traveled");
retString = itmDBAccess.getErrorString("","VTTRAVEL","");
return retString;
}
else
{
sql = " update emp_travel_info set status = 'T' , status_date = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(2, tranId);
upd = pstmt.executeUpdate();
pstmt.close();pstmt = null;
System.out.println(" transaction transaction:: "+upd);
if(upd > 0)
{
retString = "traveled";
System.out.println(" transaction traveled::");
}
}
}else
{
retString = itmDBAccess.getErrorString("","VTNOTCONF2","");
return retString;
}
}
}
catch( Exception e )
{
try
{
conn.rollback();
retString = e.getMessage();
e.printStackTrace();
}
catch (Exception e1)
{
System.out.println("Exception : "+e);e.printStackTrace();
}
throw new ITMException(e);
}
finally
{
if(retString != null && retString.indexOf("traveled") > -1)
{
try {
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
}
retString = itmDBAccess.getErrorString("","VTTRVSUC","");
}
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)
{System.out.println("Exception : "+e);e.printStackTrace();}
}
return retString ;
}
public String notTravel( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException
{
String retString = "";
String sql = "";
int count=0,upd=0,travelCount=0;
ResultSet rs = null;
PreparedStatement pstmt = null;
ibase.utility.E12GenericUtility genericUtility= null;
ITMDBAccessEJB itmDBAccess = null;
Connection conn = null;
try
{
genericUtility = new ibase.utility.E12GenericUtility();
itmDBAccess = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
//connStatus = true;
String userId="",empCode="",status="";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); System.out.println("--login code--"+userId);
sql = " select status from emp_travel_info where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString("status");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if("X".equalsIgnoreCase(status))
{ System.out.println("Travel information Cancelled");
retString = itmDBAccess.getErrorString("","VTNOTCONF3","");
return retString;
}else if("T".equalsIgnoreCase(status))
{ System.out.println("Travel information is Traveled");
retString = itmDBAccess.getErrorString("","VTNOTTRFA","");
return retString;
}
else
{
sql = " select count(*) from emp_travel_info where tran_id = ? and (case when confirmed is null then 'N' else confirmed end = 'Y') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(count > 0 )
{
sql = " select count(*) from emp_travel_info where tran_id = ? " +
" and (case when confirmed is null then 'N' else confirmed end = 'Y') " +
" and (case when status is null then 'N' else status end = 'R') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
travelCount = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(travelCount > 0 )
{
System.out.println("The transaction already not Traveled");
retString = itmDBAccess.getErrorString("","VTNOTTRA","");
return retString;
}
else
{
sql = " update emp_travel_info set status = 'R' , status_date = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(2, tranId);
upd = pstmt.executeUpdate();
pstmt.close();pstmt = null;
System.out.println(" transaction transaction:: "+upd);
if(upd > 0)
{
retString = "notTraveled";
System.out.println(" transaction notTraveled::");
}
}
}else
{
retString = itmDBAccess.getErrorString("","VTNOTCONF2","");
return retString;
}
}
}
catch( Exception e )
{
try
{
conn.rollback();
retString = e.getMessage();
e.printStackTrace();
}
catch (Exception e1)
{
System.out.println("Exception : "+e);e.printStackTrace();
}
throw new ITMException(e);
}
finally
{
if(retString != null && retString.indexOf("notTraveled") > -1)
{
try {
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
}
retString = itmDBAccess.getErrorString("","VTNOTTRSUC","");
}
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)
{System.out.println("Exception : "+e);e.printStackTrace();}
}
return retString ;
}
public String open( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException
{
String retString = "";
String sql = "";
int count=0,upd=0,travelCount=0;
ResultSet rs = null;
PreparedStatement pstmt = null;
ibase.utility.E12GenericUtility genericUtility= null;
ITMDBAccessEJB itmDBAccess = null;
Connection conn = null;
try
{
genericUtility = new ibase.utility.E12GenericUtility();
itmDBAccess = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
//connStatus = true;
String userId="",empCode="",status="";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); System.out.println("--login code--"+userId);
sql = " select status from emp_travel_info where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString("status");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if("X".equalsIgnoreCase(status))
{ System.out.println("Travel information Cancelled");
retString = itmDBAccess.getErrorString("","VTNOTCONF3","");
return retString;
}else
{
sql = " select count(*) from emp_travel_info where tran_id = ? and (case when confirmed is null then 'N' else confirmed end = 'Y') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(count > 0 )
{
sql = " select count(*) from emp_travel_info where tran_id = ? " +
" and (case when confirmed is null then 'N' else confirmed end = 'Y') " +
" and (case when status is null then 'N' else status end = 'S') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
travelCount = rs.getInt(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(travelCount > 0 )
{
System.out.println("The transaction already Open");
retString = itmDBAccess.getErrorString("","VTOPENAL","");
return retString;
}
else if("T".equalsIgnoreCase(status) || "R".equalsIgnoreCase(status))
{
sql = " update emp_travel_info set status = 'S' , status_date = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(2, tranId);
upd = pstmt.executeUpdate();
pstmt.close();pstmt = null;
System.out.println(" transaction transaction:: "+upd);
if(upd > 0)
{
retString = "open";
System.out.println(" transaction open::");
}
}else if("S".equalsIgnoreCase(status))
{
System.out.println("The transaction Open for T,R status only");
retString = itmDBAccess.getErrorString("","VTETNOTOP","");
return retString;
}
}else
{
retString = itmDBAccess.getErrorString("","VTNOTCONF2","");
return retString;
}
}
}
catch( Exception e )
{
try
{
conn.rollback();
retString = e.getMessage();
e.printStackTrace();
}
catch (Exception e1)
{
System.out.println("Exception : "+e);e.printStackTrace();
}
throw new ITMException(e);
}
finally
{
if(retString != null && retString.indexOf("open") > -1)
{
try {
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
}
retString = itmDBAccess.getErrorString("","VTOPENSUC","");
}
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) catch(Exception e)
{System.out.println("Exception : "+e);e.printStackTrace();} {System.out.println("Exception : "+e);e.printStackTrace();}
......
...@@ -15,4 +15,7 @@ public interface EmpTravelInfoConfLocal extends ActionHandlerLocal ...@@ -15,4 +15,7 @@ public interface EmpTravelInfoConfLocal extends ActionHandlerLocal
public String confirm( String tranId, String xtraParams, String forcedFlag )throws RemoteException,ITMException; public String confirm( String tranId, String xtraParams, String forcedFlag )throws RemoteException,ITMException;
//added by chitranjan for call confirm method //added by chitranjan for call confirm method
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException; public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException;
public String travel( String tranId, String xtraParams,String forcedFlag) throws RemoteException,ITMException;
public String notTravel( String tranId, String xtraParams,String forcedFlag) throws RemoteException,ITMException;
public String open( String tranId, String xtraParams,String forcedFlag) throws RemoteException,ITMException;
} }
...@@ -15,4 +15,7 @@ public interface EmpTravelInfoConfRemote extends ActionHandlerRemote ...@@ -15,4 +15,7 @@ public interface EmpTravelInfoConfRemote extends ActionHandlerRemote
public String confirm( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException; public String confirm( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException;
//added by chitranjan for call confirm method //added by chitranjan for call confirm method
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException; public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException;
public String travel( String tranId, String xtraParams,String forcedFlag) throws RemoteException,ITMException;
public String notTravel( String tranId, String xtraParams,String forcedFlag) throws RemoteException,ITMException;
public String open( String tranId, String xtraParams,String forcedFlag) 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