Customize Report Writer Model Element Template
This tutorial teach how to customize the report writer template to show use case id when generate use case model element. This tutorial will teach how to edit report writer template XML in report write user interface instead of open the XML files in the installation folder. Report Writer is a flexible report generation function to generate software design specification with UML.
Preparing your project
- Start with a new project.
- Create a new use case diagram and name it as My First Diagram.

- Draw the diagram as shown below:

- Right click on use case Transfer Money and select. Open Specification from popup menu.

- Enter "UC-001" as the ID of use case and click OK to confirm editing.

- Click on the Pin icon at the top right corner of specification dialog box.

- Click on the Auto open specification when select button below.

- Click on the Apply button at the bottom of dialog box.
- Select Pay Bill and enter "UC-002" as its ID.

- Click on Apply button at the bottom of dialog box.
- Select Donate Money and enter "UC-003" as its ID.

- Click OK to confirm editing.
Customizing template
- Start the report writer by selecting Tools > Report > Report Writer... from the main menu.

- In the Templates dialog box, enter My Company as company name, Sample Report as report name, select Blank as report template and click OK to proceed.

- We are going to create a template for use case. Therefore, expand the diagram tree and select use case Transfer Money from diagram My First Diagram.

- We are going to create a new template. Instead of doing everything from scratch, we will duplicate an existing template, and modify it a bit to fit our need. Right click on template Basic Information and select Duplicate... from the popup menu.

- In the Duplicate Template dialog box, change ID and name to Basic Information (with usecase ID), and click OK.

- In the Edit Template dialog box, scroll down to the middle of the pane to look for the segment <ValueConditionChecker property="documentation" operator="NOT EQUAL" value="">, which represents the row of documentation in the basic information table.

- We will copy it, and make it shows the ID of use case. Highlight the <ValueConditionChecker> block and press Ctrl-C to copy.

- Scroll to the top of editor to look for the segment: <DefaultConditionChecker property="rank" equalFlag="false">
- Press Enter to add a new line.

-
Press Ctrl-V to paste.
Before we start editing the pasted content, let's take a look at the elements involved:
| ValueConditionChecker |
Check whether a property equals or not equals to an expected value. Proceed if matched, otherwise stop and proceed with sibling element. In this case, when documentation is non-empty, subsequent elements will be checked. |
| ReportOptionChecker |
Check whether a report option matches with the expected value. Proceed if matched, otherwise stop and proceed with sibling element. In this case, when the option Click to Generate Model Element Documentation is on. |
| TableRow |
A row in table. |
| TableCell |
A cell in row. |
| StaticText |
Fixed text that need to be specified in template. |
| StringPropertyText |
The value of certain property. In this case, the documentation property of use case will be queried. |
- For the element <ValueConditionChecker>, change the property attribute's value from documentation to useCaseID. This means to check whether the use case ID is empty or not. If non-empty, the subsequent segment will be checked.

- Remove <ReportOptionChecker> as it is not needed in our case.

- Look for the <StaticText> element under the first <TableCell>. Change the content from Documentation : to ID :.

- Look for the <StringPropertyText> element under the first <TableCell>. Change the content from documentation to useCaseID. This means to query and print the value of useCaseID property of use case.

- Click OK to finish editing.
- Select Basic Information (with usecase ID) from the template pane.

- Drag it onto the report. You should see the ID row appear with UC-001, the ID of use case, printed.

- Select Pay Bill in diagram navigator.
- Drag the template Basic Information (with usecase ID) onto the report. There should be one more section being created, with Pay Bill's ID show in a table.

- Select Donate Money in diagram navigator.
- Drag the template Basic Information (with usecase ID) onto the report.

Rate this Article
Click on one of the stars below to rate this article from 1 (lowest) to 5 (highest).
One Moment Please
Thanks for rating this article.
Comments (1)
written by Jaylen on December 16, 2011
Thanks for sharing. Always good to find a real exerpt.