Commit dcf5f4e5 authored by abibave's avatar abibave

Request Id: M15GSUP001

Java File for Workorder Issue Workflow


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99865 ce508802-f39f-4f6c-b175-0d175dae99d5
parent afce2b59
package com.supreme;
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 WorderIssueWfJB implements Schedule
{
E12GenericUtility genericUtility=new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
@Override
public String schedule(String scheduleParamXML)throws Exception{
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
System.out.println("in schedule()-->>>>>>>>>");
try
{
System.out.println("in try block of schedule()>>>>>>>>>");
conn = connDriver.getConnectDB("DriverITM");
System.out.println("********* In Scheduler Begine TRY ***************");
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 iss.tran_id from workorder_iss iss " +
"where iss.tran_id not in (select ref_id from wf_prc_status where ref_ser = 'W-ISS') "
+ " and iss.iss_slip = 'A' and iss.confirmed = 'N'";
System.out.println("after sql while loop");
pStmt = conn.prepareStatement(sql);
System.out.println("after pstmt while loop");
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_worder_iss", "worder_iss");
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 = "";
Boolean isError = false;
PreparedStatement pStmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
GenericUtility genericUtility = null;
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
try
{
sql = "update workorder_iss set confirmed = 'Y', conf_date = sysdate where tran_id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1,tranId);
int count = pStmt.executeUpdate();
System.out.println("No of rows updated>>>>"+count);
pStmt.close();
pstmt = null;
}
catch (Exception e) {
System.out.println("Exception: confirm method ..> " + e.getMessage());
isError = true;
throw new ITMException(e);
} finally {
if (conn != null) {
try {
if (isError) {
conn.rollback();
retString = "N";
System.out.println("confirm: Connection Rollback");
} else {
conn.commit();
retString = "Y";
System.out.println("confirm: Connection Commit");
}
conn.close();
conn = null;
} catch (Exception e) {
e.printStackTrace();
}
}
}
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