Commit 2e401c6f authored by manohar's avatar manohar

changes done at sun merged


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91772 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7de3ac85
/******************************************************** /********************************************************
Title : DistributionRoute Title : DistributionRoute
Date : 31/05/12 Date : 31/05/12
Developer: Kunal Mandhre Developer: Kunal Mandhre
********************************************************/ ********************************************************/
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;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.util.*; import java.util.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
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;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.swing.text.DefaultEditorKit.CutAction; import javax.swing.text.DefaultEditorKit.CutAction;
@Stateless @Stateless
public class DistributionRoute extends ValidatorEJB implements DistributionRouteLocal,DistributionRouteRemote public class DistributionRoute extends ValidatorEJB implements DistributionRouteLocal,DistributionRouteRemote
{ {
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
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;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
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);
} }
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
{ {
String StanCodeFrom = ""; String StanCodeFrom = "";
String StanCodeTo = ""; String StanCodeTo = "";
String stateCodeTo = ""; String stateCodeTo = "";
String stateCodeFrom = ""; String stateCodeFrom = "";
String currCode = ""; String currCode = "";
String tranCode = ""; String tranCode = "";
String descr = ""; String descr = "";
String distRoute = ""; String distRoute = "";
String custCode = ""; String custCode = "";
String pinCodeTo = ""; String pinCodeTo = "";
String pinCodeFrom = ""; String pinCodeFrom = "";
String childNodeName = null; String locType = "";
String errString = ""; String frtAmount="";
String errCode = ""; String maxWeight="";
String userId = ""; String minWeight="";
String sql = ""; String childNodeName = null;
String errorType = ""; String errString = "";
int count = 0; String errCode = "";
int ctr=0; String userId = "";
int currentFormNo = 0; String sql = "";
int childNodeListLength; String errorType = "";
boolean fromBlank = false; int count = 0;
boolean toBlank = false; int ctr=0;
NodeList parentNodeList = null; int currentFormNo = 0;
NodeList childNodeList = null; int childNodeListLength;
Node parentNode = null; boolean fromBlank = false;
Node childNode = null; boolean toBlank = false;
ArrayList<String> errList = new ArrayList<String>(); NodeList parentNodeList = null;
ArrayList<String> errFields = new ArrayList<String>(); NodeList childNodeList = null;
Connection conn = null; Node parentNode = null;
PreparedStatement pstmt = null ; Node childNode = null;
ResultSet rs = null; ArrayList<String> errList = new ArrayList<String>();
ConnDriver connDriver = new ConnDriver(); ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); Connection conn = null;
try PreparedStatement pstmt = null ;
{ ResultSet rs = null;
conn = connDriver.getConnectDB("DriverITM"); ConnDriver connDriver = new ConnDriver();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode"); boolean flag=false;
if(objContext != null && objContext.trim().length() > 0) StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
{ try
currentFormNo = Integer.parseInt(objContext); {
} conn = connDriver.getConnectDB("DriverITM");
switch(currentFormNo) userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
{ if(objContext != null && objContext.trim().length() > 0)
case 1 : {
parentNodeList = dom.getElementsByTagName("Detail1"); currentFormNo = Integer.parseInt(objContext);
parentNode = parentNodeList.item(0); }
childNodeList = parentNode.getChildNodes(); switch(currentFormNo)
childNodeListLength = childNodeList.getLength(); {
for(ctr = 0; ctr < childNodeListLength; ctr ++) case 1 :
{ parentNodeList = dom.getElementsByTagName("Detail1");
childNode = childNodeList.item(ctr); parentNode = parentNodeList.item(0);
childNodeName = childNode.getNodeName(); childNodeList = parentNode.getChildNodes();
if(childNodeName.equalsIgnoreCase("dist_route")) childNodeListLength = childNodeList.getLength();
{ for(ctr = 0; ctr < childNodeListLength; ctr ++)
distRoute = checkNull(genericUtility.getColumnValue("dist_route", dom)); {
childNode = childNodeList.item(ctr);
} childNodeName = childNode.getNodeName();
else if(childNodeName.equalsIgnoreCase("descr")) if(childNodeName.equalsIgnoreCase("dist_route"))
{ {
descr = checkNull(genericUtility.getColumnValue("descr", dom)); distRoute = checkNull(genericUtility.getColumnValue("dist_route", dom));
if(descr == null || descr.trim().length() == 0)
{ }
errCode = "VMDESCR"; else if(childNodeName.equalsIgnoreCase("descr"))
errList.add(errCode); {
errFields.add(childNodeName.toLowerCase()); descr = checkNull(genericUtility.getColumnValue("descr", dom));
} if(descr == null || descr.trim().length() == 0)
} {
else if(childNodeName.equalsIgnoreCase("stan_code__fr")) errCode = "VMDESCR";
{ errList.add(errCode);
StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); errFields.add(childNodeName.toLowerCase());
}
if(StanCodeFrom != null && StanCodeFrom.trim().length() > 0) }
{ else if(childNodeName.equalsIgnoreCase("cust_code"))
sql = "select count(*) from station where stan_code = ?"; {
pstmt = conn.prepareStatement(sql); custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
pstmt.setString(1,StanCodeFrom);
rs = pstmt.executeQuery(); if(custCode != null && custCode.trim().length() > 0)
if(rs.next()) {
{ sql = "Select Count(*) from customer where cust_code = ?";
count = rs.getInt(1); pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,custCode);
if(count == 0) rs = pstmt.executeQuery();
{ if(rs.next())
errCode = "VTSTAN1"; {
errList.add(errCode); count = rs.getInt(1);
errFields.add(childNodeName.toLowerCase()); }
} if(count == 0)
rs.close(); {
rs = null; errCode = "VTCUSTCD1";
pstmt.close(); errList.add(errCode);
pstmt = null; errFields.add(childNodeName.toLowerCase());
} }
} rs.close();
else if(childNodeName.equalsIgnoreCase("stan_code__to")) rs = null;
{ pstmt.close();
StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); pstmt = null;
}
if(StanCodeTo != null && StanCodeTo.trim().length() > 0) }
{ else if(childNodeName.equalsIgnoreCase("curr_code"))
sql = "select count(*) from station where stan_code = ?"; {
pstmt = conn.prepareStatement(sql); currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
pstmt.setString(1,StanCodeTo); if(currCode == null || currCode.trim().length() == 0)
rs = pstmt.executeQuery(); {
if(rs.next()) errCode = "VTCURRBK";
{ errList.add(errCode);
count = rs.getInt(1); errFields.add(childNodeName.toLowerCase());
} }
if(count == 0) else if(currCode != null && currCode.trim().length() > 0)
{ {
errCode = "VTSTAN1"; sql = "select count(*) from currency where curr_code = ?";
errList.add(errCode); pstmt = conn.prepareStatement(sql);
errFields.add(childNodeName.toLowerCase()); pstmt.setString(1,currCode);
} rs = pstmt.executeQuery();
rs.close(); if(rs.next())
rs = null; {
pstmt.close(); count = rs.getInt(1);
pstmt = null; }
if(editFlag != null && editFlag.trim().equalsIgnoreCase("A")) if(count == 0)
{ {
sql = "select count(*) from distroute where stan_code__fr = ? and stan_code__to = ?"; errCode = "VTCURRCD1";
pstmt = conn.prepareStatement(sql); errList.add(errCode);
pstmt.setString(1,StanCodeFrom); errFields.add(childNodeName.toLowerCase());
pstmt.setString(2,StanCodeTo); }
rs = pstmt.executeQuery(); rs.close();
if(rs.next()) rs = null;
{ pstmt.close();
count = rs.getInt(1); pstmt = null;
} }
if(count > 0) }
{ else if(childNodeName.equalsIgnoreCase("frt_amt"))
errCode = "VTSTANDB"; {
errList.add(errCode); frtAmount = checkNull(genericUtility.getColumnValue("frt_amt", dom));
errFields.add(childNodeName.toLowerCase()); System.out.println("frtAmount ["+frtAmount+"]");
} if(frtAmount == null || frtAmount.trim().length() == 0)
rs.close(); {
rs = null; System.out.println(" in side if");
pstmt.close(); errCode = "VFRAMTBK";
pstmt = null; errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
}
}
} /*else if(currCode != null && currCode.trim().length() > 0)
} {
else if(childNodeName.equalsIgnoreCase("curr_code")) sql = "select count(*) from distroute where frt_amt = ?";
{ pstmt = conn.prepareStatement(sql);
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom)); pstmt.setString(1,frtAmount);
if(currCode == null || currCode.trim().length() == 0) rs = pstmt.executeQuery();
{ if(rs.next())
errCode = "VTCURRBK"; {
errList.add(errCode); count = rs.getInt(1);
errFields.add(childNodeName.toLowerCase()); }
} if(count == 0)
else if(currCode != null && currCode.trim().length() > 0) {
{ errCode = "VTFRAMT1";
sql = "select count(*) from currency where curr_code = ?"; errList.add(errCode);
pstmt = conn.prepareStatement(sql); errFields.add(childNodeName.toLowerCase());
pstmt.setString(1,currCode); }
rs = pstmt.executeQuery(); rs.close();
if(rs.next()) rs = null;
{ pstmt.close();
count = rs.getInt(1); pstmt = null;
} }*/
if(count == 0)
{ else if(childNodeName.equalsIgnoreCase("stan_code__fr"))
errCode = "VTCURRCD1"; {
errList.add(errCode); StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom));
errFields.add(childNodeName.toLowerCase());
} if(StanCodeFrom != null && StanCodeFrom.trim().length() > 0)
rs.close(); {
rs = null; sql = "select count(*) from station where stan_code = ?";
pstmt.close(); pstmt = conn.prepareStatement(sql);
pstmt = null; pstmt.setString(1,StanCodeFrom);
} rs = pstmt.executeQuery();
} if(rs.next())
else if(childNodeName.equalsIgnoreCase("cust_code")) {
{ count = rs.getInt(1);
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom)); }
if(custCode != null && custCode.trim().length() > 0) if(count == 0)
{ {
sql = "Select Count(*) from customer where cust_code = ?"; errCode = "VTSTAN1";
pstmt = conn.prepareStatement(sql); errList.add(errCode);
pstmt.setString(1,custCode); errFields.add(childNodeName.toLowerCase());
rs = pstmt.executeQuery(); }
if(rs.next()) rs.close();
{ rs = null;
count = rs.getInt(1); pstmt.close();
} pstmt = null;
if(count == 0) }
{ }
errCode = "VTCUSTCD1"; else if(childNodeName.equalsIgnoreCase("stan_code__to"))
errList.add(errCode); {
errFields.add(childNodeName.toLowerCase()); StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom));
}
rs.close(); if(StanCodeTo != null && StanCodeTo.trim().length() > 0)
rs = null; {
pstmt.close(); sql = "select count(*) from station where stan_code = ?";
pstmt = null; pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,StanCodeTo);
} rs = pstmt.executeQuery();
} if(rs.next())
break; {
case 2 : count = rs.getInt(1);
parentNodeList = dom.getElementsByTagName("Detail2"); }
parentNode = parentNodeList.item(0); if(count == 0)
childNodeList = parentNode.getChildNodes(); {
childNodeListLength = childNodeList.getLength(); errCode = "VTSTAN";
for(ctr = 0; ctr < childNodeListLength; ctr ++) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase());
childNode = childNodeList.item(ctr); }
childNodeName = childNode.getNodeName(); rs.close();
if(childNodeName.equalsIgnoreCase("stan_code__fr")) rs = null;
{ pstmt.close();
StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); pstmt = null;
if(StanCodeFrom == null || StanCodeFrom.trim().length() == 0) if(editFlag != null && editFlag.trim().equalsIgnoreCase("A"))
{ {
//errCode = "VMSTANCOD "; sql = "select count(*) from distroute where stan_code__fr = ? and stan_code__to = ?";
//errList.add(errCode); pstmt = conn.prepareStatement(sql);
//errFields.add(childNodeName.toLowerCase()); pstmt.setString(1,StanCodeFrom);
} pstmt.setString(2,StanCodeTo);
else if(StanCodeFrom != null && StanCodeFrom.trim().length() > 0) rs = pstmt.executeQuery();
{ if(rs.next())
sql = "select count(*) from station where stan_code = ?"; {
pstmt = conn.prepareStatement(sql); count = rs.getInt(1);
pstmt.setString(1,StanCodeFrom); }
rs = pstmt.executeQuery(); if(count > 0)
if(rs.next()) {
{ errCode = "VTSTANDB";
count = rs.getInt(1); errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
if(count == 0) }
{ rs.close();
errCode = "VTSTAN1"; rs = null;
errList.add(errCode); pstmt.close();
errFields.add(childNodeName.toLowerCase()); pstmt = null;
} }
rs.close();
rs = null;
pstmt.close(); }
pstmt = null; }
}
} }
else if(childNodeName.equalsIgnoreCase("stan_code__to")) break;
{ case 2 :
StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); parentNodeList = dom.getElementsByTagName("Detail2");
if(StanCodeTo == null || StanCodeTo.trim().length() == 0) parentNode = parentNodeList.item(0);
{ childNodeList = parentNode.getChildNodes();
//errCode = "VMSTANCOD "; childNodeListLength = childNodeList.getLength();
//errList.add(errCode); for(ctr = 0; ctr < childNodeListLength; ctr ++)
//errFields.add(childNodeName.toLowerCase()); {
} childNode = childNodeList.item(ctr);
else if(StanCodeTo != null && StanCodeTo.trim().length() > 0) childNodeName = childNode.getNodeName();
{ if(childNodeName.equalsIgnoreCase("stan_code__fr"))
sql = "select count(*) from station where stan_code = ?"; {
pstmt = conn.prepareStatement(sql); StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom));
pstmt.setString(1,StanCodeTo); if(StanCodeFrom == null || StanCodeFrom.trim().length() == 0)
rs = pstmt.executeQuery(); {
if(rs.next()) //errCode = "VMSTANCOD ";
{ //errList.add(errCode);
count = rs.getInt(1); //errFields.add(childNodeName.toLowerCase());
} errCode = "STNCDFRBK ";
if(count == 0) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase());
errCode = "VTSTAN1"; }
errList.add(errCode); else if(StanCodeFrom != null && StanCodeFrom.trim().length() > 0)
errFields.add(childNodeName.toLowerCase()); {
} sql = "select count(*) from station where stan_code = ?";
rs.close(); pstmt = conn.prepareStatement(sql);
rs = null; pstmt.setString(1,StanCodeFrom);
pstmt.close(); rs = pstmt.executeQuery();
pstmt = null; if(rs.next())
} {
} count = rs.getInt(1);
else if(childNodeName.equalsIgnoreCase("tran_code")) }
{ if(count == 0)
tranCode = checkNull(genericUtility.getColumnValue("tran_code", dom)); {
if(tranCode == null || tranCode.trim().length() == 0) errCode = "VTSTAN1";
{ errList.add(errCode);
errCode = "VMTRANCD1"; errFields.add(childNodeName.toLowerCase());
errList.add(errCode); }
errFields.add(childNodeName.toLowerCase()); rs.close();
} rs = null;
else if(tranCode != null && tranCode.trim().length() > 0) pstmt.close();
{ pstmt = null;
sql = "select count(*) from transporter where tran_code = ?"; }
pstmt = conn.prepareStatement(sql); }
pstmt.setString(1,tranCode); else if(childNodeName.equalsIgnoreCase("stan_code__to"))
rs = pstmt.executeQuery(); {
if(rs.next()) StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom));
{ if(StanCodeTo == null || StanCodeTo.trim().length() == 0)
count = rs.getInt(1); {
} //errCode = "VMSTANCOD ";
if(count == 0) //errList.add(errCode);
{ //errFields.add(childNodeName.toLowerCase());
errCode = "VTTRANCD1"; errCode = "STNCODTOBK ";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
rs.close(); else if(StanCodeTo != null && StanCodeTo.trim().length() > 0)
rs = null; {
pstmt.close(); sql = "select count(*) from station where stan_code = ?";
pstmt = null; pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,StanCodeTo);
} rs = pstmt.executeQuery();
else if(childNodeName.equalsIgnoreCase("curr_code")) if(rs.next())
{ {
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom)); count = rs.getInt(1);
if(currCode == null || currCode.trim().length() == 0) }
{ if(count == 0)
errCode = "VTCURRBK"; {
errList.add(errCode); errCode = "VTSTAN";
errFields.add(childNodeName.toLowerCase()); errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
else if(currCode != null && currCode.trim().length() > 0) }
{ rs.close();
sql = "select count(*) from currency where curr_code = ?"; rs = null;
pstmt = conn.prepareStatement(sql); pstmt.close();
pstmt.setString(1,currCode); pstmt = null;
rs = pstmt.executeQuery(); }
if(rs.next()) }
{ else if(childNodeName.equalsIgnoreCase("tran_code"))
count = rs.getInt(1); {
} tranCode = checkNull(genericUtility.getColumnValue("tran_code", dom));
if(count == 0) if(tranCode == null || tranCode.trim().length() == 0)
{ {
errCode = "VTCURRCD1"; errCode = "VMTRANCD1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
rs.close(); else if(tranCode != null && tranCode.trim().length() > 0)
rs = null; {
pstmt.close(); sql = "select count(*) from transporter where tran_code = ?";
pstmt = null; pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,tranCode);
} rs = pstmt.executeQuery();
else if(childNodeName.equalsIgnoreCase("state_code__to")) if(rs.next())
{ {
stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom)); count = rs.getInt(1);
StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); }
if(count == 0)
sql = "Select count(*) from state where state_code = ?"; {
pstmt = conn.prepareStatement(sql); errCode = "VTTRANCD1";
pstmt.setString(1,stateCodeTo); errList.add(errCode);
rs = pstmt.executeQuery(); errFields.add(childNodeName.toLowerCase());
if(rs.next()) }
{ rs.close();
count = rs.getInt(1); rs = null;
} pstmt.close();
if(count == 0) pstmt = null;
{ }
errCode = "VTSTATE1 "; }
errList.add(errCode); else if(childNodeName.equalsIgnoreCase("frt_amt"))
errFields.add(childNodeName.toLowerCase()); {
} frtAmount = checkNull(genericUtility.getColumnValue("frt_amt", dom));
rs.close(); System.out.println("frtAmount ["+frtAmount+"]");
rs = null; if(frtAmount == null || frtAmount.trim().length() == 0)
pstmt.close(); {
pstmt = null; System.out.println(" in side if");
errCode = "VFRAMTBK";
/* errList.add(errCode);
sql = "Select count(*) from station where stan_code = ? and state_code = ? "; errFields.add(childNodeName.toLowerCase());
pstmt = conn.prepareStatement(sql); }
pstmt.setString(1,StanCodeTo); }
pstmt.setString(2,stateCodeTo); else if(childNodeName.equalsIgnoreCase("curr_code"))
rs = pstmt.executeQuery(); {
if(rs.next()) currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
{ if(currCode == null || currCode.trim().length() == 0)
count = rs.getInt(1); {
} /*errCode = "VTCURRBK";
if(count == 0) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase()); */
errCode = "VTSTATETO"; }
errList.add(errCode); else if(currCode != null && currCode.trim().length() > 0)
errFields.add(childNodeName.toLowerCase()); {
} sql = "select count(*) from currency where curr_code = ?";
rs.close(); pstmt = conn.prepareStatement(sql);
rs = null; pstmt.setString(1,currCode);
pstmt.close(); rs = pstmt.executeQuery();
pstmt = null; if(rs.next())
*/ {
count = rs.getInt(1);
}
if(count == 0)
{
} errCode = "VTCURRCD1";
else if(childNodeName.equalsIgnoreCase("state_code__fr")) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase());
stateCodeFrom = checkNull(genericUtility.getColumnValue("state_code__fr", dom)); }
StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); rs.close();
rs = null;
sql = "Select count(*) from state where state_code = ?"; pstmt.close();
pstmt = conn.prepareStatement(sql); pstmt = null;
pstmt.setString(1,stateCodeTo); }
rs = pstmt.executeQuery(); }
if(rs.next())
{ else if(childNodeName.equalsIgnoreCase("min_weight"))
count = rs.getInt(1); {
} minWeight = checkNull(genericUtility.getColumnValue("min_weight", dom));
if(count == 0) if(minWeight == null || minWeight.trim().length() == 0)
{ {
errCode = "VTSTATE1 "; errCode = "VTMINWTBK";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
rs.close(); }
rs = null; else if(childNodeName.equalsIgnoreCase("max_weight"))
pstmt.close(); {
pstmt = null; maxWeight = checkNull(genericUtility.getColumnValue("max_weight", dom));
/* if(maxWeight == null || maxWeight.trim().length() == 0)
{
sql = "Select count(*) from station where stan_code = ? and state_code = ? "; errCode = "VTMAXWTBK";
pstmt = conn.prepareStatement(sql); errList.add(errCode);
pstmt.setString(1,StanCodeFrom); errFields.add(childNodeName.toLowerCase());
pstmt.setString(2,stateCodeFrom); }
rs = pstmt.executeQuery(); }
if(rs.next()) else if(childNodeName.equalsIgnoreCase("state_code__fr"))
{ {
count = rs.getInt(1); stateCodeFrom = checkNull(genericUtility.getColumnValue("state_code__fr", dom));
} if(stateCodeFrom == null || stateCodeFrom.trim().length() == 0)
if(count == 0) {
{ errCode = "VTSTATBK";
errCode = "VTSTATEFR"; errList.add(errCode);
errList.add(errCode); errFields.add(childNodeName.toLowerCase());
errFields.add(childNodeName.toLowerCase()); }
} else if(stateCodeFrom != null && stateCodeFrom.trim().length() > 0)
rs.close(); {
rs = null; sql = "Select count(*) from state where state_code = ?";
pstmt.close(); pstmt = conn.prepareStatement(sql);
pstmt = null; pstmt.setString(1,stateCodeFrom);
*/ rs = pstmt.executeQuery();
} if(rs.next())
else {
{ count = rs.getInt(1);
stateCodeFrom = checkNull(genericUtility.getColumnValue("state_code__fr", dom)); }
StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); if(count == 0)
stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom)); {
StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); errCode = "VTSTATE1 ";
pinCodeTo = checkNull(genericUtility.getColumnValue("pin__to", dom)); errList.add(errCode);
pinCodeFrom = checkNull(genericUtility.getColumnValue("pin__fr", dom)); errFields.add(childNodeName.toLowerCase());
}
if(StanCodeFrom.trim().length() == 0 && stateCodeFrom.trim().length() == 0 && pinCodeFrom.trim().length() == 0) rs.close();
{ rs = null;
fromBlank = true; pstmt.close();
} pstmt = null;
if(StanCodeTo.trim().length() == 0 && stateCodeTo.trim().length() == 0 && pinCodeTo.trim().length() == 0) }
{ }
toBlank = true; else if(childNodeName.equalsIgnoreCase("state_code__to"))
} {
if(fromBlank) stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom));
{ if(stateCodeTo == null || stateCodeTo.trim().length() == 0)
errCode = "VTFRVAL"; {
errList.add(errCode); errCode = "VTSTATEBK";
errFields.add(childNodeName.toLowerCase()); errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
if(toBlank) }
{ else if(stateCodeTo != null && stateCodeTo.trim().length() > 0)
errCode = "VTTOVAL"; {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); sql = "Select count(*) from state where state_code = ?";
} pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,stateCodeTo);
rs = pstmt.executeQuery();
} if(rs.next())
break; {
} count = rs.getInt(1);
int errListSize = errList.size(); }
count = 0; if(count == 0)
String errFldName = null; {
if(errList != null && errListSize > 0) errCode = "VTSTATE2 ";
{ errList.add(errCode);
for(count = 0; count < errListSize; count ++) errFields.add(childNodeName.toLowerCase());
{ }
errCode = errList.get(count); rs.close();
errFldName = errFields.get(count); rs = null;
System.out.println("errCode .........." + errCode); pstmt.close();
errString = getErrorString(errFldName, errCode, userId); pstmt = null;
errorType = errorType(conn , errCode); }
if(errString.length() > 0) }
{ /*
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); sql = "Select count(*) from station where stan_code = ? and state_code = ? ";
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); pstmt = conn.prepareStatement(sql);
errStringXml.append(bifurErrString); pstmt.setString(1,StanCodeTo);
errString = ""; pstmt.setString(2,stateCodeTo);
} rs = pstmt.executeQuery();
if(errorType.equalsIgnoreCase("E")) if(rs.next())
{ {
break; count = rs.getInt(1);
} }
} if(count == 0)
errList.clear(); {
errList = null; errCode = "VTSTATETO";
errFields.clear(); errList.add(errCode);
errFields = null; errFields.add(childNodeName.toLowerCase());
errStringXml.append("</Errors> </Root> \r\n"); }
} rs.close();
else rs = null;
{ pstmt.close();
errStringXml = new StringBuffer(""); pstmt = null;
}
}//end try sql = "Select count(*) from station where stan_code = ? and state_code = ? ";
catch(Exception e) pstmt = conn.prepareStatement(sql);
{ pstmt.setString(1,StanCodeFrom);
e.printStackTrace(); pstmt.setString(2,stateCodeFrom);
errString = e.getMessage(); rs = pstmt.executeQuery();
throw new ITMException(e); if(rs.next())
} {
finally count = rs.getInt(1);
{ }
try if(count == 0)
{ {
if(conn != null) errCode = "VTSTATEFR";
{ errList.add(errCode);
if(rs != null) errFields.add(childNodeName.toLowerCase());
{ }
rs.close(); rs.close();
rs = null; rs = null;
} pstmt.close();
if(pstmt != null) pstmt = null;
{ */
pstmt.close(); else if(childNodeName.equalsIgnoreCase("pin__fr"))
pstmt = null; {
} pinCodeFrom = checkNull(genericUtility.getColumnValue("pin__fr", dom));
conn.close(); if(pinCodeFrom == null || pinCodeFrom.trim().length() == 0)
} {
conn = null; errCode = "VTPINFRBK";
} errList.add(errCode);
catch(Exception d) errFields.add(childNodeName.toLowerCase());
{ }
d.printStackTrace(); }
throw new ITMException(d); else if(childNodeName.equalsIgnoreCase("pin__to"))
} {
} pinCodeTo = checkNull(genericUtility.getColumnValue("pin__to", dom));
errString = errStringXml.toString(); if(pinCodeTo == null || pinCodeTo.trim().length() == 0)
return errString; {
} errCode = "VTPINTOBK";
errList.add(errCode);
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException errFields.add(childNodeName.toLowerCase());
{ }
Document dom = null; }
Document dom1 = null; else if(childNodeName.equalsIgnoreCase("loc_type"))
Document dom2 = null; {
String valueXmlString = ""; locType = checkNull(genericUtility.getColumnValue("loc_type", dom));
try
{ if(locType != null && locType.trim().length() > 0)
if(xmlString != null && xmlString.trim().length() > 0) {
{ sql = "SELECT rtrim(FLD_VALUE), descr FROM GENCODES WHERE FLD_NAME IN ('LOC_TYPE') AND fld_value=?";
dom = parseString(xmlString); pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,locType);
if(xmlString1 != null && xmlString1.trim().length() > 0) rs = pstmt.executeQuery();
{ if(rs.next())
dom1 = parseString(xmlString1); {
} flag=true;
if(xmlString2 != null && xmlString2.trim().length() > 0) //count = rs.getInt(1);
{ }
dom2 = parseString(xmlString2); if(flag==false)
} {
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams); errCode = "VTLOCINV";
} errList.add(errCode);
catch(Exception e) errFields.add(childNodeName.toLowerCase());
{ }
System.out.println("Exception : [DistributionRoute][itemChanged( String, String )] :==>\n" + e.getMessage()); rs.close();
} rs = null;
return valueXmlString; pstmt.close();
} pstmt = null;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException }
{
String stanCodeFr = ""; else
String stanCodeTo = ""; {
String stateCodeTo = ""; stateCodeFrom = checkNull(genericUtility.getColumnValue("state_code__fr", dom));
String stateCodeFr = ""; StanCodeFrom = checkNull(genericUtility.getColumnValue("stan_code__fr", dom));
String currCode = ""; stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom));
String custCode = ""; StanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom));
String descr = ""; pinCodeTo = checkNull(genericUtility.getColumnValue("pin__to", dom));
String distRoute = ""; pinCodeFrom = checkNull(genericUtility.getColumnValue("pin__fr", dom));
String tranCode = "";
String stateDescr = ""; if(StanCodeFrom.trim().length() == 0 && stateCodeFrom.trim().length() == 0 && pinCodeFrom.trim().length() == 0)
String childNodeName = null; {
String sql = ""; fromBlank = true;
String pinCodeTo = ""; }
String pinCodeFrom = ""; if(StanCodeTo.trim().length() == 0 && stateCodeTo.trim().length() == 0 && pinCodeTo.trim().length() == 0)
StringBuffer valueXmlString = new StringBuffer(); {
int ctr = 0; toBlank = true;
int lineNo = 0; }
int currentFormNo = 0; if(fromBlank)
int childNodeListLength = 0; {
double exchRate = 0.0; errCode = "VTFRVAL";
NodeList parentNodeList = null; errList.add(errCode);
NodeList childNodeList = null; errFields.add(childNodeName.toLowerCase());
Node parentNode = null; }
Node childNode = null; if(toBlank)
Connection conn = null; {
PreparedStatement pstmt = null; errCode = "VTTOVAL";
ResultSet rs = null ; errList.add(errCode);
GenericUtility genericUtility = GenericUtility.getInstance(); errFields.add(childNodeName.toLowerCase());
ConnDriver connDriver = new ConnDriver(); }
try }
{
conn = connDriver.getConnectDB("DriverITM"); }
conn.setAutoCommit(false); break;
connDriver = null; }
if(objContext != null && objContext.trim().length() > 0) int errListSize = errList.size();
{ count = 0;
currentFormNo = Integer.parseInt(objContext); String errFldName = null;
} if(errList != null && errListSize > 0)
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>"); {
valueXmlString.append(editFlag).append("</editFlag> </header>"); for(count = 0; count < errListSize; count ++)
switch(currentFormNo) {
{ errCode = errList.get(count);
case 1 : errFldName = errFields.get(count);
parentNodeList = dom.getElementsByTagName("Detail1"); System.out.println("errCode .........." + errCode);
parentNode = parentNodeList.item(0); errString = getErrorString(errFldName, errCode, userId);
childNodeList = parentNode.getChildNodes(); errorType = errorType(conn , errCode);
valueXmlString.append("<Detail1>"); if(errString.length() > 0)
childNodeListLength = childNodeList.getLength(); {
do String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
{ bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
childNode = childNodeList.item(ctr); errStringXml.append(bifurErrString);
childNodeName = childNode.getNodeName(); errString = "";
ctr ++; }
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn)); if(errorType.equalsIgnoreCase("E"))
{
if(currentColumn.trim().equalsIgnoreCase("stan_code__fr")) break;
{ }
stanCodeFr = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); }
System.out.println("stanCodeFr = "+stanCodeFr); errList.clear();
sql = "Select descr from station where stan_code = ?"; errList = null;
pstmt = conn.prepareStatement(sql); errFields.clear();
pstmt.setString(1,stanCodeFr); errFields = null;
rs = pstmt.executeQuery(); errStringXml.append("</Errors> </Root> \r\n");
if(rs.next()) }
{ else
descr = rs.getString(1); {
} errStringXml = new StringBuffer("");
rs.close(); }
rs = null; }//end try
pstmt.close(); catch(Exception e)
pstmt = null; {
valueXmlString.append("<station_descr>").append("<![CDATA[" + descr +"]]>").append("</station_descr>"); e.printStackTrace();
} errString = e.getMessage();
else if(currentColumn.trim().equalsIgnoreCase("stan_code__to")) throw new ITMException(e);
{ }
stanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); finally
sql = "Select descr from station where stan_code = ?"; {
pstmt = conn.prepareStatement(sql); try
pstmt.setString(1,stanCodeTo); {
rs = pstmt.executeQuery(); if(conn != null)
if(rs.next()) {
{ if(rs != null)
descr = rs.getString(1); {
} rs.close();
rs.close(); rs = null;
rs = null; }
pstmt.close(); if(pstmt != null)
pstmt = null; {
valueXmlString.append("<station_descr_1>").append("<![CDATA[" + descr +"]]>").append("</station_descr_1>"); pstmt.close();
} pstmt = null;
else if(currentColumn.trim().equalsIgnoreCase("curr_code")) }
{ conn.close();
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom)); }
sql = "Select descr from currency where curr_code = ?"; conn = null;
pstmt = conn.prepareStatement(sql); }
pstmt.setString(1,currCode); catch(Exception d)
rs = pstmt.executeQuery(); {
if(rs.next()) d.printStackTrace();
{ throw new ITMException(d);
descr = rs.getString(1); }
} }
rs.close(); errString = errStringXml.toString();
rs = null; return errString;
pstmt.close(); }
pstmt = null;
valueXmlString.append("<currency_descr>").append("<![CDATA[" + descr +"]]>").append("</currency_descr>"); public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
} {
else if(currentColumn.trim().equalsIgnoreCase("cust_code")) Document dom = null;
{ Document dom1 = null;
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom)); Document dom2 = null;
if(custCode != null && custCode.trim().length() > 0) String valueXmlString = "";
{ try
sql = "select cust_name from customer where cust_code = ? "; {
pstmt = conn.prepareStatement(sql); if(xmlString != null && xmlString.trim().length() > 0)
pstmt.setString(1,custCode); {
rs = pstmt.executeQuery(); dom = parseString(xmlString);
if(rs.next()) }
{ if(xmlString1 != null && xmlString1.trim().length() > 0)
descr = rs.getString(1); {
} dom1 = parseString(xmlString1);
rs.close(); }
rs = null; if(xmlString2 != null && xmlString2.trim().length() > 0)
pstmt.close(); {
pstmt = null; dom2 = parseString(xmlString2);
} }
valueXmlString.append("<cust_name>").append("<![CDATA[" + descr +"]]>").append("</cust_name>"); valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} }
valueXmlString.append("</Detail1>"); catch(Exception e)
break; {
case 2 : System.out.println("Exception : [DistributionRoute][itemChanged( String, String )] :==>\n" + e.getMessage());
parentNodeList = dom.getElementsByTagName("Detail2"); }
parentNode = parentNodeList.item(0); return valueXmlString;
childNodeList = parentNode.getChildNodes(); }
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength(); public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
do {
{ String stanCodeFr = "";
childNode = childNodeList.item(ctr); String stanCodeTo = "";
childNodeName = childNode.getNodeName(); String stateCodeTo = "";
ctr ++; String stateCodeFr = "";
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn)); String currCode = "";
String custCode = "";
if(currentColumn.trim().equalsIgnoreCase("itm_default")) String descr = "";
{ String distRoute = "";
System.out.println("itm dedault called........"); String tranCode = "";
distRoute = checkNull(genericUtility.getColumnValue("dist_route", dom1)); String stateDescr = "";
System.out.println("693 distRoute = "+distRoute); String childNodeName = null;
valueXmlString.append("<dist_route protect = \"1\">").append("<![CDATA[" + distRoute +"]]>").append("</dist_route>"); String sql = "";
String pinCodeTo = "";
stateCodeFr = checkNull(genericUtility.getColumnValue("state_code__fr", dom)); String pinCodeFrom = "";
stanCodeFr = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); StringBuffer valueXmlString = new StringBuffer();
stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom)); int ctr = 0;
stanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); int lineNo = 0;
pinCodeTo = checkNull(genericUtility.getColumnValue("pin__to", dom)); int currentFormNo = 0;
pinCodeFrom = checkNull(genericUtility.getColumnValue("pin__fr", dom)); int childNodeListLength = 0;
if(stateCodeFr.trim().length() == 0) double exchRate = 0.0;
{ NodeList parentNodeList = null;
valueXmlString.append("<state_code__fr>").append("<![CDATA[ ]]>").append("</state_code__fr>"); NodeList childNodeList = null;
} Node parentNode = null;
if(stateCodeTo.trim().length() == 0) Node childNode = null;
{ Connection conn = null;
valueXmlString.append("<state_code__to>").append("<![CDATA[ ]]>").append("</state_code__to>"); PreparedStatement pstmt = null;
} ResultSet rs = null ;
if(stanCodeFr.trim().length() == 0) GenericUtility genericUtility = GenericUtility.getInstance();
{ ConnDriver connDriver = new ConnDriver();
valueXmlString.append("<stan_code__fr>").append("<![CDATA[ ]]>").append("</stan_code__fr>"); try
} {
if(stanCodeTo.trim().length() == 0) conn = connDriver.getConnectDB("DriverITM");
{ conn.setAutoCommit(false);
valueXmlString.append("<stan_code__to>").append("<![CDATA[ ]]>").append("</stan_code__to>"); connDriver = null;
} if(objContext != null && objContext.trim().length() > 0)
if(pinCodeTo.trim().length() == 0) {
{ currentFormNo = Integer.parseInt(objContext);
valueXmlString.append("<pin__to>").append("<![CDATA[ ]]>").append("</pin__to>"); }
} valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
if(pinCodeFrom.trim().length() == 0) valueXmlString.append(editFlag).append("</editFlag> </header>");
{ switch(currentFormNo)
valueXmlString.append("<pin__fr>").append("<![CDATA[ ]]>").append("</pin__fr>"); {
} case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
} parentNode = parentNodeList.item(0);
else if(currentColumn.trim().equalsIgnoreCase("stan_code__fr")) childNodeList = parentNode.getChildNodes();
{ valueXmlString.append("<Detail1>");
stanCodeFr = checkNull(genericUtility.getColumnValue("stan_code__fr", dom)); childNodeListLength = childNodeList.getLength();
stateCodeFr = ""; do
stateDescr = ""; {
descr = ""; childNode = childNodeList.item(ctr);
if(stanCodeFr != null && stanCodeFr.trim().length() > 0) childNodeName = childNode.getNodeName();
{ ctr ++;
sql = "Select descr,state_code from station where stan_code = ?"; }while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,stanCodeFr); if(currentColumn.trim().equalsIgnoreCase("stan_code__fr"))
rs = pstmt.executeQuery(); {
if(rs.next()) stanCodeFr = checkNull(genericUtility.getColumnValue("stan_code__fr", dom));
{ System.out.println("stanCodeFr = "+stanCodeFr);
descr = checkNull(rs.getString("descr")); sql = "Select descr from station where stan_code = ?";
stateCodeFr = checkNull(rs.getString("state_code")); pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,stanCodeFr);
rs.close(); rs = pstmt.executeQuery();
rs = null; if(rs.next())
pstmt.close(); {
pstmt = null; descr = rs.getString(1);
if(stateCodeFr != null && stateCodeFr.trim().length() > 0) }
{ rs.close();
sql = "select descr from state where state_code = ?"; rs = null;
pstmt = conn.prepareStatement(sql); pstmt.close();
pstmt.setString(1,stateCodeFr); pstmt = null;
rs = pstmt.executeQuery(); valueXmlString.append("<station_descr>").append("<![CDATA[" + descr +"]]>").append("</station_descr>");
if(rs.next()) }
{ else if(currentColumn.trim().equalsIgnoreCase("stan_code__to"))
stateDescr = rs.getString(1); {
} stanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom));
rs.close(); sql = "Select descr from station where stan_code = ?";
rs = null; pstmt = conn.prepareStatement(sql);
pstmt.close(); pstmt.setString(1,stanCodeTo);
pstmt = null; rs = pstmt.executeQuery();
} if(rs.next())
} {
valueXmlString.append("<state_code__fr>").append("<![CDATA[" + stateCodeFr +"]]>").append("</state_code__fr>"); descr = rs.getString(1);
valueXmlString.append("<descr_1>").append("<![CDATA[" + stateDescr +"]]>").append("</descr_1>"); }
valueXmlString.append("<stationa_descr>").append("<![CDATA[" + descr +"]]>").append("</stationa_descr>"); rs.close();
rs = null;
if(stateCodeFr.trim().length() == 0) pstmt.close();
{ pstmt = null;
valueXmlString.append("<state_code__fr>").append("<![CDATA[ ]]>").append("</state_code__fr>"); valueXmlString.append("<station_descr_1>").append("<![CDATA[" + descr +"]]>").append("</station_descr_1>");
} }
if(stanCodeFr.trim().length() == 0) else if(currentColumn.trim().equalsIgnoreCase("curr_code"))
{ {
valueXmlString.append("<stan_code__fr>").append("<![CDATA[ ]]>").append("</stan_code__fr>"); currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
} sql = "Select descr from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,currCode);
else if(currentColumn.trim().equalsIgnoreCase("stan_code__to")) rs = pstmt.executeQuery();
{ if(rs.next())
stanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom)); {
stateCodeTo = ""; descr = rs.getString(1);
descr = ""; }
stateDescr = ""; rs.close();
if(stanCodeTo != null && stanCodeTo.trim().length() > 0) rs = null;
{ pstmt.close();
sql = "Select descr,state_code from station where stan_code = ?"; pstmt = null;
pstmt = conn.prepareStatement(sql); valueXmlString.append("<currency_descr>").append("<![CDATA[" + descr +"]]>").append("</currency_descr>");
pstmt.setString(1,stanCodeTo); }
rs = pstmt.executeQuery(); else if(currentColumn.trim().equalsIgnoreCase("cust_code"))
if(rs.next()) {
{ custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
descr = checkNull(rs.getString("descr")); if(custCode != null && custCode.trim().length() > 0)
stateCodeTo = checkNull(rs.getString("state_code")); {
} sql = "select cust_name from customer where cust_code = ? ";
rs.close(); pstmt = conn.prepareStatement(sql);
rs = null; pstmt.setString(1,custCode);
pstmt.close(); rs = pstmt.executeQuery();
pstmt = null; if(rs.next())
if(stateCodeTo != null && stateCodeTo.trim().length() > 0) {
{ descr = rs.getString(1);
sql = "select descr from state where state_code = ?"; }
pstmt = conn.prepareStatement(sql); rs.close();
pstmt.setString(1,stateCodeTo); rs = null;
rs = pstmt.executeQuery(); pstmt.close();
if(rs.next()) pstmt = null;
{ }
stateDescr = rs.getString(1); valueXmlString.append("<cust_name>").append("<![CDATA[" + descr +"]]>").append("</cust_name>");
} }
rs.close(); valueXmlString.append("</Detail1>");
rs = null; break;
pstmt.close(); case 2 :
pstmt = null; parentNodeList = dom.getElementsByTagName("Detail2");
} parentNode = parentNodeList.item(0);
} childNodeList = parentNode.getChildNodes();
valueXmlString.append("<state_code__to>").append("<![CDATA[" + stateCodeTo +"]]>").append("</state_code__to>"); valueXmlString.append("<Detail2>");
valueXmlString.append("<station_descr_1>").append("<![CDATA[" + descr +"]]>").append("</station_descr_1>"); childNodeListLength = childNodeList.getLength();
valueXmlString.append("<descr>").append("<![CDATA[" + stateDescr +"]]>").append("</descr>"); do
{
if(stanCodeTo.trim().length() == 0) childNode = childNodeList.item(ctr);
{ childNodeName = childNode.getNodeName();
valueXmlString.append("<stan_code__to>").append("<![CDATA[ ]]>").append("</stan_code__to>"); ctr ++;
} }while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(stateCodeTo.trim().length() == 0)
{ if(currentColumn.trim().equalsIgnoreCase("itm_default"))
valueXmlString.append("<state_code__to>").append("<![CDATA[ ]]>").append("</state_code__to>"); {
} System.out.println("itm dedault called........");
} distRoute = checkNull(genericUtility.getColumnValue("dist_route", dom1));
else if(currentColumn.trim().equalsIgnoreCase("tran_code")) System.out.println("693 distRoute = "+distRoute);
{ valueXmlString.append("<dist_route protect = \"1\">").append("<![CDATA[" + distRoute +"]]>").append("</dist_route>");
tranCode = checkNull(genericUtility.getColumnValue("tran_code", dom));
sql = "Select tran_name from transporter where tran_code = ?"; stateCodeFr = checkNull(genericUtility.getColumnValue("state_code__fr", dom));
pstmt = conn.prepareStatement(sql); stanCodeFr = checkNull(genericUtility.getColumnValue("stan_code__fr", dom));
pstmt.setString(1,tranCode); stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom));
rs = pstmt.executeQuery(); stanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom));
if(rs.next()) pinCodeTo = checkNull(genericUtility.getColumnValue("pin__to", dom));
{ pinCodeFrom = checkNull(genericUtility.getColumnValue("pin__fr", dom));
descr = rs.getString(1); if(stateCodeFr.trim().length() == 0)
} {
rs.close(); valueXmlString.append("<state_code__fr>").append("<![CDATA[ ]]>").append("</state_code__fr>");
rs = null; }
pstmt.close(); if(stateCodeTo.trim().length() == 0)
pstmt = null; {
valueXmlString.append("<transporter_tran_name>").append("<![CDATA[" + descr +"]]>").append("</transporter_tran_name>"); valueXmlString.append("<state_code__to>").append("<![CDATA[ ]]>").append("</state_code__to>");
} }
else if(currentColumn.trim().equalsIgnoreCase("curr_code")) if(stanCodeFr.trim().length() == 0)
{ {
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom)); valueXmlString.append("<stan_code__fr>").append("<![CDATA[ ]]>").append("</stan_code__fr>");
sql = "select descr,std_exrt from currency where curr_code = ?"; }
pstmt = conn.prepareStatement(sql); if(stanCodeTo.trim().length() == 0)
pstmt.setString(1,currCode); {
rs = pstmt.executeQuery(); valueXmlString.append("<stan_code__to>").append("<![CDATA[ ]]>").append("</stan_code__to>");
if(rs.next()) }
{ if(pinCodeTo.trim().length() == 0)
descr = rs.getString("descr")== null ? "":rs.getString("descr"); {
exchRate = rs.getDouble("std_exrt"); valueXmlString.append("<pin__to>").append("<![CDATA[ ]]>").append("</pin__to>");
} }
rs.close(); if(pinCodeFrom.trim().length() == 0)
rs = null; {
pstmt.close(); valueXmlString.append("<pin__fr>").append("<![CDATA[ ]]>").append("</pin__fr>");
pstmt = null; }
valueXmlString.append("<currency_descr>").append("<![CDATA[" + descr +"]]>").append("</currency_descr>");
valueXmlString.append("<exch_rate>").append("<![CDATA[" + exchRate +"]]>").append("</exch_rate>"); }
} else if(currentColumn.trim().equalsIgnoreCase("stan_code__fr"))
else if(currentColumn.trim().equalsIgnoreCase("state_code__to")) {
{ stanCodeFr = checkNull(genericUtility.getColumnValue("stan_code__fr", dom));
stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom)); stateCodeFr = "";
stateDescr = "";
if(stateCodeTo != null && stateCodeTo.trim().length() > 0) descr = "";
{ if(stanCodeFr != null && stanCodeFr.trim().length() > 0)
sql = "select descr from state where state_code = ?"; {
pstmt = conn.prepareStatement(sql); sql = "Select descr,state_code from station where stan_code = ?";
pstmt.setString(1,stateCodeTo); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); pstmt.setString(1,stanCodeFr);
if(rs.next()) rs = pstmt.executeQuery();
{ if(rs.next())
descr = rs.getString(1); {
} descr = checkNull(rs.getString("descr"));
rs.close(); stateCodeFr = checkNull(rs.getString("state_code"));
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
} pstmt.close();
valueXmlString.append("<descr>").append("<![CDATA[" + descr +"]]>").append("</descr>"); pstmt = null;
if(stateCodeTo.trim().length() == 0) if(stateCodeFr != null && stateCodeFr.trim().length() > 0)
{ {
valueXmlString.append("<state_code__to>").append("<![CDATA[ ]]>").append("</state_code__to>"); sql = "select descr from state where state_code = ?";
} pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,stateCodeFr);
else if(currentColumn.trim().equalsIgnoreCase("state_code__fr")) rs = pstmt.executeQuery();
{ if(rs.next())
stateCodeFr = checkNull(genericUtility.getColumnValue("state_code__fr", dom)); {
if(stateCodeFr != null && stateCodeFr.trim().length() > 0) stateDescr = rs.getString(1);
{ }
sql = "select descr from state where state_code = ?"; rs.close();
pstmt = conn.prepareStatement(sql); rs = null;
pstmt.setString(1,stateCodeFr); pstmt.close();
rs = pstmt.executeQuery(); pstmt = null;
if(rs.next()) }
{ }
descr = rs.getString(1); valueXmlString.append("<state_code__fr>").append("<![CDATA[" + stateCodeFr +"]]>").append("</state_code__fr>");
} valueXmlString.append("<descr_1>").append("<![CDATA[" + stateDescr +"]]>").append("</descr_1>");
rs.close(); valueXmlString.append("<stationa_descr>").append("<![CDATA[" + descr +"]]>").append("</stationa_descr>");
rs = null;
pstmt.close(); if(stateCodeFr.trim().length() == 0)
pstmt = null; {
} valueXmlString.append("<state_code__fr>").append("<![CDATA[ ]]>").append("</state_code__fr>");
valueXmlString.append("<descr_1>").append("<![CDATA[" + descr +"]]>").append("</descr_1>"); }
if(stateCodeFr.trim().length() == 0) if(stanCodeFr.trim().length() == 0)
{ {
valueXmlString.append("<state_code__fr>").append("<![CDATA[ ]]>").append("</state_code__fr>"); valueXmlString.append("<stan_code__fr>").append("<![CDATA[ ]]>").append("</stan_code__fr>");
} }
}
}
valueXmlString.append("</Detail2>"); else if(currentColumn.trim().equalsIgnoreCase("stan_code__to"))
break; {
} stanCodeTo = checkNull(genericUtility.getColumnValue("stan_code__to", dom));
valueXmlString.append("</Root>"); stateCodeTo = "";
} descr = "";
catch(Exception e) stateDescr = "";
{ if(stanCodeTo != null && stanCodeTo.trim().length() > 0)
e.printStackTrace(); {
System.out.println("Exception ::"+ e.getMessage()); sql = "Select descr,state_code from station where stan_code = ?";
throw new ITMException(e); pstmt = conn.prepareStatement(sql);
} pstmt.setString(1,stanCodeTo);
finally rs = pstmt.executeQuery();
{ if(rs.next())
try {
{ descr = checkNull(rs.getString("descr"));
if(conn != null) stateCodeTo = checkNull(rs.getString("state_code"));
{ }
if(rs != null) rs.close();
{ rs = null;
rs.close(); pstmt.close();
rs = null; pstmt = null;
} if(stateCodeTo != null && stateCodeTo.trim().length() > 0)
if(pstmt != null) {
{ sql = "select descr from state where state_code = ?";
pstmt.close(); pstmt = conn.prepareStatement(sql);
pstmt = null; pstmt.setString(1,stateCodeTo);
rs = pstmt.executeQuery();
} if(rs.next())
conn.close(); {
} stateDescr = rs.getString(1);
conn = null; }
} rs.close();
catch(Exception d) rs = null;
{ pstmt.close();
d.printStackTrace(); pstmt = null;
} }
} }
return valueXmlString.toString(); valueXmlString.append("<state_code__to>").append("<![CDATA[" + stateCodeTo +"]]>").append("</state_code__to>");
} valueXmlString.append("<station_descr_1>").append("<![CDATA[" + descr +"]]>").append("</station_descr_1>");
private String checkNull(String input) valueXmlString.append("<descr>").append("<![CDATA[" + stateDescr +"]]>").append("</descr>");
{
if(input == null) if(stanCodeTo.trim().length() == 0)
{ {
input = ""; valueXmlString.append("<stan_code__to>").append("<![CDATA[ ]]>").append("</stan_code__to>");
} }
return input; if(stateCodeTo.trim().length() == 0)
} {
valueXmlString.append("<state_code__to>").append("<![CDATA[ ]]>").append("</state_code__to>");
private String errorType(Connection conn , String errorCode) }
{ }
String msgType = ""; else if(currentColumn.trim().equalsIgnoreCase("tran_code"))
PreparedStatement pstmt = null ; {
ResultSet rs = null; tranCode = checkNull(genericUtility.getColumnValue("tran_code", dom));
try sql = "Select tran_name from transporter where tran_code = ?";
{ pstmt = conn.prepareStatement(sql);
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; pstmt.setString(1,tranCode);
pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery();
pstmt.setString(1,errorCode); if(rs.next())
rs = pstmt.executeQuery(); {
while(rs.next()) descr = rs.getString(1);
{ }
msgType = rs.getString("MSG_TYPE"); rs.close();
} rs = null;
} pstmt.close();
catch(Exception ex) pstmt = null;
{ valueXmlString.append("<tran_name>").append(descr).append("</tran_name>");
ex.printStackTrace(); //valueXmlString.append("<tran_name>").append("<![CDATA[" + descr +"]]>").append("</tran_name>");
} }
finally else if(currentColumn.trim().equalsIgnoreCase("curr_code"))
{ {
try currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
{ sql = "select descr,std_exrt from currency where curr_code = ?";
if(rs != null) pstmt = conn.prepareStatement(sql);
{ pstmt.setString(1,currCode);
rs.close(); rs = pstmt.executeQuery();
rs = null; if(rs.next())
} {
if(pstmt != null) descr = rs.getString("descr")== null ? "":rs.getString("descr");
{ exchRate = rs.getDouble("std_exrt");
pstmt.close(); }
pstmt = null; rs.close();
} rs = null;
} pstmt.close();
catch(Exception e) pstmt = null;
{ valueXmlString.append("<currency_descr>").append("<![CDATA[" + descr +"]]>").append("</currency_descr>");
e.printStackTrace(); valueXmlString.append("<exch_rate>").append("<![CDATA[" + exchRate +"]]>").append("</exch_rate>");
} }
} else if(currentColumn.trim().equalsIgnoreCase("state_code__to"))
return msgType; {
} stateCodeTo = checkNull(genericUtility.getColumnValue("state_code__to", dom));
}
if(stateCodeTo != null && stateCodeTo.trim().length() > 0)
{
sql = "select descr from state where state_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,stateCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
valueXmlString.append("<descr>").append("<![CDATA[" + descr +"]]>").append("</descr>");
if(stateCodeTo.trim().length() == 0)
{
valueXmlString.append("<state_code__to>").append("<![CDATA[ ]]>").append("</state_code__to>");
}
}
else if(currentColumn.trim().equalsIgnoreCase("state_code__fr"))
{
stateCodeFr = checkNull(genericUtility.getColumnValue("state_code__fr", dom));
if(stateCodeFr != null && stateCodeFr.trim().length() > 0)
{
sql = "select descr from state where state_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,stateCodeFr);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
valueXmlString.append("<descr_1>").append("<![CDATA[" + descr +"]]>").append("</descr_1>");
if(stateCodeFr.trim().length() == 0)
{
valueXmlString.append("<state_code__fr>").append("<![CDATA[ ]]>").append("</state_code__fr>");
}
}
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
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);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}
}
\ No newline at end of file
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