36
1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

Embed Size (px)

Citation preview

Page 1: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

1Actuate Corporation © 2007

BIRT Exchange

Integrating BIRT within your Applications

Jason WeathersbyBIRT Evangelist

Page 2: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

2Actuate Corporation © 2009

Agenda

• BIRT Overview

• BIRT Scripting

• BIRT Engine(s) Overview

• Deploying BIRT

• Deploying the BIRT Viewer

• Deploying a custom Servlet, which calls the BIRT APIs

• RCP Deployment

Page 3: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

3Actuate Corporation © 2009

Design Engine

Report Engine

Chart Engine

Produces XML Report, Templates, and Library Designs

Produces XML Report, Templates, and Library Designs

Runs Reports and produces output – PDF, HTML, Doc, XLS, PS, PPT Etc

Runs Reports and produces output – PDF, HTML, Doc, XLS, PS, PPT Etc

Consume Chart EMF model and produces Chart Output. Supports 13 Main types and many sub types. Ouputs to PNG, JPG, BMP, SVG, PDF, SWT, and SWING

Consume Chart EMF model and produces Chart Output. Supports 13 Main types and many sub types. Ouputs to PNG, JPG, BMP, SVG, PDF, SWT, and SWING

DE API

RE API

CE API

Can be ran outside of OSGi

Report Designer Chart Builder Example Viewer

Can be ran outside of BIRT

Core BIRT Open Source ProductsCore BIRT Open Source Products

High Level BIRT Architecture

Page 4: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

4Actuate Corporation © 2009

BIRT Designer

Page 5: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

5Actuate Corporation © 2009

BIRT Report EngineBIRT Report EngineBIRT Report EngineBIRT Report Engine

PresentationServices

PresentationServices

GenerationServices

GenerationServices

DataServices

DataServices

ChartingEngine

ChartingEngine

BIRT Report DesignerBIRT Report Designer BIRT Report DesignerBIRT Report Designer

Report Design EngineReport Design Engine

EclipseReportDesigner

EclipseReportDesigner

ChartDesigner

ChartDesigner

Eclipse DTP,WTP,…

Eclipse DTP,WTP,…

High Level BIRT Architecture: APIs

XMLReportDesign

ReportDocument

HTMLPDFExcelWordPowerPointPostScript…

Data

Data

Custom Report Designer UI

Report Engine API

Open Data Access

Chart Engine API

Emitter API

Chart UI API

Scripting API

Design Engine API

Page 6: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

6Actuate Corporation © 2009

BIRT Report EngineBIRT Report EngineBIRT Report EngineBIRT Report Engine

JavaScript Events

Optional Java Events

Generation Phase Presentation Phase

HTML

PDF

CSV

WORD

XLS

PS

PPT

RptDocumentReport

Document

BIRT Report DesignerBIRT Report Designer BIRT Report DesignerBIRT Report Designer Chart BuilderChart Builder Chart BuilderChart Builder

Report Design EngineReport Design Engine Charting EngineCharting Engine

RptDesignXML

Design File

BIRT Pipeline with respect to the APIs

Page 7: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

7Actuate Corporation © 2009

Agenda

BIRT Scripting

Page 8: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

8Actuate Corporation © 2009

Scripting

• BIRT JavaScript• Based on Mozilla Rhino

- This is Server Side Scripting not Browser Based Scripting• Two types of Scripting

Expression Scripts - Scripts that return a data value. Available in the Expression Builder.Element Scripts – JavaScript methods that are called

on events. Customize the behavior of the Report. Available in the Script view. Context of when the event occurs is important. Can also be implemented in Java.

• Element Scripts are Provided for Charts as well, but these scripts run at render time, not generation time.

• Java/JavaScripts Can be debugged within the designer

Page 9: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

9Actuate Corporation © 2009

Expression Scripting

Page 10: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

10Actuate Corporation © 2009

Expression Scripting – Example Locations

