Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Java Event handler question -- ***URGENT***
hkseeram
Hi,
We are currently using BIRT3.7 version deployed in JBOSS7.0 application. We are using JNDI connection pooling.
We have a report design file that has several data set objects that were used to generate report output. I have a requirement to call and execute the following piece Java code before any data set is called.
private void prepareForExecution (BigDecimal PID, Connection conn) throws Exception {
String dbObjectName;
if(reportUIConfigService.getReportConfig(PID).getOperateOnConnection().equalsIgnoreCase("YES")){
dbObjectName = reportUIConfigService.getReportConfig(PID).getSupportingDBObjectName();
}else{
dbObjectName = "default_obj";
}
Statement st = conn.createStatement();
StringBuffer stmt = new StringBuffer();
stmt.append("DECLARE " + "\n");
stmt.append(" v_obj " + dbObjectName + " := " + dbObjectName + "();\n");
stmt.append("BEGIN " + "\n");
stmt.append(" v_obj.exec_all" + "\n");
stmt.append(" (" + "\n");
stmt.append(" p_id => " + PID + "\n");
stmt.append(" );" + "\n");
stmt.append("END;" + "\n");
logger.info("EXECUTING: " + "\n\n" + stmt.toString() + "/\n");
st.execute(stmt.toString());
}
How can I call the above java class method from birt design? The above method should be use the BIRT connection object.
Thanks for your help in advance
Find more posts tagged with
Comments
mwilliams
You just want to know where to place this so that it's called before the dataSet? If so, have you tried the initialize method?
hkseeram
Yes, I tried in both initialize and before factory methods. In both methods the following code returns null value. I need this connection object to be passed to Java Class method. I am unable to pass this connection object (I am using JNDI connection pool).<br />
<br />
Connection con = (Connection) reportContext.getAppContext().get("OdaJDBCDriverPassInConnection" );<br />
<br />
Thanks<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="83002" data-time="1316462735" data-date="19 September 2011 - 01:05 PM"><p>
You just want to know where to place this so that it's called before the dataSet? If so, have you tried the initialize method?<br /></p></blockquote>
mwilliams
Do you have parameters linked to a dataSet? This may cause whatever dataSet you have linked to a parameter to run prior to the initialize event. I have heard people say when they've done their logging that the dataSet ran prior to the initialize method. If you have a dynamic parameter linked to a dataSet, you might try putting this in the beforeFactory of that dataSet in case something like this is happening.
hkseeram
I do have parameters linked to the dataset. As you suggested I tried in beforeFactory event. It is still returning null connection.<br />
<br />
import org.eclipse.birt.report.engine.api.script.IReportContext;<br />
import org.eclipse.birt.report.engine.api.script.element.IReportDesign;<br />
import org.eclipse.birt.report.engine.api.script.eventadapter.ReportEventAdapter;<br />
<br />
import java.sql.*;<br />
<br />
public class BirtEvents extends ReportEventAdapter {<br />
<br />
@Override<
;br />
public void beforeFactory(IReportDesign report, IReportContext reportContext) {<br />
Connection conn = (Connection) reportContext.getAppContext().get("OdaJDBCDriverPassInConnection");<br />
if (conn == null)<br />
System.out.println("BIRT JNDI connection failed");<br />
else<br />
System.out.println("BIRT JNDI connection Successful");<br />
<br />
}<br />
}<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="83010" data-time="1316468121" data-date="19 September 2011 - 02:35 PM"><p>
Do you have parameters linked to a dataSet? This may cause whatever dataSet you have linked to a parameter to run prior to the initialize event. I have heard people say when they've done their logging that the dataSet ran prior to the initialize method. If you have a dynamic parameter linked to a dataSet, you might try putting this in the beforeFactory of that dataSet in case something like this is happening.<br /></p></blockquote>