Commit 4627e36e authored by jshaikh's avatar jshaikh

Added new components for indent req

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@180556 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8cf06b2e
/**
* PURPOSE : IndentConf component
* AUTHOR : Sneha Mestry
* DATE : 04-01-2017
*/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.E12CreateBatchLoadEjb; import ibase.webitm.ejb.E12CreateBatchLoadEjb;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.sys.CreateRCPXML; import ibase.webitm.ejb.sys.CreateRCPXML;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
...@@ -23,7 +19,7 @@ import java.util.Date; ...@@ -23,7 +19,7 @@ import java.util.Date;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.*;
@Stateless @Stateless
...@@ -33,7 +29,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -33,7 +29,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
DistCommon discommon = new DistCommon(); DistCommon discommon = new DistCommon();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{ {
String retString = ""; String retString = "";
...@@ -41,7 +36,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -41,7 +36,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
try try
{ {
retString = this.confirm(tranID, xtraParams, forcedFlag, conn); retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
System.out.println("retString:::::"+retString); System.out.println("retString:::::"+retString);
} }
catch(Exception e) catch(Exception e)
...@@ -52,7 +46,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -52,7 +46,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
return retString; return retString;
} }
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{ {
System.out.println(" ========= Inside IndentReqConf confirm ============= "); System.out.println(" ========= Inside IndentReqConf confirm ============= ");
System.out.println(" ========= tranId ============= "+tranId); System.out.println(" ========= tranId ============= "+tranId);
...@@ -75,8 +69,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -75,8 +69,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
ld_purcrate = "", ls_pack = "", lc_pur_lead = "", ls_pack_instr = "", ls_supp_mnfr = "", lc_qty_std = "", indno = "", ld_purcrate = "", ls_pack = "", lc_pur_lead = "", ls_pack_instr = "", ls_supp_mnfr = "", lc_qty_std = "", indno = "",
ls_str = "", ldt_today = "", ls_str = "", ldt_today = "",
ls_unit_std = "", lc_conv = "", ls_emp_pur = "", ls_remarks = "", ld_quantity_atsite = "", ld_aveconsqty_atsite = "", ls_unit_std = "", lc_conv = "", ls_emp_pur = "", ls_remarks = "", ld_quantity_atsite = "", ld_aveconsqty_atsite = "",
ld_reorderqty_atsite = "", ls_emp_code__qcaprv = "", ld_max_rate = "", ls_item_cd_mfg = "", LS_WORK_ORDER = "", ls_anal_code = "", ld_reorderqty_atsite = "", ls_emp_code__qcaprv = "", ld_max_rate = "", ls_item_cd_mfg = "", LS_WORK_ORDER = "", ls_anal_code = "";
wf_status = "", retString="";
double lc_qty_stduom = 0; double lc_qty_stduom = 0;
int qty = 0, ll_start = 1, lc_quantity = 0, ll_lineno = 0, lineno = 0; int qty = 0, ll_start = 1, lc_quantity = 0, ll_lineno = 0, lineno = 0;
...@@ -97,7 +90,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -97,7 +90,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
ls_str = "A"; ls_str = "A";
sql = "SELECT CONFIRMED,STATUS,IND_DATE,IND_TYPE,SITE_CODE__ORI, SITE_CODE__DEL, DEPT_CODE, EMP_CODE__REQ, WORK_ORDER," + sql = "SELECT CONFIRMED,STATUS,IND_DATE,IND_TYPE,SITE_CODE__ORI, SITE_CODE__DEL, DEPT_CODE, EMP_CODE__REQ, WORK_ORDER," +
" PROJ_CODE, SITE_CODE__ACCT, SITE_CODE__BIL,SITE_CODE__DES, REF_NO ,TASK_CODE, WF_STATUS FROM INDENT_HDR WHERE IND_NO = ? "; " PROJ_CODE, SITE_CODE__ACCT, SITE_CODE__BIL,SITE_CODE__DES, REF_NO ,TASK_CODE FROM INDENT_HDR WHERE IND_NO = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, indno); pstmt.setString(1, indno);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -118,8 +111,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -118,8 +111,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
ls_sitedes = checkNullAndTrim(rs.getString("SITE_CODE__DES")); ls_sitedes = checkNullAndTrim(rs.getString("SITE_CODE__DES"));
ls_ref_no = checkNullAndTrim(rs.getString("REF_NO")); ls_ref_no = checkNullAndTrim(rs.getString("REF_NO"));
ls_task_code = checkNullAndTrim(rs.getString("TASK_CODE")); ls_task_code = checkNullAndTrim(rs.getString("TASK_CODE"));
wf_status = checkNullAndTrim(rs.getString("WF_STATUS"));
} }
else else
{ {
...@@ -140,14 +131,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -140,14 +131,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
rs.close(); rs.close();
rs = null; rs = null;
} }
//java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
if("C".equalsIgnoreCase(ls_status)) if("C".equalsIgnoreCase(ls_status))
{ {
//Changed by wasim on 10-04-2017 for returning if transaction is calcelled //Changed by wasim on 10-04-2017 for returning if transaction is calcelled
...@@ -322,8 +305,8 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -322,8 +305,8 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
rs1 = null; rs1 = null;
} }
//lc_qty_std = (lc_qty_std.length() == 0) ? "0" : lc_qty_std; lc_qty_std = (lc_qty_std.length() == 0) ? "0" : lc_qty_std;
//lc_qty_stduom = (qty/lc_quantity) * Double.parseDouble(lc_qty_std); lc_qty_stduom = (qty/lc_quantity) * Double.parseDouble(lc_qty_std);
sql1 = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = ? "; sql1 = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = ? ";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
...@@ -452,76 +435,29 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -452,76 +435,29 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
} }
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime()); java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
sql1 = "UPDATE INDENT_HDR SET CONFIRMED = ? , CONF_DATE = ? WHERE IND_NO = ? ";
//String workFlwRetStr = "";
//GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
//workFlwRetStr = wfGenericClass.invokeWorkflow(conn, indno, xtraParams, "w_indent_req", "indent_req");
//System.out.println("workFlwRetStr :: "+workFlwRetStr);
// sql1 = "UPDATE INDENT_HDR SET WF_STATUS = 'S', CONFIRMED = ? , CONF_DATE = ? WHERE IND_NO = ? ";
// pstmtInsert = conn.prepareStatement(sql1);
// pstmtInsert.setString(1, "Y");
// pstmtInsert.setDate(2, currentDate);
// pstmtInsert.setString(3, indno);
// pstmtInsert.executeUpdate();
// if(pstmtInsert != null)
// {
// pstmtInsert.close();
// pstmtInsert = null;
// }
if(!"Y".equalsIgnoreCase(conf)){
if ("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status)) {
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_indent_req", "indent_req");
if ("success".equalsIgnoreCase(retString)) {
//sql1 = "UPDATE INDENT_HDR SET CONFIRMED = ? , CONF_DATE = ?, WF_STATUS = 'S' WHERE IND_NO = ? ";
sql1 = "UPDATE INDENT_HDR SET WF_STATUS = 'S' WHERE IND_NO = ? ";
pstmtInsert = conn.prepareStatement(sql1); pstmtInsert = conn.prepareStatement(sql1);
//pstmtInsert.setString(1, "Y"); pstmtInsert.setString(1, "Y");
//pstmtInsert.setDate(2, currentDate); pstmtInsert.setDate(2, currentDate);
pstmtInsert.setString(1, indno); pstmtInsert.setString(3, indno);
pstmtInsert.executeUpdate();
int updCount = pstmtInsert.executeUpdate();
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("", "VTMWFALCNF", "");
}
if(pstmtInsert != null) if(pstmtInsert != null)
{ {
pstmtInsert.close(); pstmtInsert.close();
pstmtInsert = null; pstmtInsert = null;
} }
if(errCode.length() != 0)
{
// if(errCode.length() != 0) isError = true;
// { }
// isError = true; else if(errCode.length() == 0)
// } {
// else if(errCode.length() == 0) isError = false;
// { errCode = "CONFSUCESS";
// isError = false; errList.add( errCode );
// errCode = "CONFSUCESS"; errFields.add(childNodeName.toLowerCase());
// errList.add( errCode ); }
// errFields.add(childNodeName.toLowerCase());
// }
String ediOption = ""; String ediOption = "";
String dataStr = ""; String dataStr = "";
...@@ -547,7 +483,11 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -547,7 +483,11 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
rs1 = null; rs1 = null;
} }
if ("2".equals(ediOption)) if (ediOption == null || ediOption.equalsIgnoreCase("0"))
{
}
else if ("2".equals(ediOption))
{ {
CreateRCPXML createRCPXML = new CreateRCPXML("w_indent_req", "tran_id"); CreateRCPXML createRCPXML = new CreateRCPXML("w_indent_req", "tran_id");
dataStr = createRCPXML.getTranXML(tranId, conn); dataStr = createRCPXML.getTranXML(tranId, conn);
...@@ -555,7 +495,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -555,7 +495,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
Document ediDataDom = genericUtility.parseString(dataStr); Document ediDataDom = genericUtility.parseString(dataStr);
E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb(); E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb();
retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_indent_req", "2", xtraParams, conn); String retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_indent_req", "2", xtraParams, conn);
createRCPXML = null; createRCPXML = null;
e12CreateBatchLoad = null; e12CreateBatchLoad = null;
...@@ -572,7 +512,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -572,7 +512,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
Document ediDataDom = genericUtility.parseString(dataStr); Document ediDataDom = genericUtility.parseString(dataStr);
E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb(); E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb();
retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_indent_req", ediOption, xtraParams, conn); String retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_indent_req", ediOption, xtraParams, conn);
createRCPXML = null; createRCPXML = null;
e12CreateBatchLoad = null; e12CreateBatchLoad = null;
...@@ -620,8 +560,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -620,8 +560,6 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
} }
errString = errStringXml.toString(); errString = errStringXml.toString();
} }
catch(Exception e) catch(Exception e)
{ {
try try
...@@ -710,7 +648,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca ...@@ -710,7 +648,7 @@ public class IndentReqConf extends ActionHandlerEJB implements IndentReqConfLoca
ResultSet rs = null; ResultSet rs = null;
try try
{ {
String sql = " select msg_type from messages where msg_no = ? "; String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql ); pstmt = conn.prepareStatement( sql );
pstmt.setString(1, errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
......
...@@ -18,7 +18,8 @@ import org.apache.axis.encoding.XMLType; ...@@ -18,7 +18,8 @@ import org.apache.axis.encoding.XMLType;
public class IndentReqConfWF public class IndentReqConfWF
{ {
public String confirm(String tran_id, String empCodeAprv, String xmlDataAll, String processId, String keyFlag, String userInfoStr) throws RemoteException, ITMException { public String confirm(String tran_id, String empCodeAprv, String xmlDataAll, String processId, String keyFlag) throws RemoteException, ITMException
{
System.out.println("confirm workflow invocation"); System.out.println("confirm workflow invocation");
System.out.println("Parameters ::: tranId[" + tran_id + "], empCodeAprv[" + empCodeAprv + "], xmlDataAll[" + xmlDataAll + "],processId["+processId+"],keyFlag["+keyFlag+"]"); System.out.println("Parameters ::: tranId[" + tran_id + "], empCodeAprv[" + empCodeAprv + "], xmlDataAll[" + xmlDataAll + "],processId["+processId+"],keyFlag["+keyFlag+"]");
String loginCode = ""; String loginCode = "";
...@@ -31,25 +32,26 @@ public class IndentReqConfWF ...@@ -31,25 +32,26 @@ public class IndentReqConfWF
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String confirmed = "", wf_status = "", status = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
E12GenericUtility genericUtility = null; E12GenericUtility genericUtility = null;
UserInfoBean userInfo =null;
if("C".equalsIgnoreCase(keyFlag) || "R".equalsIgnoreCase(keyFlag)){ if("C".equalsIgnoreCase(keyFlag) || "R".equalsIgnoreCase(keyFlag)){
retString = updateWfStatus(tran_id, empCodeAprv, loginSiteCode, keyFlag); retString = updateWfStatus(tran_id, empCodeAprv, loginSiteCode, keyFlag);
} }
else{ else{
try { try {
//conn = connDriver.getConnectDB("DriverITM"); System.out.println("Try block of IndentReqConfWF.confirm()");
conn = connDriver.getConnectDB("DriverITM");
//conn = getConnection(); //conn = getConnection();
System.out.println("Inside Indent Requisition confirm section: "+userInfoStr); //System.out.println("Inside Indent Requisition confirm section: "+userInfoStr);
userInfo = new UserInfoBean(userInfoStr); /* UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB(); String transDB = userInfo.getTransDB();
System.out.println("get TransDB connection : "+transDB);
if (transDB != null && transDB.trim().length() > 0) if (transDB != null && transDB.trim().length() > 0)
{ {
conn = connDriver.getConnectDB(transDB); conn = connDriver.getConnectDB(transDB);
} }
*/
connDriver = null; connDriver = null;
conn.setAutoCommit(false); conn.setAutoCommit(false);
...@@ -57,7 +59,7 @@ public class IndentReqConfWF ...@@ -57,7 +59,7 @@ public class IndentReqConfWF
String methodName = ""; String methodName = "";
String compName = ""; String compName = "", compType = "";
String businessObj = "indent_req"; String businessObj = "indent_req";
String eventCode = "pre_confirm"; String eventCode = "pre_confirm";
String serviceCode = ""; String serviceCode = "";
...@@ -100,7 +102,7 @@ public class IndentReqConfWF ...@@ -100,7 +102,7 @@ public class IndentReqConfWF
methodName = "gbf_post"; methodName = "gbf_post";
actionURI = "http://NvoServiceurl.org/" + methodName; actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = ? "; sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, businessObj); pstmt.setString(1, businessObj);
pstmt.setString(2, eventCode); pstmt.setString(2, eventCode);
...@@ -108,8 +110,9 @@ public class IndentReqConfWF ...@@ -108,8 +110,9 @@ public class IndentReqConfWF
if (rs.next()) { if (rs.next()) {
serviceCode = rs.getString("SERVICE_CODE"); serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME"); compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
} }
System.out.println("serviceCode = " + serviceCode + " compName " + compName); System.out.println("serviceCode = " + serviceCode + " compName " + compName + " compType " +compType);
rs.close(); rs.close();
rs = null; rs = null;
...@@ -130,6 +133,13 @@ public class IndentReqConfWF ...@@ -130,6 +133,13 @@ public class IndentReqConfWF
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if("EJB".equalsIgnoreCase(compType))
{
IndentReqConf indentReqConf = new IndentReqConf();
indentReqConf.confirm(tran_id, xtraParams, "Y", conn);
}
else if("WSR".equalsIgnoreCase(compType))
{
Service service = new Service(); Service service = new Service();
Call call = (Call) service.createCall(); Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(serviceURI)); call.setTargetEndpointAddress(new URL(serviceURI));
...@@ -158,6 +168,39 @@ public class IndentReqConfWF ...@@ -158,6 +168,39 @@ public class IndentReqConfWF
System.out.println("Exception while calling WSR component"); System.out.println("Exception while calling WSR component");
} }
} }
sql = "SELECT CONFIRMED,STATUS,WF_STATUS FROM INDENT_HDR WHERE IND_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tran_id);
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);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("Y".equalsIgnoreCase(confirmed))
{
retString = "Y";
}
else
{
retString = "N";
}
}
catch (Exception e) { catch (Exception e) {
try { try {
conn.rollback(); conn.rollback();
...@@ -268,4 +311,16 @@ public class IndentReqConfWF ...@@ -268,4 +311,16 @@ public class IndentReqConfWF
System.out.println("Return string from IndentReqConf updateWfStatus method is: "+retString); System.out.println("Return string from IndentReqConf updateWfStatus method is: "+retString);
return retString; return retString;
} }
private String checkNull(String str)
{
if(str == null)
{
str = "";
}
else
{
str = str.trim();
}
return str;
}
} }
package ibase.webitm.ejb.dis;
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 ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class IndentReqConfWfEJB extends ActionHandlerEJB implements IndentReqConfWfEJBLocal, IndentReqConfWfEJBRemote
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("================ IndentReqConfWfEJB : confirm ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String status = "",confirmed = "",retString = "", ind_no= "", wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try {
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
conn = getConnection();
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranID+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
ind_no = checkNull(tranID);
sql = "SELECT CONFIRMED,STATUS,WF_STATUS FROM INDENT_HDR WHERE IND_NO = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, ind_no);
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", "");
}
else if ("O".equalsIgnoreCase(wf_status) || "R".equalsIgnoreCase(wf_status) || "".equalsIgnoreCase(wf_status))
{
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranID, xtraParams, "w_indent_req", "indent_req");
if ("success".equalsIgnoreCase(retString))
{
sql = "UPDATE INDENT_HDR SET WF_STATUS = 'S' WHERE IND_NO = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranID);
int updCount = pStmt.executeUpdate();
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("", "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("IndentReqConfWfEJB: confirm: Connection Rollback");
}
else
{
conn.commit();
System.out.println("IndentReqConfWfEJB: 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
{
System.out.println("================ IndentReqConfWfEJB : rejection ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String status = "",confirmed = "",retString = "", ind_no= "", wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try {
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
conn = getConnection();
conn.setAutoCommit(false);
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranID+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
ind_no = checkNull(tranID);
sql = "SELECT CONFIRMED,STATUS,WF_STATUS FROM INDENT_HDR WHERE IND_NO = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, ind_no);
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))
{
sql = "UPDATE INDENT_HDR SET CONFIRMED = 'N' WF_STATUS = 'O' WHERE IND_NO = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, ind_no);
int updCount = pStmt.executeUpdate();
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("IndentReqConfWfEJB: rejection: Connection Rollback");
}
else
{
conn.commit();
System.out.println("IndentReqConfWfEJB: rejection: 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;
}
}
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface IndentReqConfWfEJBLocal extends ActionHandlerLocal
{
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String rejection(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface IndentReqConfWfEJBRemote extends ActionHandlerRemote
{
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String rejection(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