You are on page 1of 74

Integrating Reporting into your Application

The BIRT Programming Interfaces

Scott Rosenbaum – Innovent Solutions, BIRT PMC


scottr@innoventsolutions.com

© 2008 by Scott Rosenbaum; made available under the EPL v1.0 | 3/11/2008
Getting The Examples
• Subversion Repository

http://longlake.minnovent.com/repos/birt_example

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
How was your spring vacation?

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Agenda
• Overview
• BIRT Home
• Running Reports
• Deployment Scenarios
• Develop Designs in Code
• Modify Designs using BIRT Event Handlers
• Extending BIRT

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
High Level BIRT Architecture

Report Designer 1 Report Engine

Eclipse Eclipse Chart Eclipse Data Charting


Report
Designer
DTP
ODA
Designer WTP Transform
Services
Engine 5
2 5 3 HTML
Generation Presentation
Report Design Engine Services Services PDF
DOC
4 XLS
Print
PS
XML Report CSV
Report Data Document
Design
Data

5 Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Pipeline with respect to the APIs
Report
Chart Builder
Designer

Report
Design Chart Engine Optional Java Events
Engine Engine
Paginated
JavaScript Events HTML
PDF
RptDesign
XML
Generation Phase Presentation Phase CSV
Design File
WORD
Report Engine XLS
PostScript
RptDocument PPT
Report
Document
optional

Example Web Viewer Contains

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT API Summary
• DEAPI - Design Engine Builds a Report
 Creates XML ‘rptdesign’
 Validates correct XML format
 Requires knowledge of the Report Object Model (ROM)
 More Difficult to Use
• REAPI - Report Engine Runs the Report
 Provides a relatively simple set of ‘Tasks’
 Run reports
 Render Reports
 Manipulate Parameters
 Extract Report Data

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT API Summary
• CEAPI - Chart Engine API
 Chart Engine
 Stand-Alone Charting
 Chart Designer
 Eclipse UI Chart Building Components
 Covered in Depth on Wednesday
• BIRT Extension
 Customize and Extend Standard BIRT Behavior
 Data
 Aggregates
 Report Items
 Emitters

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Runtime Home – What Is It?
• Bare Bones Eclipse Environment
 OSGi framework
 Platform Startup
 No UI Components
• Key BIRT Components
 Report Engine
 Design Engine (no UI)
 Chart Engine
 Data Tools Connectivity
 iText, Rhino, Batik

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Runtime Home – Layout
• Lib
 Eclipse Platform Startup code
 BIRT Interfaces
• Plugins
 Loaded through OSGi
 Implementation Code (REAPI, DEAPI, CEAPI…)
 ODA (add your drivers)
• Configuration
 config.ini
• Custom – need to add
 Extensions – add to plugins
 POJOs - add to class-path
Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT API OSGi Startup
• Platform Class
 Starts up required BIRT plug-ins
 Uses OSGi
 Used by DE and RE
 PlatformConfig class configures startup
 DesignConfig & EngineConfig extend PlatformConfig
 PlatformContext Class Sets Location of plug-ins
 Factory creates DesignEngine or ReportEngine

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
setPlatformContext( IPlatformContext )
Locates OSGi plug-ins
PlatformConfig setBIRTHome( location )
Set location of BIRT plug-ins

setOSGiArguments( String[] )
Configures OSGi

Extends Extends
EngineConfig Implements DesignConfig Implements
IEngineConfig IDesignConfig
Configure BIRT Configure BIRT

setLogConfig( location, level ) setResourceLocator( IResourceLocator )


Set logging variables (null location means no file) Builds your own resource locator

setAppContext( HashMap )
Adds Java Objects for scripting

setResourcePath( ResourceLocation )
Retrieves resources – Libs, Images, etc

setResourceLocator( IResourceLocator )
Builds your own resource locator

setTempDir( location )
birt.data.engine.memcachesize (default 10M)

setMaxRowsPerQuery( location )
Maximum Rows to Retrieve

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Platform
Starts up startup OSGi and create Factory Objects. Static methods.

Startup Shutdown createFactoryObject


Start Platform Stop Platform Launch a plugin: implements FactoryService Extension

DesignEngineFactory ReportEngineFactory
Design Engine API Report Engine API
Optionally
DataAdapterFactory
implement your Data Apater API
DataEngineFactory
Data Engine API Model to Data
OSGILauncher own
Startup IPlatformContext

