® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon...

30
® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles

Transcript of ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon...

Page 1: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

®

IBM Software Group

© 2006 IBM Corporation

BIRT Integration with EGL

Damian Madden – Jon Sayles

Page 2: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

2Last update: 12/04/2007

Business Intelligence and Reporting Tools (BIRT)

An Eclipse-based open source reporting system

A mature Eclipse technology

Can create pdf/html reports

Can generate complex report design layouts: ListsChartsCross-tabulationLettersDocumentsCompound reports.

BIRT home page: http://www.eclipse.org/birt

Page 3: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

3Last update: 12/04/2007

BIRT Elements and Integration

out

out

outin

BIRT Design File (xml)

EGL JavaGen

Application

Generated report (html/PDF)

EGL BirtHandlerEGL BirtHandler

EGL ProgramEGL Program

BIRT Report DesignBIRT Report Design

Page 4: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

4Last update: 12/04/2007

Report Design Tool Report Design Perspective Create reports:

From scratch Using pre-fab layouts and templates

(see below) Tie reports directly to data sources:

Within Report Design perspective, can preview reports

From EGL BirtHandler and Program or Web page, can bass array to report

Each report element can customized extensively

U.I. Expressions (counters and

accumulators) Straightforward and Eclipse

development process

Page 5: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

5Last update: 12/04/2007

Report Design Preview Content Area tab when in

Report Design perspective

Allows you to analyze report with full data in view

Use as either: Standalone Report – if

running BIRT XML Design development tool –

if intending to execute BIRT report from EGL:

Program JSFHandler

Page 6: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

6Last update: 12/04/2007

BirtHandler EGL Part type

Called from EGL program or JSFHandler

which can pass an EGL dynamic array into the BirtHandler

The BirtHandler interacts with BIRT standard events

openEvent – reference to BIRT report data set (a data source)

fetchEvent - reference to

Page 7: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

7Last update: 12/04/2007

EGL Program That Invokes BirtHandler Report Design Perspective Create reports:

From scratch Using pre-fab layouts and

templates (see below) Tie reports directly to data

sources: Within Report Design

perspective, can preview reports

From EGL BirtHandler and Program or Web page, can bass array to report

Each report element can customized extensively

U.I. Expressions (counters and

accumulators) Straightforward and Eclipse

development process

Page 8: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

8Last update: 12/04/2007

BIRT Lab and Workshop

Let’s create an PDF report like this, using BIRT and a batch EGL program

The steps to do this start on the next slide.

Page 9: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

9Last update: 12/04/2007

Workshop and BIRT Steps

1. Download the BIRT Runtime2. Configure your project3. Watch the BIRT Report Design tutorial4. Create the Report_Design file5. Create the BIRTHandler6. Create the EGL Program that calls the

BIRTHandler7. Test

Page 10: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

10Last update: 12/04/2007

BIRT Runtime Download

Download BIRT runtime, birt-runtime-2.1.2.zip, from: http://download.eclipse.org/birt/downloads/

Note – there are a lot of different version of the Runtime. Please only download 2.1.2 – as no other versions work with EGL and RBD v7.1

From the BIRT site, select: Recent Builds Page Latest Releases:

2_1_2 Download the Report Engine

Page 11: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

11Last update: 12/04/2007

Project Configuration – 1 of 3

Unzip the downloaded Report Engine file into a directory on your PC

Set the project’s build descriptor option birtEngineHome to the location of the Report Engine directory in the BIRT runtime: e.g. C:\birt\birt-runtime-2_1_2\ReportEngine

Note that ReportEngine is a folder created by unzipping the download

Set your EGL Project Capabilities for BIRT From Window > Preferences

General– Capabilities

Select Advanced Expand EGL Developer and select EGL BIRT Click Apply then OK

Page 12: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

12Last update: 12/04/2007

Project Configuration – 2 of 3

Verify that your Default EGL Project Features Choices is BIRT enabled From Window > Preferences

EGL Check EGL with BIRT report support

Enable BIRT report support for the EGL project: Under Project > Properties, go to EGL Project

