Deploying the BIRT Engine Jason Weathersby BIRT Evangelist
Deploying the BIRT Engine Jason Weathersby BIRT Evangelist Actuate Corporation 1 2007 Actuate International User Conference ©
Agenda • • BIRT Overview BIRT Report Engine API BIRT Design Engine API Deploying BIRT Deployment Wizard and the BIRT Viewer BIRT Tag Library Custom Servlet RCP Deployment 2 2007 Actuate International User Conference ©
High Level BIRT Architecture Report Designer Eclipse Report Designer 1 Eclipse DTP ODA Report Engine Chart Designer 2 5 Eclipse WTP 3 Report Design Engine XML Report Design Data Transform. Services Charting Engine Generation Services Presentation Services 4 Data 33 2007 Actuate International User Conference © 5 Report Document HTML PDF DOC XLS Print PS CSV PPT
Agenda BIRT Project = Business Intelligence and Reporting Tools Project BIRT APIs 4 2007 Actuate International User Conference ©
BIRT Pipeline with respect to the APIs Report Designer Design Engine Chart Builder Chart Engine Report Engine Optional Java Events Java. Script Events Rpt. Design XML Design File Paginated HTML PDF Generation Phase Presentation Phase CSV WORD Report Engine XLS Post. Script optional Rpt. Document Report Document Example Web Viewer Contains 5 2007 Actuate International User Conference © PPT
Platform Startup Platform Used to startup OSGi and create Factory Objects. Static methods. Startup Start the Platform Shutdown Stop the Platform create. Factory. Object Launch a plugin that implements the Factory. Service Extension Design. Engine. Factory Design Engine API OSGILauncher Startup Optionally implement your own IPlatform. Context set. Platform. Context String Location=get. Platform() Platform. File. Context • Default Platform. Context • Looks for Plugins in BIRT_HOME 6 2007 Actuate International User Conference © Report. Engine. Factory Report Engine API Plaform. Config: Engine. Config/Design. Config Platform. Servlet. Context • Looks for javax. servlet. context. tempdir • Creates platform directory in tempdir • Uses get. Resource. Paths for /WEB-INF/platform to locate plugins • Copies plugins and configuration to the tempdir/platform directory
Platform Startup Code for DE and RE API Design Engine Sample Report Engine Sample IDesign. Engine engine = null; Design. Config config = new Design. Config( ); config. set. BIRTHome("C: /birt-runtime 2. 2. 0 m 5 rc/birt-runtime-2_2_0/Report. Engine"); try{ IReport. Engine engine=null; Engine. Config config = new Engine. Config; config. set. BIRTHome("C: /birt-runtime 2. 2. 0 m 5 rc/birt-runtime-2_2_0/Report. Engine"); try{ Platform. startup( config ); IDesign. Engine. Factory factory = (IDesign. Engine. Factory) Platform. create. Factory. Object( IDesign. Engine. Factory. EXTENSION_DESIGN_ ENGINE_FACTORY ); engine = factory. create. Design. Engine( config ); Platform. startup( config ); IReport. Engine. Factory factory = (IReport. Engine. Factory) Platform. create. Factory. Object( IReport. Engine. Factory. EXTENSION_REPORT _ENGINE_FACTORY ); engine = factory. create. Report. Engine( config ); }catch( Exception ex){ ex. print. Stack. Trace(); } 7 2007 Actuate International User Conference ©
Report Engine API • 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 Run. And. Render. Task) Data. Extraction Task for retrieving Data from a report document. Parameter. Details Task for retrieving Parameter information, including dynamic and cascading information. 8 2007 Actuate International User Conference ©
Report Engine Task Engine. Config Set configuration variables such as Engine Home and Log configuration Open Report Design and Documents. Create Engine Task. Report. Engine Generate one or more tasks Retrieve Parameters and their properties Get. Parameter. Definition. Task Does not support Pagination, TOC, Bookmarks. Run. And. Render. Task Data. Extraction. Task Run. Task Rpt. Design XML Design File 9 2007 Actuate International User Conference © Render. Task Rpt. Document Report Document Extract Data from Report Document Generate Paginated HTML, XLS, PDF Document, Postscript, XLS Retrieve TOC and Bookmarks
Simple RE API Process Engine. Config config = new Engine. Config( ); config. set. BIRTHome("C: /birt-runtime/Report. Engine"); IReport. Engine engine = null; try{ Report. Engine Create the report engine. open. Report. Design(report) Open Design create. Run. And. Render. Task(design) Create an Engine Task. HTMLRender. Options() Set rendering options. set. Render. Options(options) Set the task render options. run() Run and Render the report. Platform. startup( config ); IReport. Engine. Factory factory = (IReport. Engine. Factory) Platform. create. Factory. Object( IReport. Engine. Factory. EXTENSION_REPORT_ENGIN E_FACTORY ); engine = factory. create. Report. Engine( config ); }catch( Exception ex){ } IReport. Runnable design = null; design = engine. open. Report. Design(“Top. NPercent. rptdesign"); IRun. And. Render. Task task = engine. create. Run. And. Render. Task(design); HTMLRender. Option options = new HTMLRender. Option(); options. set. Output. File. Name("output/resample/Top. NPer cent. html"); options. set. Output. Format("html"); 10 2007 Actuate International User Conference © task. set. Render. Option(options); task. run();
REAPI examples • REAPI Examples 11 2007 Actuate International User Conference ©
Design Engine API • 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. 12 2007 Actuate International User Conference ©
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 Slot. Handle. 13 2007 Actuate International User Conference ©
Simple DE API Process Design. Engine Create the design engine. new. Session. Handle(Locale) Design. Session used to create reports, libs, etc create. Design() Returns a Report. Design. Handle. get. Element. Factory() Returns Element. Factory to Create Report Elements. Design. Config config = new Design. Config( ); config. set. BIRTHome("C: /birt-runtime/Report. Engine"); IDesign. Engine engine = null; try{ Platform. startup( config ); IDesign. Engine. Factory factory = (IDesign. Engine. Factory) Platform. create. Factory. Object( IDesign. Engine. Factory. EXTENSION_DESIGN_ENGINE _FACTORY ); engine = factory. create. Design. Engine( config ); }catch( Exception ex){ } get. Body() Returns Slot. Handle use add to add new report element. Session. Handle session = engine. new. Session. Handle( ULocale. ENGLISH ) ; Report. Design. Handle design = session. create. Design( ); Dessign. Session. save. As() Save Report Design. Element. Factory factory = design. get. Element. Factory( ); Grid. Handle grid = factory. new. Grid. Item( “mygrid”, 2 , 1 ); design. get. Body( ). add( grid ); design. save. As( "output/desample/sample. rptdesign" ); 14 2007 Actuate International User Conference ©
Element. Factory Used to create new Report Elements. Use container Slot. Handle. add. Produces Slot. Handle Label. Handle label 1 = element. Factory. new. Label("Label 1" ); Slot. Handle label 1. set. Text("Customer"); Cell. Handle cell = (Cell. Handle) tableheader. get. Cells( ). get( 0 ); cell. get. Content( ). add( label 1 ); 15 2007 Actuate International User Conference © Design. Element. Handle. <cell id="6"> Cast specific handle <labeltoname="Label 1" id="7"> <text-property name="text">Customer</textproperty> </label> </cell>
Structure. Factory Used to create new structures (complex xml). Use Property. Handle on container to add. Produces Highlight. Rule hr = struct. Factory. create. Highlight. Rule(); hr. set. Operator(Design. Choice. Constants. MAP_OPERATOR_GT); hr. set. Test. Expression("row["Customer. Credit. Limit"]"); hr. set. Value 1("100000"); hr. set. Property(Highlight. Rule. BACKGROUND_COLOR_MEMBER, "blue"); Property. Handle ph = th. get. Property. Handle(Style. Handle. HIGHLIGHT_RULES_PROP); ph. add. Item(hr); 16 2007 Actuate International User Conference © <list-property name="highlight. Rules"> <structure> <property name="operator">gt</property> <property name="background. Color">blue</property> <expression name="test. Expr">row["Customer. Credit. Limit"]</expression> <expression name="value 1">100000</expression> </structure> </list-property>
Calling the DE API from the RE API/Report Script RE API Code before. Factory Script IReport. Runnable design = null; //Open the report design = engine. open. Report. Design("Reports/Top NPercent. rptdesign"); report. Context. get. Report. Runnable(). design. Handle. get. Design. Handle(). find. Element("table 1"). drop(); Report. Design. Handle report = (Report. Design. Handle) design. get. Design. Handle( ); report. find. Element(“table 1”). drop(); 17 2007 Actuate International User Conference © Simple DE API exist for use in script as well. See example.
DEAPI examples • DEAPI Examples 18 2007 Actuate International User Conference ©
Agenda BIRT Project = Business Intelligence and Reporting Tools Project BIRT Deployment 19 2007 Actuate International User Conference ©
BIRT Deployment Scenarios APIs (DE API, CE API, RE API) BIRT Tag Libs Chart Tag Libs Custom Servlet J 2 EE AS Web Viewer Plugin RCP Application Standalone Application Paginated HTML, PDF, XLS, WORD, Post. Script, TOC, Bookmarks, CSV 20 2007 Actuate International User Conference ©
BIRT Web Project 21 2007 Actuate International User Conference ©
Web Viewer Servlet Mappings frameset run 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 Run. And. Render 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. preview This mapping is used to Run. And. Render 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. parameter This mapping is used by the designer to create a rptconfig file, when selecting the preview tab for a report that contains parameters and should not be used externally. download 22 2007 Actuate International User Conference © Used internally by the viewer (frameset) when extracting the results in csv format. Should not be used externally. Hidden form created in Birt. Simple. Export. Data. Dialog. js and submitted to Servlet to process.
BIRT Web. Viewer Structure Web. Viewer. Example The default location for BIRT logs scriptlib Location for class files used in a Scripted Data Source. Default location of Report Designs report webcontent birt ajax pages images styles Java. Script files used with the Viewer JSP Fragments used to build the Viewer Images used by the Viewer CSS files used by the Viewer WEB-INF lib Location for BIRT required Jars. platform plugins 23 2007 Actuate International User Conference © configuration BIRT required runtime plug-ins. Location for OSGi configuration files.
Web Project Demo • Example using the Web Project 24 2007 Actuate International User Conference ©
Web. Viewer Tag Libraries Birt. tld viewer Use this tag to display the complete Viewer inside an IFRAME. This tag allows you to use /frameset and /run mappings. report Use this tag to display the report inside an IFRAME or DIV tag. This tag allows you to use /preview mapping and does not create a rptdocument. The AJAX Framework is not used. param Use this tag to set parameter values when using the viewer or report tags. This tag must be nested within the viewer or report tag. parameter. Page Use this tag to launch the BIRT Parameter dialog or to create a 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. param. Def 25 2007 Actuate International User Conference © Use this Tag within a parameter. Page tag to retrieve pre-generated HTML for specific parameter control types such as radio, checkbox, dynamic or cascaded parameters.
BIRT Tag Library Deployment • 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. 1 v 20070417. 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-uri>/birt. tld</taglib-uri> <taglib-location>/WEB-INF/tlds/birt. tld</taglib-location> </taglib> </jsp-config> • Use base. URL attribute to point to BIRT Context: • <birt: report id="1" base. URL="/Birt. WTP" is. Host. Page="false" report. Design="test. rptdesign"></birt: report> 26 2007 Actuate International User Conference ©
Tag Library Demo • Example Tag Library Usage Demo 27 2007 Actuate International User Conference ©
Custom Servlet Deployment Use Singleton to launch Design or Report Engine. Start Platform on Servlet Startup and shutdown Platform on Servlet destroy. Your. Servlet. Example logs The default location for BIRT logs. report Default location of Report Designs Use. Default location for report images Platform. Servlet. Context See example images WEB-INF lib Location for BIRT required Jars. Copy from Runtime. platform plugins configuration 28 2007 Actuate International User Conference © BIRT required runtime plug-ins. Copy from runtime. Location for OSGi configuration files. Copy from runtime.
Custom Servlet Demo • Example Servlet using the Report Engine 29 2007 Actuate International User Conference ©
RCP Deployment • Using the BIRT Plugins in Eclipse based applications 30 2007 Actuate International User Conference ©
Web. Viewer Utility Class see RCPViewer Example • Web. Viewer. display() • See Example for Options. • Used with external browser or SWT Browser Widget. 31 2007 Actuate International User Conference ©
Using the RE/DE API Plugins in an RCP application • Do not set BIRT Home and use engines as normal. • See RCPEngine Example. • Uses SWT Browser Widget. 32 2007 Actuate International User Conference ©
Questions? • Resources • BIRT-Exchange. com (Examples shown in this ppt). • Birt. World. blogspot. com • Eclipse. org/birt • Eclipse Birt News Group 33 2007 Actuate International User Conference ©
- Slides: 33