Commit a852f6ba authored by ngadkari's avatar ngadkari

New Undo Receipt Adjustment (process) components

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194775 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 50a22507
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.fin.adv.UndoRecievableAdjConf;
import ibase.webitm.utility.ITMException;
@Stateless
public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAdjPrcLocal ,UndoRecievableAdjPrcRemote{
String siteCode = "";
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtrStr = "";
Document headerDom = null;
Document detailDom = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0 )
{
System.out.println("XML String :::-:"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("XML String :::-:"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :UndoRecievableAdjPrc :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
return rtrStr;
}
//getData()
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String errCode = "";
String errString = "";
String resultString = "";;
String getDataSql1= "";
String tempString = null;
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
StringBuffer retTabSepStrBuff = new StringBuffer("<?xml version = \"1.0\"?>");
retTabSepStrBuff.append("<DocumentRoot>");
retTabSepStrBuff.append("<description>").append("Datawindow Root").append("</description>");
retTabSepStrBuff.append("<group0>");
retTabSepStrBuff.append("<description>").append("Group0 description").append("</description>");
retTabSepStrBuff.append("<Header0>");
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
System.out.println("xtraParams $$$$$$$$$$$$$$$$$$$$$$$$ "+xtraParams);
String userId = "";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
String sql = "";
SimpleDateFormat sdf=null;
double netAmt =0 ,totAmt=0 , adjAmt=0;
String refNoHeader="",tranType="",tranId="",remarks="",refNo="",refSer="";
int rows = 0;
try
{
conn = getConnection();
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
siteCode = genericUtility.getColumnValue("site_code",headerDom);
System.out.println("siteCode------>"+ siteCode);
if(siteCode == null || siteCode.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMSITECD1","","",conn);
return errString;
}
refNoHeader = genericUtility.getColumnValue("ref_no",headerDom);
if ( refNoHeader == null || refNoHeader.equals("null") || refNoHeader.trim().length() == 0 )
{
refNoHeader = "";
}
/*tranType = genericUtility.getColumnValue("tran_type",headerDom);
if ( tranType == null || tranType.equals("null") || tranType.trim().length() == 0 )
{
tranType = "S-INV";
}*/
try
{
getDataSql1 = "select ref_no,ref_ser,adj_amt,tot_amt,net_amt from receivables_adj where ref_no_adj= ? ";
// + "and ref_ser_adj= ?";
pstmt = conn.prepareStatement(getDataSql1);
System.out.println("The getDataSql becomes .................:"+getDataSql1);
int cnt=1;
pstmt.setString(1, refNoHeader);
// pstmt.setString(2, tranType);
rs = pstmt.executeQuery();
while (rs.next())
{
refNo=rs.getString(1);
refSer=rs.getString(2);
adjAmt =rs.getDouble(3);
totAmt =rs.getDouble(4);
netAmt =rs.getDouble(5);
//retTabSepStrBuff.append("<Detail2>");
retTabSepStrBuff.append("<Detail2 domID=\""+cnt+"\" selected=\""+"Y"+"\" > \r\n");
retTabSepStrBuff.append("<attribute selected=\""+"Y"+"\" updateFlag=\"\" status=\"N\" pkNames=\"\" />\r\n");
cnt++;
//
retTabSepStrBuff.append("<ref_no>").append("<![CDATA[").append(refNo).append("]]>").append("</ref_no>\r\n");
retTabSepStrBuff.append("<ref_ser>").append("<![CDATA[").append(refSer).append("]]>").append("</ref_ser>\r\n");
retTabSepStrBuff.append("<tot_amt>").append("<![CDATA[").append(totAmt).append("]]>").append("</tot_amt>\r\n");
retTabSepStrBuff.append("<adj_amt>").append("<![CDATA[").append(adjAmt).append("]]>").append("</adj_amt>\r\n");
retTabSepStrBuff.append("<net_amt>").append("<![CDATA[").append(netAmt).append("]]>").append("</net_amt>\r\n");
retTabSepStrBuff.append("</Detail2>");
retTabSepStrBuff.append("\n");
rows ++;
}
//while
rs.close();rs = null;
pstmt.close();pstmt = null;
retTabSepStrBuff.append("</Header0>\r\n");
retTabSepStrBuff.append("</group0>\r\n");
retTabSepStrBuff.append("</DocumentRoot>\r\n");
System.out.println("xml:::::::::::gateData>"+ retTabSepStrBuff);
resultString = retTabSepStrBuff.toString();
if(rows == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VTNOREC1", "","", conn);
return errString;
}
}//try
catch (SQLException e)
{
System.out.println("SQLException ::UndoRecievableAdjPrc :" +sql+ e.getMessage() + ":");
throw new ITMException(e);
}
if (!errCode.equals(""))
{
resultString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);
System.out.println("resultString.........: " + resultString);
}
}//try
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :UndoRecievableAdjPrc :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
finally
{
try
{
conn.close();
conn = null;
}
catch(Exception e)
{}
}
return resultString;
}
//process()
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
System.out.println("xmlString :::"+ xmlString);
System.out.println("xmlString2 :::"+ xmlString2);
System.out.println("below genericUtility :::-");
try
{
System.out.println("inside try1 block :::");
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom " + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom " + detailDom);
}
System.out.println("windowName" + windowName);
System.out.println("xtraParams" + xtraParams);
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :UndoRecievableAdjPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("DetailDom ::"+ detailDom);
String childNodeName = "";
String siteCode = "",loginSite="";
String stringxmlInvString = "";
String custCode = "",sundryCode="",tranSer="",sTranDate="",refNo="",sRefDate="",sTotAmt="",sAdjAmt="",acctCode="",status="";
String cctrCode = "",currCode="",sExchRate="",sDueDate="",finEntity="",bankCode="",refSerPay="",keyString="",recvTranID="";
double totAmt=0,adjAmt=0,fTotAmt=0,fAdjAmt=0,trfAmt=0;
String errCode = "";
String errString = "";
String insertSql = "",sql="";
String tranId = null,paytoRecAutoConf="";
Connection conn = null;
Statement st = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
java.sql.Timestamp instr_Date = null;
Timestamp dueDate = null;
Timestamp refDate = null;
Timestamp statDate = null;
StringBuffer xmlBuff = null;
int lineNo = 0;
int updCnt = 0,cnt=0;
int parentNodeListLength = 0;
int childNodeListLength = 0;
String refNoHeader="",tranType="",remarks="";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
boolean flag = false;
Timestamp tranDate = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
conn = getConnection();
sTranDate = checkNull(genericUtility.getColumnValue("tran_date", headerDom));
tranType= checkNull(genericUtility.getColumnValue("tran_type", headerDom));
siteCode=checkNull(genericUtility.getColumnValue("site_code", headerDom));
refNoHeader= checkNull(genericUtility.getColumnValue("ref_no", headerDom));
custCode= checkNull(genericUtility.getColumnValue("cust_code", headerDom));
if(sTranDate != null && sTranDate.trim().length() > 0){
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(sTranDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("ParentNodeListLength ..........."+parentNodeListLength);
if( xmlBuff == null )
{
xmlBuff = new StringBuffer();
}
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("undo_rec_adj").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"undo_rec_adj\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sTranDate +"]]></tran_date>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("<cust_code><![CDATA["+custCode+"]]></cust_code>");
xmlBuff.append("<ref_no><![CDATA["+refNoHeader+"]]></ref_no>");
xmlBuff.append("</Detail1>");
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
tranSer=checkNull(genericUtility.getColumnValueFromNode("ref_ser", parentNode));
refNo=checkNull(genericUtility.getColumnValueFromNode("ref_no", parentNode));
adjAmt=checkDoubleNull(genericUtility.getColumnValueFromNode("adj_amt", parentNode));
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"undo_rec_adj\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>");
lineNo++;
xmlBuff.append("<line_no><![CDATA["+ lineNo +"]]></line_no>");
xmlBuff.append("<ref_no><![CDATA["+ refNo +"]]></ref_no>");
xmlBuff.append("<ref_ser><![CDATA["+ tranSer +"]]></ref_ser>");
xmlBuff.append("<adj_amt><![CDATA["+ adjAmt +"]]></adj_amt>");
xmlBuff.append("</Detail2>");
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
errString=saveData(xtraParams,siteCode, xmlBuff.toString(), conn);
if( errString.indexOf("Success") == -1 )
{
return errString;
}
String[] arrayForTranId = errString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
tranId= arrayForTranId[1].substring(0,endIndex);
if(tranId != null && tranId.trim().length() > 0)
{
System.out.println("tran_id [" + tranId + "]");
errString = null;
}
UndoRecievableAdjConf undoRecAdjConf = new UndoRecievableAdjConf();
String forcedFlag="N";
errString=undoRecAdjConf.confirm(tranId, xtraParams, forcedFlag,conn);
undoRecAdjConf = null;
if( errString.indexOf("VTCNFSUCC") > -1)
{
errString = itmDBAccessEJB.getErrorString("","VTCOMPL","","",conn);
if(conn != null){
conn.commit();
System.out.println("commited....!!!");
}
return errString;
}
else
{
if(conn != null){
conn.rollback();
System.out.println("rollback....!!!");
}
return errString;
}
}//try end
catch(Exception e)
{
System.out.println("Exception :UndoRecievableAdjPrc ::" + e.getMessage() + ":");
try
{
conn.rollback();
} catch (Exception d)
{
System.out.println("Exception : UndoRecievableAdjPrc =>"+ d.toString());
d.printStackTrace();
d.printStackTrace();
errString = d.getMessage();
throw new ITMException(d);
}
}
finally
{
System.out.println("Closing Connection....");
try
{
conn.close();
conn = null;
}
catch(Exception se){}
}
System.out.println("errString: "+errString);
return errString;
}
private String saveData(String xtraParams,String siteCode, String xmlString, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
String userId ="";
MasterStatefulLocal masterStateful = null;
E12GenericUtility genericUtility=new E12GenericUtility();
ibase.utility.UserInfoBean userInfoBean=new UserInfoBean();
try
{
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("userId" + userId + "]");
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
String[] authencate = new String[2];
//authencate[0] = "";
authencate[0] = userId;
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
userInfoBean.setEmpCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
userInfoBean.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
userInfoBean.setSiteCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
userInfoBean.setLoginCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
userInfoBean.setEntityCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
} catch (ITMException itme)
{
System.out.println("ITMException :UndoRecievableAdjPrc :saveData :==>");
throw itme;
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :UndoRecievableAdjPrc :saveData :==>");
throw new ITMException(e);
}
return retString;
}
private String checkNullAndTrim(String inputVal)
{
if ( inputVal == null || "null".equals(inputVal))
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
}
private String checkNull(String input)
{
if (input == null || "null".equals(input))
{
input = "";
}
return input;
}
private double checkDoubleNull(String str) {
if (str == null || str.trim().length() == 0) {
return 0.0;
} else {
return Double.parseDouble(str);
}
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.ejb.Stateless;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class UndoRecievableAdjPrcIC extends ValidatorEJB implements UndoRecievableAdjPrcICLocal,UndoRecievableAdjPrcICRemote{
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
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 = "";
try
{
System.out.println("xmlString::["+xmlString+"]\nxmlString1::["+xmlString1+"]\nxmlString2::["+xmlString2+"]");
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [UndoRecievableAdjPrcICl][itemChanged( String, String )] :==>\n" + e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
int currentFormNo = 0;
int ctr = 0;
String sql = "",refNo="";
String refSer="",tranDate="",siteCode="";
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null ;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
Timestamp statusDate=null;
String descr = "",custName="",custCode="";
String columnValue="",loginSite="";
int childNodeListLength = 0;
SimpleDateFormat sdf = null;
try
{
conn = getConnection();
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("**********ITEMCHANGE FOR CASE" + currentFormNo + "**************");
switch (currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
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().equalsIgnoreCase("itm_default"))
{
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("----------- inside itm_default ---------------");
tranDate = simpleDateFormat.format(currentDate.getTime());
valueXmlString.append("<tran_date>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
setNodeValue(dom,"site_code" , loginSite);
/*valueXmlString.append("<tran_type>").append("<![CDATA[" +"S-INV"+ "]]>").append("</tran_type>");*/
}
if (currentColumn.trim().equals( "cust_code" ))
{
custCode = checkNull(genericUtility.getColumnValue( "cust_code", dom));
System.out.println("Customer Code====="+custCode);
if(custCode!=null && custCode.trim().length()>0)
{
sql = "select cust_name from customer where cust_code= ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
custName = rs.getString("cust_name");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<cust_name>").append("<![CDATA[" + custName+ "]]>").append("</cust_name>");
}
else
{
valueXmlString.append("<cust_name>").append("<![CDATA[" + ""+ "]]>").append("</cust_name>");
}
}
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); System.out.println("--login code--"+userId);
loginSite = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
String chgUser = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgUser");
String chgTerm = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
valueXmlString.append("</Detail1>"); // close tag
System.out.println(" itemchanged case 1 valueXmlString : "+valueXmlString);
break;
}
valueXmlString.append("</Root>");
}// end of try block
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
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 d)
{
d.printStackTrace();
}
}// end of finally statement
return valueXmlString.toString();
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
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 = "";
try
{
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("retString:::"+errString);
}
catch(Exception e)
{
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
int ctr=0;
int childNodeListLength;
int currentFormNo = 0;
int cnt = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String siteCode = "";
String userId = "";
String sql="";
String errCode="";
String errorType = "";
String childNodeName = null;
String errString = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null;
String existFlag = "";
String sundryCode = "",trfType="",refNo="",refSer="",reasCode="",sDueDateTo="",sundryType="",tranId="";
String site_code="",loginSiteCode="";
Timestamp dueDateTo = null, dueDateFr = null, TranDate =null;
String tranDateStr="",custCode="",tranType="";
double trfAmt=0.0;
String lineNo = "", refNoDet = "", currLineNo = "",refSerDet="";
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
SimpleDateFormat sdf1= new SimpleDateFormat(genericUtility.getDBDateFormat());
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo)
{
case 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("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code", dom);
System.out.println("siteCode: " + siteCode);
if (siteCode == null || siteCode.trim().length() == 0) {
errCode = "VMSITECD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Site Code can not be blank!!");
} else {
if (siteCode != null && siteCode.trim().length() > 0) {
if (!(isExist(conn, "site", "site_code", siteCode))) {
errCode = "VMSITE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}// end of if block for site_code
else if (childNodeName.equalsIgnoreCase("tran_date"))
{
tranDateStr = checkNull(genericUtility.getColumnValue("tran_date", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
System.out.println("@@@@ Tran Date[" + tranDateStr + "]");
TranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr.toString(),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+" 00:00:00.0");
System.out.println("Trandate is"+TranDate);
errCode = finCommon.nfCheckPeriod("FIN", TranDate,siteCode, conn);
System.out.println("Errorcode in TranDate"+errCode);
if (errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("cust_code"))
{
custCode = checkNull(genericUtility.getColumnValue("cust_code",dom));
System.out.println(" Customer_code =" + custCode);
if (custCode == null || custCode.trim().length() == 0)
{
errCode = "VMCUSTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
if(!isExist(conn, "customer", "cust_code", custCode))
{
errCode = "VTCUSTCD1 ";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("ref_no"))
{
refNo=genericUtility.getColumnValue("ref_no", dom);
//tranType=genericUtility.getColumnValue("tran_type", dom);
System.out.println("refNo============="+refNo);
//System.out.println("tranType============="+tranType);
if(refNo==null||refNo.trim().length()==0)
{
errCode = "VTREF02";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql="select count(1) from receivables where ref_no= ? and adj_amt <> 0";
pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, tranType);
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("count frm ref _no==="+cnt);
if(cnt==0)
{
errCode = "VTREF01";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
break;
}// end of switch statement
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
errString = itmDBAccessEJB.getErrorString("", errCode, userId, "", conn);
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);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();
}// End of try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
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 d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}//end of validation
private String isExist(String table, String field, String value, Connection conn) throws SQLException
{
String sql = "", retStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int cnt = 0;
sql = " SELECT COUNT(1) FROM " + table + " WHERE " + field + " = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0)
{
retStr = "TRUE";
}
if (cnt == 0)
{
retStr = "FALSE";
}
System.out.println("@@@@ isexist[" + value + "]:::[" + retStr + "]:::[" + cnt + "]");
return retStr;
}
private boolean isExist(Connection conn, String tableName, String columnName, String value)
throws ITMException, RemoteException {
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
boolean status = false;
try {
sql = "SELECT count(*) from " + tableName + " where " + columnName + " = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value);
rs = pstmt.executeQuery();
if (rs.next()) {
if (rs.getBoolean(1)) {
status = true;
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (Exception e) {
System.out.println("Exception in isExist ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from isExist ");
return status;
}
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 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");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
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;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface UndoRecievableAdjPrcICLocal 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;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface UndoRecievableAdjPrcICRemote 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
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.utility.ITMException;
@Local
public interface UndoRecievableAdjPrcLocal extends ibase.webitm.ejb.ProcessLocal{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.utility.ITMException;
@Remote
public interface UndoRecievableAdjPrcRemote extends ibase.webitm.ejb.ProcessRemote{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
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