Birt Integration


Published on

Integrating BIRT in to Your Applications from Eclipse Summit Europe October 28, 2009

Published in: Technology, Education
1 Comment
  • Thank you. Very clearly and useful! I like it.
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • SWING is Graphics2D context SWT is GC context – PaintEvent.gc
  • Detailed in eclipse wiki
  • Birt Integration

    1. 1. Integrating BIRT Within Your Applications Mica J. Block Director, Actuate Corporate Engineers
    2. 2. Agenda <ul><li>BIRT Overview </li></ul><ul><li>BIRT Scripting </li></ul><ul><li>BIRT Engine(s) Overview </li></ul><ul><li>Deploying BIRT </li></ul><ul><ul><li>Deploying the BIRT Viewer </li></ul></ul><ul><ul><li>Deploying a custom Servlet, which calls the BIRT APIs </li></ul></ul><ul><ul><li>RCP Deployment </li></ul></ul>
    3. 3. Design Engine Report Engine Chart Engine Produces XML Report, Templates, and Library Designs 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 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 Products High Level BIRT Architecture
    4. 4. BIRT Designer
    5. 5. High Level BIRT Architecture: APIs BIRT Report Engine Presentation Services Generation Services Data Services Charting Engine BIRT Report Designer Report Design Engine Eclipse Report Designer Chart Designer Eclipse DTP, WTP,… XML Report Design Report Document HTML PDF Excel Word PowerPoint PostScript … 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
    6. 6. BIRT Report Engine JavaScript Events Optional Java Events Generation Phase Presentation Phase HTML PDF CSV WORD XLS PS PPT RptDocument Report Document BIRT Report Designer Chart Builder Report Design Engine Charting Engine RptDesign XML Design File BIRT Pipeline with respect to the APIs
    7. 7. BIRT Extensions Points <ul><li>BIRT is not just a tool but a framework. </li></ul><ul><li>Predominant Extension Points. </li></ul><ul><ul><li>Emitter – Used to create additional output formats. </li></ul></ul><ul><ul><li>ODA – DTP – Used to add customized Data Source Drivers </li></ul></ul><ul><ul><li>Report Item – Used to extend the Palette with additional items. </li></ul></ul><ul><ul><li>Chart Types – Used to add or extend chart types </li></ul></ul>
    8. 8. Agenda <ul><ul><ul><li>BIRT Scripting </li></ul></ul></ul>
    9. 9. Scripting <ul><li>BIRT JavaScript </li></ul><ul><ul><li>Based on Mozilla Rhino - This is Server Side Scripting not Browser Based Scripting </li></ul></ul><ul><ul><li>Two types of Scripting </li></ul></ul><ul><ul><ul><li>Expression Scripts - Scripts that return a data value. Available in the Expression Builder. </li></ul></ul></ul><ul><ul><ul><li>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. </li></ul></ul></ul><ul><ul><li>Element Scripts are Provided for Charts as well, but these scripts run at render time, not generation time. </li></ul></ul><ul><ul><li>Java and JavaScript can be debugged within the designer </li></ul></ul>
    10. 10. Expression Scripting
    11. 11. Expression Scripting – Example Locations <ul><li>Creating the display value for a report item </li></ul><ul><li>Creating a computed field in Data Explorer </li></ul><ul><li>Specifying a filter condition </li></ul><ul><li>Specifying a data series for a chart </li></ul><ul><li>Specifying a map condition </li></ul><ul><li>Specifying a highlight condition </li></ul><ul><li>Specifying a group key </li></ul><ul><li>Specifying a hyperlink </li></ul><ul><li>Specifying the URI for an image </li></ul><ul><li>Specifying dynamic data in a text control </li></ul>
    12. 12. Report Scripting JavaScript Events Generation Phase Report Level initialize beforeFactory afterFactory onPageStart onPageEnd Data Source/Set beforeOpen afterOpen onFetch beforeClose afterClose Report Element onPrepare onCreate onPageBreak Report Level initialize beforeRender afterRender Presentation Phase Report Element onRender Optional Java Events Chart Events onRender .. Master Page onPageStart onPageEnd
    13. 13. Element Scripting
    14. 14. Element Event Handlers using Java <ul><li>A set of Adapters are supplied that allow most event handlers to be built in Java. </li></ul><ul><li>The class is a property of the element. </li></ul><ul><li>Can be debugged with JDT using the BIRT Report Configuration. </li></ul><ul><li>BIRT 2.5 adds new instance setting </li></ul>
    15. 15. Events - Run then Render Pipeline (Web viewer) General Order Generation Phase Initialize onPrepare beforeFactory beforeOpen afterOpen onFetch onPrepare onPrepare onCreate beforeClose afterClose onCreate onCreate Table Row DataItem Data Set Report afterFactory Presentation Phase beforeRender onRender onRender onRender afterRender
    16. 16. Events - Run & Render Pipeline (Default Preview) Initialize onPrepare beforeFactory beforeRender beforeOpen afterOpen onFetch onPrepare onPrepare onCreate onRender beforeClose afterClose onCreate onRender onCreate onRender afterRender afterFactory Table Row DataItem Data Set Report
    17. 17. Chart Generation Events General Order beforeDataSetFilled iterate Events afterDataSetFilled beforeGeneration beforeComputations afterComputations afterGeneration
    18. 18. Chart Render Events General Order beforeRendering Next Slide beforeDrawBlock - Main afterDrawBlock - Main beforeDrawBlock - Title afterDrawBlock - Title beforeDrawBlock - Plot beforeDrawMarkerRange afterDrawMarkerRange beforeDrawMarkerLine afterDrawMarkerLine beforeDrawSeries -base afterDrawSeries - base afterDrawBlock - Plot beforeDrawBlock – Plot – for each series beforeDrawSeries beforeDrawDataPoint afterDrawDataPoint beforeDrawFittingCurve afterDrawFittingCurve afterDrawSeries afterDrawBlock – Do not call after last series beforeDrawDataPointLabel afterDrawDataPointLabel Series Render Event order vary depending on Renderer – Bar chart shown RenderSeries iterate Events
    19. 19. Chart Render Events General Order Previous Slide afterRendering For Each Axis beforeDrawAxisLabel afterDrawAxisLabel beforeDrawAxisTitle afterDrawAxisTitle afterDrawBlock - Plot iterate Chart With Axis beforeDrawBlock - Legend beforeDrawLegendItem afterDrawLegendItem afterDrawBlock - Legend Events
    20. 20. BIRT Scripting Demo DEMO
    21. 21. Agenda <ul><ul><ul><li>BIRT Engine(s) Overview </li></ul></ul></ul>
    22. 22. Report Engine <ul><li>Used to Generate Report Documents. </li></ul><ul><li>Used to Generate Report Output (PDF, HTML, Paginated HTML,WORD, XLS, Postscript) </li></ul><ul><li>Engine Creates task to implement operations. </li></ul><ul><li>One or Two Phase operation (Run Task then Render Task or RunAndRenderTask) </li></ul><ul><li>DataExtraction Task for retrieving Data from a report document. </li></ul><ul><li>ParameterDetails Task for retrieving Parameter information, including dynamic and cascading information. </li></ul>
    23. 23. Report Engine Task EngineConfig Set configuration variables such as Engine Home and Log configuration ReportEngine Generate one or more tasks Open Report Design and Documents. Create Engine Task. 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 RptDesign XML Design File RptDesign XML Design File RptDesign XML Design File RptDocument Report Document RptDocument Report Document RptDocument Report Document
    24. 24. Design Engine <ul><li>Used to Generate/Modify Report Designs, Templates and Libraries. </li></ul><ul><li>Can be used in conjunction with the RE API to modify designs on the fly. </li></ul><ul><li>Can be used within BIRT Script to modify designs on the fly. </li></ul><ul><li>Create and delete report elements. </li></ul><ul><li>Put report elements into slots. </li></ul><ul><li>Get and set parameter values. </li></ul><ul><li>Retrieve metadata from report elements, properties and slots. </li></ul><ul><li>Undo/Redo </li></ul><ul><li>Semantic Checks on report designs. </li></ul>
    25. 25. Chart Engine - Two different Chart APIs Optional Prepare Method. Called before Bind Data. In BIRT this sets up the Run Time Context
    26. 26. Chart Engine Flow – ChartEngine Generator class Chart Engine Chart Model 2. bind data 3. build 4. render Device Renderer 1. prepare <ul><ul><ul><li>dv.SWT </li></ul></ul></ul><ul><ul><ul><li>dv.PNG </li></ul></ul></ul><ul><ul><ul><li>dv.JPG </li></ul></ul></ul><ul><ul><ul><li>dv.PDF </li></ul></ul></ul><ul><ul><ul><li>dv.SVG </li></ul></ul></ul><ul><ul><ul><li>dv.SWING </li></ul></ul></ul><ul><ul><ul><li>dv.BMP </li></ul></ul></ul>
    27. 27. Platform Startup Code for DE, CE and RE API <ul><li>Design Engine Sample </li></ul><ul><li>IDesignEngine engine = null ; </li></ul><ul><li>DesignConfig config = new DesignConfig( ); </li></ul><ul><li>config.setBIRTHome(&quot;C:/birt/birt-runtime-2_5_1/ReportEngine&quot;); </li></ul><ul><li>try { </li></ul><ul><li>Platform. startup ( config ); </li></ul><ul><li>IDesignEngineFactory factory = (IDesignEngineFactory) Platform </li></ul><ul><li>. createFactoryObject ( IDesignEngineFactory. EXTENSION_DESIGN_ENGINE_FACTORY ); </li></ul><ul><li>engine = factory.createDesignEngine( config ); </li></ul><ul><li>Report Engine Sample </li></ul><ul><li>IReportEngine engine= null ; </li></ul><ul><li>EngineConfig config = new EngineConfig(); </li></ul><ul><li>config.setBIRTHome(&quot;C:/birt/birt-runtime-2_5_1/ReportEngine&quot;); </li></ul><ul><li>try { </li></ul><ul><li>Platform. startup ( config ); </li></ul><ul><li>IReportEngineFactory factory = (IReportEngineFactory) Platform </li></ul><ul><li>. createFactoryObject ( IReportEngineFactory. EXTENSION_REPORT_ENGINE_FACTORY ); </li></ul><ul><li>engine = factory.createReportEngine( config ); </li></ul>Chart Engine Sample PlatformConfig pf = new PlatformConfig(); pf.setBIRTHome(&quot;C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine&quot;); ChartEngine ce = ChartEngine.instance(pf); //non OSGi startup of CE PlatformConfig pf = new PlatformConfig(); pf.setProperty(&quot;STANDALONE&quot;, 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.
    28. 28. Engine Extras <ul><li>Using a supplied connection </li></ul><ul><ul><li>JNDI </li></ul></ul><ul><ul><li>Connection Profiles </li></ul></ul><ul><ul><li>Driver Bridge </li></ul></ul><ul><ul><li>ODA App Context </li></ul></ul><ul><ul><ul><li>config.getAppContext().put(&quot;OdaJDBCDriverClassPath&quot;, &quot;c:/birt/mysql/mysql-connector-java-5.0.4-bin.jar&quot;) ; </li></ul></ul></ul><ul><ul><ul><li>task.getAppContext().put(&quot;OdaJDBCDriverPassInConnection&quot;, this .getConnection()); </li></ul></ul></ul><ul><li>ClassPath Management </li></ul><ul><ul><li>Set the Parent Class loader </li></ul></ul><ul><ul><ul><li>config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, yourclass.class.getClassLoader()); </li></ul></ul></ul><ul><ul><li>Add to the class path </li></ul></ul><ul><ul><ul><li>config.getAppContext().put(EngineConstants.WEBAPP_CLASSPATH_KEY, &quot;c:/jars/mjo.jar&quot;); </li></ul></ul></ul>
    29. 29. Calling the DE API from the RE API/Report Script <ul><li>RE API Code </li></ul><ul><li>IReportRunnable design = null; </li></ul><ul><li>//Open the report design </li></ul><ul><li>design = engine.openReportDesign(&quot;Reports/TopNPercent.rptdesign&quot;); </li></ul><ul><li>ReportDesignHandle report = (ReportDesignHandle) design.getDesignHandle( ); </li></ul><ul><li>report.findElement(“table1”).drop(); </li></ul><ul><li>beforeFactory Script </li></ul><ul><li>reportContext.getReportRunnable(). </li></ul><ul><li>designHandle.getDesignHandle(). </li></ul><ul><li>findElement(&quot;table1&quot;).drop(); </li></ul><ul><li>Simple DE API exist for use in script as well. </li></ul>
    30. 30. Agenda <ul><ul><ul><li>BIRT Deployment </li></ul></ul></ul>
    31. 31. BIRT Deployment Scenarios APIs (DE API, CE API, RE API) Web Viewer J2EE AS Custom Servlet BIRT Tag Libs RCP Application Standalone Application Web Viewer Plugin Paginated HTML, PDF, XLS, WORD, PostScript, TOC, Bookmarks, CSV Chart Tag Libs
    32. 32. 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.
    33. 33. 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
    34. 34. 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.
    35. 35. RCP Deployment <ul><li>Using the BIRT Plug-ins in Eclipse based applications </li></ul>
    36. 36. WebViewer Utility Class see RCPViewer Example <ul><li>WebViewer.display() </li></ul><ul><li>See Example for Options. </li></ul><ul><li>Used with external browser or SWT Browser Widget. </li></ul><ul><li>Use the BIRT Runtime download and add the plugins to your project – See example target </li></ul>
    37. 37. Using the RE/DE API Plugins in an RCP application <ul><li>Do not set BIRT Home, Do not startup the Platform, and use engines as normal. </li></ul><ul><li>See RCPEngine Example. </li></ul><ul><li>Uses SWT Browser Widget. </li></ul><ul><li>Use the BIRT Runtime download and add the plugins to your project – See example target </li></ul>
    38. 38. BIRT Engine and Deployment Demo <ul><li> </li></ul><ul><li> </li></ul>DEMO
    39. 39. BIRT Momentum: Publications BIRT: A Field Guide to Reporting 2nd Edition Integrating and Extending BIRT 2nd Edition Practical Data Analysis and Reporting with BIRT Eclipse BIRT: Business Intelligence und Reporting Tool
    40. 40. Resources BIRT Exchange Community Site <ul><li>Centralized hub for BIRT developers </li></ul><ul><li>Access demos, tutorials, tips and techniques, documentation… </li></ul><ul><li>Enables developers to be more productive and build applications faster </li></ul><ul><li>Marketplace for applications </li></ul><ul><li>Explore </li></ul><ul><li>Search/sort </li></ul><ul><li>Rate, comment </li></ul><ul><li>Forums </li></ul><ul><li>Download </li></ul><ul><li>Documentation </li></ul><ul><li>Software </li></ul><ul><li>Examples </li></ul><ul><li>Contribute </li></ul><ul><li>BIRT designs, code </li></ul><ul><li>Technical tips </li></ul><ul><li>Applications </li></ul>