Features Check EGL with BIRT report support

Page 13: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

13Last update: 12/04/2007

Project Configuration – 3 of 3

To generate PDF reports, download the iText 1.5.2 jar file and add it to the project’s class path. It can be downloaded from:

http://prdownloads.sourceforge.net/itext/itext-1.5.2.jar

Once you’ve downloaded the file, open the Resource Perspective, and: From Windows, copy the file to your:

\src\ folder… and into the …

\WebContent\WEB-INF\lib folder

Close the Resource Perspective, and return to the Web Perspective

Page 14: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

14Last update: 12/04/2007

Watch the BIRT Tutorial

The BIRT site has two excellent tutorials for learning how to use the Report Design tool:

Flash movie with annotations

Step for Step tutorial

http://www.eclipse.org/birt/phoenix/tutorial/

Page 15: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

15Last update: 12/04/2007

Create Your Report Design Layout

From Project Explorer, create a \\reportsreports\\ folder under the EGLWeb project

Open the Report Design perspectiveReport Design perspective From the FileFile menu, create a new, report For the parent folder, specify the EGLWeb/reportsEGLWeb/reports Name the report: customerList.rptdesigncustomerList.rptdesign Click NextNext Note the abundance of cool report templates Select My First ReportMy First Report Click FinishFinish

Page 16: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

16Last update: 12/04/2007

Create the Report’s Data Source and Data Set

Open the Data Explorer view Right-click over Data Sources and create a

New Data Source As a Scripted Data SourceAs a Scripted Data Source

Named: Named: scrDataSourcescrDataSource

Right-click over Data Sets and create a Right-click over Data Sets and create a New Data SetNew Data Set Named: Named: scrDataSetscrDataSet With the four Output columns shownWith the four Output columns shown

And their Display NamesAnd their Display Names

When you are finished, your Data When you are finished, your Data Explorer should show the following Explorer should show the following defined resourcesdefined resources

Page 17: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

17Last update: 12/04/2007

Layout the Report Using the Data Set

From the Content Area, select the Layout tab From the Outline View, Select drag and drop the scrDataSet into the top left-hand corner of the

report layout, where it will create a report table as shown below Optionally open the Palette view on the left

Page 18: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

18Last update: 12/04/2007

Customize the Column Headers and Row Font

From the Content Area, click the left-most cell to select the column header row From the Property Editor – customize the properties

Change the Font type and make the column headers bold From General, change the row background color

Then, select the detail row, and change it’s font

Page 19: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

19Last update: 12/04/2007

Add a Total Expression

From the Palette, drag a Dynamic Text element into the Report, and add it to the footer row From the Expression Builder, select:

Category: BIRT Functions Sub-Category: Total Double-Click: count(filter, group_level): number Click OKOK

Page 20: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

20Last update: 12/04/2007

Add a Report Heading

From the Palette, drag a Label element into the top of the report Customize one or more of its General properties:

Background color Bold text Centered Text Color: White (if you make the background darker)

Page 21: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

21Last update: 12/04/2007

EGL BIRTHandler

From Project Explorer, create a new EGL BIRTHandler, in the programsprograms folder, named: arrayHandler

Copy paste the code in the ***Notes***Notes

Review the inline comments, note the following: The handler is

passed a dynamic array of customer records

Which it uses with the two reserved functions that fire automatically:

openFunction fetchFunction

fetchFunction adds values to the BIRT design report by calling the setColumnValue function (built into the BIRTHandler)

Page 22: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

22Last update: 12/04/2007

EGL Program Calling BIRTHandler

From Project Explorer, create a new, EGL Program in the programsprograms folder, named: BIRTHandler, named: birtReportProgram1

Copy paste the code in the ***Notes***Notes

Review the inline comments, note the following:

You must reference your input (Report Design file), and output file – as shown

You retrieve and process your dynamic array data (in this case, a sub-set of the Customer table)

You declare a variable of type: BIRTHandler, with the specific value shown

You pass your dynamic array to the BIRTHandler

