Welcome!

Tuesday, June 29, 2010

How to Implement Subreports using JasperReport and SpagoBI?

This article records the steps to implement subreports and their master report using JasperReport (iReport) and deploy them to SpagoBI reporting server.

Both sub-reports and master report are reports. Sub-reports, like building blocks, can be insert into master report to generate complex reports.

Environment
============
SpagoBI: version 2.5
Data Source: OE example database on Oracle 11g R2
iReport : version 3.7.3

We are going to create Order (master) report to show order level data and Order Items (sub-report) report to show order detail data.

1) Create a sub-report to display the order items detail for one order.

Open iReport, create the order items detail report -- “subreport_orderitems”

Report Query:

Report Layout:


2)
Create the master report to show order level data and insert the sub-report (detail) to show the order item level data.
Using iReport to create the master (order level) report -- “Master_Order”

Report Query:


Report Layout:

Sub-report Parameter:


Setup sub-report parameter(s) in master report will let master report know how to pass values to sub-0report.

Create a variable (parameter) -- “SBI_RESOURCE_PATH”

On SpagoBI reporting server, this variable will point to folder: Tomcat_home/resources/img/
Later, we will copy resource files (needed by this example) to the above folder on SpagoBI server.
On developer workstation (in iReport), we can set this variable a default value to point to a local folder where the image files reside.


Resource - Image Expression

And

Subreport Expression:

The subreport file (“subreport_orderitems”) should be just referenced (or pointed) by its name in master report (“Master_Order”).

Finally, test the Master / subreport.

3) Prepare to deploy to SpagoBI reporting server

Copy the resource files (in this example, two image files “coffee.jpg” and “coffee_stain.png”) from your local developing environment to the folder on SpagoBI reporting server: Tomcat_home/resources/img/

4) Deploy to SpagoBI reporting server

First, add an analytical driver for the parameter (in this example, the parameter name is “p_OrderID”) used in the report, as below:


You may also need to specify the “Roles Associations” and “Predefined Value Constraints” for this parameter.


Click the “Save and return” button.
Then, click “insert” button to insert the “Document” for sub-report:


Click the “Save and return” button.

Next, click “insert” button to insert a “Document” for the Master report:


Click the “Links” button to specify the sub-report document that this master (report) document will use.


Click the “Save and return” button.

Click the “Save and return” button.


Test the Master report:

Click “User Menu” --> “Documents Execution”, and run the report “OrderEntry_Master”:


Final report output:

Thursday, June 24, 2010

How to Tune SpagoBI + Tomcat

In the previous section, I showed how to install and config the Oracle data source connection in SpagoBI 2.5 step-by-step. This time, I will show the steps of tuning the SpagoBI 2.5 environment.

Environment
============
SpagoBI: version 2.5
OS Server: Windows server 2008 R2 (x64)
App Server: Tomcat 6.0.18 (in the SpagoBI demo package)
Java: JDK 1.6.0_20

Problems
============
Here is the screenshot of Tomcat console:


We can find three issues:
1) APR (Apache Portable Runtime) is not installed by default. APR is to provide superior scalability, performance, and better integration with native server technologies;
2) No persistent store is configured for session management;
3) There is log4j warning of log4j system not being initialized properly;

Fixes
=============
1) First, download APR from here, and save to folder like Tomcat_home\APR;


Then, open and edit file "Tomcat_home\bin\catalina.bat", and add one line after ":okHome", just like below:



2) Edit the file "context.xml" at "tomcat_home\webapps\SpagoBI\META-INF":


The same change can apply to other context file;

3) Edit the file "log4j.properties" at "tomcat_home\webapps\SpagoBIJPXMLAEngine\WEB-INF\classes":

Add the following 2 lines:


Save and restart Tomcat server.

Tuesday, June 22, 2010

How to Config SpagoBI with Oracle database?

SpagoBI is an open source business intelligence (BI) platform developed following FOSS philosophy. It covers all the BI areas (reporting tool, data mining, ETL tool, OLAP analysis, and BI dashboard).

This document records the steps to install and config the Oracle database connection as reporting data source in SpagoBI.

You can config the database connection using JNDI resource that is shared between reporting applications; or you can config JDBC data source connection, so, a new JDBC connection (non-shareable) will be created for each of reporting applications (document) execution.


Environment
============
SpagoBI: version 2.5
OS Server: Windows server 2008 R2 (x64)
App Server: Tomcat 6.0.18 (in the SpagoBI demo package)
Oracle database: 11g R2 (for windows x64)
JDBC driver: ojdbc5.jar (for JDK 1.5 or up)
Java: JDK 1.6.0_20

1. Create JNDI Data Source Connection

1) Download and unzip the file "Demo-SpagoBI-2.5.0-apache-tomcat-6.0.18-04092010.zip" to your local folder (like tomcathome\);
2) Copy the Oracle jdbc driver file "ojdbc5.jar" to your tomcathome\lib folder;
3) Edit the file "server.xml" at the folder "tomcathome\conf" and add / edit the following items:


4) Edit the file "context.xml" at the folder "tomcathome\webapps\SpagoBI\META-INF" as showing below:


5) Edit the file "context.xml" at the folder "tomcathome\webapps\SpagoBIJasperReportEngine\META-INF" as showing below:


6) Start Tomcat server to enable the above changes;

7) Log on to SpagoBI at http://localhost:8080/SpagoBI to create a data source connection:

Click "Resources" -> "Data Source"


Click Insert button (icon) to add a new data source


Enter the settings for the new data source


Test the new connection before you save and exit.



2. Create JDBC Connection

1) Download and unzip the file "Demo-SpagoBI-2.5.0-apache-tomcat-6.0.18-04092010.zip" to your local folder (like tomcathome\);
2) Copy the Oracle jdbc driver file "ojdbc5.jar" to your tomcathome\lib folder;
3) Start Tomcat server to enable the above changes;
4) Log on to SpagoBI at http://localhost:8080/SpagoBI to create a data source connection:

Click "Resources" -> "Data Source"


Click Insert button (icon) to add a new data source


Enter the settings for the new data source


Test the new connection before you save and exit.