Commit 6d284107 authored by vvengurlekar's avatar vvengurlekar

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192126 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9ce0445f
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.text.*;
import java.util.Date;
import java.util.ArrayList;
import java.util.Calendar;
import java.sql.*;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
@Stateless
public class ChqNoChgIC extends ValidatorEJB implements ChqNoChgICLocal,ChqNoChgICRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : ChqNoChgIC : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String columnValue = null;
String childNodeName = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String userId = null,loginSite = null;
int cnt = 0;
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
String bankCode = "", refSeries = "", tranIdPay = "", tableName = "",confirmed = "", status = "", chqNoNew = "";
String msgType = "", errCode = "", errorType = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
System.out.println( "wfValData called" );
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
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( "bank_code" ) )
{
bankCode = checkNull(genericUtility.getColumnValue("bank_code",dom));
sql = "select Count(*) as cnt from bank where bank_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMBANK1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
if( childNodeName.equalsIgnoreCase( "tran_id__pay" ))
{
tranIdPay = checkNull(genericUtility.getColumnValue("tran_id__pay",dom));
refSeries = checkNull(genericUtility.getColumnValue("ref_ser",dom));
if(refSeries.equalsIgnoreCase("E-PAY"))
{
tableName = "payment_exp";
}
else
{
tableName = "misc_payment";
}
cnt = 0;
sql = "select confirmed from "+tableName+" where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdPay);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt ++;
confirmed = checkNull(rs.getString("confirmed"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0 || confirmed.equalsIgnoreCase("N"))
{
errCode = "VTPAY3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = "select status from banktran_log where tran_ser = ? and tran_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refSeries);
pstmt.setString(2,tranIdPay);
rs = pstmt.executeQuery();
if(rs.next())
{
status = checkNull(rs.getString("status"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(!(("E").equalsIgnoreCase(status)))
{
errCode = "VTRECO7";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
if( childNodeName.equalsIgnoreCase( "chq_no__new" ))
{
chqNoNew = checkNull(genericUtility.getColumnValue("chq_no__new",dom));
bankCode = checkNull(genericUtility.getColumnValue("bank_code",dom));
if(chqNoNew == null || chqNoNew.trim().length() == 0)
{
errCode = "VECHQ";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
cnt = 0;
sql = "select count(*) as cnt from banktran_log where bank_code = ? and tran_type = 'P' and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode);
pstmt.setString(2,chqNoNew);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
errCode = "VTCHQ4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
//END OF CASE1
break;
}//END SWITCH
int errListSize = errList.size();
System.out.println("errListSize::::::::::"+errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString>>>>>>>>>"+errString);
errorType = errorType(conn, errCode);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < ChqNoChgIC > CONNECTION IS CLOSED");
}
errString = errStringXml.toString();
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
System.out.println("xmlString" + xmlString);
dom = parseString(xmlString);
System.out.println("xmlString1" + xmlString1);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [ChqNoChgIC][itemChanged] :==>\n"+e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String loginSite = null;
String chguserhdr = null;
SimpleDateFormat sdf = null;
Date tranDate = null, refDate = null;
String todayDate = "", varValue = "", tranIdPay = "", refSeries = "", tranDateStr = "", refDateStr = "", siteCode = "", sundryType = "",
sundryCode = "", bankCode = "", currCode = "", refNo = "", bankName = "", siteDescr = "", sundryName = "";
double netAmount = 0.0;
FinCommon finCommon = new FinCommon();
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
chguserhdr = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
todayDate = sdf.format(new java.util.Date());
//todayTm = Timestamp.valueOf(genericUtility.getValidDateString(todayDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals( "itm_default" ))
{
valueXmlString.append("<tran_date><![CDATA[").append(todayDate).append("]]></tran_date>\r\n");
setNodeValue(dom, "tran_date", todayDate);
varValue = checkNull(finCommon.getFinparams("999999", "ALLOW_CHQ_DT_CHG", conn)).toUpperCase();
if(varValue == null || varValue.equalsIgnoreCase("NULLFOUND") || varValue.equalsIgnoreCase("N"))
{
valueXmlString.append("<ref_date protect=\"1\"><![CDATA[").append(todayDate).append("]]></ref_date>\r\n");
}
}
if((currentColumn.trim().equalsIgnoreCase("tran_id__pay")) || (currentColumn.trim().equalsIgnoreCase("ref_ser")))
{
tranIdPay = checkNull(getColumnValue("tran_id__pay",dom));
refSeries = checkNull(getColumnValue("ref_ser",dom));
if((tranIdPay != null && tranIdPay.trim().length()>0) && (refSeries != null && refSeries.trim().length()>0))
{
tranDate = null; siteCode = ""; sundryType = ""; sundryCode = ""; currCode = ""; netAmount = 0.0;
bankCode = ""; refNo = ""; refDate = null;
if(refSeries.equalsIgnoreCase("M-PAY"))
{
sql = "select tran_date, site_code, sundry_type, sundry_code, curr_code, net_amt, bank_code, ref_no, ref_date " +
" from misc_payment where tran_id = ? ";
}
else if(refSeries.equalsIgnoreCase("E-PAY"))
{
sql = "select tran_date, site_code, sundry_type, sundry_code, curr_code, net_amt, bank_code, ref_no, ref_date " +
" from payment_exp where tran_id = ? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdPay);
rs = pstmt.executeQuery();
if(rs.next())
{
tranDate = rs.getDate("tran_date");
siteCode = checkNull(rs.getString("site_code"));
sundryType = checkNull(rs.getString("sundry_type"));
sundryCode = checkNull(rs.getString("sundry_code"));
currCode = checkNull(rs.getString("curr_code"));
netAmount = rs.getDouble("net_amt");
bankCode = checkNull(rs.getString("bank_code"));
refNo = checkNull(rs.getString("ref_no"));
refDate = rs.getDate("ref_date");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(tranDate != null)
{
tranDateStr = sdf.format(tranDate);
}
else
{
tranDateStr = "";
}
if(refDate != null)
{
refDateStr = sdf.format(refDate);
}
else
{
refDateStr = "";
}
valueXmlString.append("<misc_payment_tran_date><![CDATA[").append(tranDateStr).append("]]></misc_payment_tran_date>\r\n");
valueXmlString.append("<site_code><![CDATA[").append(siteCode).append("]]></site_code>\r\n");
valueXmlString.append("<sundry_type><![CDATA[").append(sundryType).append("]]></sundry_type>\r\n");
valueXmlString.append("<sundry_code><![CDATA[").append(sundryCode).append("]]></sundry_code>\r\n");
valueXmlString.append("<curr_code><![CDATA[").append(currCode).append("]]></curr_code>\r\n");
valueXmlString.append("<net_amt><![CDATA[").append(netAmount).append("]]></net_amt>\r\n");
valueXmlString.append("<bank_code><![CDATA[").append(bankCode).append("]]></bank_code>\r\n");
valueXmlString.append("<chq_no__old><![CDATA[").append(refNo).append("]]></chq_no__old>\r\n");
valueXmlString.append("<ref_date><![CDATA[").append(refDateStr).append("]]></ref_date>\r\n");
valueXmlString.append("<ref_date__old><![CDATA[").append(refDateStr).append("]]></ref_date__old>\r\n");
setNodeValue(dom, "tran_date", todayDate);
setNodeValue(dom, "site_code", siteCode);
setNodeValue(dom, "sundry_type", sundryType);
setNodeValue(dom, "sundry_code", sundryCode);
setNodeValue(dom, "curr_code", currCode);
setNodeValue(dom, "bank_code", bankCode);
bankName = findValue("bank_name", "bank", "bank_code", bankCode, conn);
siteDescr = findValue("descr", "site", "site_code", siteCode, conn);
sql = "select fn_sundry_name(?,?,'N') as sundry_name from dual ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryType);
pstmt.setString(2, sundryCode);
rs = pstmt.executeQuery();
if(rs.next())
{
sundryName = checkNull(rs.getString("sundry_name"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<bank_name><![CDATA[").append(bankName).append("]]></bank_name>\r\n");
valueXmlString.append("<site_descr><![CDATA[").append(siteDescr).append("]]></site_descr>\r\n");
valueXmlString.append("<sundry_name><![CDATA[").append(sundryName).append("]]></sundry_name>\r\n");
}
else
{
valueXmlString.append("<misc_payment_tran_date><![CDATA[").append("").append("]]></misc_payment_tran_date>\r\n");
valueXmlString.append("<site_code><![CDATA[").append("").append("]]></site_code>\r\n");
valueXmlString.append("<sundry_type><![CDATA[").append("").append("]]></sundry_type>\r\n");
valueXmlString.append("<sundry_code><![CDATA[").append("").append("]]></sundry_code>\r\n");
valueXmlString.append("<curr_code><![CDATA[").append("").append("]]></curr_code>\r\n");
valueXmlString.append("<net_amt><![CDATA[").append("").append("]]></net_amt>\r\n");
valueXmlString.append("<bank_code><![CDATA[").append("").append("]]></bank_code>\r\n");
valueXmlString.append("<chq_no__old><![CDATA[").append("").append("]]></chq_no__old>\r\n");
valueXmlString.append("<ref_date><![CDATA[").append("").append("]]></ref_date>\r\n");
valueXmlString.append("<ref_date__old><![CDATA[").append("").append("]]></ref_date__old>\r\n");
valueXmlString.append("<bank_name><![CDATA[").append("").append("]]></bank_name>\r\n");
valueXmlString.append("<site_descr><![CDATA[").append("").append("]]></site_descr>\r\n");
valueXmlString.append("<sundry_name><![CDATA[").append("").append("]]></sundry_name>\r\n");
}
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
}//END OF TRY
}
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("Returned string for itemchanged from ChqNoChgIC:::["+valueXmlString.toString()+"]");
return valueXmlString.toString();
}//END OF ITEMCHANGE
private static void setNodeValue(Document dom, String nodeName,String nodeVal) throws Exception {
Node tempNode = dom.getElementsByTagName(nodeName).item(0);
if (tempNode != null) {
if (tempNode.getFirstChild() == null) {
CDATASection cDataSection = dom.createCDATASection(nodeVal);
tempNode.appendChild(cDataSection);
} else {
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
private String findValue(String getCoulmn, String tableName, String columnName, String columnValue, Connection conn) throws SQLException, ITMException
{
String sql="";
PreparedStatement pstmt = null;
String returnValue = "";
ResultSet rs = null;
try
{
sql = "select "+getCoulmn+" from "+tableName+" where "+columnName+" = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,columnValue);
rs = pstmt.executeQuery();
if(rs.next())
{
returnValue = checkNull(rs.getString(getCoulmn));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception in findValue::"+e.getMessage());
throw new ITMException(e);
}
finally {
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
return returnValue;
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
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();
if (rs.next())
{
msgType = checkNull(rs.getString("MSG_TYPE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
private String getCurrdateAppFormat()
{
String s = "";
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
import ibase.webitm.ejb.ValidatorLocal;// added for ejb3
@Local // added for ejb3
public interface ChqNoChgICLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1,String xmlString2, 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;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface ChqNoChgICRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1,String xmlString2, 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;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
......@@ -65,7 +65,7 @@ public class ChqNoChgPos extends ValidatorEJB implements ChqNoChgPosLocal ,ChqN
logDir = new File(logDirName);
filePtr = new File(logDirName+ File.separator + "ChqNoChgPos.log");
System.out.println("--------------------------------------->ChqNoChgPosEJB called");
System.out.println("--------------------------------------->ChqNoChgPosEJB called xmlString1: "+xmlString1);
writeLog(filePtr,"ChqNoChgPosEJB called",true);
Document dom = null;
try
......@@ -92,8 +92,8 @@ public class ChqNoChgPos extends ValidatorEJB implements ChqNoChgPosLocal ,ChqN
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null;
String oldChqNo = "", newChqNo = "", tranIDPay = "" ;
String sqlUpd = "";
String oldRefDate = "", newRefDate = "";
String sqlUpd = "", tableName = "";
String oldRefDate = "", newRefDate = "", newRefSeries = "";
int updCnt = 0, updCnt1 = 0;
writeLog(filePtr,"dom-->"+dom,true);
......@@ -109,21 +109,35 @@ public class ChqNoChgPos extends ValidatorEJB implements ChqNoChgPosLocal ,ChqN
// GenericUtility genericUtility = GenericUtility.getInstance();
if (dom != null )
{
oldChqNo = genericUtility.getColumnValue("chq_no__old",dom);
oldChqNo = checkNull(genericUtility.getColumnValue("chq_no__old",dom));
writeLog(filePtr,"oldChqNo-->"+oldChqNo,true);
newChqNo = genericUtility.getColumnValue("chq_no__new",dom);
newChqNo = checkNull(genericUtility.getColumnValue("chq_no__new",dom));
writeLog(filePtr,"newChqNo-->"+newChqNo,true);
tranIDPay = genericUtility.getColumnValue("tran_id__pay",dom);
tranIDPay = checkNull(genericUtility.getColumnValue("tran_id__pay",dom));
writeLog(filePtr,"tranIDPay-->"+tranIDPay,true);
oldRefDate = genericUtility.getColumnValue("ref_date__old",dom);
oldRefDate = checkNull(genericUtility.getColumnValue("ref_date__old",dom));
writeLog(filePtr,"oldRefDate-->"+oldRefDate,true);
newRefDate = genericUtility.getColumnValue("ref_date",dom);
newRefDate = checkNull(genericUtility.getColumnValue("ref_date",dom));
writeLog(filePtr,"newRefDate-->"+newRefDate,true);
newRefSeries = checkNull(genericUtility.getColumnValue("ref_ser",dom));
writeLog(filePtr,"newRefSeries-->"+newRefSeries,true);
}
System.out.println("oldChqNo--> "+ oldChqNo + " newChqNo--> "+ newChqNo + " tranIDPay--> " + tranIDPay + " oldRefDate--> "
+ oldRefDate + " newRefDate--> " + newRefDate + " newRefSeries--> "+newRefSeries);
//changed by msalam on 24/10/07 for
//directly appending tran_id in sqlUpd and removing ? and setString
//next line commented and changed line added.
//sqlUpd = "UPDATE MISC_PAYMENT SET REF_NO = ? , REF_NO__OLD = ? ,REF_DATE = ?, REF_DATE__OLD = ? where tran_id = ? ";
if(newRefSeries.equalsIgnoreCase("M-PAY"))
{
tableName = "MISC_PAYMENT";
}
else if(newRefSeries.equalsIgnoreCase("E-PAY"))
{
tableName = "PAYMENT_EXP";
}
if(newRefSeries.equalsIgnoreCase("M-PAY"))
{
sqlUpd = " UPDATE MISC_PAYMENT SET REF_NO = ? , REF_NO__OLD = ? ,REF_DATE = ?, REF_DATE__OLD = ? "
+ " where tran_id = '" + tranIDPay.trim() + "'";
writeLog(filePtr,"sqlUpd-->"+sqlUpd,true);
......@@ -148,17 +162,47 @@ public class ChqNoChgPos extends ValidatorEJB implements ChqNoChgPosLocal ,ChqN
//next line commented and changed line added.
//sqlUpd = "UPDATE BANKTRAN_LOG SET REF_NO = ?, REF_DATE = ? WHERE TRAN_SER = 'M-PAY' AND TRAN_NO = ? ";
sqlUpd = " UPDATE BANKTRAN_LOG SET REF_NO = ?, REF_DATE = ? "
+ " WHERE TRAN_SER = 'M-PAY' AND TRAN_NO = '" + tranIDPay.trim() + "'";
+ " WHERE TRAN_SER = ? AND TRAN_NO = '" + tranIDPay.trim() + "'";
System.out.println("Update Sql :"+sqlUpd);
writeLog(filePtr,"sqlUpd-->"+sqlUpd,true);
pstmt1 = conn.prepareStatement(sqlUpd);
pstmt1.setString(1,newChqNo);
pstmt1.setTimestamp(2,java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(newRefDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())));
pstmt1.setString(3, newRefSeries);
//changed by msalam on 24/10/07 for
//directly appending tran_id in sqlUpd and removing ? and setString
//next line commented as not required.
//pstmt1.setString(3,tranIDPay);
updCnt1 = pstmt1.executeUpdate();
}
else if(newRefSeries.equalsIgnoreCase("E-PAY"))
{
sqlUpd = " UPDATE PAYMENT_EXP SET REF_NO = ? , REF_DATE = ? "
+ " where tran_id = '" + tranIDPay.trim() + "'";
writeLog(filePtr,"sqlUpd-->"+sqlUpd,true);
System.out.println("Update Sql :"+sqlUpd);
pstmt = conn.prepareStatement(sqlUpd);
pstmt.setString(1,newChqNo);
//pstmt.setString(2,oldChqNo);
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(newRefDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())));
//pstmt.setTimestamp(4,java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(oldRefDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())));
updCnt = pstmt.executeUpdate();
if (updCnt == 1)
{
System.out.println("Update Into PAYMENT_EXP Sucessfully : updCnt : " + updCnt);
writeLog(filePtr,"updCnt-->"+updCnt,true);
}
sqlUpd = " UPDATE BANKTRAN_LOG SET REF_NO = ?, REF_DATE = ? "
+ " WHERE TRAN_SER = ? AND TRAN_NO = '" + tranIDPay.trim() + "'";
System.out.println("Update Sql :"+sqlUpd);
writeLog(filePtr,"sqlUpd-->"+sqlUpd,true);
pstmt1 = conn.prepareStatement(sqlUpd);
pstmt1.setString(1,newChqNo);
pstmt1.setTimestamp(2,java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(newRefDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())));
pstmt1.setString(3, newRefSeries);
updCnt1 = pstmt1.executeUpdate();
}
if (updCnt1 == 1)
{
System.out.println("Update Into BANKTRAN_LOG Sucessfully : updCnt1 : " + updCnt1);
......@@ -166,8 +210,8 @@ public class ChqNoChgPos extends ValidatorEJB implements ChqNoChgPosLocal ,ChqN
}
if (updCnt == 1 && updCnt1 == 1)
{
System.out.println("Update Into MISC_PAYMENT and BANKTRAN_LOG Sucessfully : And conn.commit() called ::");
writeLog(filePtr,"Update Into MISC_PAYMENT and BANKTRAN_LOG Sucessfully : And conn.commit() called ::",true);
System.out.println("Update Into "+tableName+" and BANKTRAN_LOG Sucessfully : And conn.commit() called ::");
writeLog(filePtr,"Update Into "+tableName+" and BANKTRAN_LOG Sucessfully : And conn.commit() called ::",true);
//conn.commit();
}
}
......@@ -226,4 +270,9 @@ public class ChqNoChgPos extends ValidatorEJB implements ChqNoChgPosLocal ,ChqN
writeLog(filePtr,"Return from executepostSaveRec()",true);
return "";
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
}
\ 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