About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Question & Answer
Question
This technote describes how to map hierarchical data structures in a model to relational data structures in a BIRT report using IBM® Rational® Software Modeler or IBM® Rational® Systems Developer v7.0.5 or higher
Cause
The data stored in UML model is hierarchical (tree-like) as you can see by looking at
the organization of the Model Elements in Project Explorer.
BIRT reports on the other hand use data stored in a relational fashion.
Answer
DISCLAIMER
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
In order to create a BIRT report that can show the hierarchical structures found in the UML Metamodel,
there are some specific patterns that you can follow.
A typical scenario is constituted by the following type of relationships in the UML Metamodel:
- 1. Metaclass A has a one to many relationship towards Metaclass B.
2. An instance of Metaclass B has a property (called ref_to_parent in the sequel)
to retrieve its associated instance of Metaclass A.
A1. Package has a one to many relationship with Class
A2. Class has a property that allows it to identify its parent Package.
B1. Class has a one to many relationship with Operation
B2. Operation has a property that allows it to identify its parent Class.
as follows:
- 1. Create a Data Set A that queries the model for all instances on Metaclass A
This can be done by setting the following XPath expression in the Table Mapping:
//MetaclassA
which finds recursively all instances of MetaclassA no matter how deeply nested they are
in the model.
In the Column Mapping, ensure that you expose a column defined as:
Name: uri
XPath: getURI(.)
Type: String
where getURI() is a custom XPath function described in the on-line Help.
2. Create a Data Set B that queries the model for all instances of MetaclassB, as above, and in addition
expose one more column defined as:
Name: parentURI
XPath: getURI(ref_to_parent)
Type: String
3. Create a Joint Data Set C. Use A and B as Data Sets and create an Innner Join that equates the
properties
uri of Data Set A
parentURI of Data Set B
4. To layout this structure in a report, create a Table or List bound to the Joint Data Set C.
5. Add to the Table or List a Group and group on the same column used to define the Joint Data Set.
Examples:
Display all Packages with Classes
Display all Classes with Operations
a. Given a Model so defined:

b. Create a New Report based on the Blank Model Report (see technote 1294412 for a step-by-step description of this task)
c. In the Report Designer Data Explorer view, open the Data Source and link it to your model
d. Delete all existing Data Sets as we will create them one by one.
e. Create a new Data Set called Packages with XPath Expression
//Package
as shown below:
and make sure to expose the column:
Name: uri
XPath: getURI(.)
Type: String
as shown below. Expose any additional columns that you may be interested in.

f. Create a new Data Set called Classes with XPath Expression
//Class
as shown below:
and make sure to expose the column:
Name: packageURI
XPath: getURI(package)
Type: String
as shown below. Note that "Package" is a property of the Metaclass "Class" that you can see expanding the UML Structure tree. Add any other columns you may be interested in.

g. Create a new Joint Data Set called: Packages With Classes.
define an inner join that equates column
Packages::uri
to column Classes::packageURI

h. Create a new Data Set called Operations with the Table Mapping
//Class/ownedOperations
which retrieves the ownedOperation's from all classes in the model, regardless of how deeply nested the classes are.
However this will not not find any ownedOperation's that are not part of a class.

and expose at least one column defined as:
Name: classURI
XPath: getURI(..)
Type: String

Here we are using the fact that the operation is contained in the class in the .emx file, so we can use an XPath expression that refers to the parent xml tag ("..").
i. Create a Joint Data Set called: Classes With Operations
Define an inner join that equates column
Classes::uri
to Operations::classURI

To display these data sets onto the Report:
1. Add a new List onto the Report Editor
2. Bind the list to the Packages with Classes data set
3. Inside the list add a new Group
4. Make it group on the column:
Packages::uri

5. Inside the Group add a Table
6. Bind it to Classes With Operations
7. Make it group on the column:
Classes::uri[</code>]
8. Add a filter like so:
row["Classes::packageURI"] Equal to row._outer["Packages::URI"]

This avoids the need to create one more Joint Data Set (packages with Classes With Operations).
Related Information
[{"Product":{"code":"SSCLKU","label":"Rational Software Modeler"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Reports","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"}],"Version":"7.0.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSJP3D","label":"Rational Systems Developer"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Reports","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]
Was this topic helpful?
Document Information
More support for:
Rational Software Modeler
Software version:
7.0.5
Operating system(s):
Windows, Linux
Document number:
95337
Modified date:
16 June 2018
UID
swg21294555
Manage My Notification Subscriptions