• Creating the display value for a report item• Creating a computed field in Data Explorer• Specifying a filter condition• Specifying a data series for a chart• Specifying a map condition• Specifying a highlight condition• Specifying a group key• Specifying a hyperlink• Specifying the URI for an image• Specifying dynamic data in a text control

Page 11: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

11Actuate Corporation © 2009

Report Scripting

JavaScript Events

Generation Phase

Report Levelinitialize

beforeFactoryafterFactoryonPageStartonPageEnd

Data Source/SetbeforeOpenafterOpenonFetch

beforeCloseafterClose

Report ElementonPrepareonCreate

onPageBreak

Report Levelinitialize

beforeRenderafterRender

Presentation Phase

Report ElementonRender

Optional Java Events

Chart EventsonRender

..

Master PageonPageStartonPageEnd

Page 12: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

12Actuate Corporation © 2009

Element Scripting

Page 13: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

13Actuate Corporation © 2009

Element Event Handlers using Java

• A set of Adapters are supplied that allow most event handlers to be built in Java.

• The class is a property of the element.

• Can be debugged with JDT using the BIRT Report Configuration.

• BIRT 2.5 adds new instance setting

Page 14: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

19Actuate Corporation © 2009

BIRT Scripting Demo

DEMO

See Hidden Slides for Event Orders

Page 15: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

20Actuate Corporation © 2009

Agenda

BIRT Engine(s) Overview

Page 16: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

21Actuate Corporation © 2009

Report Engine

• Used to Generate Report Documents.

• Used to Generate Report Output (PDF, HTML, Paginated HTML,WORD, XLS, Postscript)

• Engine Creates task to implement operations.

• One or Two Phase operation (Run Task then Render Task or RunAndRenderTask)

• DataExtraction Task for retrieving Data from a report document.

• ParameterDetails Task for retrieving Parameter information, including dynamic and cascading information.

Page 17: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

22Actuate Corporation © 2009

Report Engine Task

EngineConfig Set configuration variables such as Engine Home and Log configuration

ReportEngineGenerate one or more tasks

Open Report Design and Documents. Create Engine Task.

RptDesignXML

Design File

RptDesignXML

Design File

RptDesignXML

Design File

RptDocumentReport

Document

RptDocumentReport

Document

RptDocumentReport

Document

DataExtractionTask

GetParameterDefinitionTask

RunTask RenderTask

RunAndRenderTask

Retrieve Parameters and their properties

Does not support Pagination, TOC, Bookmarks.

Generate Paginated HTML, XLS, PDF Document, Postscript, XLS

Retrieve TOC and Bookmarks

Extract Data from Report Document

Page 18: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

23Actuate Corporation © 2009

Design Engine

• Used to Generate/Modify Report Designs, Templates and Libraries.

• Can be used in conjunction with the RE API to modify designs on the fly.

• Can be used within BIRT Script to modify designs on the fly.

• Create and delete report elements.

• Put report elements into slots.

• Get and set parameter values.

• Retrieve metadata from report elements, properties and slots.

• Undo/Redo

• Semantic Checks on report designs.

Page 19: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

24Actuate Corporation © 2009

Chart Engine - Two different Chart APIs

24

Optional Prepare Method. Called before Bind Data. In BIRT this sets up the Run Time Context

Page 20: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

25Actuate Corporation © 2009

Chart EngineChart Engine

Chart Engine Flow – ChartEngine Generator class

25

Chart ModelChart Model 2. bind data2. bind data

3. build3. build

4. render4. render

Device RendererDevice

Renderer

1. prepare1. prepare

dv.SWT

dv.PNG

dv.JPG

dv.PDF

dv.SVG

dv.SWING

dv.BMP

Page 21: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

26Actuate Corporation © 2009

BIRT OSGi Startup

• Platform Class

• Used to startup required BIRT Plugins.

• Uses OSGi.

• Needed by DE API, CE API and the RE API

