Commit cbb7d126 authored by abibave's avatar abibave

Request Id:W16LSER003,W16LSER006

Source Files of Pricelist Generation and Sales Return Workflow.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@105509 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b6e88f72
package ibase.webitm.ejb.dis;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.XML2DBEJB;
import ibase.webitm.utility.GenerateXmlFromDB;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class GenericWorkflowClass {
public String invokeWorkflow(Connection conn, String tranId, String xtraParams, String winName, String objName) throws ITMException {
E12GenericUtility genericUtility = new E12GenericUtility();
Document domAll = null;
NodeList nodeList = null;
Node node = null;
Element nodeElement = null;
String sql = "";
PreparedStatement pStmt = null;
ResultSet rs = null;
String retString = "";
String wrkflwInit = "";
String refSer = "";
String nodeName = "";
try {
XML2DBEJB xml2dbObj = new XML2DBEJB();
GenerateXmlFromDB generateXmlFromDB = new GenerateXmlFromDB();
String retXml = generateXmlFromDB.getXMLData(winName, tranId, conn, true, true);
retXml = retXml.replace("<Root>", "");
retXml = retXml.replace("</Root>", "");
if ((retXml != null) && (retXml.trim().length() > 0)) {
domAll = genericUtility.parseString(retXml);
}
nodeList = domAll.getElementsByTagName("Detail1");
node = nodeList.item(0);
if (node != null) {
objName = node.getAttributes().getNamedItem("objName").getNodeValue();
nodeList = node.getChildNodes();
int nodeListLength = nodeList.getLength();
for (int i = 0; i < nodeListLength; i++) {
node = nodeList.item(i);
if (node != null) {
nodeName = node.getNodeName();
}
if ("wf_status".equalsIgnoreCase(nodeName)) {
if (node.getFirstChild() != null) {
node.getFirstChild().setNodeValue("S");
} else {
nodeElement = (Element) node;
nodeElement.appendChild(domAll.createCDATASection("S"));
}
}
}
}
nodeList = domAll.getElementsByTagName("DocumentRoot");
node = nodeList.item(0);
sql = "SELECT WRKFLW_INIT,REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = 'w_" + objName + "'";
pStmt = conn.prepareStatement(sql);
rs = pStmt.executeQuery();
if (rs.next()) {
wrkflwInit = rs.getString("WRKFLW_INIT") == null ? "" : rs.getString("WRKFLW_INIT");
refSer = rs.getString("REF_SER") == null ? "" : rs.getString("REF_SER");
}
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
String entityCodeInit = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
retString = xml2dbObj.invokeWorkflowExternal(domAll, entityCodeInit, wrkflwInit, objName, refSer, tranId);
System.out.println("retString From xml2dbObj.invokeWorkflowExternal --->" + retString);
} catch (Exception ex) {
ex.printStackTrace();
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
} catch (SQLException sqlEx) {
System.out.println("Exception in Finally " + sqlEx.getMessage());
sqlEx.printStackTrace();
}
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
} catch (SQLException sqlEx) {
System.out.println("Exception in Finally " + sqlEx.getMessage());
sqlEx.printStackTrace();
}
}
return "success";
}
}
\ No newline at end of file
This diff is collapsed.
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
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;
import javax.ejb.Stateless;
@Stateless
public class PricelistGenerationWfEJB extends ActionHandlerEJB implements PricelistGenerationWfEJBLocal, PricelistGenerationWfEJBRemote {
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException {
System.out.println("@@@@@@@@@@@@@@@@@@@@ PricelistGenerationWfEJB @@@@@@@@@@@@@@@@");
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 = "";
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);
tranId = checkNull(tranId);
sql = " select wf_status,confirmed from pricelist_hdr where tran_id = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next()) {
status = rs.getString("wf_status");
confirmed = rs.getString("confirmed");
}
status = checkNull(status);
confirmed = checkNull(confirmed);
closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed)){
if ("O".equalsIgnoreCase(status) || "R".equalsIgnoreCase(status) || "".equalsIgnoreCase(status)) {
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_pricelist_tran", "pricelist_tran");
if ("success".equalsIgnoreCase(retString)) {
sql = "UPDATE PRICELIST_HDR SET WF_STATUS = 'S' WHERE TRAN_ID = ? ";
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 (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
if (pStmt != null) {
try {
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
if (conn != null) {
try {
if (isError) {
conn.rollback();
System.out.println("PricelistGenerationWfEJB: confirm: Connection Rollback");
} else {
conn.commit();
System.out.println("PricelistGenerationWfEJB: confirm: 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 PricelistGenerationWfEJBLocal extends ActionHandlerLocal {
public String confirm(String paramString1, String paramString2,String paramString3) 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 PricelistGenerationWfEJBRemote extends ActionHandlerRemote {
public String confirm(String paramString1, String paramString2,String paramString3) throws RemoteException, ITMException;
}
This diff is collapsed.
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
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;
import javax.ejb.Stateless;
@Stateless
public class SalesReturnWfEJB extends ActionHandlerEJB implements SalesReturnWfEJBLocal, SalesReturnWfEJBRemote {
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException {
System.out.println("@@@@@@@@@@@@@@@@@@@@ SalesReturnWfEJB @@@@@@@@@@@@@@@@");
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 = "";
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);
tranId = checkNull(tranId);
sql = " SELECT wf_status,confirmed FROM sreturn WHERE tran_id = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
rs = pStmt.executeQuery();
if (rs.next()) {
status = rs.getString("wf_status");
confirmed = rs.getString("confirmed");
}
status = checkNull(status);
confirmed = checkNull(confirmed);
closePstmtRs(pStmt, rs);
if(!"Y".equalsIgnoreCase(confirmed)){
if ("O".equalsIgnoreCase(status) || "R".equalsIgnoreCase(status)) {
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranId, xtraParams, "w_salesreturn_retn", "salesreturn_retn");
if ("success".equalsIgnoreCase(retString)) {
sql = "UPDATE SRETURN SET WF_STATUS = 'S' WHERE TRAN_ID = ? ";
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("SalesReturnWfEJB: confirm: Connection Rollback");
} else {
conn.commit();
System.out.println("SalesReturnWfEJB: confirm: 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 SalesReturnWfEJBLocal extends ActionHandlerLocal {
public String confirm(String paramString1, String paramString2,String paramString3) 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 SalesReturnWfEJBRemote extends ActionHandlerRemote {
public String confirm(String paramString1, String paramString2,String paramString3) 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