Commit 2fb091fd authored by dsawant's avatar dsawant

updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95847 ce508802-f39f-4f6c-b175-0d175dae99d5
parent df6ec260
......@@ -7,28 +7,22 @@
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import org.w3c.dom.CDATASection;
import java.io.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import javax.ejb.Stateless;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
......@@ -208,12 +202,77 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
}
break;
/*case 2:
case 2:
System.out.println("DOM>>>> Elements>>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1>> Elements>>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2>> Elements>>["+genericUtility.serializeDom(dom2).toString()+"]");
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
System.out.println("parentNode >>>{"+parentNode+"}");
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
/* boolean flag = false;
parentNodeList = dom.getElementsByTagName("Detail2");
if(parentNodeList != null)
{
System.out.println("for dom >>>>");
parentNode = parentNodeList.item(0);
if(parentNode != null)
{
try{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}catch(Exception e)
{
e.printStackTrace();
flag = true;
}
}
}
if(flag)
{
flag = false;
parentNodeList = dom1.getElementsByTagName("Detail2");
if(parentNodeList != null)
{
System.out.println("for dom 1");
parentNode = parentNodeList.item(0);
if(parentNode != null)
{
try{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}catch(Exception e)
{
e.printStackTrace();
flag = true;
}
}
}
if(flag)
{
System.out.println("for dom 2");
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
if(parentNode != null)
{
try{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}catch(Exception e)
{
e.printStackTrace();
flag = true;
}
}
}
}
*/
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
......@@ -224,7 +283,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
if(childNodeName.equalsIgnoreCase("work_order"))
{
workOrder = genericUtility.getColumnValue("work_order",dom);
workOrder = genericUtility.getColumnValue("work_order",dom2);
if (workOrder == null || workOrder.trim().length() == 0)
{
......@@ -282,7 +341,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
else if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom);
itemCode = genericUtility.getColumnValue("item_code",dom2);
if (itemCode == null || itemCode.trim().length() == 0)
{
......@@ -317,7 +376,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
else if(childNodeName.equalsIgnoreCase("no_art"))
{
String noArt = genericUtility.getColumnValue("no_art",dom);
String noArt = genericUtility.getColumnValue("no_art",dom2);
if (noArt == null || noArt.trim().length() == 0)
{
......@@ -338,7 +397,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
else if(childNodeName.equalsIgnoreCase("quantity"))
{
squantity = genericUtility.getColumnValue("quantity",dom);
squantity = genericUtility.getColumnValue("quantity",dom2);
if (squantity == null || squantity.trim().length() == 0)
{
......@@ -359,10 +418,10 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
}
break;*/
break;
case 3:
parentNodeList = dom.getElementsByTagName("Detail3");
parentNodeList = dom2.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
......@@ -377,7 +436,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
if(childNodeName.equalsIgnoreCase("work_order"))
{
workOrder = genericUtility.getColumnValue("work_order",dom);
workOrder = genericUtility.getColumnValue("work_order",dom2);
if (workOrder == null || workOrder.trim().length() == 0)
{
......@@ -433,7 +492,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
}
else if(childNodeName.equalsIgnoreCase("no_art"))
{
String noArt = genericUtility.getColumnValue("no_art",dom);
String noArt = genericUtility.getColumnValue("no_art",dom2);
if (noArt == null || noArt.trim().length() == 0)
{
......@@ -454,7 +513,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
else if(childNodeName.equalsIgnoreCase("quantity"))
{
squantity = genericUtility.getColumnValue("quantity",dom);
squantity = genericUtility.getColumnValue("quantity",dom2);
if (squantity == null || squantity.trim().length() == 0)
{
......@@ -475,7 +534,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
else if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom);
itemCode = genericUtility.getColumnValue("item_code",dom2);
if (itemCode == null || itemCode.trim().length() == 0)
{
......@@ -579,18 +638,25 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
ConnDriver connDriver = new ConnDriver();
SimpleDateFormat simpleDateFormat = null;
GenericUtility genutility = new GenericUtility();
String locCode="",lotNo="",lotsl="",itmdesc="",loginSite="",siteCode="";
String locCode="",lotNo="",lotsl="",itmdesc="",loginSite="",siteCode="",atranid="";
System.out.println("DOM111 Elements>>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM222 Elements>>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM322 Elements>>["+genericUtility.serializeDom(dom2).toString()+"]");
String workOrder = "",itemCode = "",itemDescr="",sql="",lineNo="";
java.sql.Timestamp currDate = null;
String workOrder = "",itemCode = "",itemDescr="",sql="",lineNo="",unit="",packCode="",qcReqd="",locGrp="";
double totDetQuan = 0.0,totNoArt=0.0;
java.sql.Timestamp currDate = null,mfgDateStart = null,startDate=null,expDate=null;
double quantity = 0,grossWeight = 0,tareWeight = 0,netWeight = 0,noOfArt=0,shippsize = 0;
SimpleDateFormat sdf = null;
String currAppdate = "";
String currAppdate = "",woSiteCode="",sStartDate="",sExpDate="",sMfgDateStart="";
String tranid ="";
double rate = 0,conquan,conOldRate,oldAmount,amount,amtdiff,oldRate=0,getquantity=0;
int cnt = 0;
TransIDGenerator generator = null;
String autoTranid = "";
String scrFlag = "";
String xmlString = "";
String todayDate = "";
try
{
......@@ -617,8 +683,6 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
break;
case 2 :
parentNodeList = dom.getElementsByTagName("Detail2");
......@@ -626,16 +690,85 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
childNodeList = parentNode.getChildNodes();
System.out.println("DOM2 Elements["+genericUtility.serializeDom(dom2).toString()+"]");
System.out.println("itm_default >>>>> 2>>");
workOrder = genericUtility.getColumnValue("work_order", dom1);
sql = "select count(1) from workorder_receipt where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
System.out.println("for new tran id");
sql = "update obj_forms set scr_flag = ? where win_name = 'w_worder_rcp_det_wiz' and form_no = '2'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "F");
cnt = pstmt.executeUpdate();
System.out.println(">>>>>>>successfully updated record bom post save cnt1:" + cnt);
conn.commit();
pstmt.close();
pstmt = null;
sdf=new SimpleDateFormat(genutility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
todayDate = simpleDateFormat.format(currDate);
String xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + loginSite + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + todayDate + "</tran_date>";
xmlValues = xmlValues + "<tran_type>F</tran_type>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
atranid = tg.generateTranSeqID("W-RCP","tran_id","_spsite_code,T,tran_type,_pptran_date,seq04",conn);
System.out.println(">>>>>NEW id"+atranid);
}else
{
System.out.println("for existing tran id");
sql = "update obj_forms set scr_flag = ? where win_name = 'w_worder_rcp_det_wiz' and form_no = '2'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "T");
cnt = pstmt.executeUpdate();
System.out.println(">>>>>>>successfully updated record bom post save cnt1:" + cnt);
conn.commit();
pstmt.close();
pstmt = null;
}
sql = "select scr_flag from obj_forms where win_name = 'w_worder_rcp_det_wiz' and form_no = '2'";
pstmt=conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
scrFlag = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(scrFlag.equals("T"))
{
System.out.println("non add record");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("itm_default >>>>> 3");
workOrder = genericUtility.getColumnValue("work_order", dom1);
System.out.println("work order from header is"+workOrder);
System.out.println(">>>>>>>>>>>SXD"+workOrder);
sql = "select a.tran_id,a.work_order,a.tran_date,a.item_code,a.no_art,a.quantity,a.gross_weight,"
+ "a.tare_weight,a.net_weight,b.descr from workorder_receipt a,item b where "
+ "a.item_code=b.item_code and work_order = ?";
......@@ -658,7 +791,8 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
simpleDateFormat=new SimpleDateFormat(genutility.getApplDateFormat());
currAppdate = simpleDateFormat.format(currDate);
valueXmlString.append("<Detail2>");
valueXmlString.append("<Detail2 objContext = '"+currentFormNo+"' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[" + tranid + "]]>").append("</tran_id>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + currAppdate + "]]>").append("</tran_date>");
valueXmlString.append("<work_order>").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
......@@ -677,6 +811,170 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
rs.close();
pstmt = null;
rs = null;
}
}else
{
System.out.println("add record");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
sql = "select site_code,rel_date,item_code,lot_no,exp_date,mfg_date__start from workorder where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
woSiteCode = rs.getString(1) == null ? "":rs.getString(1);
startDate = rs.getTimestamp(2);
itemCode = rs.getString(3) == null ? "":rs.getString(3);
lotNo = rs.getString(4) == null ? "":rs.getString(4);
expDate = rs.getTimestamp(5);
mfgDateStart = rs.getTimestamp(6);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
sdf=new SimpleDateFormat(genutility.getApplDateFormat());
sStartDate = simpleDateFormat.format(startDate);
sExpDate = simpleDateFormat.format(expDate);
sMfgDateStart = simpleDateFormat.format(mfgDateStart);
valueXmlString.append("<Detail2 objContext = '"+currentFormNo+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[" + atranid + "]]>").append("</tran_id>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + todayDate + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<work_order>").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<date__start>").append("<![CDATA[" + sStartDate + "]]>").append("</date__start>");
valueXmlString.append("<date__compl>").append("<![CDATA[" + todayDate + "]]>").append("</date__compl>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<loc_code>").append("<![CDATA[ ]]>").append("</loc_code>");
valueXmlString.append("<lot_no>").append("<![CDATA[" + lotNo + "]]>").append("</lot_no>");
valueXmlString.append("<lot_sl>").append("<![CDATA[ ]]>").append("</lot_sl>");
valueXmlString.append("<exp_date>").append("<![CDATA[" + sExpDate + "]]>").append("</exp_date>");
valueXmlString.append("<site_code__own>").append("<![CDATA[" + woSiteCode + "]]>").append("</site_code__own>");
sql = "select sum(quantity) from workorder_rcp_det where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
totDetQuan = rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<quantity>").append("<![CDATA[" + totDetQuan + "]]>").append("</quantity>");
sql = "select unit from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
unit = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
sql = "select pack_code from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
packCode = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<pack_code>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<potency_perc>").append("<![CDATA[0]]>").append("</potency_perc>");
valueXmlString.append("<chg_user>").append("<![CDATA[" + chgUser + "]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA[" + chgTerm + "]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA[" + todayDate + "]]>").append("</chg_date>");
valueXmlString.append("<confirmed>").append("<![CDATA[N]]>").append("</confirmed>");
valueXmlString.append("<mfg_date>").append("<![CDATA[" + sMfgDateStart + "]]>").append("</mfg_date>");
valueXmlString.append("<tran_type>").append("<![CDATA[F]]>").append("</tran_type>");
valueXmlString.append("<operation>").append("<![CDATA[0]]>").append("</operation>");
sql = "select qc_reqd from siteitem where site_code = ? and item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,loginSite);
pstmt.setString(2,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
qcReqd = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<qc_reqd>").append("<![CDATA[" + qcReqd + "]]>").append("</qc_reqd>");
valueXmlString.append("<conv__qty_stduom>").append("<![CDATA[1]]>").append("</conv__qty_stduom>");
sql = "select sum(no_art) from workorder_rcp_det where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
totNoArt = rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<no_art>").append("<![CDATA[" + totNoArt + "]]>").append("</no_art>");
valueXmlString.append("<unit__std>").append("<![CDATA[" + unit + "]]>").append("</unit__std>");
valueXmlString.append("<std_qty>").append("<![CDATA[" + totDetQuan + "]]>").append("</std_qty>");
valueXmlString.append("<create_stab>").append("<![CDATA[N]]>").append("</create_stab>");
valueXmlString.append("<gross_weight>").append("<![CDATA[0]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[0]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[0]]>").append("</net_weight>");
if(qcReqd.equalsIgnoreCase("Y"))
{
sql = "select var_value from mfgparm where var_name = 'WORCP_LOCK_GROUP'";
pstmt=conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
locGrp = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(locGrp != null && locGrp.trim().length() > 0)
{
valueXmlString.append("<lock_group>").append("<![CDATA[" + locGrp + "]]>").append("</lock_group>");
}
}
valueXmlString.append("</Detail2>");
}
}
......@@ -684,7 +982,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
break;
case 3 :
parentNodeList = dom.getElementsByTagName("Detail3");
parentNodeList = dom2.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
tranid = genericUtility.getColumnValue("tran_id", dom2, "2").trim();
......@@ -743,7 +1041,9 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
}
else if(currentColumn.trim().equalsIgnoreCase("itm_default_add"))
{
tranid = genericUtility.getColumnValue("tran_id", dom2, "2").trim();
workOrder = genericUtility.getColumnValue("work_order", dom2, "2").trim();
itemCode = genericUtility.getColumnValue("item_code", dom2, "2").trim();
System.out.println("TRANID IS>>>"+tranid);
NodeList nodeList = dom2.getElementsByTagName("Detail3");
......@@ -753,7 +1053,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
System.out.println("tran id is"+tranid);
sql = "select work_order,item_code,lot_sl,lot_no,no_art,quantity,gross_weight,tare_weight,net_weight "
/* sql = "select work_order,item_code,lot_sl,lot_no,no_art,quantity,gross_weight,tare_weight,net_weight "
+ "from workorder_receipt where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranid);
......@@ -842,9 +1142,14 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
pstmt.close();
rs.close();
pstmt = null;
rs = null;
rs = null;*/
valueXmlString.append("<Detail3 domID='" + domId+ "' objContext = '"+currentFormNo+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id><![CDATA[" + tranid + "]]></tran_id>");
valueXmlString.append("<line_no><![CDATA[" + domId + "]]></line_no>");
valueXmlString.append("<work_order>").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("</Detail3>");
}
......@@ -894,224 +1199,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
return valueXmlString.toString();
}
private StringBuffer getXMLTransData(Connection conn, String sql, String objName) throws Exception
{
System.out.println("In getXMLTransData");
ConnDriver connDriver1 = new ConnDriver();
Connection conn1=null;
StringBuffer valueXmlString = new StringBuffer("");
HashMap<String,Double> issueSiteMap=new HashMap<String,Double>();
HashMap<String,Double> reseiverSiteMap=new HashMap<String,Double>();
HashMap<String,String> issueSiteRefMap=new HashMap<String,String>();
HashMap<String,String> reseiverSiteRefMap=new HashMap<String,String>();
ArrayList<ArrayList> arrayListData = null;
ArrayList traceData = null;
Document dom = null;
String rType="";
TransIDGenerator generator = null;
if(conn!=null){
ResultSet rs = null;
PreparedStatement pstmt = null;
int columnCnt = 0;
int columnItr = 0, detailListCnt = 1;
ResultSetMetaData resultSetMetaData = null;
try {
//Added by Dadaso pawar on 26-MAy-14 [Start]
// check reconcile type if Auto then following query will executed otherwise
// manually--> then only those ref id compare or reconcile whose amount is matched.
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if ( rs != null ) {
System.out.println("In First If");
System.out.println("In CallByItemChange");
resultSetMetaData = rs.getMetaData();
columnCnt = resultSetMetaData.getColumnCount();
while(rs.next())
{
valueXmlString.append("<Detail2 domID='"+ detailListCnt++ +"' selected = 'N'>\r\n");
for (columnItr = 1;columnItr <= columnCnt;columnItr++) {
valueXmlString.append("<");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr).toLowerCase());
valueXmlString.append(">");
valueXmlString.append("<![CDATA[");
valueXmlString.append(rs.getString(columnItr) == null ? "" : rs.getString(columnItr).trim());
valueXmlString.append("]]>");
valueXmlString.append("</");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr).toLowerCase());
valueXmlString.append(">\r\n");
}
valueXmlString.append("</Detail2>\r\n");
}
pstmt = null;
rs = null;
}
}
catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
try{
conn.rollback();
}
catch(Exception e1){
e1.printStackTrace();
}
}
catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
try{
conn.rollback();
}
catch(Exception e1){
e1.printStackTrace();
}
ex.printStackTrace();
} finally {
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
if(conn1!=null){
conn1.close();
conn1=null;
}
}catch (SQLException se) {
se.printStackTrace();
}
sql = null;
objName = null;
}
}else{
try {
throw new SQLException("Connection passed to InterCompReconcileProcess.getXMLTransData() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return valueXmlString;
}
public String preSaveForm(String tranid)throws ITMException
{
String errString = "";
Document dom = null;
System.out.println("@@@@@@@@@---------preSaveForm EJB called...");
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
System.out.println("@@@@@@@xmlString1["+tranid+"]");
if (tranid != null && tranid.trim().length() > 0)
{
try{
writeFile(tranid,"/home/deepak/myfile.txt");
}catch (Exception e) {
e.printStackTrace();
}
}
}
catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
ex.printStackTrace();
} finally {
try {
if(conn != null) {
conn.close();
}
conn = null;
} catch(Exception d) {
d.printStackTrace();
}
}
return "";
}
private String readFile(String file) throws Exception
{
String errString = "";
String sqlQry = "";
try
{
System.out.println("File "+file);
FileInputStream fin = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fin));
String tempStr = "";
while ((tempStr = br.readLine()) != null)
{
sqlQry = sqlQry + tempStr;
}
tempStr = null;
br = null;
fin.close();
} catch (FileNotFoundException fe)
{
System.out.println("FileNotFoundException :InterCompReconcileProcess :readFile(String).." + fe.getMessage());
fe.printStackTrace();
errString = fe.getMessage();
throw new ITMException(fe);
}
catch (Exception e)
{
System.out.println("Exception :InterCompReconcileProcess :readFile(String).." + e.getMessage());
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
return sqlQry;
}
private void writeFile(String adpQuery,String fileName) throws Exception
{
String errString;
try
{
System.out.println("fileName "+fileName);
FileOutputStream fout = null;
BufferedWriter bw = null;
fout = new FileOutputStream(fileName);
bw = new BufferedWriter(new OutputStreamWriter(fout));
bw.write(adpQuery);
bw.close();
fout.close();
} catch (FileNotFoundException fe)
{
System.out.println("FileNotFoundException :InterCompReconcileProcess :writeFile(String,String).." + fe.getMessage());
fe.printStackTrace();
errString = fe.getMessage();
throw new ITMException(fe);
}
catch (Exception e)
{
System.out.println("Exception :InterCompReconcileProcess :writeFile(String,String).." + e.getMessage());
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
}
private static String getAbsString( String str )
{
......
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