Commit 0db715f6 authored by jshaikh's avatar jshaikh

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@181488 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e0e3dc07
...@@ -2,70 +2,122 @@ package ibase.webitm.ejb.dis.adv; ...@@ -2,70 +2,122 @@ package ibase.webitm.ejb.dis.adv;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.UserInfoBean; import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
public class ConsumpIssueConfWF public class ConsumpIssueConfWF
{ {
public String confirm(String consIssue, String empCodeAprv, String xmlDataAll, String processId, String keyFlag, String userInfoStr) throws RemoteException, ITMException public String confirm(String consIssue, String empCodeAprv, String xmlDataAll, String processId, String keyFlag, String userInfoStr) throws RemoteException, ITMException
{ {
String retString = "";
String retString = ""; String errString = "";
Connection conn = null; Connection conn = null;
ITMDBAccessEJB itmDBAccessEJB = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
String status = "", confirmed = "", wf_status = "", line_no = "";
String sql = ""; String sql = "";
String loginCode = "", loginSiteCode = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
int updcnt = 0; int updcnt = 0;
try { try {
System.out.println("Inside Try block of ConsumpIssueConfWF.confirm()"); System.out.println("Inside Try block of ConsumpIssueConfWF.confirm()");
//conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
System.out.println("Inside ConsumpIssueConfWF confirm section: "+userInfoStr); System.out.println("Inside PContractConfWF confirm section: "+userInfoStr);
UserInfoBean userInfo = new UserInfoBean(userInfoStr); UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB(); String transDB = userInfo.getTransDB();
System.out.println("get TransDB connetion in ConsumpIssueConfWF : "+transDB); System.out.println("get TransDB connection in ConsumpIssueConfWF : "+transDB);
if (transDB != null && transDB.trim().length() > 0) if (transDB != null && transDB.trim().length() > 0)
{ {
conn = connDriver.getConnectDB(transDB); conn = connDriver.getConnectDB(transDB);
} }
else else
{ {
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
} }
connDriver = null;
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null;
empCodeAprv = empCodeAprv == null ? "" : empCodeAprv.trim(); empCodeAprv = empCodeAprv == null ? "" : empCodeAprv.trim();
sql = " select site_code__def,code from users where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCodeAprv);
rs = pstmt.executeQuery();
if (rs.next()) {
loginCode = checkNull(rs.getString("code"));
loginSiteCode = checkNull(rs.getString("site_code__def"));
}
closePstmtRs(pstmt, rs);
sql = " SELECT select status, confirmed, wf_status from consume_iss WHERE cons_issue = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, consIssue);
rs = pstmt.executeQuery();
if (rs.next()) {
status = checkNull(rs.getString("status"));
confirmed = checkNull(rs.getString("confirmed"));
wf_status = checkNull(rs.getString("wf_status"));
}
closePstmtRs(pstmt, rs);
if("Y".equalsIgnoreCase(confirmed))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "");
return errString;
}
else if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
return errString;
}
else
{
if ((xmlDataAll != null) && (xmlDataAll.trim().length() != 0)) if((xmlDataAll != null) && (xmlDataAll.trim().length() != 0))
{ {
sql = "update consume_iss set confirmed = 'Y', conf_date = sysdate where cons_order = ?"; sql = "update consume_iss set confirmed = 'Y', conf_date = ?, status = 'O' where cons_issue = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, consIssue); pstmt.setDate(1, currentDate);
updcnt = pstmt.executeUpdate(); pstmt.setString(2, consIssue);
pstmt.close(); updcnt = pstmt.executeUpdate();
pstmt = null; pstmt.close();
System.out.println("Updated Successfully:" + updcnt); pstmt = null;
System.out.println("Updated Successfully:" + updcnt);
if (updcnt > 0) if (updcnt > 0)
{ {
conn.commit(); conn.commit();
retString = "Y"; retString = "Y";
} }
else
else {
{ conn.rollback();
conn.rollback(); retString = "N";
retString = "N"; }
} }
} }
} }
catch (Exception e) { catch (Exception e) {
try try
...@@ -77,7 +129,7 @@ public class ConsumpIssueConfWF ...@@ -77,7 +129,7 @@ public class ConsumpIssueConfWF
e1.printStackTrace(); e1.printStackTrace();
} }
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception occurred in catch block of ConsumpIssueConfWF.confirm()"); System.out.println("Catch block of ConsumpIssueConfWF.confirm()");
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -93,12 +145,44 @@ public class ConsumpIssueConfWF ...@@ -93,12 +145,44 @@ public class ConsumpIssueConfWF
catch (SQLException e) catch (SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception occurred in finally block of ConsumpIssueConfWF.confirm()"); System.out.println("Finally block of ConsumpIssueConfWF.confirm()");
} }
} }
} }
System.out.println("Return string from ConsumpIssueConfWF confirm method is: "+retString);
return retString; return retString;
} }
private String checkNull(String str)
{
if(str == null){
str = "";
}
else{
str = str.trim();
}
return str;
}
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
{
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
if (pStmt != null) {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
}
} }
...@@ -7,6 +7,8 @@ import java.sql.ResultSet; ...@@ -7,6 +7,8 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
...@@ -14,18 +16,39 @@ import ibase.webitm.ejb.dis.GenericWorkflowClass; ...@@ -14,18 +16,39 @@ import ibase.webitm.ejb.dis.GenericWorkflowClass;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
@Stateless @Stateless
public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIssueConfWfEJBLocal, ConsumpIssueConfWfEJBRemote { public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIssueConfWfEJBLocal, ConsumpIssueConfWfEJBRemote
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException { {
System.out.println("@@@@@@@@@@@@@@@@@@@@ ConsumpIssueConfWfEJB @@@@@@@@@@@@@@@@"); public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
String userInfoStr = "";
String errString = "";
try
{
userInfoStr = confirm(tranId, xtraParams, forcedFlag, userInfoStr);
System.out.println("userInfoStr of confirm::::: " +userInfoStr);
}
catch(Exception e)
{
System.out.println("Exception in [ConsumpIssueConfWfEJB] confirm " + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException, ITMException
{
System.out.println("@@@@@@@@@@@@@@@@@@@@ ConsumpIssueConfWfEJB : confirm @@@@@@@@@@@@@@@@");
String userId = ""; String userId = "";
String errString = ""; String errString = "";
String transDB = "";
ValidatorEJB validatorEJB = null; ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String status = "",confirmed = "",retString = ""; String status = "",confirmed = "",retString = "",wf_status = "";
String[] authencate = new String[2]; String[] authencate = new String[2];
authencate[0] = ""; authencate[0] = "";
authencate[1] = ""; authencate[1] = "";
...@@ -34,51 +57,83 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs ...@@ -34,51 +57,83 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs
try { try {
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB(); validatorEJB = new ValidatorEJB();
conn = getConnection(); //conn = getConnection();
conn.setAutoCommit(false); if(userInfoStr != null && userInfoStr.trim().length() > 0)
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
transDB = userInfo.getTransDB();
}
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
//connDriver = null;
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranId+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag); System.out.println("tran_id ..> " + tranId+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
tranId = checkNull(tranId); tranId = checkNull(tranId);
sql = " SELECT confirmed FROM consume_iss WHERE cons_issue = ? "; sql = " SELECT status, confirmed, wf_status FROM consume_iss WHERE cons_issue = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId); pStmt.setString(1, tranId);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if (rs.next()) { if (rs.next()) {
confirmed = rs.getString("confirmed"); status = checkNull(rs.getString("status"));
confirmed = checkNull(rs.getString("confirmed"));
wf_status = checkNull(rs.getString("wf_status"));
} }
confirmed = checkNull(confirmed);
closePstmtRs(pStmt, rs); closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed) || "".equalsIgnoreCase(confirmed)) if(!"Y".equalsIgnoreCase(confirmed))
{ {
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass(); if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_consume_issue", "consume_issue"); {
if ("success".equalsIgnoreCase(retString)) errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
}
else if ("O".equalsIgnoreCase(status) || "".equalsIgnoreCase(status))
{
if("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{ {
sql = "UPDATE CONSUME_ISS SET SET conf_date = sysdate WHERE CONS_ISSUE = ? "; GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
pStmt = conn.prepareStatement(sql); retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_consume_issue", "consume_issue");
//pStmt.setString(1, confirmed); if ("success".equalsIgnoreCase(retString)) {
pStmt.setString(1, tranId);
int updCount = pStmt.executeUpdate();
if (updCount > 0) sql = "UPDATE CONSUME_ISS SET wf_status = 'S' WHERE CONS_ISSUE = ? ";
{ pStmt = conn.prepareStatement(sql);
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWS", ""); pStmt.setString(1, tranId);
} int updCount = pStmt.executeUpdate();
else{ closePstmtRs(pStmt, rs);
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
isError=true; if (updCount > 0) {
} errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWS", "");
} }
else{ else{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
isError=true;
}
} else {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", ""); errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
} }
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALINT", "");
}
}
else {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
}
} }
else{ else{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", ""); errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "");
...@@ -108,9 +163,162 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs ...@@ -108,9 +163,162 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs
} }
return errString; return errString;
} }
public String rejection(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String userInfoStr = "";
String errString = "";
try
{
userInfoStr = rejection(tranId, xtraParams, forcedFlag, userInfoStr);
System.out.println("userInfoStr of rejection::::: " +userInfoStr);
}
catch(Exception e)
{
System.out.println("Exception in [ConsumpIssueConfWfEJB] rejection " + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException
{
System.out.println("================ ConsumpIssueConfWfEJB : rejection ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String transDB = "";
String status = "",confirmed = "",retString = "", wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try {
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
//conn = getConnection();
if(userInfoStr != null && userInfoStr.trim().length() > 0)
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
transDB = userInfo.getTransDB();
}
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
//connDriver = null;
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranId+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
tranId = checkNull(tranId);
sql = "SELECT status, confirmed, wf_status FROM consume_iss WHERE cons_issue = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next())
{
confirmed = checkNull(rs.getString("confirmed"));
status = checkNull(rs.getString("status"));
wf_status = checkNull(rs.getString("wf_status"));
}
closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed))
{
/*if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
}*/
if ("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "S".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{
sql = "UPDATE CONSUME_ISS SET WF_STATUS = 'O' WHERE CONS_ISSUE = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
int updCount = pStmt.executeUpdate();
closePstmtRs(pStmt, rs);
if (updCount > 0)
{
retString="Y";
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFOPN", "");
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFFAIL", "");
isError=true;
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALINT", "");
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFCONFN", "");
}
}
catch (Exception e)
{
isError = true;
System.out.println("Exception: rejection method ..> " + e.getMessage());
e.printStackTrace();
//errString = itmDBAccessEJB.getErrorString("", "VFMWRKFLWF", userId);
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
if (isError)
{
conn.rollback();
System.out.println("ConsumpIssueConfWfEJB: rejection: Connection Rollback");
}
else
{
conn.commit();
System.out.println("ConsumpIssueConfWfEJB: rejection: Connection Commit");
}
conn.close();
conn = null;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
return retString;
}
private String checkNull(String str) { private String checkNull(String str)
{
if(str == null){ if(str == null){
str = ""; str = "";
} }
...@@ -120,14 +328,8 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs ...@@ -120,14 +328,8 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs
return str; return str;
} }
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs) { private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
if (pStmt != null) { {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
if (rs != null) { if (rs != null) {
try { try {
rs.close(); rs.close();
...@@ -136,6 +338,15 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs ...@@ -136,6 +338,15 @@ public class ConsumpIssueConfWfEJB extends ActionHandlerEJB implements ConsumpIs
} }
rs = null; rs = null;
} }
if (pStmt != null) {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
} }
} }
......
...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException; ...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException;
public interface ConsumpIssueConfWfEJBLocal extends ActionHandlerLocal public interface ConsumpIssueConfWfEJBLocal extends ActionHandlerLocal
{ {
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException; public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
public String rejection(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
} }
...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException; ...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException;
public interface ConsumpIssueConfWfEJBRemote extends ActionHandlerRemote public interface ConsumpIssueConfWfEJBRemote extends ActionHandlerRemote
{ {
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException; public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
public String rejection(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
} }
package ibase.webitm.ejb.dis.adv;
import ibase.system.config.ConnDriver;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class SContractConfWF
{
public String confirm(String contractNo, String empCodeCon, String xmlDataAll, String processId, String keyFlag, String userInfoStr) throws RemoteException, ITMException
{
String retString = "";
String errString = "";
Connection conn = null;
ITMDBAccessEJB itmDBAccessEJB = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String status = "", confirmed = "", wf_status = "", line_no = "";
String sql = "";
String loginCode = "", loginSiteCode = "";
ConnDriver connDriver = new ConnDriver();
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
int updcnt = 0;
try {
System.out.println("Try block of SContractConfWF.confirm()");
//conn = connDriver.getConnectDB("DriverITM");
System.out.println("Inside SContractConfWF confirm section: "+userInfoStr);
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB();
System.out.println("TransDB connection in SContractConfWF : "+transDB);
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
connDriver = null;
conn.setAutoCommit(false);
empCodeCon = empCodeCon == null ? "" : empCodeCon.trim();
sql = " select site_code__def,code from users where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCodeCon);
rs = pstmt.executeQuery();
if (rs.next()) {
loginCode = checkNull(rs.getString("code"));
loginSiteCode = checkNull(rs.getString("site_code__def"));
}
closePstmtRs(pstmt, rs);
sql = " SELECT status,confirmed,wf_status FROM scontract WHERE contract_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, contractNo);
rs = pstmt.executeQuery();
if (rs.next()) {
status = checkNull(rs.getString("status"));
confirmed = checkNull(rs.getString("confirmed"));
wf_status = checkNull(rs.getString("wf_status"));
}
closePstmtRs(pstmt, rs);
if("Y".equalsIgnoreCase(confirmed))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "");
return errString;
}
else if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
return errString;
}
else
{
if((xmlDataAll != null) && (xmlDataAll.trim().length() != 0))
{
sql = "update scontract set confirmed = 'Y', status_date = ?, status = 'O' where contract_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setDate(1, currentDate);
pstmt.setString(2, contractNo);
updcnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Updated Successfully:" + updcnt);
if (updcnt > 0)
{
conn.commit();
retString = "Y";
}
else
{
conn.rollback();
retString = "N";
}
}
}
}
catch (Exception e) {
try
{
conn.rollback();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
e.printStackTrace();
System.out.println("In catch block of SContractConfWF.confirm()");
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
conn.close();
conn = null;
}
catch (SQLException e)
{
e.printStackTrace();
System.out.println("In finally block of SContractConfWF.confirm()");
}
}
}
System.out.println("Return string from SContractConfWF confirm method is: "+retString);
return retString;
}
private String checkNull(String str)
{
if(str == null){
str = "";
}
else{
str = str.trim();
}
return str;
}
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
{
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
if (pStmt != null) {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
}
}
...@@ -8,6 +8,8 @@ import java.sql.SQLException; ...@@ -8,6 +8,8 @@ import java.sql.SQLException;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
...@@ -17,17 +19,37 @@ import ibase.webitm.utility.ITMException; ...@@ -17,17 +19,37 @@ import ibase.webitm.utility.ITMException;
@Stateless @Stateless
public class SContractConfWfEJB extends ActionHandlerEJB implements SContractConfWfEJBLocal, SContractConfWfEJBRemote public class SContractConfWfEJB extends ActionHandlerEJB implements SContractConfWfEJBLocal, SContractConfWfEJBRemote
{ {
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException { public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
System.out.println("@@@@@@@@@@@@@@@@@@@@ SContractConfWfEJB @@@@@@@@@@@@@@@@"); {
String userInfoStr = "";
String errString = "";
try
{
userInfoStr = confirm(tranId, xtraParams, forcedFlag, userInfoStr);
System.out.println("userInfoStr of SContractConfWfEJB : confirm::::: " +userInfoStr);
}
catch(Exception e)
{
System.out.println("Exception in [SContractConfWfEJB] confirm " + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException, ITMException
{
System.out.println("@@@@@@@@@@@@@@@@@@@@ SContractConfWfEJB : confirm @@@@@@@@@@@@@@@@");
String userId = ""; String userId = "";
String errString = ""; String errString = "";
String transDB = "";
ValidatorEJB validatorEJB = null; ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String status = "",confirmed = "",retString = ""; String status = "",confirmed = "",retString = "",wf_status = "";
String[] authencate = new String[2]; String[] authencate = new String[2];
authencate[0] = ""; authencate[0] = "";
authencate[1] = ""; authencate[1] = "";
...@@ -36,52 +58,86 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon ...@@ -36,52 +58,86 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon
try { try {
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB(); validatorEJB = new ValidatorEJB();
conn = getConnection(); //conn = getConnection();
conn.setAutoCommit(false); if(userInfoStr != null && userInfoStr.trim().length() > 0)
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
transDB = userInfo.getTransDB();
}
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
//connDriver = null;
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranId+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag); System.out.println("tran_id ..> " + tranId+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
tranId = checkNull(tranId); tranId = checkNull(tranId);
sql = "SELECT confirmed FROM scontract WHERE contract_no = ? "; sql = " SELECT status,confirmed,wf_status FROM scontract WHERE contract_no = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId); pStmt.setString(1, tranId);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if (rs.next()) { if (rs.next()) {
status = rs.getString("status");
confirmed = rs.getString("confirmed"); confirmed = rs.getString("confirmed");
wf_status = rs.getString("wf_status");
} }
status = checkNull(status);
confirmed = checkNull(confirmed); confirmed = checkNull(confirmed);
wf_status = checkNull(wf_status);
closePstmtRs(pStmt, rs); closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed)) if(!"Y".equalsIgnoreCase(confirmed))
{ {
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass(); if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_scontract", "scontract"); {
if ("success".equalsIgnoreCase(retString)) errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
}
else if ("O".equalsIgnoreCase(status) || "".equalsIgnoreCase(status))
{ {
if("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_scontract", "scontract");
if ("success".equalsIgnoreCase(retString)) {
sql = "UPDATE SCONTRACT SET SET conf_date = sysdate WHERE CONTRACT_NO = ? "; sql = "UPDATE SCONTRACT SET wf_status = 'S' WHERE CONTRACT_NO = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
//pStmt.setString(1, confirmed); pStmt.setString(1, tranId);
pStmt.setString(1, tranId); int updCount = pStmt.executeUpdate();
int updCount = pStmt.executeUpdate(); closePstmtRs(pStmt, rs);
if (updCount > 0) if (updCount > 0) {
{ errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWS", "");
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWS", ""); }
else{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
isError=true;
}
} else {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
}
} }
else{ else
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", ""); {
isError=true; errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALINT", "");
} }
} }
else { else {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", ""); errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
} }
} }
else{ else{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", ""); errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "");
...@@ -111,9 +167,166 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon ...@@ -111,9 +167,166 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon
} }
return errString; return errString;
} }
public String rejection(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String userInfoStr = "";
String errString = "";
try
{
userInfoStr = rejection(tranId, xtraParams, forcedFlag, userInfoStr);
System.out.println("userInfoStr of rejection::::: " +userInfoStr);
}
catch(Exception e)
{
System.out.println("Exception in [SContractConfWfEJB] rejection " + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException
{
System.out.println("================ SContractConfWfEJB : rejection ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String transDB = "";
String status = "",confirmed = "",retString = "", wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try {
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
//conn = getConnection();
if(userInfoStr != null && userInfoStr.trim().length() > 0)
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
transDB = userInfo.getTransDB();
}
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
//connDriver = null;
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranId+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
tranId = checkNull(tranId);
private String checkNull(String str) { sql = "SELECT status,confirmed,wf_status FROM scontract WHERE contract_no = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next())
{
confirmed = rs.getString("confirmed");
status = rs.getString("status");
wf_status = rs.getString("wf_status");
}
confirmed = checkNull(confirmed);
status = checkNull(status);
wf_status = checkNull(wf_status);
closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed))
{
/*if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
}*/
if ("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "S".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{
sql = "UPDATE SCONTRACT SET WF_STATUS = 'O' WHERE CONTRACT_NO = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
int updCount = pStmt.executeUpdate();
closePstmtRs(pStmt, rs);
if (updCount > 0)
{
retString="Y";
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFOPN", "");
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFFAIL", "");
isError=true;
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALINT", "");
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFCONFN", "");
}
}
catch (Exception e)
{
isError = true;
System.out.println("Exception: rejection method ..> " + e.getMessage());
e.printStackTrace();
//errString = itmDBAccessEJB.getErrorString("", "VFMWRKFLWF", userId);
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
if (isError)
{
conn.rollback();
System.out.println("SContractConfWfEJB: rejection: Connection Rollback");
}
else
{
conn.commit();
System.out.println("SContractConfWfEJB: rejection: Connection Commit");
}
conn.close();
conn = null;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
return retString;
}
private String checkNull(String str)
{
if(str == null){ if(str == null){
str = ""; str = "";
} }
...@@ -123,14 +336,8 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon ...@@ -123,14 +336,8 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon
return str; return str;
} }
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs) { private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
if (pStmt != null) { {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
if (rs != null) { if (rs != null) {
try { try {
rs.close(); rs.close();
...@@ -139,5 +346,14 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon ...@@ -139,5 +346,14 @@ public class SContractConfWfEJB extends ActionHandlerEJB implements SContractCon
} }
rs = null; rs = null;
} }
if (pStmt != null) {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
} }
} }
...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException; ...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException;
public interface SContractConfWfEJBLocal extends ActionHandlerLocal public interface SContractConfWfEJBLocal extends ActionHandlerLocal
{ {
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException; public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
public String rejection(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
} }
...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException; ...@@ -11,4 +11,7 @@ import ibase.webitm.utility.ITMException;
public interface SContractConfWfEJBRemote extends ActionHandlerRemote public interface SContractConfWfEJBRemote extends ActionHandlerRemote
{ {
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException; public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
public String rejection(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
} }
package ibase.webitm.ejb.dis.adv;
import ibase.system.config.ConnDriver;
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;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class SorderConfWfEJB extends ActionHandlerEJB implements SorderConfWfEJBLocal, SorderConfWfEJBRemote
{
public String confirm(String sOrder, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
String userInfoStr = "";
String errString = "";
try
{
userInfoStr = confirm(sOrder, xtraParams, forcedFlag, userInfoStr);
System.out.println("userInfoStr of confirm::::: " +userInfoStr);
}
catch(Exception e)
{
System.out.println("Exception in [SorderConfWfEJB] confirm " + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String confirm(String sOrder, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException, ITMException
{
System.out.println("@@@@@@@@@@@@@@@@@@@@ SorderConfWfEJB : confirm @@@@@@@@@@@@@@@@");
String userId = "";
String errString = "";
String transDB = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String status = "",confirmed = "",retString = "",wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try {
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
//conn = getConnection();
if(userInfoStr != null && userInfoStr.trim().length() > 0)
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
transDB = userInfo.getTransDB();
}
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
//connDriver = null;
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + sOrder+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
sql = "SELECT status,confirmed,workflow_status from sorder WHERE sale_order = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, sOrder);
rs = pStmt.executeQuery();
if (rs.next())
{
confirmed = checkNull(rs.getString("confirmed"));
status = checkNull(rs.getString("status"));
wf_status = checkNull(rs.getString("workflow_status"));
}
closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed))
{
if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
}
else if ("O".equalsIgnoreCase(status) || "".equalsIgnoreCase(status))
{
if("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, sOrder, xtraParams, "w_sorder", "sorder");
if ("success".equalsIgnoreCase(retString)) {
sql = "UPDATE SORDER SET workflow_status = 'S' WHERE SALE_ORDER = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, sOrder);
int updCount = pStmt.executeUpdate();
closePstmtRs(pStmt, rs);
if (updCount > 0) {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWS", "");
}
else{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
isError=true;
}
} else {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALINT", "");
}
}
else {
errString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
}
}
else{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "");
}
} catch (Exception e) {
isError = true;
System.out.println("Exception: confirm method ..> " + e.getMessage());
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("", "VFMWRKFLWF", userId);
throw new ITMException(e);
} finally {
if (conn != null) {
try {
if (isError) {
conn.rollback();
System.out.println("SorderConfWfEJB: confirm: Connection Rollback");
} else {
conn.commit();
System.out.println("SorderConfWfEJB: confirm: Connection Commit");
}
conn.close();
conn = null;
} catch (Exception e) {
e.printStackTrace();
}
}
}
return errString;
}
public String rejection(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String userInfoStr = "";
String errString = "";
try
{
userInfoStr = rejection(tranId, xtraParams, forcedFlag, userInfoStr);
System.out.println("userInfoStr of rejection::::: " +userInfoStr);
}
catch(Exception e)
{
System.out.println("Exception in [SorderConfWfEJB] rejection " + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String rejection(String sOrder, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException
{
System.out.println("================ SorderConfWfEJB : rejection ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String transDB = "";
String status = "",confirmed = "",retString = "", wf_status = "";
String loginEmpCode="";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try {
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
//conn = getConnection();
if(userInfoStr != null && userInfoStr.trim().length() > 0)
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
transDB = userInfo.getTransDB();
}
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
//connDriver = null;
conn.setAutoCommit(false);
loginEmpCode = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
if(loginEmpCode == null || loginEmpCode.trim().length() == 0)
{
errString = new ITMDBAccessEJB().getErrorString("", "EMPAPRV", "");
return errString;
}
//userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("pOrder ..> " +sOrder+" loginEmpCode: "+loginEmpCode+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
sOrder = checkNull(sOrder);
sql = "SELECT status,confirmed,workflow_status from sorder WHERE sale_order = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, sOrder);
rs = pStmt.executeQuery();
if (rs.next())
{
confirmed = checkNull(rs.getString("confirmed"));
status = checkNull(rs.getString("status"));
wf_status = checkNull(rs.getString("workflow_status"));
}
closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed))
{
/*if("X".equalsIgnoreCase(status) || "C".equalsIgnoreCase(status))
{
errString = new ITMDBAccessEJB().getErrorString("", "VTWFCLOCAN", "");
}*/
if ("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "S".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{
sql = "UPDATE SORDER SET WORKFLOW_STATUS = 'O' WHERE SALE_ORDER = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, sOrder);
int updCount = pStmt.executeUpdate();
closePstmtRs(pStmt, rs);
if (updCount > 0)
{
retString="Y";
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFOPN", "");
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFFAIL", "");
isError=true;
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALINT", "");
}
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VFMWFCONFN", "");
}
}
catch (Exception e)
{
isError = true;
System.out.println("Exception: rejection method of SorderConfWfEJB..> " + e.getMessage());
e.printStackTrace();
//errString = itmDBAccessEJB.getErrorString("", "VFMWRKFLWF", userId);
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
if (isError)
{
conn.rollback();
System.out.println("SorderConfWfEJB: rejection: Connection Rollback");
}
else
{
conn.commit();
System.out.println("SorderConfWfEJB: rejection: Connection Commit");
}
conn.close();
conn = null;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
return retString;
}
private String checkNull(String str)
{
if(str == null){
str = "";
}
else{
str = str.trim();
}
return str;
}
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
{
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
if (pStmt != null) {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
}
}
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
public interface SorderConfWfEJBLocal extends ActionHandlerLocal
{
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
public String rejection(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
public interface SorderConfWfEJBRemote extends ActionHandlerRemote
{
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, String userInfoStr) throws RemoteException,ITMException;
public String rejection(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
public String rejection(String tranId, String xtraParams, String forcedFlag, String userInfoStr) 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