Commit 321f518d authored by abibave's avatar abibave

Request Id: D16EBAS004

Added code for updating  wf_status column in EJB file for sales return workflow.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@103347 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6b833886
...@@ -42,119 +42,203 @@ public class SaleReturnConfWF implements SaleReturnConfWFRemote, SaleReturnConfW ...@@ -42,119 +42,203 @@ public class SaleReturnConfWF implements SaleReturnConfWFRemote, SaleReturnConfW
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
E12GenericUtility genericUtility = null; E12GenericUtility genericUtility = null;
try { if("C".equalsIgnoreCase(keyFlag) || "R".equalsIgnoreCase(keyFlag)){
conn = connDriver.getConnectDB("DriverITM"); retString = updateWfStatus(tran_id, empCodeAprv, loginSiteCode, keyFlag);
connDriver = null; }
conn.setAutoCommit(false); else{
empCodeAprv = empCodeAprv == null ? "" : empCodeAprv.trim(); try {
conn = connDriver.getConnectDB("DriverITM");
String methodName = ""; connDriver = null;
String compName = ""; conn.setAutoCommit(false);
String businessObj = "salesreturn_retn"; empCodeAprv = empCodeAprv == null ? "" : empCodeAprv.trim();
String eventCode = "pre_confirm";
String serviceCode = ""; String methodName = "";
String serviceURI = ""; String compName = "";
String actionURI = ""; String businessObj = "salesreturn_retn";
String eventCode = "pre_confirm";
sql = " select code from users where emp_code = ? "; String serviceCode = "";
pstmt = conn.prepareStatement(sql); String serviceURI = "";
pstmt.setString(1, empCodeAprv); String actionURI = "";
rs = pstmt.executeQuery();
if (rs.next()) { sql = " select code from users where emp_code = ? ";
loginCode = rs.getString(1); pstmt = conn.prepareStatement(sql);
} pstmt.setString(1, empCodeAprv);
rs = pstmt.executeQuery();
if (rs.next()) {
loginCode = rs.getString(1);
}
loginCode = loginCode == null ? "" : loginCode.trim(); loginCode = loginCode == null ? "" : loginCode.trim();
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
xtraParams = "loginCode=" + loginCode + "~~" + "loginSiteCode=" + loginSiteCode + "~~" + "loginEmpCode=" + empCodeAprv; xtraParams = "loginCode=" + loginCode + "~~" + "loginSiteCode=" + loginSiteCode + "~~" + "loginEmpCode=" + empCodeAprv;
genericUtility = new E12GenericUtility(); genericUtility = new E12GenericUtility();
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 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);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
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");
}
serviceCode = serviceCode == null ? "" : serviceCode.trim();
compName = compName == null ? "" : compName.trim();
System.out.println("serviceCode = " + serviceCode + " compName " + compName);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, serviceCode);
rs = pstmt.executeQuery();
if (rs.next()) {
serviceURI = rs.getString("SERVICE_URI");
}
serviceURI = serviceURI == null ? "" : serviceURI.trim();
System.out.println("serviceURI = " + serviceURI);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(serviceURI));
call.setOperationName(new QName("http://NvoServiceurl.org", methodName));
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[4];
call.addParameter(new QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName("http://NvoServiceurl.org", "tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName("http://NvoServiceurl.org", "forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compName);
aobj[1] = new String(tran_id);
aobj[2] = new String(xtraParams);
System.out.println("@@@@@@@@@@loginEmpCode:" + genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode") + ":");
call.setReturnType(XMLType.XSD_STRING);
retString = (String) call.invoke(aobj);
System.out.println("Confirm Complete @@@@@@@@@@@Return string from NVO is:==>[" + retString + "]");
if ((retString.indexOf("success") > -1) || (retString.indexOf("Success") > -1) || (retString.indexOf("VTSUCC1") > -1)) {
System.out.println("Transaction Successfull");
retString = "Y";
} else {
retString = "N";
System.out.println("Exception in SaleReturnConfWF while calling WSR component");
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exeption occured");
throw new ITMException(e);
} finally {
if (conn != null) {
try {
conn.close();
conn = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
} }
serviceCode = serviceCode == null ? "" : serviceCode.trim(); }
compName = compName == null ? "" : compName.trim(); System.out.println("Return string from SaleReturnConfWF confirm method is: "+retString);
System.out.println("serviceCode = " + serviceCode + " compName " + compName); return retString;
}
rs.close();
rs = null; public String updateWfStatus(String tran_id,String empCodeAprv, String loginSiteCode, String wfStatus) {
pstmt.close(); String retString = "";
pstmt = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver();
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? "; PreparedStatement pStmt = null;
pstmt = conn.prepareStatement(sql); ResultSet rs = null;
pstmt.setString(1, serviceCode); String sql = "";
rs = pstmt.executeQuery();
if (rs.next()) { try
serviceURI = rs.getString("SERVICE_URI"); {
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
if ("C".equalsIgnoreCase(wfStatus)) {
sql = "UPDATE SRETURN SET WF_STATUS = 'C' WHERE TRAN_ID = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tran_id);
int cnt = pStmt.executeUpdate();
if (cnt > 0) {
conn.commit();
retString = "Y";
}
else{
retString = "N";
}
} else if("R".equalsIgnoreCase(wfStatus)){
sql = "UPDATE SRETURN SET WF_STATUS = 'R' WHERE TRAN_ID = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tran_id);
int cnt = pStmt.executeUpdate();
if (cnt > 0) {
conn.commit();
retString = "Y";
}
else{
retString = "N";
}
} }
serviceURI = serviceURI == null ? "" : serviceURI.trim(); else{
System.out.println("serviceURI = " + serviceURI); System.out.println("Workflow In Progress");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(serviceURI));
call.setOperationName(new QName("http://NvoServiceurl.org", methodName));
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[4];
call.addParameter(new QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName("http://NvoServiceurl.org", "tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName("http://NvoServiceurl.org", "forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compName);
aobj[1] = new String(tran_id);
aobj[2] = new String(xtraParams);
System.out.println("@@@@@@@@@@loginEmpCode:" + genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode") + ":");
call.setReturnType(XMLType.XSD_STRING);
retString = (String) call.invoke(aobj);
System.out.println("Confirm Complete @@@@@@@@@@@Return string from NVO is:==>[" + retString + "]");
if ((retString.indexOf("success") > -1) || (retString.indexOf("Success") > -1) || (retString.indexOf("VTSUCC1") > -1)) {
System.out.println("Transaction Successfull");
retString = "Y";
} else {
retString = "N";
System.out.println("Exception while calling WSR component");
} }
} catch (Exception e) { }
catch (Exception e)
{
try {
conn.rollback();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
System.out.println("Exception : SaleReturnConfWF : updateWfStatus() : ==>\n" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
System.out.println("Exeption occured"); }
throw new ITMException(e); finally
} finally { {
if (conn != null) { try
try { {
if(rs !=null)
{
rs.close();rs=null;
}
if(pStmt != null)
{
pStmt.close();pStmt = null;
}
if(conn!=null)
{
conn.close(); conn.close();
conn = null; conn=null;
} catch (SQLException e) {
e.printStackTrace();
} }
} }
catch(SQLException sqlEx)
{
System.out.println("Exception in updateWfStatus() Finally "+sqlEx.getMessage());
sqlEx.printStackTrace();
}
} }
System.out.println("Return string from confirm method is: "+retString);
return retString; return retString;
} }
} }
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