Commit 4ce2895e authored by pshinde's avatar pshinde

Migration of Transporter


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96498 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5413a087
......@@ -14,6 +14,8 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
......@@ -47,7 +49,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
return(errString);
}
@SuppressWarnings("null")
// @SuppressWarnings("null")
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
......@@ -56,6 +58,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
Node childNode = null;
int ctr = 0;
int childNodeListLength;
int currentFormNo = 0;
String contactCode = "";
String stanCode = "";
String transporterType = "";
......@@ -91,10 +94,30 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
ResultSet rs = null;
ResultSet rs1 = null;
ConnDriver connDriver = new ConnDriver();
String regCode="",descr="", validUpto="",regDate="";
SimpleDateFormat simpleDateFormat1 = null;
java.sql.Timestamp currDate = null;
String currAppdate ="";
Timestamp validDate=null,registerDate=null;
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
simpleDateFormat1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate);
conn = connDriver.getConnectDB("DriverITM");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("Priyanka testing : currentFormNo :"+currentFormNo);
}
switch (currentFormNo)
{
case 1:
System.out.println("Priyanka testing case 1 for validation ");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
......@@ -103,7 +126,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("trancode>>>><<<<NERHRBKFLYSH");
System.out.println("trancode>>>><<<<");
if(childNodeName.equalsIgnoreCase("tran_code"))
{
......@@ -124,19 +147,19 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
if(keyFlag.equalsIgnoreCase("M"))
{
if(!editFlag.equalsIgnoreCase("E"))
{
if(tranCode == null || tranCode.trim().length() == 0 )
{
System.out.println("trancode null validatioon fire");
errCode = "VMCODNULLL";
errCode="VMTRANCD1 ";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
if(keyFlag.equalsIgnoreCase("M") || keyFlag.equalsIgnoreCase("A"))
//if(keyFlag.equalsIgnoreCase("M") || keyFlag.equalsIgnoreCase("A"))
if(editFlag.equals("A"))
{
sql = "select count(*) from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql);
......@@ -165,15 +188,12 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
}
}
else if(childNodeName.equalsIgnoreCase("contact_code")) //done
{
contactCode = genericUtility.getColumnValue("contact_code", dom);
if(contactCode == null || contactCode.trim().length() == 0)
{
errCode = "VMCONTACDD";
errCode = "VTCONTNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
......@@ -207,7 +227,8 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
transporterType = genericUtility.getColumnValue("transporter_type", dom);
if(transporterType == null || transporterType.trim().length() == 0)
{
errCode = "VMTYPECK";
//errCode = "VMTYPECK";
errCode = "VMTYPE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
......@@ -220,18 +241,8 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
tranCode = genericUtility.getColumnValue("tran_code", dom);
System.out.println("<<<<<<+"+groupCode+"+>>>>>>>"+tranCode);
if(groupCode == null || groupCode.trim().length() == 0)
{
System.out.println("enter for null validation group code");
errCode = "VMGRPCD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
/* else
{
if(tranCode != null && tranCode.trim().length() > 0)
if((tranCode != null && tranCode.trim().length() > 0) && (groupCode != null && groupCode.trim().length() >0))
{
if(!(groupCode.equals(tranCode)))
{
......@@ -255,7 +266,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
pstmt = null;
}
}
}*/
}
else if(childNodeName.equalsIgnoreCase("tran_code__pay"))
......@@ -271,6 +282,31 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
//added by priyanka as per pb code
else if((tranCodePay!=null && tranCodePay.trim().length()>0) &&(tranCode!=null && tranCode.trim().length()>0))
{
if(!tranCodePay.equals(tranCode))
{
sql = " select count(*) from transporter where tran_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranCodePay);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VMPAYTO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
......@@ -282,16 +318,6 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
if (sitecodepay != null && sitecodepay.trim().length() > 0 )
{
// System.out.println("site_code null validation fire");
// errCode = "";
// errList.add(errCode);
// errFields.add(childNodeName.toLowerCase());
// break;
//
// }
// else
// {
sql = "select count(1) from site where site_code = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,sitecodepay);
......@@ -312,14 +338,10 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
else if(childNodeName.equalsIgnoreCase("stan_code"))
{
......@@ -328,15 +350,8 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
if(stanCode != null && stanCode.trim().length() > 0 )
{
// System.out.println("STAN CODE BLANK VAL");
// errCode = "";
// errList.add(errCode);
// errFields.add(childNodeName.toLowerCase());
// break;
// }
// else
// {
System.out.println("bvdvg>KL"+stanCode);
System.out.println("stanCode>>>>"+stanCode);
sql = " select count(*) from station where stan_code = ? ";
pstmt = conn.prepareStatement(sql);
......@@ -358,7 +373,6 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
pstmt.close();
pstmt = null;
}
}
......@@ -414,8 +428,6 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
pstmt.close();
pstmt = null;
}
}
......@@ -435,7 +447,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VMCRTERM1";
errCode = "VTCRTERM1 ";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
......@@ -597,8 +609,6 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
}
}
else if(childNodeName.equalsIgnoreCase("cctr_code__fp"))
{
cctrCodeFp = genericUtility.getColumnValue("cctr_code__fp", dom);
......@@ -683,19 +693,110 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
// pstmt = null;
// }
// }
}
//added by priyanka
break;
//case2
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("reg_code"))
{
regCode = genericUtility.getColumnValue("reg_code", dom);
if(regCode==null || regCode.trim().length()==0)
{
errCode = "VTRCODNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql=" select count(*) from reg_requirements where reg_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, regCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt==0)
{
errCode = "VTRCODEXT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if(childNodeName.equalsIgnoreCase("reg_date"))
{
regDate = genericUtility.getColumnValue("reg_date", dom);
validUpto = genericUtility.getColumnValue("valid_upto", dom);
System.out.println(">>>>>>>>>>>regDate===="+regDate);
System.out.println(">>>>>>>>>>>validUpto===="+validUpto);
if(regDate==null || regDate.trim().length()==0)
{
errCode = "VTREGNULL";//entry message error
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if(childNodeName.equalsIgnoreCase("valid_upto"))
{
validUpto = genericUtility.getColumnValue("valid_upto", dom);
regDate = genericUtility.getColumnValue("reg_date", dom);
System.out.println(">>>>>>>>>>>validUpto===="+validUpto);
if(validUpto==null || validUpto.trim().length()==0)
{
errCode = "VTVALNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
if(regDate!=null && regDate.trim().length()>0)
{
registerDate = Timestamp.valueOf(genericUtility.getValidDateString(regDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
validDate = Timestamp.valueOf(genericUtility.getValidDateString(validUpto, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(validDate.equals(registerDate)||validDate.compareTo(registerDate)<0)
{
errCode = "VTVALREGDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
}
int errListSize = errList.size();
cnt = 0;
if(errList != null && errListSize > 0)
......@@ -798,7 +899,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String tranCode = "";
String tranCode = "",regCode="",regDescr="";
String tranCodePay = "";
String groupCode = "";
String tranName = "";
......@@ -811,6 +912,8 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
String currencyDescr = "";
String crTerm = "";
String contPers = "";
String add1="";
String emailadd="";
String addr1 = "";
String addr2 = "";
String addr3 = "";
......@@ -825,26 +928,56 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
String contPfx = "";
String fax = "";
String mail = "";
String tranName1="";
String contactPer="";
String sql1 = "";
String sql2 = "";
int childNodeListLength = 0;
Connection conn = null;
PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
ResultSet rs1 = null ;
ResultSet rs2 = null ;
int currentFormNo = 0;
ConnDriver connDriver = new ConnDriver();
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("Priyanka itemchanged 1 currentFormNo : "+currentFormNo);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1:
System.out.println("Transporter itemchanged case 1");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild();
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
if(currentColumn.trim().equalsIgnoreCase("tran_code"))
{
......@@ -852,45 +985,32 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
tranCodePay = genericUtility.getColumnValue("tran_code__pay", dom);
groupCode = genericUtility.getColumnValue("group_code", dom);
//changes by deepak
if(tranCode != null && tranCode.trim().length()>0)
//changes done by priyanka as per pb code on 26/9/14
if(tranCodePay == null || tranCodePay.trim().length()==0)
{
valueXmlString.append("<tran_code__pay>").append("<![CDATA[" + tranCode + "]]>").append("</tran_code__pay>");
valueXmlString.append("<group_code>").append("<![CDATA[" + tranCode + "]]>").append("</group_code>");
}
else
if(groupCode == null || groupCode.trim().length()==0)
{
valueXmlString.append("<tran_code__pay>").append("<![CDATA[]]>").append("</tran_code__pay>");
valueXmlString.append("<group_code>").append("<![CDATA[]]>").append("</group_code>");
valueXmlString.append("<group_code>").append("<![CDATA[" + tranCode + "]]>").append("</group_code>");
}
//changes by deepak
}
else if(currentColumn.trim().equalsIgnoreCase("tran_name"))
{
tranName = genericUtility.getColumnValue("tran_name", dom);
chqName = genericUtility.getColumnValue("chq_name", dom);
//changes by deepak
if(tranName != null && tranName.trim().length() > 0)
//changes done by priyanka as per pb code on 26/9/14
if(chqName == null || chqName.trim().length() == 0)
{
valueXmlString.append("<chq_name>").append("<![CDATA[" + tranName + "]]>").append("</chq_name>");
}
else
{
valueXmlString.append("<chq_name>").append("<![CDATA[]]>").append("</chq_name>");
}
//changes by deepak
}
else if(currentColumn.trim().equalsIgnoreCase("stan_code"))
{
stanCode = genericUtility.getColumnValue("stan_code", dom);
sql1 = " select state_code from station where stan_code = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, stanCode);
......@@ -927,6 +1047,7 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
pstmt1.close();
pstmt1 = null;
}
else if(currentColumn.trim().equalsIgnoreCase("curr_code"))
{
currCode = genericUtility.getColumnValue("curr_code", dom);
......@@ -951,12 +1072,12 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
valueXmlString.append("<currency_descr>").append("<![CDATA[]]>").append("</currency_descr>");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
else if(currentColumn.trim().equalsIgnoreCase("cr_term"))
{
crTerm = genericUtility.getColumnValue("cr_term", dom);
......@@ -977,16 +1098,18 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
valueXmlString.append("<credit_prd>").append("<![CDATA[]]>").append("</credit_prd>");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
else if(currentColumn.trim().equalsIgnoreCase("contact_code"))
{
contactCode = genericUtility.getColumnValue("contact_code", dom);
//changes by priyanka as per pb code on 29/09/14
if(contactCode != null && contactCode.trim().length() > 0)
{
sql1 = " select name, sh_name, cont_pers, cont_pfx, addr1, addr2, " +
"addr3, city, pin, state_code, count_code, tele1, tele2, tele3, " +
......@@ -997,11 +1120,11 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
if(rs1.next())
{
if(rs1.getString(1) != null)
tranName = rs1.getString(1);
tranName1 = rs1.getString(1);
if(rs1.getString(2) != null)
shName = rs1.getString(2);
if(rs1.getString(3) != null)
contPers = rs1.getString(3);
contactPer = rs1.getString(3);
if(rs1.getString(4) != null)
contPfx = rs1.getString(4);
if(rs1.getString(5) != null)
......@@ -1032,14 +1155,29 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
if(rs1.getString(17) != null)
mail = rs1.getString(17);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(contactCode != null && contactCode.trim().length() > 0)
{
tranName = genericUtility.getColumnValue("tran_name", dom);
valueXmlString.append("<tran_name>").append("<![CDATA[" + tranName + "]]>").append("</tran_name>");
if(tranName==null||tranName.trim().length()==0)
{
valueXmlString.append("<tran_name>").append("<![CDATA[" + tranName1 + "]]>").append("</tran_name>");
valueXmlString.append("<sh_name>").append("<![CDATA[" + shName + "]]>").append("</sh_name>");
}
contPers = genericUtility.getColumnValue("cont_pers", dom);
if(contPers==null||contPers.trim().length()==0)
{
valueXmlString.append("<cont_pfx>").append("<![CDATA[" + contPfx + "]]>").append("</cont_pfx>");
valueXmlString.append("<cont_pers>").append("<![CDATA[" + contPers + "]]>").append("</cont_pers>");
valueXmlString.append("<cont_pers>").append("<![CDATA[" + contactPer + "]]>").append("</cont_pers>");
}
add1 = genericUtility.getColumnValue("addr1", dom);
if(add1==null||add1.trim().length()==0)
{
valueXmlString.append("<addr1>").append("<![CDATA[" + addr1 + "]]>").append("</addr1>");
valueXmlString.append("<addr2>").append("<![CDATA[" + addr2 + "]]>").append("</addr2>");
valueXmlString.append("<addr3>").append("<![CDATA[" + addr3 + "]]>").append("</addr3>");
......@@ -1052,11 +1190,16 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
valueXmlString.append("<tele3>").append("<![CDATA[" + tele3 + "]]>").append("</tele3>");
valueXmlString.append("<tele_ext>").append("<![CDATA[" + teleExt + "]]>").append("</tele_ext>");
valueXmlString.append("<fax>").append("<![CDATA[" + fax + "]]>").append("</fax>");
valueXmlString.append("<mail_option>").append("<![CDATA[" + mail + "]]>").append("</mail_option>");
}
emailadd = genericUtility.getColumnValue("email_addr", dom);
if(emailadd==null||emailadd.trim().length()==0)
{
valueXmlString.append("<email_addr>").append("<![CDATA[" + mail + "]]>").append("</email_addr>");
}
//valueXmlString.append("<stan_code protect=\"1\">").append("").append("</stan_code>");
}
}else
else
{
valueXmlString.append("<tran_name>").append("<![CDATA[]]>").append("</tran_name>");
valueXmlString.append("<sh_name>").append("<![CDATA[]]>").append("</sh_name>");
......@@ -1078,17 +1221,71 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
valueXmlString.append("<stan_code protect=\"0\">").append("").append("</stan_code>");
}
// changes by deepak
}
valueXmlString.append("</Detail1>");
break;
case 2:
System.out.println("Transporter itemchanged case 2");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild();
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println("CURRENT COLUMN Case 2 Transporter *******["+currentColumn+"]");
if (currentColumn.trim().equalsIgnoreCase("reg_code"))
{
System.out.println("reg_code========itemChanged");
regCode=genericUtility.getColumnValue("reg_code", dom);
sql1="select descr from reg_requirements where reg_code=?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, regCode);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
regDescr = checkNull(rs1.getString("descr"));
// changes by deepak
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("Reg Code description:=="+regDescr);
if(regDescr == null)
{
valueXmlString.append("<descr>").append("<![CDATA["+""+"]]>").append("</descr>");
}
valueXmlString.append("</Detail1>");
else
{
valueXmlString.append("<descr>").append("<![CDATA["+regDescr+"]]>").append("</descr>");
}
}
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
......@@ -1125,6 +1322,8 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
return valueXmlString.toString();
}
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
......@@ -1167,4 +1366,18 @@ public class TransporterIC extends ValidatorEJB implements TransporterICLocal, T
}
return msgType;
}
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str ;
}
}
}
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