IBM Support

How to build a BIRT template to recursively list all the sub packages of a selected package

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:

  1. Assume you have in your model the following content:



  2. Create a new BIRT Report

  3. Create a new Data Source of type UML Model

  4. 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 is uml:Package



  5. Specify the Column Mapping, so that Name, Query, and Type are qualifiedName, @qualifiedName, and String, respectively in the first row and packUri, getURI(.), and String, respectively, in the second row:




  6. Create a new Data Set called NestedPackage and a new parameter called pack to the Query Parameters




  7. Use the Row Mapping, so that the Row Query Expression contains resolveURI($pack)//nestedPackage and the Row Query Type containsuml:Package. Here you use the resolveURI 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.)




  8. Specify the Column Mapping, so that Name, Query, and Type are qualifiedName, @qualifiedName, and String, respectively




  9. 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:


  10. Add a new Table with 2 columns and 1 details and on the report surface and bind the table to the data set AllPackages:




  11. 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




  12. Name the group SelectedPackageGroup and Group On the qualifiedName



  13. Add a filter and choose row["qualifiedName"], Equal to, and Build expression as the filter condition:



  14. Build the expression using the the report parameter pack2Select created in Step 9 by choosingReport Parameters >All > {} pack2Select (params["pack2Select"].value]) available column binding.








  15. Add a new Table with 1 columns and 1 details in the Detail Row of the package table second column

  16. Bind the table to the data set NestedPackages

    You will get the following result:



  17. 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:



  18. 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:


  19. Modify the table by removing rows and formatting the text.:



  20. 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.

[{"Product":{"code":"SSYK2S","label":"Rational Software Architect Designer"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Reports","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"8.5.1;8.5;8.0.4.2;8.0.4.1;8.0.4;8.0.3;8.0.2;8.0.1;8.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS4JCV","label":"Rational Software Architect for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Reports","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5;7.5.5.1;7.5.5.2;7.5.5.3;7.5.5.4;7.5.5.5;8.0;8.0.1;8.0.2;8.0.3;8.0.4;8.0.4.1;8.0.4.2;8.5;8.5.1","Edition":"","Line of Business":{"code":"LOB15","label":"Integration"}},{"Product":{"code":"SS4JE2","label":"Rational Software Architect Standard Edition"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Reports","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5;7.5.5.1;7.5.5.2;7.5.5.3;7.5.5.4;7.5.5.5","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
10 September 2020

UID

swg21634059