Commit 0f5c5ccd authored by ssurve's avatar ssurve

code improvements and changes


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96166 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6cf19b13
...@@ -16,6 +16,8 @@ import org.w3c.dom.Document; ...@@ -16,6 +16,8 @@ import org.w3c.dom.Document;
@javax.ejb.Stateless @javax.ejb.Stateless
public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWizPostSaveLocal,DistIssDelWizPostSaveRemote{ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWizPostSaveLocal,DistIssDelWizPostSaveRemote{
boolean isLocalConn = false;
public String postSave(String xmlString,String editFlag,String tranId, String xtraParams,Connection conn) throws RemoteException,ITMException public String postSave(String xmlString,String editFlag,String tranId, String xtraParams,Connection conn) throws RemoteException,ITMException
{ {
...@@ -23,24 +25,29 @@ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWiz ...@@ -23,24 +25,29 @@ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWiz
System.out.println("------------ DisIssDelWizPostSave postSave method called-----------------tranId : "+ tranId); System.out.println("------------ DisIssDelWizPostSave postSave method called-----------------tranId : "+ tranId);
Document dom = null; Document dom = null;
String errString=""; String errString="";
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
if(xmlString != null && xmlString.trim().length()!=0) if(xmlString != null && xmlString.trim().length()!=0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
System.out.println("xmlString d" + xmlString); System.out.println("xmlString *===> " + xmlString);
} }
tranId = GenericUtility.getInstance().getColumnValue("tran_id",dom); tranId = GenericUtility.getInstance().getColumnValue("tran_id",dom);
System.out.println("------------ DisIssDelWizPostSave postSave method called-----------------tranId from dom: "+ tranId); System.out.println("------------ DisIssDelWizPostSave postSave method called-----------------tranId from dom: "+ tranId);
conn = null; //conn = null;
ConnDriver connDriver = new ConnDriver(); if(conn==null){
conn = connDriver.getConnectDB("DriverITM");
connDriver= null; ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
//connDriver= null;
conn.setAutoCommit(false);
isLocalConn = true;
}
errString = postSave(dom,tranId,editFlag,xtraParams,conn); errString = postSave(dom,tranId,editFlag,xtraParams,conn);
...@@ -55,46 +62,75 @@ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWiz ...@@ -55,46 +62,75 @@ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWiz
public String postSave(Document dom,String tranId,String editflag,String xtraParams,Connection conn) public String postSave(Document dom,String tranId,String editflag,String xtraParams,Connection conn)
{ {
System.out.println("post save dom data1 ---------------:"+dom); System.out.println("post save dom arg --------------- > "+dom);
String sql = "", error = ""; String sql = "", error = "";
String lotSl="", chgTerm = "", chgUser = ""; String lotSl="", chgTerm = "", chgUser = "";
int cnt = 0; int cnt = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr=0;
String childNodeName = null;
int childNodeListLength;
System.out.println("tranId in postSave dom ----> "+tranId);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs=null; ResultSet rs=null;
try try
{ {
lotSl = GenericUtility.getInstance().getColumnValue("lot_sl",dom); //lotSl = GenericUtility.getInstance().getColumnValue("lot_sl",dom);
chgTerm = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "chgTerm"); chgTerm = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
chgUser = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginCode"); chgUser = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginCode");
sql = "delete from distord_issdet where tran_id = ? and lot_sl = ?"; parentNodeList = dom.getElementsByTagName("Detail3");
pstmt = conn.prepareStatement(sql); parentNode = parentNodeList.item(0);
pstmt.setString(1, tranId); childNodeList = parentNode.getChildNodes();
pstmt.setString(2, lotSl); childNodeListLength = childNodeList.getLength();
cnt = pstmt.executeUpdate();
if(pstmt != null){
pstmt.close();
pstmt = null;
}
System.out.println(">>>>>>>successfully deleted record DisIssDelWizPostSave cnt = :" + cnt);
if(cnt > 0){ for(ctr = 0; ctr < childNodeListLength; ctr++)
sql = "update distord_iss set chg_date = sysdate, chg_user = ?, chg_term = ? where tran_id = ?"; {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("Child name --->> "+childNodeName);
lotSl = GenericUtility.getInstance().getColumnValue("lot_sl",dom);
System.out.println("lotSl in DOM --->>" +lotSl);
"
sql = "delete from distord_issdet where tran_id = ? and lot_sl = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, chgUser); pstmt.setString(1, tranId);
pstmt.setString(2, chgTerm); pstmt.setString(2, lotSl);
pstmt.setString(3, tranId);
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
} if(pstmt != null){
pstmt.close();
pstmt = null;
}
System.out.println(">>>>>>>successfully deleted record DisIssDelWizPostSave cnt = :" + cnt);
if(cnt > 0){
sql = "update distord_iss set chg_date = sysdate, chg_user = ?, chg_term = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, chgUser);
pstmt.setString(2, chgTerm);
pstmt.setString(3, tranId);
cnt = pstmt.executeUpdate();
}
}
conn.commit(); conn.commit();
System.out.println(">>>>>>> commit executed ");
}catch(Exception e) }catch(Exception e)
{ {
try { try {
System.out.println(">>>>>>>>>>>>In catch Before rollback>>>"); System.out.println(">>>>>>>>>>>>In catch Before rollback>>>");
conn.rollback(); conn.rollback();
System.out.println(">>>>>>>>>>>>rollback issued >>>");
} catch (SQLException e1) { } catch (SQLException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
...@@ -109,18 +145,27 @@ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWiz ...@@ -109,18 +145,27 @@ public class DistIssDelWizPostSave extends ValidatorEJB implements DistIssDelWiz
{ {
try { try {
System.out.println(">>>>>>>>>>>>In finally Before Commit>>>"); System.out.println(">>>>>>>>>>>>In finally Before Commit>>>");
if(pstmt != null)
if(pstmt != null){
pstmt.close(); pstmt.close();
if(conn != null) pstmt = null;
{
conn.close();
} }
if(rs != null) if(rs != null){
rs.close(); rs.close();
rs = null;
pstmt = null; }
rs = null;
if(isLocalConn){
if(conn != null)
{
conn.close();
conn = null;
isLocalConn = false;
}
}
} catch (SQLException e) { } catch (SQLException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
......
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