Commit 7492637b authored by skumbhar's avatar skumbhar

Supplier Internet Portel Workflow


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97595 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e061c2ca
package ibase.webitm.ejb.fin.adv;
import ibase.webitm.ejb.XML2DBEJB;
import ibase.webitm.utility.GenerateXmlFromDB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.PrintStream;
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.NamedNodeMap;
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 {
GenericUtility genericUtility = null;
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();
genericUtility = GenericUtility.getInstance();
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
package ibase.webitm.ejb.fin.adv;
import ibase.system.config.ConnDriver;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class SupplierInetPortalAprv
{
public String confirm(String tranId, String empCodeAprv, String xmlDataAll, String processId, String keyFlag) throws RemoteException, ITMException {
System.out.println("confirm workflow invocation");
System.out.println("Parameters ::: tranId["+tranId+"],empCodeAprv["+empCodeAprv+"],xmlDataAll["+xmlDataAll+"],processId["+processId+"],keyFlag["+keyFlag+"]");
String retString = "";
Document dom = null;
Connection conn = null;
PreparedStatement pstmt = null;
String sql = "";
ConnDriver connDriver = new ConnDriver();
GenericUtility genericUtility = GenericUtility.getInstance();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0, childNodeListLength = 0, cnt = 0;
String childNodeName = null;
String supp_type="",group_code="",addr1="",addr2="",addr3="",supp_code="",
city="",state_code="",pin="",count_code="",sh_name="",tele1="",tax_reg="",
chq_name="",pan_no="",excise_ref="",ser_tax_reg="",full_name="",supp_name="";
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
empCodeAprv = empCodeAprv == null ? "" : empCodeAprv.trim();
System.out.println("start");
if (xmlDataAll != null && xmlDataAll.trim().length() != 0)
{
dom = genericUtility.parseString(xmlDataAll);
System.out.println("dom:["+genericUtility.serializeDom(dom)+"]");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName:" + childNodeName);
supp_code = genericUtility.getColumnValue("supp_code", dom);
System.out.println("supp_code="+supp_code);
if (childNodeName.equalsIgnoreCase("supp_code"))
{
supp_code = genericUtility.getColumnValue("supp_code", dom);
supp_code = supp_code == null ? "" : supp_code.trim();
}
else if (childNodeName.equalsIgnoreCase("supp_type"))
{
supp_type = genericUtility.getColumnValue("supp_type", dom);
supp_type = supp_type == null ? "" : supp_type.trim();
}
else if (childNodeName.equalsIgnoreCase("group_code"))
{
group_code = genericUtility.getColumnValue("group_code", dom);
group_code = group_code == null ? "" : group_code.trim();
}
else if (childNodeName.equalsIgnoreCase("addr1"))
{
addr1 = genericUtility.getColumnValue("addr1", dom);
addr1 = addr1 == null ? "" : addr1.trim();
}
else if (childNodeName.equalsIgnoreCase("addr2"))
{
addr2 = genericUtility.getColumnValue("addr2", dom);
addr2 = addr2 == null ? "" : addr2.trim();
}
else if (childNodeName.equalsIgnoreCase("addr3"))
{
addr3 = genericUtility.getColumnValue("addr3", dom);
addr3 = addr3 == null ? "" : addr3.trim();
}
else if (childNodeName.equalsIgnoreCase("city"))
{
city = genericUtility.getColumnValue("city", dom);
city = city == null ? "" : city.trim();
}
else if (childNodeName.equalsIgnoreCase("state_code"))
{
state_code = genericUtility.getColumnValue("state_code", dom);
state_code = state_code == null ? "" : state_code.trim();
}
else if (childNodeName.equalsIgnoreCase("pin"))
{
pin = genericUtility.getColumnValue("pin", dom);
pin = pin == null ? "" : pin.trim();
}
else if (childNodeName.equalsIgnoreCase("count_code"))
{
count_code = genericUtility.getColumnValue("count_code", dom);
count_code = count_code == null ? "" : count_code.trim();
}
else if (childNodeName.equalsIgnoreCase("sh_name"))
{
sh_name = genericUtility.getColumnValue("sh_name", dom);
sh_name = sh_name == null ? "" : sh_name.trim();
}
else if (childNodeName.equalsIgnoreCase("tele1"))
{
tele1 = genericUtility.getColumnValue("tele1", dom);
tele1 = tele1 == null ? "" : tele1.trim();
}
else if (childNodeName.equalsIgnoreCase("tax_reg"))
{
tax_reg = genericUtility.getColumnValue("tax_reg", dom);
tax_reg = tax_reg == null ? "" : tax_reg.trim();
}
else if (childNodeName.equalsIgnoreCase("chq_name"))
{
chq_name = genericUtility.getColumnValue("chq_name", dom);
chq_name = chq_name == null ? "" : chq_name.trim();
}
else if (childNodeName.equalsIgnoreCase("pan_no"))
{
pan_no = genericUtility.getColumnValue("pan_no", dom);
pan_no = pan_no == null ? "" : pan_no.trim();
}
else if (childNodeName.equalsIgnoreCase("excise_ref"))
{
excise_ref = genericUtility.getColumnValue("excise_ref", dom);
excise_ref = excise_ref == null ? "" : excise_ref.trim();
}
else if (childNodeName.equalsIgnoreCase("ser_tax_reg"))
{
ser_tax_reg = genericUtility.getColumnValue("ser_tax_reg", dom);
ser_tax_reg = ser_tax_reg == null ? "" : ser_tax_reg.trim();
}
else if (childNodeName.equalsIgnoreCase("full_name"))
{
full_name = genericUtility.getColumnValue("full_name", dom);
full_name = full_name == null ? "" : full_name.trim();
}
else if (childNodeName.equalsIgnoreCase("supp_name"))
{
supp_name = genericUtility.getColumnValue("supp_name", dom);
supp_name = supp_name == null ? "" : supp_name.trim();
}
}
sql = "UPDATE SUPPLIER SET SUPP_TYPE=?,GROUP_CODE=?,ADDR1=?,ADDR2=?,ADDR3=?,CITY=?,STATE_CODE=?,PIN=?," +
"COUNT_CODE=?,SH_NAME=?,TELE1=?,TAX_REG=?,CHQ_NAME=?,PAN_NO=?,EXCISE_REF=?,SER_TAX_REG=?,FULL_NAME=?,SUPP_NAME=?"+
"WHERE SUPP_CODE=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, supp_type);
pstmt.setString(2, group_code);
pstmt.setString(3, addr1);
pstmt.setString(4, addr2);
pstmt.setString(5, addr3);
pstmt.setString(6, city);
pstmt.setString(7, state_code);
pstmt.setString(8, pin);
pstmt.setString(9, count_code);
pstmt.setString(10, sh_name);
pstmt.setString(11, tele1);
pstmt.setString(12, tax_reg);
pstmt.setString(13, chq_name);
pstmt.setString(14, pan_no);
pstmt.setString(15, excise_ref);
pstmt.setString(16, ser_tax_reg);
pstmt.setString(17, full_name);
pstmt.setString(18, supp_name);
pstmt.setString(19, tranId);
cnt += pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Saved Successfully:"+cnt);
if(cnt > 0) {
conn.commit();
retString = "Y";
} else
{
conn.rollback();
retString = "N";
}
}
}
catch (Exception e)
{
try
{
conn.rollback();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
e.printStackTrace();
System.out.println("Exeption occured");
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
conn.commit();
conn.close();
conn = null;
}
catch (SQLException e)
{
e.printStackTrace();
System.out.println("Exeption in Finally");
}
}
System.gc();
}
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