• Uses a PlatformConfig class to configure the startup.

• DesignConfig and EngineConfig extend the PlatformConfig.

• PlatformContext Class Determines location of Plugins.

• Factory used to create DesignEngine or ReportEngine

Page 22: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

27Actuate Corporation © 2009

IPlatformContext setPlatformContextString Location=getPlatform()

PlatformUsed to startup OSGi and create Factory Objects. Static methods.

StartupStart the Platform

ShutdownStop the Platform

createFactoryObjectLaunch a plugin that implements the FactoryService Extension

ReportEngineFactoryReport Engine API

DesignEngineFactoryDesign Engine API

OSGILauncherStartup

PlatformServletContext

•Looks for javax.servlet.context.tempdir•Creates platform directory in tempdir•Uses getResourcePaths for /WEB-INF/platform to locate plugins•Copies plugins and configuration to the tempdir/platform directory

PlatformFileContext

•Default PlatformContext•Looks for Plugins in BIRT_HOME

PlaformConfig: EngineConfig/DesignConfig

Optionally implement your

own IPlatformContext

Platform Startup

Page 23: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

28Actuate Corporation © 2009

Platform Startup Code for DE, CE and RE API

Design Engine SampleIDesignEngine engine = null;DesignConfig config = new DesignConfig( );config.setBIRTHome("C:/birt/birt-runtime-2_5_1/

ReportEngine");try{Platform.startup( config );IDesignEngineFactory factory = (IDesignEngineFactory)

Platform.createFactoryObject( IDesignEngineFactory.EXTENSION_

DESIGN_ENGINE_FACTORY );engine = factory.createDesignEngine( config );

Report Engine SampleIReportEngine engine=null;EngineConfig config = new EngineConfig();config.setBIRTHome("C:/birt/birt-runtime-2_5_1/

ReportEngine");try{Platform.startup( config );IReportEngineFactory factory = (IReportEngineFactory)

Platform.createFactoryObject( IReportEngineFactory.EXTENSION_R

EPORT_ENGINE_FACTORY );engine = factory.createReportEngine( config );

Chart Engine SamplePlatformConfig pf = new PlatformConfig();

pf.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine");

ChartEngine ce = ChartEngine.instance(pf);

//non OSGi startup of CE

PlatformConfig pf = new PlatformConfig();

pf.setProperty("STANDALONE", true);

ChartEngine ce = ChartEngine.instance(pf);

Notes:

If you are using the APIs in an application that is already using OSGi and the BIRT plugins are deployed, alter the code like:

Confing.setBIRTHome(“”); and do not do a Platform.startup();

Only startup the platform once for the lifetime of your application.

Page 24: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

29Actuate Corporation © 2009

Engine Extras

• Using a supplied connection• JNDI• Connection Profiles• Driver Bridge• ODA App Context

config.getAppContext().put("OdaJDBCDriverClassPath", "c:/birt/mysql/mysql-connector-java-5.0.4-bin.jar");task.getAppContext().put("OdaJDBCDriverPassInConnection",

this.getConnection());

• ClassPath Management• Set the Parent Class loader

config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, yourclass.class.getClassLoader());

• Add to the class pathconfig.getAppContext().put(EngineConstants.WEBAPP_CLAS

SPATH_KEY, "c:/jars/mjo.jar");

Page 25: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

30Actuate Corporation © 2009

Calling the DE API from the RE API/Report Script

RE API Code

IReportRunnable design = null;

//Open the report design

design = engine.openReportDesign("Reports/TopNPercent.rptdesign");

ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle( );

report.findElement(“table1”).drop();

beforeFactory Script

reportContext.getDesignHandle().

findElement("table1").drop();

Simple DE API exist for use in script as well. See example.

Page 26: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

31Actuate Corporation © 2009

BIRT Engine Demo

DEMO

Page 27: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

32Actuate Corporation © 2009

Agenda

BIRT Deployment

Page 28: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

33Actuate Corporation © 2009

BIRT Deployment Scenarios

APIs (DE API, CE API, RE API)

Web Viewer

J2EE AS

Custom Servlet

BIRT Tag Libs

RCP Application Standalone Application

Web ViewerPlugin

Paginated HTML, PDF, XLS, WORD, PostScript, TOC, Bookmarks, CSV

Chart Tag Libs

Page 29: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

34Actuate Corporation © 2009

Main Web Viewer Servlet Mappings

Web Viewer Servlet Mappings

frameset

run

preview

Use this mapping to launch the complete AJAX based report viewer. Contains toolbar, navbar and table of contents features. Run and Render task are separated. This option will also create a rptdocument file.

Use this mapping to launch the viewer without the navbar, toolbar or table of contents. This mapping uses the RunAndRender task to create the output and does not support pagination and does not create a rptdocument. This mapping does use the AJAX framework to allow cancelling a report.

This mapping is used to RunAndRender a report directly to an output format, or to render an existing rptdocument directly to an output format. It does not use the AJAX framework, but will launch a parameter entry dialog.

Page 30: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

35Actuate Corporation © 2009

WebViewerExample

plugins

logs

scriptlib

WEB-INF

lib

BIRT required runtime plug-ins.

The default location for BIRT logs.

Location for BIRT required Jars.

platform

configuration Location for OSGi configuration files.

report

webcontent

birt

ajax

pages

images

styles

Location for class files used in a Scripted Data Source.

Default location of Report Designs

JavaScript files used with the Viewer

JSP Fragments used to build the Viewer

Images used by the Viewer

CSS files used by the Viewer

BIRT WebViewer Structure

Page 31: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

36Actuate Corporation © 2009

YourServletExample

plugins

logs

WEB-INF

lib

BIRT required runtime plug-ins. Copy from runtime.

The default location for BIRT logs.

Location for BIRT required Jars. Copy from Runtime.

platform

configuration Location for OSGi configuration files. Copy from runtime.

report

images

Default location of Report Designs

Default location for report images

Custom Servlet Deployment

Use Singleton to launch Design or Report Engine. Start Platform on

Servlet Startup and shutdown Platform on Servlet destroy.

Page 32: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

37Actuate Corporation © 2009

RCP Deployment

• Using the BIRT Plugins in Eclipse based applications

Page 33: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

38Actuate Corporation © 2009

WebViewer Utility Class see RCPViewer Example

• WebViewer.display()

• See Example for Options.

• Used with external browser or SWT Browser Widget.

• Use the BIRT Runtime download and add the plugins to your project – See example target

Page 34: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

39Actuate Corporation © 2009

Using the RE/DE API Plugins in an RCP application

• Do not set BIRT Home, Do not startup the Platform, and use engines as normal.

• See RCPEngine Example.

• Uses SWT Browser Widget.

• Use the BIRT Runtime download and add the plugins to your project – See example target

Page 35: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

40Actuate Corporation © 2009

BIRT Extensions Points

• BIRT is not just a tool but a framework.

• Predominant Extension Points.

• Emitter – Used to create additional output formats.

• ODA – DTP – Used to add customized Data Source Drivers

• Report Item – Used to extend the Palette with additional items.

• Chart Types – Used to add or extend chart types

Page 36: 1 Actuate Corporation © 2007 BIRT Exchange Integrating BIRT within your Applications Jason Weathersby BIRT Evangelist

41Actuate Corporation © 2009

ResourcesBIRT Exchange Community Site

Centralized hub for BIRT developers• Access demos, tutorials, tips and techniques, documentation…• Enables developers to be more productive and build applications faster• Marketplace for applications

Explore• Search/sort• Rate, comment• Forums

Download• Documentation• Software• Examples

Contribute• BIRT designs, code• Technical tips• Applicationswww.birt-exchange.comwww.birt-exchange.com