Commit e121b267 authored by vkadam's avatar vkadam

Change in validation.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96753 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4a85ed6e
...@@ -27,47 +27,53 @@ import org.w3c.dom.Node; ...@@ -27,47 +27,53 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@Stateless @Stateless
public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryICRemote { public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryICRemote
{
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
String winName = null; String winName = null;
FinCommon finCommon = null; FinCommon finCommon = null;
ValidatorEJB validator = null; ValidatorEJB validator = null;
public String wfValData(String xmlString, String xmlString1,String xmlString2, public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
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("<Root>" + xmlString2 + "</Root>"); dom2 = parseString("<Root>" + xmlString2 + "</Root>");
} }
errString = wfValData(dom, dom1, dom2, objContext, editFlag,xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} catch (Exception e) { } catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
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, public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
String xtraParams)throws RemoteException, ITMException { {
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String childNodeName = null; String childNodeName = null;
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
String userId = "",sql = "",errCode = "",errorType = "",errString = "",tranId = "",blankVar=""; String userId = "", sql = "", errCode = "", errorType = "", errString = "", tranId = "", blankVar = "";
String countCode="",keyFlag="",descr="",currCode="",transCode="",regCode="",validUpto="",regDate=""; String countCode = "", keyFlag = "", descr = "", currCode = "", transCode = "", regCode = "", validUpto = "", regDate = "";
int ctr = 0,currentFormNo = 0,cnt = 0,cnt1=0; int ctr = 0, currentFormNo = 0, cnt = 0, cnt1 = 0;
ArrayList errList = new ArrayList(); ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList(); ArrayList errFields = new ArrayList();
Connection conn = null; Connection conn = null;
...@@ -75,17 +81,20 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -75,17 +81,20 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
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
{
this.finCommon = new FinCommon(); this.finCommon = new FinCommon();
this.validator = new ValidatorEJB(); this.validator = new ValidatorEJB();
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);
} }
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>"); 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);
...@@ -93,17 +102,20 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -93,17 +102,20 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength(); int childNodeListLength = childNodeList.getLength();
tranId = checkNull(this.genericUtility.getColumnValue("tran_id", dom)); tranId = checkNull(this.genericUtility.getColumnValue("tran_id", dom));
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();
System.out.println("CURRENT COLUMN IN VALIDATION ["+ childNodeName + "]"); System.out.println("CURRENT COLUMN IN VALIDATION [" + childNodeName + "]");
if (childNodeName.equalsIgnoreCase("count_code")) { if (childNodeName.equalsIgnoreCase("count_code"))
{
countCode = this.genericUtility.getColumnValue("count_code", dom); countCode = this.genericUtility.getColumnValue("count_code", dom);
sql = "select key_flag from transetup where tran_window = 'w_country'"; sql = "select key_flag from transetup where tran_window = 'w_country'";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
keyFlag = rs.getString("key_flag"); keyFlag = rs.getString("key_flag");
} }
rs.close(); rs.close();
...@@ -111,20 +123,24 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -111,20 +123,24 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(keyFlag==null){ if (keyFlag == null)
keyFlag="M"; {
keyFlag = "M";
} }
if(keyFlag.equalsIgnoreCase("M") && (countCode==null || countCode.trim().length()<=0)){ if (keyFlag.equalsIgnoreCase("M") && (countCode == null || countCode.trim().length() <= 0))
{
errCode = "VMCODNULL"; errCode = "VMCODNULL";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
}else if(editFlag.equalsIgnoreCase("A")){ } else if (editFlag.equalsIgnoreCase("A"))
cnt=0; {
cnt = 0;
sql = "select count(*) as cnt from country where count_code =?"; sql = "select count(*) as cnt from country where count_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, countCode); pstmt.setString(1, countCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
...@@ -132,81 +148,94 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -132,81 +148,94 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt>0){ if (cnt > 0)
{
errCode = "VMDUPL1"; errCode = "VMDUPL1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
}else if(childNodeName.equalsIgnoreCase("descr")){ } else if (childNodeName.equalsIgnoreCase("descr"))
{
descr = this.genericUtility.getColumnValue("descr", dom); descr = this.genericUtility.getColumnValue("descr", dom);
if(descr==null || descr.trim().length()<=0){ if (descr == null || descr.trim().length() <= 0)
{
errCode = "VMDESCR"; errCode = "VMDESCR";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
}else{ } else
{
countCode = this.genericUtility.getColumnValue("count_code", dom); countCode = this.genericUtility.getColumnValue("count_code", dom);
cnt=0; cnt = 0;
sql = "select count(1) as cnt from country where count_code !=? and descr =?"; sql = "select count(1) as cnt from country where count_code !=? and descr =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, countCode); pstmt.setString(1, countCode);
pstmt.setString(2, descr); pstmt.setString(2, descr);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt>0){ if (cnt > 0)
{
errCode = "VMDUPDESCR"; errCode = "VMDUPDESCR";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
}else if(childNodeName.equalsIgnoreCase("curr_code")){ } else if (childNodeName.equalsIgnoreCase("curr_code"))
{
currCode = this.genericUtility.getColumnValue("curr_code", dom); currCode = this.genericUtility.getColumnValue("curr_code", dom);
cnt=0; cnt = 0;
sql = "select count(*) as cnt from currency where curr_code =?"; sql = "select count(*) as cnt from currency where curr_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode); pstmt.setString(1, currCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt==0){ if (cnt == 0)
{
errCode = "VMCUR1"; errCode = "VMCUR1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else if(childNodeName.equalsIgnoreCase("trans_code")){ } else if (childNodeName.equalsIgnoreCase("trans_code"))
{
transCode = this.genericUtility.getColumnValue("trans_code", dom); transCode = this.genericUtility.getColumnValue("trans_code", dom);
if(transCode!=null){ if (transCode != null)
cnt=0; {
cnt = 0;
sql = "select count(*) as cnt from transporter where tran_code =?"; sql = "select count(*) as cnt from transporter where tran_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, transCode); pstmt.setString(1, transCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt==0){ if (cnt == 0)
{
errCode = "VMTRAN1"; errCode = "VMTRAN1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
...@@ -222,65 +251,72 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -222,65 +251,72 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>"); valueXmlString.append("<Detail2>");
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("reg_code")) { if (childNodeName.trim().equalsIgnoreCase("reg_code"))
{
regCode = this.genericUtility.getColumnValue("reg_code", dom); regCode = this.genericUtility.getColumnValue("reg_code", dom);
if(regCode!=null){ if (regCode != null)
cnt=0; {
cnt = 0;
sql = "select count(*) as cnt from reg_requirements where reg_code=?"; sql = "select count(*) as cnt from reg_requirements where reg_code=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, regCode); pstmt.setString(1, regCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt==0){ if (cnt == 0)
{
errCode = "VTRCODEXT"; errCode = "VTRCODEXT";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else { } else
{
errCode = "VTRCODNULL"; errCode = "VTRCODNULL";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} else if(childNodeName.trim().equalsIgnoreCase("reg_date")){ } else if (childNodeName.trim().equalsIgnoreCase("reg_date"))
{
regDate = this.genericUtility.getColumnValue("reg_date", dom); regDate = this.genericUtility.getColumnValue("reg_date", dom);
if(regDate==null || regDate.trim().length()<=0){
if (regDate == null)
{
errCode = "VTREGNULL"; errCode = "VTREGNULL";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} } else if (childNodeName.trim().equalsIgnoreCase("valid_upto"))
else if(childNodeName.trim().equalsIgnoreCase("valid_upto")){ {
validUpto = this.genericUtility.getColumnValue("valid_upto", dom); validUpto = this.genericUtility.getColumnValue("valid_upto", dom);
regDate = this.genericUtility.getColumnValue("reg_date", dom); regDate = this.genericUtility.getColumnValue("reg_date", dom);
if(validUpto==null){
errCode = "VTVALNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}else if (regDate != null)
{
Timestamp validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(validUpto, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
Timestamp regDateNew = Timestamp.valueOf(genericUtility.getValidDateString(regDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(validUpto!=null){ if (validUptoDate.compareTo(regDateNew) <= 0)
Timestamp validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(validUpto,
genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
Timestamp regDateNew = Timestamp.valueOf(genericUtility.getValidDateString(regDate,
genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(validUptoDate.compareTo(regDateNew)<=0)
{ {
errCode = "VTVALREGDT"; errCode = "VTVALREGDT";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else{ }
errCode = "VTVALNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} }
} }
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
...@@ -288,45 +324,57 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -288,45 +324,57 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
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 = (String) errList.get(cnt); errCode = (String) errList.get(cnt);
errFldName = (String) errFields.get(cnt); errFldName = (String) errFields.get(cnt);
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>")); {
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); errStringXml.append(bifurErrString);
errString = ""; errString = "";
} }
if (errorType.equalsIgnoreCase("E")) { if (errorType.equalsIgnoreCase("E"))
{
break; break;
} }
} }
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 { {
if (conn != null) { try
if (rs != null) { {
if (conn != 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;
} }
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);
} }
...@@ -335,40 +383,43 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -335,40 +383,43 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
return errString; return errString;
} }
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException { {
Document dom = null,dom1 = null,dom2 = null; Document dom = null, dom1 = null, dom2 = null;
String valueXmlString = ""; String valueXmlString = "";
try { try
{
dom = parseString(xmlString); dom = parseString(xmlString);
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0) { if (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);
System.out.println("valueXmlString[" + valueXmlString + "]"); System.out.println("valueXmlString[" + valueXmlString + "]");
} 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());
throw new ITMException(e); throw new ITMException(e);
} }
return valueXmlString; return valueXmlString;
} }
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
String editFlag,String xtraParams) throws RemoteException, ITMException { {
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String childNodeName = null; String childNodeName = null;
String sql = "",sql1 = "",sql2 = ""; String sql = "", sql1 = "", sql2 = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null,pstmt1=null,pstmt2=null; PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ResultSet rs = null,rs1=null,rs2=null; ResultSet rs = null, rs1 = null, rs2 = null;
String currCode="",currCodeDesr="",regCode="",regDescr=""; String currCode = "", currCodeDesr = "", regCode = "", regDescr = "";
int ctr = 0,currentFormNo = 0,childNodeListLength = 0; int ctr = 0, currentFormNo = 0, childNodeListLength = 0;
java.util.Date reqDate = null,statusDate = null; java.util.Date reqDate = null, statusDate = null;
ArrayList errList = new ArrayList(); ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList(); ArrayList errFields = new ArrayList();
SimpleDateFormat sdf; SimpleDateFormat sdf;
...@@ -376,50 +427,57 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -376,50 +427,57 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
try { try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
this.finCommon = new FinCommon(); this.finCommon = new FinCommon();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if ((objContext != null) && (objContext.trim().length() > 0)) { if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>"); 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();
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
do { do
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn)) { if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild(); childNode.getFirstChild();
} }
ctr++; ctr++;
} while ((ctr < childNodeListLength)&& (!childNodeName.equals(currentColumn))); } while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println("CURRENT COLUMN [" + currentColumn + "]"); System.out.println("CURRENT COLUMN [" + currentColumn + "]");
if (currentColumn.trim().equalsIgnoreCase("curr_code")) { if (currentColumn.trim().equalsIgnoreCase("curr_code"))
{
currCode = checkNull(this.genericUtility.getColumnValue("curr_code", dom)); currCode = checkNull(this.genericUtility.getColumnValue("curr_code", dom));
sql = "Select descr from currency where curr_code =?"; sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode); pstmt.setString(1, currCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
currCodeDesr = checkNull(rs.getString("descr")); currCodeDesr = checkNull(rs.getString("descr"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
valueXmlString.append("<currency_descr ><![CDATA[" + currCodeDesr + "]]></currency_descr>"); valueXmlString.append("<currency_descr ><![CDATA[" + currCodeDesr + "]]></currency_descr>");
} }
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
...@@ -431,43 +489,51 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -431,43 +489,51 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
valueXmlString.append("<Detail2>"); valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
do { do
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn)) { if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild(); childNode.getFirstChild();
} }
ctr++; ctr++;
} while ((ctr < childNodeListLength)&& (!childNodeName.equals(currentColumn))); } while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println("CURRENT COLUMN [" + currentColumn + "]"); System.out.println("CURRENT COLUMN [" + currentColumn + "]");
if (currentColumn.trim().equalsIgnoreCase("reg_code")) { if (currentColumn.trim().equalsIgnoreCase("reg_code"))
{
regCode = checkNull(this.genericUtility.getColumnValue("reg_code", dom)); regCode = checkNull(this.genericUtility.getColumnValue("reg_code", dom));
sql = "select descr from reg_requirements where reg_code=?"; sql = "select descr from reg_requirements where reg_code=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, regCode); pstmt.setString(1, regCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
regDescr = checkNull(rs.getString("descr")); regDescr = checkNull(rs.getString("descr"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
valueXmlString.append("<descr ><![CDATA[" + regDescr + "]]></descr>"); valueXmlString.append("<descr ><![CDATA[" + regDescr + "]]></descr>");
} }
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
} }
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 { {
if (conn != null) { try
{
if (conn != null)
{
if (pstmt != null) if (pstmt != null)
pstmt.close(); pstmt.close();
if (rs != null) if (rs != null)
...@@ -477,66 +543,88 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC ...@@ -477,66 +543,88 @@ public class CountryIC extends ValidatorEJB implements CountryICLocal, CountryIC
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);
} }
} }
return valueXmlString.toString(); return valueXmlString.toString();
} }
private String checkNull(String str) {
if (str == null) { private String checkNull(String str)
{
if (str == null)
{
return ""; return "";
} else { } else
{
return str; return str;
} }
} }
private double checkDoubleNull(String str) {
if (str == null || str.trim().length() == 0) { private double checkDoubleNull(String str)
{
if (str == null || str.trim().length() == 0)
{
return 0.0; return 0.0;
} else { } else
{
return Double.parseDouble(str); return Double.parseDouble(str);
} }
} }
private String errorType(Connection conn, String errorCode)
throws ITMException { private String errorType(Connection conn, String errorCode) throws ITMException
{
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();
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();
throw new ITMException(e); throw new ITMException(e);
} }
} finally { } finally
try { {
if (rs != null) { try
{
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();
throw new ITMException(e); throw new ITMException(e);
} }
......
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