And you call the EGL built-in functions to create the report

Page 23: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

23Last update: 12/04/2007

Produce the PDF Report

From Project Explorer, open the Java Resource:src folder, from the \programs\ sub-folder: Select

birtReportProgram1.java Right-click and:

Run asRun as Java ApplicationJava Application

This should create the PDF shown here

Optional things to do: Create an html page

(see next slide) From the tutorial, learn

how to: Customize the column

widths and row height Outline the State data Add a label to the Total

Count() value Do a grouped report

Page 24: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

24Last update: 12/04/2007

HTML Report

In this section we have just scratched the surface of what you can do with BIRT and EGL.

Page 25: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

25Last update: 12/04/2007

EGL JSFHandler Calling BIRTHandler

You can – if your project requirements dictate, call BIRT from a JSFHandler. You will need to configure your project to call BIRT. Below is the Use Case model for this. Let’s see what we need to do to make this work.

Special Thanks to Matt Heitz, for this one!

Special Thanks to Matt Heitz, for this one!

Output PDF

Selected rows

Page 26: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

26Last update: 12/04/2007

EGL JSFHandler Calling BIRTHandler – Configure Your Project – 1 of 2

Complete the following four tasks (starting on this slide)

1. Edit the deployment description for the Web module (web.xml).

Add a new EnvironmentVariable named birt.report.engine.home of type java.lang.String.

The value should be the location of the BIRT runtime.

This is the same value that you would place in the build descriptor option birtEngineHome.

2. (If you are using WebSphere Application Server) Edit the EAR's deployment descriptor

(application.xml). Set the web module's classloader policy to

PARENT_LAST.PARENT_LAST.

3. Ensure that the EGL program uses absolute paths to the report design files. Relative paths will not work. See the JSFHandler for an example of this

Page 27: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

27Last update: 12/04/2007

Step 4. RBD 7.1 includes BIRT version 2.1.2, which does not work on WAS 6.1. BIRT 2.1.3 has fixed this problem. You can download BIRT 2.1.3 from the link below. Once downloaded,

Copy the following files from the BIRT 2.1.3 ReportEngine\lib folder into the web module's WEB-INF\lib\WEB-INF\lib\ folder:

coreapi.jar engineapi.jar js.jar modelapi.jar scriptapi.jar

EGL JSFHandler Calling BIRTHandler – Configure Your Project – 2 of 2

Download BIRT 2.1.3 Runtime http://fullmoon.ottawa.ibm.com/birt/downloads/drops/R-R1-2_1_3-200707051847/birt-runtime-2.1.3.zip

Page 28: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

28Last update: 12/04/2007

EGL JSFHandler Calling BIRTHandler – Create the Page and JSFHandler

From Project Explorer: Create a new .JSP page, named: testBIRT.jsp

Modify the default page header text

Edit the JSFHandler

Delete the existing code, and replace it with the code in the slide ***Notes***Notes

Note the following: Absolute path to the

report_design file .pdf output file sel int[0]; array – used to

catch the rows the users select with the dataTable checkboxes

Looping through the sel[0] array, to populate the customersOut array, which is eventually written to the pdf file

Save your changes.Save your changes.

Page 29: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

29Last update: 12/04/2007

EGL JSFHandler Calling BIRTHandler – Create the Page

From Page Designer / From Page Data – Drag the customers[] array onto the

page, and select some columns – as output (read only) fields

With the entire dataTable selected, from Properties - Row actions

Click: Add selection column to the table

This will add a checkbox to the dataTable

With the checkbox selected, from the Value:

Click the icon Select the sel int [] array

Finally - Drag the writeToPDF function on to the page, where it will render as a Submit Button

Page 30: ® IBM Software Group © 2006 IBM Corporation BIRT Integration with EGL Damian Madden – Jon Sayles.

30Last update: 12/04/2007

Run the Page

Run the page on the server. Select any # of rows, and press: writeToPDF - this should create a file on your c:\ drive, called: reportOut.pdf. Open the file

C:\reportOut.pdf

Selected rows