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;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
......@@ -18,16 +18,18 @@ import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
// added for ejb3
@Stateless
public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitConvICRemote
// added for ejb3
@Stateless
public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal,UnitConvICRemote
{
//GenericUtility genericUtility = GenericUtility.getInstance();
//FinCommon finCommon = null;
//ValidatorEJB validator = null;
// GenericUtility genericUtility = GenericUtility.getInstance();
// FinCommon finCommon = 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 = "";
Document dom = null;
......@@ -37,33 +39,35 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
{
System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
System.out.println("Val xmlString2 :: " + xmlString2 );
if(xmlString != null && xmlString.trim().length() > 0)
System.out.println("Val xmlString2 :: " + xmlString2);
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);
}
catch(Exception e)
errString = wfValData(dom, dom1, dom2, objContext, editFlag,
xtraParams);
} catch (Exception 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 childNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
......@@ -82,146 +86,147 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null ;
PreparedStatement pstmt = null;
ResultSet rs = null;
ConnDriver connDriver = 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
{
connDriver = new ConnDriver();
genericUtility = GenericUtility.getInstance();
genericUtility = GenericUtility.getInstance();
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
switch (currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++)
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.trim().equalsIgnoreCase("unit__fr"))
if (childNodeName.trim().equalsIgnoreCase("unit__fr"))
{
unitFr = genericUtility.getColumnValue("unit__fr", dom);
if(unitFr == null || unitFr.trim().length() <= 0)
if (unitFr == null || unitFr.trim().length() <= 0)
{
errCode = "VMUNIT1";
errList.add(errCode);
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 = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitFr);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unitFr);
rs = pstmt.executeQuery();
if(rs.next())
if (rs.next())
{
cnt = rs.getInt(1);
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
if (cnt == 0)
{
errCode = "VTUNIT1";
errCode = "VTUNIT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.trim().equalsIgnoreCase("unit__to"))
} else if (childNodeName.trim()
.equalsIgnoreCase("unit__to"))
{
unitTo = genericUtility.getColumnValue("unit__to", dom);
unitFr = genericUtility.getColumnValue("unit__fr", dom);
if(unitTo == null || unitTo.trim().length() <= 0)
if (unitTo == null || unitTo.trim().length() <= 0)
{
errCode = "VMUNIT1";
errList.add(errCode);
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 = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitTo);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unitTo);
rs = pstmt.executeQuery();
if(rs.next())
if (rs.next())
{
cnt = rs.getInt(1);
}
if(cnt == 0)
{
errCode = "VTUNIT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if (cnt == 0)
{
errCode = "VTUNIT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
if(unitFr.equalsIgnoreCase(unitTo))
if (unitFr.equalsIgnoreCase(unitTo))
{
errCode = "VTUNIT2";
errList.add(errCode);
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);
unitFr = genericUtility.getColumnValue("unit__fr", dom);
if(itemCode == null && itemCode.trim().length() <= 0)
if (itemCode == null && itemCode.trim().length() <= 0)
{
errCode = "VMITEMCD";
errList.add(errCode);
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 = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode.trim());
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode.trim());
rs = pstmt.executeQuery();
if(rs.next())
if (rs.next())
{
cnt = rs.getInt(1);
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
if (cnt == 0)
{
errCode = "VMITEMCD1 ";
errList.add(errCode);
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 = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitFr.trim());
pstmt.setString(2,unitTo.trim());
pstmt.setString(3,itemCode.trim());
sql = "select count(1) from uomconv where unit__fr = ? and unit__to = ? and item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unitFr.trim());
pstmt.setString(2, unitTo.trim());
pstmt.setString(3, itemCode.trim());
rs = pstmt.executeQuery();
if(rs.next())
if (rs.next())
{
cnt = rs.getInt(1);
}
......@@ -229,39 +234,44 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
rs = null;
pstmt.close();
pstmt = null;
if(cnt > 0)
if (cnt > 0)
{
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
}//END OF FOR
}//END OF SWITCH
}// END OF FOR
}// END OF SWITCH
int errListSize = errList.size();
cnt = 0;
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);
errFldName = errFields.get((int) cnt);
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode);
if(errString.length() > 0)
errorType = errorType(conn, errCode);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString = bifurErrString +errString.substring(errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
String bifurErrString = errString.substring(
errString.indexOf("<Errors>") + 8,
errString.indexOf("<trace>"));
bifurErrString = bifurErrString
+ errString.substring(
errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if(errorType.equalsIgnoreCase("E"))
if (errorType.equalsIgnoreCase("E"))
{
break;
}
......@@ -271,31 +281,28 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
} else
{
errStringXml = new StringBuffer("");
}
}
catch(Exception e)
} catch (Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
} finally
{
try
{
if(conn != null)
if (conn != null)
{
if(rs != null)
if (rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
if (pstmt != null)
{
pstmt.close();
pstmt = null;
......@@ -304,8 +311,7 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
conn.close();
}
conn = null;
}
catch(Exception d)
} catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
......@@ -314,8 +320,11 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
errString = errStringXml.toString();
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");
Document dom = null;
......@@ -323,31 +332,34 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
Document dom2 = null;
String valueXmlString = "";
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);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
valueXmlString = itemChanged(dom, dom1, dom2, objContext,
currentColumn, editFlag, xtraParams);
} 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;
}
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");
......@@ -356,186 +368,199 @@ public class UnitConvIC extends ValidatorEJB implements UnitConvICLocal, UnitCon
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Node parentNode1 = null ;
Node parentNode1 = null;
String childNodeName = null;
String sql = "";
String unitTo ="";
String unitFr ="";
String unitDescrTo="";
String unitDescrFr="";
String unitTo = "";
String unitFr = "";
String unitDescrTo = "";
String unitDescrFr = "";
String round = "";
String chgTerm= "",chgUser = "";
String chgTerm = "", chgUser = "";
int ctr = 0;
int currentFormNo = 0;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
try
{
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(
genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDate);
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_term");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>");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,
"chgTerm");
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>");
switch(currentFormNo)
switch (currentFormNo)
{
case 1 :
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
do
{
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
ctr++;
} 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_term><![CDATA[" ).append( chgTerm ).append( "]]></chg_term>\r\n" );
valueXmlString.append( "<chg_date><![CDATA[" ).append( sysDate ).append( "]]></chg_date>\r\n" );
}
else if(currentColumn.trim().equalsIgnoreCase("unit__fr"))
valueXmlString.append("<chg_user><![CDATA[")
.append(chgUser).append("]]></chg_user>\r\n");
valueXmlString.append("<chg_term><![CDATA[")
.append(chgTerm).append("]]></chg_term>\r\n");
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);
sql = "select descr from uom where unit =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitFr);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unitFr);
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 = null;
pstmt.close();
pstmt = null;
}
else if(currentColumn.trim().equalsIgnoreCase("unit__to"))
} else if (currentColumn.trim().equalsIgnoreCase("unit__to"))
{
unitTo = genericUtility.getColumnValue("unit__to", dom);
sql = "select descr from uom where unit =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,unitTo);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unitTo);
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 = null;
pstmt.close();
pstmt = null;
}
else if(currentColumn.trim().equalsIgnoreCase("round"))
else if (currentColumn.trim().equalsIgnoreCase("round"))
{
round = genericUtility.getColumnValue("round", dom);
System.out.println("::round::"+round);
if(round.equalsIgnoreCase("X") || round.equalsIgnoreCase("P") ||round.equalsIgnoreCase("R"))
System.out.println("::round::" + round);
if (round.equalsIgnoreCase("X")
|| round.equalsIgnoreCase("P")
|| round.equalsIgnoreCase("R"))
{
System.out.println("::round::1"+round);
valueXmlString.append("<round_to protect='0'>").append("<![CDATA[1]]>").append("</round_to>");
System.out.println("::round::1" + round);
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);
valueXmlString.append("<round_to protect='1'>").append("<![CDATA[0]]>").append("</round_to>");;
System.out.println("::round:N:" + round);
valueXmlString.append("<round_to protect='1'>")
.append("<![CDATA[0]]>").append("</round_to>");
;
}
}
valueXmlString.append("</Detail1>");
}
valueXmlString.append("</Root>");
}catch(Exception e)
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
} finally
{
try
{
if(conn != null)
if (conn != null)
{
if(pstmt != null)
if (pstmt != null)
pstmt.close();
if(rs != null)
if (rs != null)
rs.close();
rs = null;
pstmt = null;
conn.close();
conn = null;
}
}
catch(Exception d)
} catch (Exception d)
{
d.printStackTrace();
}
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn , String errorCode)
}
private String errorType(Connection conn, String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode);
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while(rs.next())
while (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
}
} catch (Exception ex)
{
ex.printStackTrace();
}
finally
} finally
{
try
{
if(rs != null)
if (rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
} catch (Exception e)
{
e.printStackTrace();
}
}
}
return msgType;
}
}
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