Commit 04060e29 authored by skumbhar's avatar skumbhar

Failed Business Logic


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98125 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 78550dda
/*****************************************
* ANIKET BIBAVE
* FailedBusiLogicConf.java
* Request Id:- [D14LSUN005]
* 14/MAY/15
* ********************************************/
package ibase.webitm.ejb.fin;
import java.net.URL;
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 java.util.HashMap;
import java.util.Set;
import javax.naming.InitialContext;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.fin.adv.GenericWorkflowClass;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.utility.CommonConstants;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
@SuppressWarnings({"unused"})
public class FailedBusiLogicConf implements Schedule
{
E12GenericUtility genericUtility=new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
@Override
public String schedule(String scheduleParamXML) throws Exception
{
System.out.println("In schedule() of FailedBusiLogicConf.java");
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql="",refId="",retString="",errString="";
String tranId="",loginSiteCode="";
ibase.utility.UserInfoBean userInfo = null;
String sysDate ="";
boolean isError = false;
String xtraParams = "",siteCode=""; //The parameters from BaseApplication.xml
try
{
conn = connDriver.getConnectDB("DriverITM");
Document dom = null;
int noOfParam=0;
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
loginSiteCode = userInfo.getSiteCode();
xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+"~~loginEmpCode="+userInfo.getEmpCode();
System.out.println("XTRAPARAMS contain :- ["+xtraParams+"]");
System.out.println("ScheduleParamXML contains :- ["+scheduleParamXML+"]");
sql = "select tran_id from business_logic_check blc " +
"join sorder so on so.sale_order = blc.sale_order and so.cr_check_stat = 'F' and so.confirmed = 'N' " +
"where tran_id not in (select ref_id from wf_prc_status where ref_ser = 'T-BLOG')";
pStmt = conn.prepareStatement(sql);
rs = pStmt.executeQuery();
System.out.println("before while loop");
while (rs.next()) {
refId = rs.getString(1);
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn,refId, xtraParams, "w_business_logic_chk", "business_logic_chk");
if ("success".equalsIgnoreCase(retString)) {
errString = new ITMDBAccessEJB().getErrorString("","VFMWRKFLWS", "");
} else {
isError = true;
errString = new ITMDBAccessEJB().getErrorString("","VFMWRKFLWF", "");
}
}
closePstmtRs(pStmt, rs);
}
catch(Exception e)
{
System.out.println(">>>>>>>>>>>>>In catch:");
e.printStackTrace();
System.out.println(e);
}
finally
{
if(conn != null)
{
if( ! conn.isClosed())
{
conn.close();
conn = null;
}
}
}
return retString;
}
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;
}
}
public String confirm(String tranId, String empCodeAprv, String xmlDataAll, String processId, String keyFlag) throws ITMException, Exception
{
System.out.println("confirm workflow invocation");
System.out.println("Parameters ::: tranId["+tranId+"],empCodeAprv["+empCodeAprv+"],xmlDataAll["+xmlDataAll+"],processId["+processId+"],keyFlag["+keyFlag+"]");
String loginCode = "";
String loginSiteCode = "";
String loginEmpCode = "";
String xtraParams = "loginCode=" + loginCode + "~~" + "loginSiteCode=" + loginSiteCode + "~~" + "loginEmpCode=" + loginEmpCode;
String retString = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
GenericUtility genericUtility = null;
try
{
String methodName = "";
String compName = "";
String businessObj = "business_logic_chk";
String eventCode = "pre_override";
String serviceCode = "";
String serviceURI = "";
String actionURI = "";
conn = connDriver.getConnectDB("DriverITM");
sql="select site_code from sorder where sale_order = (select sale_order from business_logic_check where tran_id = ?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next()) {
loginSiteCode = rs.getString(1);
}
loginSiteCode = loginSiteCode == null ? "" : loginSiteCode.trim();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
empCodeAprv = empCodeAprv == null ? "" : empCodeAprv.trim();
sql = " select code from users where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCodeAprv);
rs = pstmt.executeQuery();
if (rs.next()) {
loginCode = rs.getString(1);
}
loginCode = loginCode == null ? "" : loginCode.trim();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
xtraParams = "loginCode=" + loginCode + "~~" + "loginSiteCode=" + loginSiteCode + "~~" + "loginEmpCode=" + empCodeAprv;
genericUtility = GenericUtility.getInstance();
methodName = "gbf_post";
actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, businessObj);
pstmt.setString(2, eventCode);
rs = pstmt.executeQuery();
if (rs.next()) {
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
}
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");
}
System.out.println("serviceURI = " + serviceURI + " compName = " + compName);
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(tranId);
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("Sucess") > -1)) {
System.out.println("Transaction Successfull");
retString = "Y";
} else {
System.out.println("Exception while calling WSR component");
}
}
catch (Exception eX)
{
eX.printStackTrace();
}
finally
{
if(conn!=null)
{
conn.close();
conn=null;
}
}
return retString;
}
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
}
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