Commit 1fc17c33 authored by pnayak's avatar pnayak

Added coding for itemchange

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@189387 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 93c3903e
......@@ -25,7 +25,7 @@ import ibase.utility.E12GenericUtility;
@Stateless //Added for EJB3 -sarah-10/06/2009
//public class GenLedgerEJB extends ValidatorEJB implements SessionBean
public class GenLedger extends ValidatorEJB implements GenLedgerLocal,GenLedgerRemote //Added for EJB3 -sarah-10/06/2009
public class Ledger - All ACs-Account Wise extends ValidatorEJB implements Ledger - All ACs-Account WiseLocal,Ledger - All ACs-Account WiseRemote //Added for EJB3 -sarah-10/06/2009
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
......
package ibase.webitm.ejb.fin;
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.Document;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.PrintStream;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class Ledger extends ValidatorEJB
implements LedgerLocal, LedgerRemote
import java.util.*;
import java.util.Date;
import java.text.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
@Stateless //Added for EJB3 -sarah-10/06/2009
//public class GenLedgerEJB extends ValidatorEJB implements SessionBean
public class Ledger extends ValidatorEJB implements LedgerLocal,LedgerRemote //Added for EJB3 -sarah-10/06/2009
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
int ctr;
int currentFormNo = 0;
String columnValue = null;
int ctr,currentFormNo=0;
String columnValue=null;
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
public void setSessionContext(SessionContext paramSessionContext)
E12GenericUtility e12genericUtility = new E12GenericUtility();
/*--Commented for EJB3--sarah--10/06/2009
public void ejbCreate() throws RemoteException,CreateException
{
}
public void ejbRemove()
{
public String itemChanged()
throws RemoteException, ITMException
}
public void ejbActivate()
{
return "";
}
public String itemChanged(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6, String paramString7) throws RemoteException, ITMException {
String str = "";
Document localDocument1 = null; Document localDocument2 = null; Document localDocument3 = null;
try {
System.out.println("xmlString : " + paramString1);
System.out.println("xmlString1 : " + paramString2);
if (paramString1 != null)
public void ejbPassivate()
{
localDocument1 = GenericUtility.getInstance().parseString(paramString1);
}
if (paramString2 != null)
*/
//End Comment--10/06/2009
public void setSessionContext(SessionContext sess){
}
public String itemChanged() throws RemoteException,ITMException
{
localDocument2 = GenericUtility.getInstance().parseString(paramString2);
return "";
}
if (paramString3 != null)
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String resultString = "";
Document dom = null,dom1 = null,dom2 = null;
try{
System.out.println("xmlString : "+xmlString);
System.out.println("xmlString1 : "+xmlString1);
if(xmlString != null)
{
localDocument3 = GenericUtility.getInstance().parseString(paramString3);
dom = GenericUtility.getInstance().parseString(xmlString);
}
str = itemChanged(localDocument1, localDocument2, localDocument3, paramString4, paramString5, paramString6, paramString7);
if(xmlString1 != null)
{
dom1 = GenericUtility.getInstance().parseString(xmlString1);
}
catch (ITMException localITMException) {
System.out.println("ITMException " + localITMException);
localITMException.printStackTrace();
throw localITMException;
if(xmlString2 != null)
{
dom2 = GenericUtility.getInstance().parseString(xmlString2);
}
catch (Exception localException)
resultString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
} catch(ITMException e)
{
System.out.println("Exception in itemchange " + localException);
localException.printStackTrace();
throw new ITMException(localException);
System.out.println("ITMException "+e);
e.printStackTrace();
throw e;
}
System.out.println("ResultString :: " + str);
return str;
catch(Exception e)
{
System.out.println("Exception in itemchange "+e);
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("ResultString :: "+resultString);
return resultString;
} //end of item change
public String itemChanged(Document paramDocument1, Document paramDocument2, Document paramDocument3, String paramString1, String paramString2, String paramString3, String paramString4)
throws RemoteException, ITMException
public String itemChanged(Document dom,Document dom1,Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Object localObject1 = null;
Timestamp localTimestamp = null;
String str1 = null;
String str2 = null;
Object localObject2 = null;
Connection localConnection = null;
PreparedStatement localPreparedStatement = null;
ResultSet localResultSet = null;
String str3 = "";
String str4 = "";
String str5 = "";
StringBuffer localStringBuffer = new StringBuffer();
String str6 = "";
localStringBuffer = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
localStringBuffer.append(paramString3).append("</editFlag></header>");
localStringBuffer.append("<Detail1>");
java.sql.Timestamp chgdateTo=null;
java.sql.Timestamp chgdateFr=null;
String acct_prd="";
String period="";
Statement stmt=null;
String dateFrom=null ;
String dateTo=null ;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String acctperiod = "";
//String acctcode = "";
//String fromdate = "";
String errorString = "";
java.sql.Date today = null;
StringBuffer valueXmlString = new StringBuffer();
String sitecode = "";
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append("<Detail1>");
System.out.println("=======================xtraParams is==============");
System.out.println("xtraParams is" + paramString4);
System.out.println("xtraParams is"+xtraParams);
System.out.println("=======================xtraParams is==============");
String str7 = getValueFromXTRA_PARAMS(paramString4, "loginSiteCode");
String str8 = "";
try
{
/* ConnDriver localConnDriver = new ConnDriver();
localConnection = localConnDriver.getConnectDB("DriverITM");*/
String loginSite = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
String sitecodeany="";
//dateTo = genericUtility.getColumnValue("adt_fr",dom);
//sitecode = genericUtility.getColumnValue("msitecode",dom);
try{
//===============Convert date to TimeStamp date format===========
//Timestamp chgdateFrom = null,chgdateTo = null;
//Object date = null;
//SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
//date = sdf.parse(dateFrom);
//SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
//SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getDBDateFormat());
//dateFrom =sdf1.format(date).toString() + " 00:00:00.0";
//chgdateFrom = java.sql.Timestamp.valueOf(sdf1.format(date).toString() + " 00:00:00.0");
//date = sdf.parse(dateTo);
//dateTo = sdf2.format(date).toString() + ".00:00:00";
//chgdateTo = java.sql.Timestamp.valueOf(sdf1.format(date).toString() + " 00:00:00.0");
//===============================================================
//conn = getConnection();
/* ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");*/
//Added for multi tenancy
localConnection = getConnection();
conn = getConnection();
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
this.parentNodeList = paramDocument1.getElementsByTagName("Detail1");
this.parentNode = this.parentNodeList.item(0);
this.childNodeList = this.parentNode.getChildNodes();
this.ctr = 0;
int i = this.childNodeList.getLength();
}
System.out.println("[" + getClass().getSimpleName()
+ "] [itemChanged(D)]:currentFormNo:" + currentFormNo);
System.out.println("currentColumn:::::["+currentColumn+"]");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
int childNodeListLength = childNodeList.getLength();
do
{
this.childNode = this.childNodeList.item(this.ctr);
this.childNodeName = this.childNode.getNodeName();
if (this.childNodeName.equals(paramString2))
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (this.childNode.getFirstChild() != null)
if (childNode.getFirstChild() != null)
{
this.columnValue = this.childNode.getFirstChild().getNodeValue().trim();
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
this.ctr += 1;
ctr++;
}
while ((this.ctr < i) && (!this.childNodeName.equals(paramString2)));
while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
if (paramString2.trim().equalsIgnoreCase("site_code"))
if(currentColumn.trim().equalsIgnoreCase("msite_code"))
{
str8 = this.genericUtility.getColumnValue("site_code", paramDocument1);
localStringBuffer.append("<m_site_arg>").append("<![CDATA[" + str8.trim() + "]]>").append("</m_site_arg>");
sitecodeany = genericUtility.getColumnValue("msite_code",dom);
valueXmlString.append("<m_site_arg>").append("<![CDATA["+sitecodeany.trim()+"]]>").append("</m_site_arg>");
//valueXmlString.append("<as_ason_date>").append("<![CDATA["+dateFrom+"]]>").append("</as_ason_date>");
// System.out.println("sitecodeany=========> : "+sitecodeany);
}
String str9;
String str10;
String str11;
String str12;
String str13;
if (paramString2.trim().equalsIgnoreCase("m_date_from"))
/*
if(currentColumn.trim().equalsIgnoreCase( "m_date_from" ))
{
dateFrom = genericUtility.getColumnValue( "m_date_from", dom );
String dateFromStr = null;
String acctPrdSql = null;
dateFromStr = genericUtility.getValidDateString(dateFrom, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
acctPrdSql = "select fr_date from acctprd where ? between fr_date and to_date";
PreparedStatement acctStmt = null;
ResultSet acctRs = null;
acctStmt = conn.prepareStatement( acctPrdSql );
acctStmt.setTimestamp( 1, Timestamp.valueOf( dateFromStr + " 00:00:00.0") ) ;
acctRs = acctStmt.executeQuery();
acctRs.close();
acctRs = null;
acctStmt.close();
acctStmt = null;
valueXmlString.append("<as_date_from>").append("<![CDATA[" + dateFromStr.trim() + " 00:00:00" +"]]>").append("</as_date_from>");
valueXmlString.append("<m_frst_date>").append("<![CDATA[" + dateFromStr.trim() + " 00:00:00" +"]]>").append("</m_frst_date>");*/
System.out.println("chgdateToStr BEFORE ==========>: ");
str1 = this.genericUtility.getColumnValue("m_date_from", paramDocument1);
dateFrom = genericUtility.getColumnValue("m_date_from",dom);
if ((str1 != null) && (str1.trim().length() > 0))
{
str9 = this.genericUtility.getValidDateString(str1, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat());
localTimestamp = Timestamp.valueOf(str9 + " 00:00:00");
str10 = str9 + " 00:00:00";
System.out.println("chgdateToStr ==========>: " + localTimestamp);
str11 = "";
str12 = "";
str13 = "";
String str14 = "";
str3 = "SELECT ACCT_PRD,CODE FROM PERIOD WHERE FR_DATE<=? AND TO_DATE >=?";
localPreparedStatement = localConnection.prepareStatement(str3);
localPreparedStatement.setTimestamp(1, localTimestamp);
localPreparedStatement.setTimestamp(2, localTimestamp);
localResultSet = localPreparedStatement.executeQuery();
System.out.println("chgdateFr :=======================> " + localTimestamp);
System.out.println("chgdateTo :=======================> " + localObject1);
if (localResultSet.next())
{
str12 = localResultSet.getString("acct_prd");
str13 = localResultSet.getString("CODE");
}
localResultSet.close();
localPreparedStatement.close();
str3 = "SELECT FR_DATE FROM PERIOD WHERE CODE=?";
localPreparedStatement = localConnection.prepareStatement(str3);
localPreparedStatement.setString(1, str13);
localResultSet = localPreparedStatement.executeQuery();
if (localResultSet.next())
{
str11 = localResultSet.getString("FR_DATE");
}
localResultSet.close();
localPreparedStatement.close();
if ((str11 != null) && (str11.trim().length() > 0))
{
str11 = str11.substring(0, str11.trim().length() - 2);
}
System.out.println("frDateDBStr :" + str14);
str14 = this.genericUtility.getValidDateString(str11, this.genericUtility.getDBDateFormat(), this.genericUtility.getApplDateFormat());
System.out.println("frDateDBStr :" + str14);
localStringBuffer.append("<m_frst_date>").append("<![CDATA[" + str14 + "]]>").append("</m_frst_date>");
localStringBuffer.append("<as_frst_date>").append("<![CDATA[" + str11 + "]]>").append("</as_frst_date>");
localStringBuffer.append("<as_date_from>").append("<![CDATA[" + str10 + "]]>").append("</as_date_from>");
localStringBuffer.append("<acct_prd>").append("<![CDATA[" + str12.trim() + "]]>").append("</acct_prd>");
localStringBuffer.append("<mprd_fr>").append("<![CDATA[" + str13.trim() + "]]>").append("</mprd_fr>");
}
else
{
localStringBuffer.append("<m_frst_date>").append("").append("</m_frst_date>");
localStringBuffer.append("<as_frst_date>").append("").append("</as_frst_date>");
localStringBuffer.append("<as_date_from>").append("").append("</as_date_from>");
localStringBuffer.append("<acct_prd>").append("").append("</acct_prd>");
localStringBuffer.append("<mprd_fr>").append("").append("</mprd_fr>");
}
}
if (paramString2.trim().equalsIgnoreCase("m_date_to"))
{
str9 = "";
str10 = "";
str2 = this.genericUtility.getColumnValue("m_date_to", paramDocument1);
str11 = this.genericUtility.getValidDateString(str2, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat());
localObject1 = Timestamp.valueOf(str11 + " 00:00:00");
str12 = str11 + " 00:00:00";
str1 = this.genericUtility.getColumnValue("m_date_from", paramDocument1);
if ((str1 != null) && (str1.trim().length() > 0))
if ( dateFrom != null && dateFrom.trim().length() > 0)
{
str13 = this.genericUtility.getValidDateString(str1, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat());
localTimestamp = Timestamp.valueOf(str13 + " 00:00:00");
str3 = "Select acct_prd,Code from period where Fr_date<=? and To_date >=?";
System.out.println("SQL******************************* : " + str3);
localPreparedStatement = localConnection.prepareStatement(str3);
localPreparedStatement.setTimestamp(1, localTimestamp);
localPreparedStatement.setTimestamp(2, localTimestamp);
localResultSet = localPreparedStatement.executeQuery();
System.out.println("chgdateFr :=======================> " + localTimestamp);
System.out.println("chgdateTo :=======================> " + localObject1);
if (localResultSet.next())
String sDateFr= genericUtility.getValidDateString(dateFrom, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
chgdateFr = java.sql.Timestamp.valueOf(sDateFr + " 00:00:00");
//chgdateFr= java.sql.Timestamp.valueOf(sDateFr + " 00:00:00");
String chgdateToStr = sDateFr + " 00:00:00";
//valueXmlString.append("<m_frst_date>").append("<![CDATA["+chgdateToStr.trim()+"]]>").append("</m_frst_date>");
System.out.println("chgdateToStr ==========>: "+chgdateFr);
//Sarah - 11/06/10
String frDateDB = "";
String accPrd = "";
String codePrd = "";
String frDateDBStr = "";
sql = "SELECT ACCT_PRD,CODE ,FR_DATE FROM PERIOD WHERE FR_DATE<=? AND TO_DATE >=?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,chgdateFr);
pstmt.setTimestamp(2,chgdateFr);
rs = pstmt.executeQuery();
System.out.println("chgdateFr :=======================> "+chgdateFr);
System.out.println("chgdateTo :=======================> "+chgdateTo);
if(rs.next())
{
str9 = localResultSet.getString("acct_prd");
str10 = localResultSet.getString("Code");
}
localResultSet.close();
System.out.println("accPrd :==========================> " + str9);
System.out.println("codePrd :==========================> " + str10);
localStringBuffer.append("<acct_prd>").append("<![CDATA[" + str9.trim() + "]]>").append("</acct_prd>");
localStringBuffer.append("<mprd_fr>").append("<![CDATA[" + str10.trim() + "]]>").append("</mprd_fr>");
accPrd = rs.getString("acct_prd");
codePrd=rs.getString("CODE");
frDateDB = rs.getString("FR_DATE");
}
rs.close();
pstmt.close();
valueXmlString.append("<as_date_from>").append("<![CDATA[" + frDateDB.trim() + " 00:00:00" +"]]>").append("</as_date_from>");
valueXmlString.append("<m_frst_date>").append("<![CDATA[" + frDateDB.trim() + " 00:00:00" +"]]>").append("</m_frst_date>");
valueXmlString.append("<macct_prd>").append("<![CDATA["+accPrd.trim()+"]]>").append("</macct_prd>");
valueXmlString.append("<mprd_fr>").append("<![CDATA["+codePrd.trim()+"]]>").append("</mprd_fr>");
}
localStringBuffer.append("</Detail1>");
localStringBuffer.append("</Root>");
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
}
catch (ITMException localITMException)
//end of try
catch(ITMException e)
{
System.out.println("ITMException :: " + localITMException);
localITMException.printStackTrace();
throw localITMException;
System.out.println("ITMException :: "+e);
e.printStackTrace();
throw e;
}
catch (Exception localException2)
catch(Exception ie)
{
System.out.println("Exception :: " + localException2);
localException2.printStackTrace();
throw new ITMException(localException2);
System.out.println("Exception :: "+ie);
ie.printStackTrace();
throw new ITMException(ie);
}
finally
{
try
{
if (localConnection != null)
if(conn!=null)
{
localConnection.close();
localConnection = null;
conn.close();
conn=null;
}
}
catch (Exception localException3)
catch (Exception e)
{
}
}
return valueXmlString.toString() ;
}
//end of item change
return (String)localStringBuffer.toString();
private String checkNull(String input) {
return input == null ? "" : input.trim();
}
}
\ 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