Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
Complete the form below to send this article, Creating a Reporting Site using BIRT-An Extension, to a friend (or to yourself). We will never share your details (or your friend's) with anyone. For more information, read our Privacy Policy.
In the previous article How to Create a Reporting Site
In this article series by John Ward,author of BIRT 2.6 Data Analysis and Reporting we will be looking at :
- Bug Status- A Report to show open issues compared to all bugs
- Developer issues reports-this report will accomplish two things—shows us a Pie Chart showing fixed versus non-fixed bugs and gives us a list of bugs in an open status assigned to that developer.
Bug status
The next report we are going to undertake is the report to show open issues compared to all bugs. What we are trying to build here is a graph that shows, by category, the bugs that are open in relation to the total number of bugs for that category. No other grouping is required. Under the graph, we also want to show a list of open bugs that we can click on and have them drill down to the detail for that bug so that we can see the history of changes to that bug.
What this means is we need a bar graph showing all the status.
- Open BugzillaReportsTemplate.rptTemplate and save as bugStatusReport.rptDesign.
- Drag getAllBugs over to the Report Designer.

- Delete all columns except the bug_status field and short_desc field.

- In the table, group data by the components' name.

- With the new category created in the Table, insert a new column on the right. Delete the header labels. Move the data fields to look like the following screenshot:

- In the Outline tab, select the root element. Apply bugZillaTheme.
- In the group header row with the name, apply the DetailTableHeader style.

- In the Detail row, apply the DetailTableRow style.
- In the header row, select all the cells and merge them.

- In to the new merged cell, insert a chart.

- Select a Bar Chart and change the Output Format to PNG.

- Open the Select Data tab.
- Set the Inherit Data from Container drop-down list to Inherit Columns Only.
- Drag the bug_status field to the Optional Y Series Grouping slot.
- Drag the name field to the Category (X) Series slot.

- Click on the Edit group and sorting button.
- In the Group and sorting dialog, check the Enabled checkbox.
- Set the Type to Text.
- Set the Interval to 0.
- Set the Aggregate Expression to Count.

- As the Value (Y) Series, enter 1.

- Under the Format Chart tab, go to Title. Enter the title as Bug Status Report.

- Select the Axis option.
- Under X-Axis, check the Stagger checkbox.

- Click Finish.
- Resize the chart to fit the number of categories.

- The last thing we need to do is add the drill-through from the descriptions to the bug detail. Select the short_desc data item in the report designer.

- Under the Property Editor, select the Hyperlink tab.

- Click on the Edit... button next to Link To.
- From the Hyperlink dialog, select the Drill-through as Hyperlink type.
- Select BugzillaDetailReport.rptDesign as the target report.

- Set up the target report parameter bugID to be linked to row["bug_id"].

- Click OK and save the report
.

Developer issues reports
The next report is a combination of the last two reports in our list. Given a developer ID, this report will accomplish two things—shows us a Pie Chart showing fixed versus non-fixed bugs and gives us a list of bugs in an open status assigned to that developer. Let's now build the report:
- Open BugzillaReportsTemplate.rptTemplate and save as DeveloperPerformanceReport.rptDesign.
- Modify the getAllBugs query to look like the following:
SELECT
bugs.bug_id,
bugs.bug_severity,
bugs.bug_status,
bugs.short_desc,
profiles.userid,
profiles.login_name,
profiles.realname,
components.id,
components.name,
components.description
FROM
bugs,
profiles,
components
WHERE
bugs.component_id = components.id
AND bugs.assigned_to = profiles.userid
and profiles.userid = ? - Bind the dataset parameter to a report parameter called developerID.
- We want to use a drop-down list for the developer ID parameter. Create a new dataset to display the unique developer IDs using the following query and call it developerIDList:
SELECT distinct
profiles.userid,
profiles.realname
FROM
profiles
- Open the report parameter developerID for editing.
- Change the Display type to Combo Box.

- For the Selection list values option, change the radio buttons to Dynamic. Under the list of datasets, select developerIDList.

- For the value column, select userid.
- As the display text, use the following expression:
dataSetRow["userid"] + " - " + dataSetRow["realname"]
- As the Default value, enter 1. The dialog should look like the following:

- Click on OK to save our changes.
- Drag getAllBugs dataset over to the Report Designer.
- Delete all columns except bug_id and short_desc.

- Insert a new row in the header above the column labels.

- Merge all the cells in the new row.
- Insert a chart into the new large cell.
- Select a Pie Chart and set the Output Format to PNG.

- Select the Select Data tab.
- Set the Inherit Data from Container drop down item to Inherit Columns only.
- Under the Category Definition, use the following expression:
if (row["bug_status"].toUpperCase() == "RESOLVED")
"Fixed";
else
"Open"; - Click on the Edit Group and Sorting button.
- Check the Enabled option under Grouping tab.
- Set the Type to Text.
- Set the Interval to 0.
- Set the Aggregate Expression to Count.

- Click OK.
- Under the Slice Size Definition, enter 1 for the value.

- Under the Format Chart tab, go to Title.

- Change the Title to Open Issue Chart.
- CLick Finish
- Resize the chart.
- Change the labels for Bug ID and Bug Short Description.

- Select the Detail row of the chart.

- Under the Property Editor, select the Visibility tab.
- Check Hide Element.
- Use the expression, illustrated in the following screenshot:

- Select the bug_id data element.
- Under the Property Editor, select the Hyperlink tab.
- Click the Edit... button.
- Create a drill-through to the detail report using the column binding's bug_id as the parameter value.

- Select the root of the report in the Outline tab, and apply bugzillaTheme.
- Apply TableHeaderStyle to the header row.

- As we used the visibility expression to hide rows that are resolved, this will throw the Highlight used in the DetailRow style off. So, we are going to use a little bit of scripting to apply our highlight. Open up the Outline view.
- In the Report Designer, open the Script tab.
- Select the Reports Root element and, in the Script editor, choose the initialize method.
- Type the code shown in the following screenshot in to the Script editor:

- Select the Detail row in the Outline tab.

- In the onRender method, type the following code:
if (this.getRowData().getColumnValue("bug_status").toUpperCase() == "RESOLVED")
{
displayedRow++;
}
- In the Property Editor, select the Highlight tab.
- Create a Highlight using the following code:
displayedRow % 2 instead of row.__rownum

- Save and preview the report.

The reason this worked is because we needed to get the values in the data rows before the visibility rule takes effect. Once we have those components created, we check in the Render phase to see if the value of bug_status is set to the RESOLVED value. If not, then we advance the counter that would normally be advanced by ROWNUM. This keeps it nice and uniform.

Summary
In this article we looked at a realistic example of a series of reports that could be used in a real life project.
We have illustrated just about every major element of reporting with BIRT, from Report Projects, Report Components, Charts, Scripting, and Formatting. We even looked at how to look at requirements and find reports with similar specs and data, and how to combine reports. If a single report can take the place of multiple reports and tell a more complete story, it is always beneficial to do so. In addition, we also introduced the Visibility rule, which is very similar to the Highlight rule. These reports can now be deployed to a report platform and be used for production reports.
About the Author :
John Ward
John Ward is a consultant for Innovent Solutions, specializing in BIRT and e-commerce search and navigation solutions. Prior to that, John was an Assistant Vice President for Citibank, North America, managing the training MIS group and overseeing development of new technology-based training initiatives. John actively works with and tests BIRT—an open-source reporting platform built on Eclipse—including development work based on BIRT reports and the BIRT APIs.
John also maintains The Digital Voice blog at http://digiassn.blogspot.com



Post new comment