Question & Answer
Question
How do you build a BIRT template to report recursively on all the nested packages of a selected package using IBM Rational Software Architect (RSA)?
Cause
Usually models contain different levels of package nesting. Having a sample template showing you how this can be achieved with BIRT and RSA, will help you to build you own custom template.
Answer
ANSWER
One option is to use a report parameter that allows you to select one package among all the ones contained in your model and reuse this parameter in your template.
For this this you need to create two data sets:
- the first one (AllPackages) will retrieve all the packages of your models and be used to let you choose your package as a parameter in your BIRT template
- the second one (NestedPackages) will retrieve all the nested package based on the package previously selected
Bellow are the step-by-step instructions on how you can achieve this:
- Assume you have in your model the following content:
- Create a new BIRT Report
- Create a new Data Source of type UML Model
- Create a new Data Set called All Packages using the Row Mapping, so that the Row Query Expression is
instanceOf(//*, "uml:Package")
and the Row Query type isuml:Package
- Specify the Column Mapping, so that Name, Query, and Type are
qualifiedName
,@qualifiedName
, andString
, respectively in the first row andpackUri
,getURI(.)
, andString
, respectively, in the second row:
- Create a new Data Set called NestedPackage and a new parameter called pack to the Query Parameters
- Use the Row Mapping, so that the Row Query Expression contains
resolveURI($pack)//nestedPackage
and the Row Query Type containsuml:Package
. Here you use theresolveURI
method to get the Package based on the URI will you pass with the parameter pack and the"//nestedPackage"
xpath to recursively retrieve all the sub packages ("/nestedPackage"
would have only given you the packaged directly own by the package passed as parameter.)
- Specify the Column Mapping, so that Name, Query, and Type are
qualifiedName
,@qualifiedName
, andString
, respectively
- Add a Report Parameter called pack2select, select ListBox as the Display type, check theDynamic option in the Selection list Values, select qualifiedName in the Select value column, and select qualifiedName in the Select display text. (The rest of values are either default or optional.)
You have now the following structure in the Data Explorer:
- Add a new Table with 2 columns and 1 details and on the report surface and bind the table to the data set AllPackages:
- Create a group to filter the list to to only out the package you will select by right clicking on the Details Row and selecting Insert Group
- Name the group SelectedPackageGroup and Group On the qualifiedName
- Add a filter and choose
row["qualifiedName"]
,Equal to
, andBuild expression
as the filter condition:
- Build the expression using the the report parameter pack2Select created in Step 9 by choosingReport Parameters >All > {} pack2Select (params["pack2Select"].value]) available column binding.
- Add a new Table with 1 columns and 1 details in the Detail Row of the package table second column
- Bind the table to the data set NestedPackages
You will get the following result:
- Drag and drop in the Detail Row the mapped column qualifiedName of the NestedPackages data set (delete the Header and Footer rows) to get the following result:
- Bind the Parameter data set to the packUri column of the AllPackages data set by:
- selecting the table
- going to the Properties Editor of the table and selecting the Binding tab
- clicking on the Data Set Parameter Binding button to edit it
- building the expression using the AllPackages table packUri (row["packUri"]) available column binding:
- verifying that the following is set:
- Modify the table by removing rows and formatting the text.:
- Save the temple and run the report or use the preview. You are first prompted to select a package among the ones in the model:
If you select the Blank Package::Pack3, then the output is:
NOTE:
A template created with RSA 8.5.1 is attached to this document along with the sample model.
Was this topic helpful?
Document Information
Modified date:
10 September 2020
UID
swg21634059