Commit 0749f61b authored by pnayak's avatar pnayak

d_subledger_acc_fin

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