Commit f2ca5544 authored by sgadve's avatar sgadve

updated bussiness component for the scheme approval

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195231 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cbac57db
This diff is collapsed.
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.ibm.db2.jcc.b.co;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.GenericWorkflowClass;
import ibase.webitm.utility.ITMException;
public class SchemeApprvWF extends ActionHandlerEJB
{
String responseFlag = "";
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() :: ");
String retString = "";
Connection conn = null;
try
{
retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
}
catch(Exception e)
{
System.out.println("SchemeConf Exception.confirm() : "+e);
throw new ITMException(e);
}
return retString;
}
public String confirm(String tranID,String xtraParams, String forcedFlag,String userInfoStr,String responseFlag) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() userInfo responseFlag : "+responseFlag);
String retString = "";
String appResult="", userId = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ValidatorEJB validatorEJB = new ValidatorEJB();
try
{
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB();
System.out.println("#### TransDB connection in : "+transDB);
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
conn.setAutoCommit(false);
connDriver = null;
System.out.println("Response flag:"+responseFlag);
/*retString = this.confirm(tranID, xtraParams, forcedFlag, conn, responseFlag);*/
String updateResponseFlag="UPDATE SCHEME_APPRV SET APRV_STATUS= ?, EMP_CODE_APPRV = ? WHERE TRAN_ID = ?";
pStmt=conn.prepareStatement(updateResponseFlag);
pStmt.setString(1, responseFlag);
pStmt.setString(2, userId);
pStmt.setString(3, tranID);
int i=pStmt.executeUpdate();
System.out.println("Uodated : "+i);
pStmt.close();
if(i>0)
{
conn.commit();
}
if(responseFlag.equalsIgnoreCase("A"))
{
SchemeConf sc=new SchemeConf();
sc.confirm(tranID, xtraParams, forcedFlag,conn);
}
System.out.println("appresult:"+appResult);
//return retString;
}
catch(Exception e)
{
System.out.println("Exception in [IndentReqConf] confirm " + e.getMessage());
throw new ITMException(e);
}
//return retString;
return "1";
}
/*public String confirm(String tranID, String xtraParams, String forcedFlag, Connection conn, String responseFlag) throws RemoteException,ITMException
{
this.responseFlag = responseFlag;
return confirm(tranID, xtraParams, forcedFlag, conn);
}*/
public String confirm(String tranID, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
System.out.println("================ SchemeApprvWF : confirm ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String confirmed = "",retString = "", apprvStatus= "", wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
if(conn == null)
{
conn = getConnection();
conn.setAutoCommit(false);
}
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranID+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
sql = "SELECT CONFIRMED, APRV_STATUS FROM SCHEME_APPRV WHERE TRAN_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranID);
rs = pStmt.executeQuery();
if (rs.next())
{
confirmed = E12GenericUtility.checkNull(rs.getString("CONFIRMED"));
apprvStatus = E12GenericUtility.checkNull(rs.getString("APRV_STATUS"));
}
System.out.println("confirmed : "+confirmed);
rs.close();
pStmt.close();
if(!"Y".equalsIgnoreCase(confirmed) || confirmed.length() <= 0)
{
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranID, xtraParams, "w_scheme_apprv", "scheme_apprv");
System.out.println("return String : "+retString);
errString = new ITMDBAccessEJB().getErrorString("", "VTSUCORDER", "","",conn);
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "","",conn);
}
}
catch (Exception e)
{
isError = true;
System.out.println("SchemeApprvWF.confirm() : "+e);
e.printStackTrace();
//errString = itmDBAccessEJB.getErrorString("", "VFMWRKFLWF", userId,"",conn);
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
if (isError)
{
conn.rollback();
System.out.println("SchemeApprvWF: confirm: Connection Rollback");
}
else
{
conn.commit();
System.out.println("SchemeApprvWF: confirm: Connection Commit");
}
conn.close();
conn = null;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
return errString;
}
private String checkNull(String str)
{
if(str == null)
{
str = "";
}
else
{
str = str.trim();
}
return str;
}
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
{
if (pStmt != null)
{
try
{
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
}
}
/********************************************************
Title : SchemeConf []
Date : 27/12/16
Developer: Pankaj R
Purpose: To conf scheme
********************************************************/
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.adv.GenericWorkflowClass;
import ibase.webitm.utility.ITMException;
@Stateless
public class SchemeConf extends ActionHandlerEJB
{
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() :: ");
String retString = "";
Connection conn = null;
try
{
retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
}
catch(Exception e)
{
System.out.println("SchemeConf.confirm() : "+e);
throw new ITMException(e);
}
return retString;
}
public String confirm(String tranID,String xtraParams, String forcedFlag,String userInfoStr) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() userInfo : ");
String retString = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB();
System.out.println("#### TransDB connection in : "+transDB);
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
conn.setAutoCommit(false);
connDriver = null;
retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
//return retString;
return "1";
}
catch(Exception e)
{
System.out.println("Exception in [SchemeConf] confirm " + e.getMessage());
throw new ITMException(e);
}
}
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() connectuion ");
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String isConfirmed = "", returnStr = "", loginEmpCode = "";
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
boolean isError = false;
try
{
Date currentDate = new java.sql.Date(new java.util.Date().getTime());
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
if ( conn == null )
{
conn = getConnection();
}
String checkConf = "SELECT CONFIRMED FROM SCHEME_APPRV WHERE TRAN_ID = ?";
preparedStatement = conn.prepareStatement(checkConf);
preparedStatement.setString(1, tranId);
resultSet = preparedStatement.executeQuery();
if(resultSet.next())
{
isConfirmed = E12GenericUtility.checkNull(resultSet.getString("CONFIRMED"));
}
resultSet.close();
resultSet = null;
preparedStatement.close();
preparedStatement = null;
if(isConfirmed.length() > 0 && isConfirmed.equalsIgnoreCase("Y"))
{
returnStr = itmDBAccess.getErrorString("","VTINDCONF","","",conn);
return returnStr;
}
else
{
String updateScheme = "UPDATE SCHEME_APPRV SET CONFIRMED = ?, CONF_DATE = ? WHERE TRAN_ID = ?";
preparedStatement = conn.prepareStatement(updateScheme);
preparedStatement.setString(1, "Y");
preparedStatement.setDate(2, currentDate);
preparedStatement.setString(3, tranId);
int updateCount = preparedStatement.executeUpdate();
if(updateCount > 0)
{
returnStr = itmDBAccess.getErrorString("CONFIRMED", "VTMCONF2", loginEmpCode);
conn.commit();
}
}
}
catch(Exception e)
{
isError = true;
System.out.println("Exception in SchemeConf.confirm(4 param) : "+e);
}
finally
{
try
{
System.out.println("isError in Finally SchemeConf="+isError);
if( !isError )
{
System.out.println("----------commmit-----------");
conn.commit();
}
else if ( isError )
{
System.out.println("--------------rollback------------");
conn.rollback();
}
if ( preparedStatement != null )
{
preparedStatement.close();
preparedStatement= null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return returnStr;
}
}
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