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 import java.util.*;
public class Ledgerdatewise extends ValidatorEJB import java.util.Date;
implements LedgerdatewiseLocal, LedgerdatewiseRemote 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 Ledgerdatewise extends ValidatorEJB implements LedgerdatewiseLocal,LedgerdatewiseRemote //Added for EJB3 -sarah-10/06/2009
{ {
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String childNodeName = ""; String childNodeName = "";
int ctr; int ctr,currentFormNo=0;
int currentFormNo = 0; String columnValue=null;
String columnValue = null;
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String errString = null; String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility e12genericUtility = new E12GenericUtility();
public void setSessionContext(SessionContext paramSessionContext) /*--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 void ejbPassivate()
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)
{ {
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) { if(xmlString2 != null)
System.out.println("ITMException " + localITMException); {
localITMException.printStackTrace(); dom2 = GenericUtility.getInstance().parseString(xmlString2);
throw localITMException;
} }
catch (Exception localException) resultString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
} catch(ITMException e)
{ {
System.out.println("Exception in itemchange " + localException); System.out.println("ITMException "+e);
localException.printStackTrace(); e.printStackTrace();
throw new ITMException(localException); throw e;
} }
System.out.println("ResultString :: " + str); catch(Exception e)
return str; {
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) public String itemChanged(Document dom,Document dom1,Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
throws RemoteException, ITMException
{ {
Object localObject1 = null; java.sql.Timestamp chgdateTo=null;
Timestamp localTimestamp = null; java.sql.Timestamp chgdateFr=null;
String str1 = null; String acct_prd="";
String str2 = null; String period="";
Object localObject2 = null; Statement stmt=null;
Connection localConnection = null; String dateFrom=null ;
PreparedStatement localPreparedStatement = null; String dateTo=null ;
ResultSet localResultSet = null; Connection conn = null;
String str3 = ""; PreparedStatement pstmt = null;
String str4 = ""; PreparedStatement pstmt1 = null;
ResultSet rs = null;
String str5 = ""; ResultSet rs1 = null;
StringBuffer localStringBuffer = new StringBuffer(); String sql = "";
String str6 = ""; String sql1 = "";
localStringBuffer = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); String acctperiod = "";
localStringBuffer.append(paramString3).append("</editFlag></header>"); //String acctcode = "";
localStringBuffer.append("<Detail1>"); //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==============");
System.out.println("xtraParams is" + paramString4); System.out.println("xtraParams is"+xtraParams);
System.out.println("=======================xtraParams is=============="); System.out.println("=======================xtraParams is==============");
String str7 = getValueFromXTRA_PARAMS(paramString4, "loginSiteCode"); String loginSite = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
String str8 = ""; String sitecodeany="";
try //dateTo = genericUtility.getColumnValue("adt_fr",dom);
{ //sitecode = genericUtility.getColumnValue("msitecode",dom);
/* ConnDriver localConnDriver = new ConnDriver(); try{
localConnection = localConnDriver.getConnectDB("DriverITM");*/ //===============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 //Added for multi tenancy
localConnection = getConnection(); conn = getConnection();
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[" + getClass().getSimpleName()
+ "] [itemChanged(D)]:currentFormNo:" + currentFormNo);
System.out.println("currentColumn:::::["+currentColumn+"]");
this.parentNodeList = paramDocument1.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
this.parentNode = this.parentNodeList.item(0); parentNode = parentNodeList.item(0);
this.childNodeList = this.parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
this.ctr = 0; ctr = 0;
int i = this.childNodeList.getLength(); int childNodeListLength = childNodeList.getLength();
do do
{ {
this.childNode = this.childNodeList.item(this.ctr); childNode = childNodeList.item(ctr);
this.childNodeName = this.childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (this.childNodeName.equals(paramString2)) 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("msite_code")) if(currentColumn.trim().equalsIgnoreCase("msite_code"))
{ {
str8 = this.genericUtility.getColumnValue("msite_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; if(currentColumn.trim().equalsIgnoreCase( "m_date_from" ))
String str12;
String str13;
if (paramString2.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 ==========>: "); 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)) if ( dateFrom != null && dateFrom.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); String sDateFr= genericUtility.getValidDateString(dateFrom, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
} chgdateFr = java.sql.Timestamp.valueOf(sDateFr + " 00:00:00");
System.out.println("frDateDBStr :" + str14); //chgdateFr= java.sql.Timestamp.valueOf(sDateFr + " 00:00:00");
str14 = this.genericUtility.getValidDateString(str11, this.genericUtility.getDBDateFormat(), this.genericUtility.getApplDateFormat()); String chgdateToStr = sDateFr + " 00:00:00";
System.out.println("frDateDBStr :" + str14); //valueXmlString.append("<m_frst_date>").append("<![CDATA["+chgdateToStr.trim()+"]]>").append("</m_frst_date>");
localStringBuffer.append("<m_frst_date>").append("<![CDATA[" + str14 + "]]>").append("</m_frst_date>"); System.out.println("chgdateToStr ==========>: "+chgdateFr);
localStringBuffer.append("<as_frst_date>").append("<![CDATA[" + str11 + "]]>").append("</as_frst_date>"); //Sarah - 11/06/10
String frDateDB = "";
localStringBuffer.append("<as_date_from>").append("<![CDATA[" + str10 + "]]>").append("</as_date_from>"); String accPrd = "";
localStringBuffer.append("<macct_prd>").append("<![CDATA[" + str12.trim() + "]]>").append("</macct_prd>"); String codePrd = "";
localStringBuffer.append("<mprd_fr>").append("<![CDATA[" + str13.trim() + "]]>").append("</mprd_fr>"); String frDateDBStr = "";
} String first_date = "";
else 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())
{ {
localStringBuffer.append("<m_frst_date>").append("").append("</m_frst_date>"); accPrd = rs.getString("acct_prd");
localStringBuffer.append("<as_frst_date>").append("").append("</as_frst_date>"); codePrd=rs.getString("CODE");
localStringBuffer.append("<as_date_from>").append("").append("</as_date_from>"); frDateDB = rs.getString("FR_DATE");
localStringBuffer.append("<macct_prd>").append("").append("</macct_prd>");
localStringBuffer.append("<mprd_fr>").append("").append("</mprd_fr>");
} }
}
if (paramString2.trim().equalsIgnoreCase("m_date_to"))
{ rs.close();
str9 = ""; pstmt.close();
str10 = "";
str2 = this.genericUtility.getColumnValue("m_date_to", paramDocument1); sql1 = "SELECT fr_date FROM period where '"+dateFrom+"' between fr_date and to_date and code='"+codePrd+"'";
str11 = this.genericUtility.getValidDateString(str2, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat()); pstmt1 = conn.prepareStatement(sql1);
localObject1 = Timestamp.valueOf(str11 + " 00:00:00"); rs1 = pstmt1.executeQuery();
str12 = str11 + " 00:00:00";
str1 = this.genericUtility.getColumnValue("m_date_from", paramDocument1); if(rs1.next())
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);
localResultSet = localPreparedStatement.executeQuery();
System.out.println("chgdateFr :=======================> " + localTimestamp);
System.out.println("chgdateTo :=======================> " + localObject1);
if (localResultSet.next())
{ {
str9 = localResultSet.getString("acct_prd"); first_date = rs1.getString("fr_date");
str10 = localResultSet.getString("Code");
}
localResultSet.close();
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>");
} }
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>");
} }
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); System.out.println("ITMException :: "+e);
localITMException.printStackTrace(); e.printStackTrace();
throw localITMException; throw e;
} }
catch (Exception localException2) catch(Exception ie)
{ {
System.out.println("Exception :: " + localException2); System.out.println("Exception :: "+ie);
localException2.printStackTrace(); ie.printStackTrace();
throw new ITMException(localException2); throw new ITMException(ie);
} }
finally finally
{ {
try try
{ {
if (localConnection != null) if(conn!=null)
{ {
localConnection.close(); conn.close();
localConnection = null; 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