IPlatformContext PlaformConfig: EngineConfig/DesignConfig


Location=getPlatform()

PlatformFileContext PlatformServletContext

•Looks for javax.servlet.context.tempdir


•Default PlatformContext
•Creates platform directory in tempdir
•Looks for plug-ins in BIRT_HOME
•Uses getResourcePaths for /WEB-INF/platform to locate plug-ins
•Copies plug-ins and configuration to tempdir/platform directory

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Report Engine Platform Startup Code
IReportEngine engine=null;
EngineConfig config = new EngineConfig;
config.setBIRTHome(“../ReportEngineProject");
try{
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory)
Platform.createFactoryObject(

IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

engine = factory.createReportEngine( config );

} catch ( Exception ex){


ex.printStackTrace();
}
Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Design Engine Platform Startup Code
IDesignEngine engine = null;
DesignConfig config = new DesignConfig( );
config.setBIRTHome(“/path2/BIRT/ReportEngine");
try{
Platform.startup( config );
IDesignEngineFactory factory =(IDesignEngineFactory)
Platform.createFactoryObject(

IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY
);
engine = factory.createDesignEngine( config );
} catch( Exception ex){
ex.printStackTrace();
}

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Platform Start Up - Logging
• BIRT core uses java.util.logging
 command line options
 jre/lib/logging.properties
 engineConfig.setLogConfig(fileName, Level)

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Platform Startup – ClassPath
• Standard Java Class Loader
• Class loader set through appContext
 WEBAPP_CLASSPATH_KEY
 WebViewer sets this through scriptlib parm
 PROJECT_CLASSPATH_KEY
 WORKSPACE_CLASSPATH_KEY
• What do you add – Why?
 Plug-ins are automatically added through OSGi (so don’t add
them to class path)
 Any other java classes that your reports call (through
expressions or event handlers) need to be added to the
classpath.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Platform Startup – Resource Home
• Designer
 Defaults to Project Home
 Configure : Windows => Preferences => Report Design => Resource
 Need to locate Resources in your deployment
engineConfig.setResourcePath(“path/to/resource/home”)
• Web Viewer
 BIRT_VIEWER_WORKING_FOLDER ${birt home}
 BIRT_VIEWER_DOCUMENT_FOLDER ${birt home}/documents
 BIRT_VIEWER_IMAGE_DIR ${birt home}/report/images
 BIRT_VIEWER_LOG_DIR ${birt home}/logs
 BIRT_VIEWER_LOG_LEVEL WARNING
 BIRT_VIEWER_SCRIPTLIB_DIR ${birt home}/scriptlib
 BIRT_RESOURCE_PATH ${birt home}
 BIRT_VIEWER_LOCALE

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Platform Startup/Shutdown
• Relatively Expensive Process
 IReportEngine
 IDesignEngine
 Thread-safe
 Save for re-use
• Shutdown
 Call reportEngine.destroy()
 Platform.shutdown()

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Platform Startup
• Demo

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Report Engine API
• Engine Tasks are used to implement operations
 RunAndRenderTask
 RunTask
 Render Task
 DataExtraction Task
 ParameterDetails Task
 Retrieves Parameter information
 Dynamic and Cascading Parameters
• Report Engine Basic Operation
 Open rptdesign
 Run Report
 Generate Report Output (HTML, PDF, Excel…)

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Set configuration variables such
EngineConfig
as Engine Home and Log
configuration

Open Report Design and Documents Create Engine Task

ReportEngine
Generate one or more tasks

Retrieve Parameters and their


GetParameterDefinitionTask
properties

RunAndRenderTask Does not support Pagination, TOC,


Bookmarks

DataExtractionTask Extract Data from Report Document

Generate Paginated HTML, XLS,


RunTask RenderTask
PDF Document, Postscript, XLS

RptDesign RptDocument
RptDesign
XML RptDocument
Report
RptDesign
XML
Design File RptDocument
Report
Document Retrieve TOC and Bookmarks
DesignXML
File Report
Document
Design File Document

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Runtime Demos
• Two Eclipse Projects
 Runtime Lib Project
 Runtime Example
• Demos
 RunAndRender
 Run Then Render
 Data Extraction
 Parameters
 Automated Report Testing

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment - Scenarios
APIs (DE API, CE API, RE API)

BIRT Tag
Libs

Web Viewer
Chart Tag Custom Servlet Web Viewer
Plugin
Libs

J2EE AS RCP Application Google Web Toolkit Standalone Application

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

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment - BIRT and Web Tools Project

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Web Viewer Servlet Mappings

Web Viewer Servlet Mappings

Use this mapping to launch the complete AJAX based report


frameset 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
run 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
preview
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.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Web Viewer Example
WebViewerExample
logs The default location for BIRT logs.
Location for class files used in a Scripted Data Source.
scriptlib
report Default location of Report Designs

webcontent
birt
ajax JavaScript files used with the Viewer
The Viewer example
JSP Fragmentsuses
usedato build the Viewer
pages
PlatformServletContext.
images Images
So by default the used by the Viewer
plug-ins
stylesare searchedCSSfor inused
files WEB-by the Viewer
WEB-INF INF/platform.
lib Location for BIRT required Jars.
platform
plug-ins BIRT required runtime plug-ins.
configuration Location for OSGi configuration files.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
WebViewer Tag Libraries
Birt.tld
Use this tag to display the complete Viewer inside an IFRAME.
viewer This tag allows you to use /frameset and /run mappings.

Use this tag to display the report inside an IFRAME or DIV tag.
report This tag allows you to use /preview mapping and does not create a
rptdocument. The AJAX Framework is not used.
Use this tag to set parameter values when using the viewer or report
param
tags. This tag must be nested within the viewer or report tag.

Use this tag to launch the BIRT Parameter dialog or to create a


parameterPage
customized parameter entry page. This tag can be used with the
/frameset, /run, or /preview mappings to launch the viewer after the
parameters are entered.

Use this Tag within a parameterPage tag to retrieve pre-generated


paramDef HTML for specific parameter control types such as radio, checkbox,
dynamic or cascaded parameters.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment - BIRT Tag Library
• Automatically deployed if using a Web Project or by deploying the Web
Viewer Example
• Can Deploy Tag Library in separate context by:
 Copy birt.tld to your /WEB-INF/tlds directory.
 Copy com.ibm.icu_3.6.1v20070417.jar, viewerservlets.jar, modelapi.jar,
coreapi.jar to your web-inf/lib directory. Add the following to the web.xml of
your application.
 <jsp-config>
 <taglib>
 <taglib-uri>/birt.tld</taglib-uri>
 <taglib-location>/WEB-INF/tlds/birt.tld</taglib-location>
 </taglib>
 </jsp-config>

 Use baseURL attribute to point to BIRT Context:


 <birt:report id="1" baseURL="/BirtWTP" isHostPage="false"
reportDesign="test.rptdesign"></birt:report>

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment – From a Servlet
Use Singleton to launch Design or Report
Engine. Start Platform on Servlet Startup and
shutdown Platform on Servlet destroy.
YourServletExample
logs The default location for BIRT logs.

report Default location of Report Designs

images UseDefault location for report images


PlatformServletContext
WEB-INF
lib Location for BIRT required Jars. Copy from
Runtime.
platform
plug-ins BIRT required runtime plug-ins. Copy from
runtime.
configuration Location for OSGi configuration files. Copy
from runtime.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment - Servlet Demo
• Example Servlet using the Report Engine

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment – RCP Application
• Using the BIRT plug-ins in Eclipse based applications

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
WebViewer Utility Class (RCPViewer Example)
• WebViewer.display()
• See Example for Options.
• Used with external browser or SWT Browser Widget.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Using the RE/DE API plug-ins in an RCP application

• Do not set BIRT Home and use engines as normal.


• See RCPEngine Example.
• Uses SWT Browser Widget.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Deployment – Google Web Toolkit
• Utility Classes
 Needed due to Asyncronous nature of GWT
 Client Side
 AsyncReportServices
 ReportItem
 Must extend isSerializable
 ServerSide
 BirtTasks
 RPC Web Services providing actual BIRT calls

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Develop Designs in Code
• Design Engine API
• Manipulate Report Designs, Templates and Libraries
• Build New Designs
• Modify Existing Designs
• Combine with 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

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Elements
• Elements – Report Objects such as
Table, Label, Style etc.
• Properties – Modify the Element
state and often support inheritance.
Discussed in ROM specification.
Simple and Complex properties.
• Slots – Describes element -
container relationships. For
example a Report element
contains slots for Data Sources,
Data Sets, Report Body, etc.
Represented by SlotHandle.

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Figuring Things Out
• Build it with the designer
• Explore the Outline view
• Explore the XML Source
• Property names and values are often static properties
 DesignChoiceConstants
 IStyleModel
 IReportItemModel
• ElementFactory to build new element
• StructureFactory to build new structures
• BIRT Source Test Cases

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Basic Report Elements
• Page Layout
• Data Source
• Data Sets
• Body
 Grids
 Tables
 Rows, Columns, Cells
 Data, Labels, Text, Charts
• Parameters
• Styles

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Getting Started
• Create a SessionHandle Instance (platform startup)
• Get the ReportDesignHandle
ReportDesignHandle reportDesignHandle = session.createDesign()
• Get the ElementFactory
ElementFactory eFactory = reportDesignHandle.getElementFactory()
• Build elements using ElementFactory
• Add new elements to the reportDesignHandle slots
 Master Page Slot
 Data Source Slot
 Data Set Slot
 Body Slot

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Basic Workflow
• Use ElementFactory to build new elements
• Populate simple properties
 Use static values where possible
• Populate complex properties
 Use StructureFactory to build new complex properties
• Add the elements to the appropriate parent slot
reportDesignHandle.getMasterPages().add(simpleMasterPage)
reportDesignHandle.getDataSources().add(dsHandle)
reportDesignHandle.getBody().add(tableHandle)
• Multi-Element Slots use lists
tableHandle.getDetail().getContents().add(rowHandle)

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Master Page Slot
• Create the simpleMasterPage
DesignElementHandle simpleMasterPage =
elementFactory().newSimpleMasterPage("Master Page");
• Customize the simpleMasterPage
simpleMasterPage.setProperty(“topMargin”, “0.5in”)
simpleMasterPage.setProperty(“orientation”, “portrait”)
• Add the element to the designHandle
reportDesignHandle.getMasterPages().add(simpleMasterPage)
• Creates the following XML element
<simple-master-page name="Simple MasterPage" id="2">
<property name="orientation">portrait</property>
<property name="topMargin">0.5in</property>
</simple-master-page>

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Data Sources
• Create the Data Source
OdaDataSourceHandle dsHandle = eFactory.newOdaDataSource

("srcClassicModels",“org.eclipse.birt.report.data.oda.jdbc")
• Set Data Source Properties
dsHandle.setProperty("odaDriverClass",
"org.eclipse.birt.report.data.oda.sampledb.Driver")
dsHandle.setProperty("odaURL", "jdbc:classicmodels:sampledb")
dsHandle.setProperty("odaUser", "ClassicModels")
• Add the Data Source to the report handle
reportDesignHandle.getDataSources().add(dsHandle);

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – DataSets
• Create the DataSet
OdaDataSetHandle dataSetHandle = eFactory.newOdaDataSet
("setOrderDetails",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");
• Set the Data Source
dataSetHandle.setDataSource("srcClassicModels");
• Set the query
dataSetHandle.setQueryText("Select * from ORDERDETAILS");
• Add columns (next page)
• Add to the reportHandle
reportDesignHandle.getDataSets().add(dataSetHandle);

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Add ResultSet Columns
• ResultSet Columns
PropertyHandle resultSet = dataSetHandle.getPropertyHandle
(ScriptDataSetHandle.RESULT_SET_PROP);
OdaResultSetColumn resultColumn =
StructureFactory.createOdaResultSetColumn();
resultColumn.setPosition(1);
resultColumn.setColumnName(“column_1”);
resultColumn.setDataType(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY)
resultSet.addItem(resultColumn);

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Add Computed Columns
PropertyHandle computedSet = dataSetHandle.getPropertyHandle
(ScriptDataSetHandle.COMPUTED_COLUMNS_PROP);
ComputedColumn compCol = StructureFactory.createComputedColumn();
compCol.setName("TotalAmount");
compCol.setExpression
("row[\"PRICEEACH\"] * row[\"ORDERQUANTITY\"]");
compCol.setDataType(DesignChoiceConstants.COLUMN_DATA_TYPE_DECIMAL);
computedSet.addItem(compCol);

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Body Element
TableHandle tHandle = elementFactory.newTableItem(“tbl",3,1,1,1);
tableHandle.setProperty(IStyleModel.TEXT_ALIGN_PROP,
DesignChoiceConstants.TEXT_ALIGN_CENTER);
tableHandle.setWidth("80%");
tableHandle.setProperty(IReportItemModel.DATA_SET_PROP,
"setOrderDetails");

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Body Element
• Create TableHandle
• Build table bindings
• Manipulate Slots
 Columns (ColumnHandle) tableHandle.getColumns().get(0)
 Rows (RowHandle) tableHandle.getHeader().get(0)
 Cells (CellHandle) rowHandle.getCells().get(0)
 Labels, TextItems, and DataItems
 Use ElementFactory to create and add to Cells

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEMO - Design Engine API Examples
• Build a Simple Report
• Data Sources and Data Sets
• Tables and Data Binding
• Slots, Groups, and Styles
• Parameters
• Modify Existing Design
• Access Libraries

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – BIRT Event Handlers
• Dynamically modify your design using the DEAPI
• Where to you modify the Design
 Better to think When not where
 BeforeFactory
 OnPrepare
 Later events are too late
• DataSets un-available at OnPrepare
 You can use REAPI and ParameterTask to get name / value
pairs

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Handles versus Items
• Two types of objects in BIRT
 Handles = design objects
 Items = instantiated objects
• Handles in OnPrepare or BeforeFactory
 Use the DEAPI
• Items are ‘tricky’
 Items are wrapped for scripting
 Script items do not provide full control
 Access to the ‘real’ item is tricky and discouraged

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Java vs JavaScript
• Java event handlers
(+) Easier to debug
(+) Easier to reuse
(+) Better code assist
(-) Strong type checking - requires frequent casts
(-) May introduce deploy issue
• JavaScript event handlers
(-) Harder to debug
(-) Harder to reuse (cut and paste or libraries)
(-) Code assist can be misleading
(+) No type checking means no casts
(+) Easy to deploy

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEAPI – Java vs JavaScript
• Drop a table in Java
IReportRunnable runnable = reportContext.getReportRunnable();
DesignElementHandle designHdl = runnable.getDesignHandle();
ModuleHandle moduleHdl = designHdl.getModuleHandle();
TableHandle tableHdl = (TableHandle)moduleHdl.findElement(“tbl1”);
tableHdl.drop();
• Drop a table in JavaScript
var runnable = reportContext.getReportRunnable();
var designHandle = runnable.designHandle.getDesignHandle();
designHandle.findElement("table1").drop();

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
DEMO – DEAPI BIRT Event Handlers
• JavaScript
 Drop a Table
 Add a DataSet Filter
• Java
 Modify a Table
 Debug using Runtime Engine
 Debug using Tester

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
BIRT Extensions
• Data Tool Extension Points
 DriverBridge
 Open Data Access (ODA)
 ODA UI
• BIRT Extension Points
 Aggregates
 Report Items
 Emitters
 Charts
• BIRT Extensions use Eclipse Plug-In Framework

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
What Is a Plug-In ?
• Plugins - Reusable component arch.
• Eclipse is built using Plug-ins
• Core Platform provides Extension Points
• BIRT extends the core Eclipse Plug-Ins
• You extend BIRT through extension points

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Interfaces vs. Adapters
• All BIRT Extensions are defined by an Interface
• Most extension interfaces have an adapter class
• Implement the Interface
 Required to implement all methods
 Interface changes may break your code
• Extend the Adapter
 Hides infrequently used interfaces
 Isolate implementation from an Interface change
 Recommended procedure

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Extension Contribution And Use

contributes
Extension Point: aggregation Extensions: aggregation

Exports: Classes:
- Aggregation implements
- MyAggegator
- Accumulator - MyAccumulator
- ….

Runs
org.eclipse.birt.report.data.adapter my.new.birt.aggregates

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
What is a Plug-in (more)
• A new plug-in:
 Uses dependency to resolve required classes
 Implements extension points through extensions
 Optionally – can export packages to clients
 Optionally – can create extension points
• Eclipse framework is based on OSGi framework R4.0
spec
 Eclipse plug-ins ≈ OSGi bundles

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Aggregate Extension Point
• Allows you to define your own aggregates
 Total.yourFunctionHere()
• Relatively easy to implement
 Create a Plug-in project
 Add Dependencies
 Fill-out Extension interface
 Implement Aggregate classes
 Aggregator extends Aggregation
 Accumulator extends Accumulator
 Test using Runtime Workbench instance

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
ODA = Open Data Architecture
• Create new data access components
 Data Sources
 Connect to the data
 Data Sets
 Specify what to get
 Can re-use same Data Source w/o re-connect
• Access to Non-Standard Data Sources
 Based on standard DataSource and DataSet UI
 Filter, Computed Columns, Preview, Joint Data Set are all
built in
 Report Developers use a Similar Drag and Drop UI

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
ODA Runtime Interfaces
IDriver
IResultSetMetaData
create: PlugIn
IQuery
prepare

execute IResultSet
IConnection
Generates data rows
getParameterMetaData
newQuery(dataSetType)

getMetaData IParameterMetaData
IAdvancedQuery If query uses params
Supports In/Out, complex param
Supports Blob/Clob Types
Supports multiple resultsets
IDataSetMetaData IParameterRowSet
Design time only
IBlob IClob Supports Complex
one per Data Set Type Parameter Types

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
ODA Runtime Sequence
• Initialize
• Prepare Query
• Execute Query
• Close

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
ODA DataSource Wizards
• RunTime Wizard
 Creates plugin.xml, manifest.mf, and plugin.properties
 Creates hard code example of ODA interfaces
 Works, but requires a Designer component
• DesignTime Wizard
 Creates simple UI for DataSource
 Uses Eclipse property editor
 Creates simple query based UI for DataSet

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
ReportItem Extension
• Add New Items to the Palette
 Charts are ReportItem extension
 Crosstab is a ReportItem extension
• Implements multiple extension points
 Report Object Model – How is persisted in the rptdesign
 Report Item UI – How does the designer interact
 Report Item Generation – What happens at run time
 Report Item Presentation – What happens at view time
• Creating ReportItem extensions is non-trivial
 Data handling, Presentation, Script handling, Styles
 UI Issues

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Report Object Model (simplified)

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Emitters – Interfaces
• IContentEmitter
 Walks through all of the components in the report
 Tables, Rows, Cells, Data, Styles, Script …
 Use ContentEmitterAdapter
 Stubs out required interfaces, implement as needed
• IEmitterServices
 Provides required info for emitter
 E.g. OutputStream, report name, report context, etc.
• IContentVisitor
• XMLWriter

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Emitters - Difficulty
• Data Dump Emitters
 Relatively trivial
 Walk through each component and wrap/write the value
• Full function Emitters
 Styles, links, actions, etc.
 Create numerous complex issues for layout and function
mapping
• Report Complexity = Emitter Complexity
 Complex report designs
 Require complex emitters

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Want More BIRT Talks?
• Introduction to BIRT 2.2
Tuesday 11:10 207 Paul Clenahan

• Because Size Matters :


Combining CDT and BIRT to Analyze Binary Code Size of Embedded Applications
Tuesday 14:00 209/210 Philippe Coucaud

• BIRT Chart API's


Tuesday 16:30 207 Jason Weathersby

• Using Eclipse BIRT in the real word seriously


Tuesday 16:30 Great America Ballroom JK Justin Miranda

• Getting the most from your BIRT reports


Wednesday 10:10 Ballroom E Virgil Dodson

• Introducing DTP Open Data Access Framework


Wednesday 13:30 Great America Room 2 Linda Chan

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
We’re not done yet…
• BIRT Short Talks
Wednesday 15:30 (5 talks in one hour) 203/204
Amazon Web Service Report Virgil Dodson
BIRT and Google Maps Mashup Pierre Tessier
BIRT and Google Web Toolkit John Ward
Charting Everywhere Philippe Coucaud
OpenDocument Format Spread-Sheet Emitter for BIRT Santosh Kumar

• Meeting customer’s reporting reqs by extending BIRT


Wednesday 4:30 207 Neil Wang, Wei Liu,
Santosh Kumar, Maged Elaasar

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Finally
• BIRT BOF - Birts of a Feather
Wednesday 8:45pm Grand Ballroom C
Talk to the BIRT tech leads about what you are doing, what you want to do,
how we can make the product better, etc.
We’re buying the beer …

• Come by the Actuate Booth at the Exhibitor Hall

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0
Questions?
• Thank You Very Much
• www.eclipse.org/birt
• birtworld.blogspot.com
• www.birt-exchange.com
• longlake.minnovent.com/repos/birt_example
 Example Code

• scottr@innoventsolutions.com

Integrating Reporting Into your Application | © 2008 by Scott Rosenbaum; made available under the EPL v1.0

You might also like