Model Reporting with IBM® Rational® Software Architect 7.5: An Introduction Maged Elaasar Senior Software Engineer Rational Modeling Tools melaasar@ca.ibm.com Steven Hovater Senior Managing Consultant Rational Lab Services svhovater@us.ibm.com MAC09 © 2009 IBM Corporation IBM Rational Software Conference 2009 Objectives of this Presentation Introduce you to model reporting with BIRT in RSx 7.5 Walk you through the process of authoring and generating a model report Give you insight about report authoring decisions and their implications Educate you on some interesting details of report authoring Give you a demo showing tips and tricks of using the tool. MAC09 2 IBM Rational Software Conference 2009 Outline Why model reporting? Evolution of model reporting in RSx Introduction to BIRT BIRT reporting process Demo of model reporting in RSx 7.5 Success stories MAC09 3 IBM Rational Software Conference 2009 Why Model Reporting? Models represent repositories of intellectual investment Typically you need to be a modeler to be able to distill info from and reason about models Model reporting gives you the ability to represent selected model info to non-modelers Example: how many use-cases do we have? How many scenarios associated with them? Example: what layers do we have in the architecture and what dependencies do they have? Model MAC09 Report 4 IBM Rational Software Conference 2009 Evolution of Model Reporting in RSx Pre-7.0.5 : XSLT-based model reporting, Java-based model reporting UML UML to XML Transformation XML XSLT Template Report WDoc (Java API to MS Word) 7.0.5 : Initial support for BIRT-based model reporting DSL BIRT Template EMF Driver Report UML BIRT Template UML Driver Report UML/DSL Model to Model Transformation Report DSL BIRT Template EMF Driver Report 7.5 : Enhanced support for BIRT-based model reporting Enhanced performance, usability and extensibility Added more report authoring features, prepackaged API and sample reports Simplified report generation and supported more output formats Post-7.5 : Learn by talking to product management Product Manager: William (Bill) T. Smith (smithtw@us.ibm.com) MAC09 5 IBM Rational Software Conference 2009 What is BIRT? BIRT - Business Intelligent Reporting Tools Created by Actuate, Inc., released to Eclipse as open source project Provides visual report authoring experience Supports a variety of report content (text, tables, charts…etc) Creates various report output formats (HTML, PDF, DOC, …etc) Natively works with data in tabular format Provides Open Data Access (ODA) interface to support data from arbitrary formats Prepackaged with drivers for SQL databases, XML, flat-files, web-services Used by RSx to implement a generic driver for arbitrary EMF-based model reporting EMF driver is extended by specific drivers for UML, Deployment and Data domains MAC09 6 IBM Rational Software Conference 2009 BIRT Basics Open Data Access (ODA) Driver Establishes a connection with a data source, accesses metadata about the data, maps the data to a tabular format, and executes queries on the data Data Source The ‘raw’ data being reported on Data Set A subset of the data source that is fetched using a query and mapped to a tabular format that can be used by BIRT report template. MAC09 7 IBM Rational Software Conference 2009 1. Identify Report Requirements BIRT Reporting Process Report Author 2. Create Report Design Template a. Create data sources b. Create data sets e. Preview report d. Create report design c. Create report parameters Report Author 3. Create Report Configuration a. Bind data sources b. Configure report output e. Run report Report User MAC09 d. Hook front transformation c. Bind report parameters 8 IBM Rational Software Conference 2009 1. Identify Report Requirements Identify the data domains to report on Learn what domains are supported Any EMF-based domain (e.g. UML, Deployment, Data, Diagram…etc) Available integration with ReqPro when installed Learn the used metadata (metamodels, profiles, schemas…etc) Example: UML metamodel, Profile for business modeling, Notation metamodel…etc Learn their query languages (OCL, XPath, SQL…etc) Supported versions: OCL version 2.0 and XPath 1.0 Identify the subset of data to be included in the report Think of the queries that need to be made to extract this data from data sources Identify the required presentation and layout options in the report Think of the report widgets to use, their layout relative to each other…etc. MAC09 9 IBM Rational Software Conference 2009 For More Information About Domains Standard specification documentation UML 2.0 Specification (www.omg.org/spec/UML/2.0/) OCL 2.0 specification (www.omg.org/spec/OCL/2.0/) XPath 1.0 specification (www.w3.org/TR/xpath) Various standard DSLs/Profiles (www.omg.org) Eclipse open source project documentation UML2 project –UML metamodel (www.eclipse.org/modeling/mdt/?project=uml2#uml2) OCL2 project – OCL tools (www.eclipse.org/modeling/mdt/?project=ocl#ocl) GMF project – Diagram/Notation metamodel (www.eclipse.org/modeling/gmf) Other metamodel implementations (www.eclipse.org/modeling/mdt/) Your success with reporting is dependent upon your understanding of the structure of the domain data and how to navigate to it and extract it. MAC09 10 IBM Rational Software Conference 2009 2. Create Report Design Template Change to the Report Design perspective Create a new Report Project Create a new Report Report Data Report Design / Layout Report Widgets MAC09 Report Properties 11 IBM Rational Software Conference 2009 2.a. Create Data Sources Choose the most specific data source for the data domain: Domain-specific data sources (e.g. UML Data Source, Zephyr Topology Data Source…etc) EMF Data Source if your domain is EMF-based but does not have a specific data source Data sources specify how to access data repositories and their metadata For UML: data are EMX / UML models (optional for preview) For UML: metadata are UML2 / Notation metamodels and used profiles Create one data set for each related set of data repositories (i.e. models) MAC09 12 IBM Rational Software Conference 2009 2.b. Create Data Sets Data sets define queries against data sources and put the result into a tabular format (with rows and columns) Select the data source of this data set Define data set parameters (for reusable data sets): Query Parameters tab: define parameters’ native names Parameters tab: define other attributes of parameters MAC09 13 IBM Rational Software Conference 2009 2.b. Create Data Sets Row mapping: specifies a query to collect model elements representing the rows of a table Browse data source models using the LHS browser Specify the row query using the RHS fields: Expression: an XPath query that collects elements Type: the type of elements being collected Stereotypes: the relevant stereotypes applied to elements being collected Instance Model Browser MAC09 Metamodel Browser Profile Browser 14 IBM Rational Software Conference 2009 Row Query XPath Expression The expression’s context is the instance models in the data source The expression’s return value is a collection of elements (no scalar values) The expression consists of model traversals, calculations, searching, filtering…etc Each model traversal in the expression Starts from the model root “/elem/ref”, a parameter “$elem/ref” or the context “elem/ref” Consists of a series of traversal steps : step 1 / step 2 /…/ step N Where each step describes going to a related set of objects for each object of previous step Resolves into the result of the last step The expression can invoke XPath functions (implemented in java) MAC09 15 IBM Rational Software Conference 2009 XPath Functions Prepackaged EMF-Generic Functions getURI( xpath ) gets the URI of a given element resolveURI( uri ) resolves the given URI to its element instanceOf( xpath, type ) checks if a given element conforms to a given type getXMIID( xpath ) gets the unique GUID of an element getXMIType( xpath ) gets the type of an element oclQuery( xpath, OCL statement ) gets a subset of given elements that satisfy given OCL condition oclEvaluate( xpath, OCL statement ) evaluates the given OCL expression on the given element Prepackaged GMF-Specific Functions getDiagramImage( xpath, maxWidth, maxHeight ) renders given diagram subject to given maximum resolution getDiagramHTMLImage( xpath, path, tileWidth, tileHeight ) renders the given diagram as HTML tile grid Prepackaged UML-Specific Functions getDiagrams( xpath ) gets the diagram of the given UML namespace element getElementsWithStereotype( xpath, stereotype ) gets a subset of given elements with given stereotype getStereotypePropertyValue( xpath, stereotype attribute ) gets value of a given stereotype attribute Custom Functions Implement org.eclipse.jet.xpath.XPathFunction interface with one method Object evaluate(List args) Package implementation in a PDE plugin and register it with the org.eclipse.jet.xpathFunctions extension point MAC09 16 IBM Rational Software Conference 2009 Row Query Examples To get Query expression All interfaces //Interface All kinds of classes instanceOf(//*, “uml:Class”) All first level packages Model/nestedPackages All class diagrams contained by any package getDiagrams(//Package)[@type = “Class”] All attributes of a class parameter resolveURI($classURI)/ownedAttribute All interfaces whose owner’s name is specified //Interface[owner/@name=$owner_name] All diagrams whose name starts with the “st” getDiagrams(//*)[upper-case(substring(@name,1,2))='ST'] All classes matching the given OCL expression oclQuery(//Class, “isAbstract and self.ownedAttributes->isEmpty()”) All classes with a given stereotype getElementsWithStereotype(//Class, “Profile1::Stereotype1”) MAC09 17 IBM Rational Software Conference 2009 2.b. Create Data Sets Column mapping: specifies queries to extract various data from row elements Browse row type / stereotypes using LHS browser Specify column queries using the RHS table: name: user specified name for the column query: XPath expression to extract primitive data from each row element Type Browser type: the primitive type of the query result Use context-sensitive column auto add button Recommended to have one column as a unique key Use URI for EMF elements: getURI(.) Stereotype Browser MAC09 18 IBM Rational Software Conference 2009 Column Query XPath Expression The expression’s context is each element collected by row query The expression’s return value is a scalar of one of the standard primitive types The expression’s return value is a single value (no collections) The expression can explicitly refer to the context element by using “.” An expression navigating to an attribute will be of the same type as the attribute Only exception is boolean attributes: use @attribute = ‘true’ to make the type boolean Any expression can be converted to a string by setting the type to ‘String’ MAC09 19 IBM Rational Software Conference 2009 Column Query Examples To get Query expression The name of the element @name The URI (unique id) of the element getXMIID(.) The type of the element getXMIType(.) The isAbstract attribute of a class @isAttribute = ‘true’ The count of attributes of a class count(/.ownedAttribute) The diagram’s image blob up to a maximum resolution getDiagramImage(., $maxWidth, $maxHeight) The diagram’s image as an HTML grid of tiles getDiagramHTMLImage(., /temp, $tileWidth, $tileHeight) A value derived using an OCL expression oclEvaluete(., “self.getQualifiedName()”) A value of a stereotype attribute getStereotypePropertyValue(., “Profile1::Stereotype1::property1”) MAC09 20 IBM Rational Software Conference 2009 2.b. Create Data Sets Other Data Set Operations Computed Columns Preview Results MAC09 Filters 21 IBM Rational Software Conference 2009 2.b. Create Data Sets Joint Data Sets MAC09 22 IBM Rational Software Conference 2009 2.c. Create Report Parameters Report parameters allow authors to capture variability in a report Report parameters can be configured with various styles and presented with various widgets Text Box Dynamic Combo Box MAC09 Static Combo Box 23 IBM Rational Software Conference 2009 2.c. Create Report Parameters Report parameters can be linked to data set parameters Report parameters can be used in report design directly MAC09 24 IBM Rational Software Conference 2009 2.d. Create Report Design Use the palette view to insert various widgets in your reports Static text HTML Text Computed Text (Static / HTML) e.g. for model doc Image : embedded, from URL, from expression, e.g. for diagrams Table with rows / columns Chats of various kinds MAC09 25 IBM Rational Software Conference 2009 2.d. Create Report Design Link the report widgets to data in your data sets MAC09 26 IBM Rational Software Conference 2009 2.d. Create Report Design Model diagram images an be reported on in two ways: Do you want to Include diagrams at full size or scaled? How much memory do you have to render diagram images? 1. Sampled Image MAC09 2. HTML Tiled Image 27 IBM Rational Software Conference 2009 2.d. Create Report Design Nested tables can be done with parameterized data sets $element $element $stereotype MAC09 28 IBM Rational Software Conference 2009 2.e. Preview Report Frequently preview the result of the report to validate design Enter the parameter values for parameterized reports MAC09 29 IBM Rational Software Conference 2009 3. Create Report Configuration Once a report design template is finished, it is ready for generation by users Bring up the report configuration wizard From the modeling perspective toolbar, select the “Report” button Or right click on a .rptdesign file in Project Explorer and select “Report As” menu Create a new BIRT report configuration Choose a report design template from the main tab Built In reports: select one of the prepackaged reports Location: browse to the location of the .rptdesign file MAC09 30 IBM Rational Software Conference 2009 Prepackaged Sample Reports Demonstrates how to report on numbers & bind data to charts Demonstrates how to include sampled diagram images Demonstrates how to include tiled diagram images Demonstrates how to use HTML text and create tables Demonstrates how to create nested tables MAC09 31 IBM Rational Software Conference 2009 3.a. Bind Data Sources For every data source in a report design template: Add the actual instance models (e.g. EMX models) This will replace the sample instance models MAC09 32 IBM Rational Software Conference 2009 3.b. Configure Report Output Configure the report output by selecting: The path to the generated report file The format of the report from supported formats: HTML PDF PS DOC PPT XLS MAC09 33 IBM Rational Software Conference 2009 3.c. Bind Report Parameters Bind the report parameters from the parameters tab Set the parameter values using the same UI Clear parameter values to unset the values Unset parameters take default values if any MAC09 34 IBM Rational Software Conference 2009 3.d. Hook Front Transformation Hook a front M2M transformation if required Report is created with one domain while various transformations exist from other domains to it Transforms instance models bound to data sources and replaces them with the resulting models Transformations can be defined visually using M2M transformation authoring framework in RSx MAC09 35 IBM Rational Software Conference 2009 3.e Run Report Once a report configuration is ready, the report can be generated repeatedly User would be prompted for any unbound report parameters MAC09 36 IBM Rational Software Conference 2009 MAC09 37 IBM Rational Software Conference 2009 Success Stories Customers realize that BIRT provides an ad-hoc query capability Use those UML models you’ve invested in! Customers using BIRT for model reporting (to name a few!) ACS Boeing Serco Raytheon US Navy US Army Northrup-Grummond IBM Rational UPIA/IAM2 Produce DoDAF/MODAF products from UML models MAC09 38 IBM Rational Software Conference 2009 For More Information About Model Reporting With BIRT developerWorks Articles: http://www.ibm.com/developerworks/rational/library/07/1211_hovater/ http://www.ibm.com/developerworks/edu/dw-r-umltracebirt.html http://www.ibm.com/developerworks/edu/dw-r-umltracebirt2.html http://www.ibm.com/developerworks/rational/library/edge/08/jan08/densmore/ MAC09 39 IBM Rational Software Conference 2009 MAC09 40 IBM Rational Software Conference 2009 © Copyright IBM Corporation 2009. All rights reserved. The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. IBM, the IBM logo, Rational, the Rational logo, Telelogic, the Telelogic logo, and other IBM products and services are trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others. MAC09 41