Commit da975413 authored by rtiwari's avatar rtiwari

change chg term parameter


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93828 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c30ee201
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
...@@ -18,16 +18,18 @@ import javax.ejb.Stateless; ...@@ -18,16 +18,18 @@ import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
// added for ejb3 // added for ejb3
@Stateless @Stateless
public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal,UnitConvICRemote
public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitConvICRemote
{ {
//GenericUtility genericUtility = GenericUtility.getInstance(); // GenericUtility genericUtility = GenericUtility.getInstance();
//FinCommon finCommon = null; // FinCommon finCommon = null;
//ValidatorEJB validator = null; // ValidatorEJB validator = null;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(String xmlString, String xmlString1,
String xmlString2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException
{ {
String errString = ""; String errString = "";
Document dom = null; Document dom = null;
...@@ -37,29 +39,31 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -37,29 +39,31 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
{ {
System.out.println("Val xmlString :: " + xmlString); System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1); System.out.println("Val xmlString1 :: " + xmlString1);
System.out.println("Val xmlString2 :: " + xmlString2 ); System.out.println("Val xmlString2 :: " + xmlString2);
if(xmlString != null && xmlString.trim().length() > 0) if (xmlString != null && xmlString.trim().length() > 0)
{ {
dom = parseString(xmlString); dom = parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length() > 0) if (xmlString1 != null && xmlString1.trim().length() > 0)
{ {
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length() > 0) if (xmlString2 != null && xmlString2.trim().length() > 0)
{ {
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag,
} xtraParams);
catch(Exception e) } catch (Exception e)
{ {
throw new ITMException(e); throw new ITMException(e);
} }
return(errString); return (errString);
} }
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(Document dom, Document dom1, Document dom2,
String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException
{ {
NodeList parentNodeList = null; NodeList parentNodeList = null;
...@@ -82,49 +86,50 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -82,49 +86,50 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = null; ConnDriver connDriver = null;
GenericUtility genericUtility = null; GenericUtility genericUtility = null;
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer(
"<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try try
{ {
connDriver = new ConnDriver(); connDriver = new ConnDriver();
genericUtility = GenericUtility.getInstance(); genericUtility = GenericUtility.getInstance();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) switch (currentFormNo)
{ {
case 1 : case 1:
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++) for (ctr = 0; ctr < childNodeListLength; ctr++)
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if(childNodeName.trim().equalsIgnoreCase("unit__fr")) if (childNodeName.trim().equalsIgnoreCase("unit__fr"))
{ {
unitFr = genericUtility.getColumnValue("unit__fr", dom); unitFr = genericUtility.getColumnValue("unit__fr", dom);
if(unitFr == null || unitFr.trim().length() <= 0) if (unitFr == null || unitFr.trim().length() <= 0)
{ {
errCode = "VMUNIT1"; errCode = "VMUNIT1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if(unitFr != null && unitFr.trim().length() > 0) if (unitFr != null && unitFr.trim().length() > 0)
{ {
sql = "select count(*) from uom where unit = ?"; sql = "select count(*) from uom where unit = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitFr); pstmt.setString(1, unitFr);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
...@@ -132,35 +137,35 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -132,35 +137,35 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt == 0) if (cnt == 0)
{ {
errCode = "VTUNIT1"; errCode = "VTUNIT1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} } else if (childNodeName.trim()
else if(childNodeName.trim().equalsIgnoreCase("unit__to")) .equalsIgnoreCase("unit__to"))
{ {
unitTo = genericUtility.getColumnValue("unit__to", dom); unitTo = genericUtility.getColumnValue("unit__to", dom);
unitFr = genericUtility.getColumnValue("unit__fr", dom); unitFr = genericUtility.getColumnValue("unit__fr", dom);
if(unitTo == null || unitTo.trim().length() <= 0) if (unitTo == null || unitTo.trim().length() <= 0)
{ {
errCode = "VMUNIT1"; errCode = "VMUNIT1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if(unitTo != null && unitTo.trim().length() > 0) if (unitTo != null && unitTo.trim().length() > 0)
{ {
sql = "select count(*) from uom where unit = ? "; sql = "select count(*) from uom where unit = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitTo); pstmt.setString(1, unitTo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
if(cnt == 0) if (cnt == 0)
{ {
errCode = "VTUNIT1"; errCode = "VTUNIT1";
errList.add(errCode); errList.add(errCode);
...@@ -171,34 +176,34 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -171,34 +176,34 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(unitFr.equalsIgnoreCase(unitTo)) if (unitFr.equalsIgnoreCase(unitTo))
{ {
errCode = "VTUNIT2"; errCode = "VTUNIT2";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} } else if (childNodeName.trim().equalsIgnoreCase("item_code"))
else if(childNodeName.trim().equalsIgnoreCase("item_code") )
{ {
itemCode = genericUtility.getColumnValue("item_code", dom); System.out.println(""+""+""+"Change not made in UnitComnIC EJB extending ValidateEJB"+""+""+""+""+""+""+""+""+""+""+""+""+""+""+"");
itemCode = genericUtility.getColumnValue("item_code",dom);
unitTo = genericUtility.getColumnValue("unit__to", dom); unitTo = genericUtility.getColumnValue("unit__to", dom);
unitFr = genericUtility.getColumnValue("unit__fr", dom); unitFr = genericUtility.getColumnValue("unit__fr", dom);
if(itemCode == null && itemCode.trim().length() <= 0) if (itemCode == null && itemCode.trim().length() <= 0)
{ {
errCode = "VMITEMCD"; errCode = "VMITEMCD";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if(itemCode != null && itemCode.trim().length() > 0) if (itemCode != null && itemCode.trim().length() > 0)
{ {
if(!"X".equalsIgnoreCase(itemCode.trim())) if (!"X".equalsIgnoreCase(itemCode.trim()))
{ {
sql = "SELECT COUNT(*) FROM ITEM WHERE ITEM_CODE = ? "; sql = "SELECT COUNT(*) FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode.trim()); pstmt.setString(1, itemCode.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
...@@ -206,22 +211,22 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -206,22 +211,22 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt == 0) if (cnt == 0)
{ {
errCode = "VMITEMCD1 "; errCode = "VMITEMCD1 ";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
if(editFlag.equalsIgnoreCase("A")) if (editFlag.equalsIgnoreCase("A"))
{ {
sql="select count(1) from uomconv where unit__fr = ? and unit__to = ? and item_code = ? "; sql = "select count(1) from uomconv where unit__fr = ? and unit__to = ? and item_code = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitFr.trim()); pstmt.setString(1, unitFr.trim());
pstmt.setString(2,unitTo.trim()); pstmt.setString(2, unitTo.trim());
pstmt.setString(3,itemCode.trim()); pstmt.setString(3, itemCode.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
...@@ -229,7 +234,7 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -229,7 +234,7 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt > 0) if (cnt > 0)
{ {
errCode = "VMDUPL1"; errCode = "VMDUPL1";
errList.add(errCode); errList.add(errCode);
...@@ -240,28 +245,33 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -240,28 +245,33 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
} }
} }
}//END OF FOR }// END OF FOR
}//END OF SWITCH }// END OF SWITCH
int errListSize = errList.size(); int errListSize = errList.size();
cnt = 0; cnt = 0;
String errFldName = null; String errFldName = null;
if(errList != null && errListSize > 0) if (errList != null && errListSize > 0)
{ {
for(cnt = 0; cnt < errListSize; cnt ++) for (cnt = 0; cnt < errListSize; cnt++)
{ {
errCode = errList.get((int) cnt); errCode = errList.get((int) cnt);
errFldName = errFields.get((int) cnt); errFldName = errFields.get((int) cnt);
System.out.println("errCode .........." + errCode); System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode); errorType = errorType(conn, errCode);
if(errString.length() > 0) if (errString.length() > 0)
{ {
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); String bifurErrString = errString.substring(
bifurErrString = bifurErrString +errString.substring(errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>")); errString.indexOf("<Errors>") + 8,
errString.indexOf("<trace>"));
bifurErrString = bifurErrString
+ errString.substring(
errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
errString = ""; errString = "";
} }
if(errorType.equalsIgnoreCase("E")) if (errorType.equalsIgnoreCase("E"))
{ {
break; break;
} }
...@@ -271,31 +281,28 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -271,31 +281,28 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors> </Root> \r\n"); errStringXml.append("</Errors> </Root> \r\n");
} } else
else
{ {
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }
} } catch (Exception e)
catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
} } finally
finally
{ {
try try
{ {
if(conn != null) if (conn != null)
{ {
if(rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
...@@ -304,8 +311,7 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -304,8 +311,7 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
conn.close(); conn.close();
} }
conn = null; conn = null;
} } catch (Exception d)
catch(Exception d)
{ {
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
...@@ -315,7 +321,10 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -315,7 +321,10 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
return errString; return errString;
} }
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException public String itemChanged(String xmlString, String xmlString1,
String xmlString2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException,
ITMException
{ {
System.out.println("@@@@@@@ itemChanged called"); System.out.println("@@@@@@@ itemChanged called");
Document dom = null; Document dom = null;
...@@ -324,30 +333,33 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -324,30 +333,33 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
String valueXmlString = ""; String valueXmlString = "";
try try
{ {
if(xmlString != null && xmlString.trim().length() > 0 ) if (xmlString != null && xmlString.trim().length() > 0)
{ {
dom = parseString(xmlString); dom = parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length() > 0 ) if (xmlString1 != null && xmlString1.trim().length() > 0)
{ {
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length() > 0 ) if (xmlString2 != null && xmlString2.trim().length() > 0)
{ {
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams); valueXmlString = itemChanged(dom, dom1, dom2, objContext,
} currentColumn, editFlag, xtraParams);
catch(Exception e) } catch (Exception e)
{ {
System.out.println("Exception : [MiscVal][itemChanged( String, String )] :==>\n" + e.getMessage()); System.out
.println("Exception : [MiscVal][itemChanged( String, String )] :==>\n"
+ e.getMessage());
} }
return valueXmlString; return valueXmlString;
} }
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException public String itemChanged(Document dom, Document dom1, Document dom2,
String objContext, String currentColumn, String editFlag,
String xtraParams) throws RemoteException, ITMException
{ {
System.out.println("@@@@@@@ itemChanged called"); System.out.println("@@@@@@@ itemChanged called");
...@@ -356,21 +368,21 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -356,21 +368,21 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
Node parentNode1 = null ; Node parentNode1 = null;
String childNodeName = null; String childNodeName = null;
String sql = ""; String sql = "";
String unitTo =""; String unitTo = "";
String unitFr =""; String unitFr = "";
String unitDescrTo=""; String unitDescrTo = "";
String unitDescrFr=""; String unitDescrFr = "";
String round = ""; String round = "";
String chgTerm= "",chgUser = ""; String chgTerm = "", chgUser = "";
int ctr = 0; int ctr = 0;
int currentFormNo = 0; int currentFormNo = 0;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
try try
...@@ -378,21 +390,27 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -378,21 +390,27 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext.trim()); currentFormNo = Integer.parseInt(objContext.trim());
} }
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(
genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime()); String sysDate = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDate); System.out.println("Now the date is :=> " + sysDate);
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_term");System.out.println(":: chg term"+chgTerm); chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_user");System.out.println(":: chg term"+chgUser); "chgTerm");
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>"); System.out.println(":: chg term" + chgTerm);
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,
"chg_user");
System.out.println(":: chg term" + chgUser);
valueXmlString = new StringBuffer(
"<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>"); valueXmlString.append(editFlag).append("</editFlag> </header>");
switch(currentFormNo) switch (currentFormNo)
{ {
case 1 : case 1:
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
...@@ -402,64 +420,75 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -402,64 +420,75 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
ctr ++; ctr++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn)); } while (ctr < childNodeListLength
&& !childNodeName.equals(currentColumn));
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) ) if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{ {
valueXmlString.append( "<chg_user><![CDATA[" ).append(chgUser).append( "]]></chg_user>\r\n" ); valueXmlString.append("<chg_user><![CDATA[")
valueXmlString.append( "<chg_term><![CDATA[" ).append( chgTerm ).append( "]]></chg_term>\r\n" ); .append(chgUser).append("]]></chg_user>\r\n");
valueXmlString.append( "<chg_date><![CDATA[" ).append( sysDate ).append( "]]></chg_date>\r\n" ); valueXmlString.append("<chg_term><![CDATA[")
} .append(chgTerm).append("]]></chg_term>\r\n");
else if(currentColumn.trim().equalsIgnoreCase("unit__fr")) valueXmlString.append("<chg_date><![CDATA[")
.append(sysDate).append("]]></chg_date>\r\n");
} else if (currentColumn.trim().equalsIgnoreCase("unit__fr"))
{ {
unitFr = genericUtility.getColumnValue("unit__fr", dom); unitFr = genericUtility.getColumnValue("unit__fr", dom);
sql = "select descr from uom where unit =?"; sql = "select descr from uom where unit =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitFr); pstmt.setString(1, unitFr);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
unitDescrFr = rs.getString(1); unitDescrFr = rs.getString(1);
} }
valueXmlString.append("<uom_from_descr>").append("<![CDATA[" + unitDescrFr +"]]>").append("</uom_from_descr>"); valueXmlString.append("<uom_from_descr>")
.append("<![CDATA[" + unitDescrFr + "]]>")
.append("</uom_from_descr>");
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} } else if (currentColumn.trim().equalsIgnoreCase("unit__to"))
else if(currentColumn.trim().equalsIgnoreCase("unit__to"))
{ {
unitTo = genericUtility.getColumnValue("unit__to", dom); unitTo = genericUtility.getColumnValue("unit__to", dom);
sql = "select descr from uom where unit =?"; sql = "select descr from uom where unit =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitTo); pstmt.setString(1, unitTo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
unitDescrTo = rs.getString(1); unitDescrTo = rs.getString(1);
} }
valueXmlString.append("<uom_to_descr>").append("<![CDATA[" + unitDescrTo +"]]>").append("</uom_to_descr>"); valueXmlString.append("<uom_to_descr>")
.append("<![CDATA[" + unitDescrTo + "]]>")
.append("</uom_to_descr>");
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
else if(currentColumn.trim().equalsIgnoreCase("round")) else if (currentColumn.trim().equalsIgnoreCase("round"))
{ {
round = genericUtility.getColumnValue("round", dom); round = genericUtility.getColumnValue("round", dom);
System.out.println("::round::"+round); System.out.println("::round::" + round);
if(round.equalsIgnoreCase("X") || round.equalsIgnoreCase("P") ||round.equalsIgnoreCase("R")) if (round.equalsIgnoreCase("X")
|| round.equalsIgnoreCase("P")
|| round.equalsIgnoreCase("R"))
{ {
System.out.println("::round::1"+round); System.out.println("::round::1" + round);
valueXmlString.append("<round_to protect='0'>").append("<![CDATA[1]]>").append("</round_to>"); valueXmlString.append("<round_to protect='0'>")
.append("<![CDATA[1]]>").append("</round_to>");
} }
if(round.equalsIgnoreCase("N") || round == null) if (round.equalsIgnoreCase("N") || round == null)
{ {
System.out.println("::round:N:"+round); System.out.println("::round:N:" + round);
valueXmlString.append("<round_to protect='1'>").append("<![CDATA[0]]>").append("</round_to>");; valueXmlString.append("<round_to protect='1'>")
.append("<![CDATA[0]]>").append("</round_to>");
;
} }
} }
...@@ -467,71 +496,67 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon ...@@ -467,71 +496,67 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
} }
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
}catch(Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage()); System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} } finally
finally
{ {
try try
{ {
if(conn != null) if (conn != null)
{ {
if(pstmt != null) if (pstmt != null)
pstmt.close(); pstmt.close();
if(rs != null) if (rs != null)
rs.close(); rs.close();
rs = null; rs = null;
pstmt = null; pstmt = null;
conn.close(); conn.close();
conn = null; conn = null;
} }
} } catch (Exception d)
catch(Exception d)
{ {
d.printStackTrace(); d.printStackTrace();
} }
} }
return valueXmlString.toString(); return valueXmlString.toString();
} }
private String errorType(Connection conn , String errorCode)
private String errorType(Connection conn, String errorCode)
{ {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while(rs.next()) while (rs.next())
{ {
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
} } catch (Exception ex)
catch(Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
} } finally
finally
{ {
try try
{ {
if(rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception e)
catch(Exception e)
{ {
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