Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

BIRT variables can be used to resolve a lot of issues. We will use it to point to the JIRA server URL and display JIRA icons on BIRT reports.


Issue 1: The JIRA Base URL

We want to display JIRA icons for the issue type instead of their urls. The SQL for JIRA Driver returns relative URLs to the JIRA Base URL for issue type icons. 

For example, for the Issue Type Task icon Image Added the URL is: 

/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype

It cannot be used as is on Eclipse because it is relative to the JIRA Base URL:

http://localhost:2990/jira

So the JIRA Base URL must be added to the icon''s relative URL. A BIRT variable will be used to store the JIRA BASE URL so it could be change easily in to run the same report on a different JIRA instance with a different Base URL. In later sections we will learn how to get the Base URL dynamically so just the same report will run on any JIRA instance without any change.

Right click on the Variables folder in the Data Explorer view and select the New Variable option and fill out the Name and the Default Value fields in the dialog:

  • Name: JIRA Base URL
  • Default Value: "http://localhost:2990" 

Please use your own JIRA Base URL value including the double quotes:

Image Added

A new variable is added to the BIRT report:

Image Added


Issue 2: Replace the Issue Type URL with their icons

Select the cell in the Table Detail for the Type Url column and remove its conent:

Image Added

Select the Palette view and drag and drop a Dynamic Text item into the blank cell. Then click on the Availabe Column Bindings category and the Table sub-category.Then click on the TypeUrl entry. This will add the column binding into the Expresion Builder:

row["TypeUrl"]


Image Added

At the moment, we have made no progress as we have simply replaced a binded label with a binded dynamic text. However, we are now able to wrtie HTML code to create the image on the report.

Plase copy and paste the text below into the Expression Builder:


"<img src='"+vars["JIRA Base URL"]+row["TypeUrl"]+"' title ='"+row["Type"]+"'/>"

Pay attention to:

  • It is a standard Image HTML tag: <img src='...' title='...'/>
  • The entire expression is enclosed with double quotes as it has to return a Javascript String object.
  • The rest of the quotes are single, just like in Javascript.
  • The JIRA Base URL variable is used in the image src attributte appened to the the TypeURL column bind

At runtime, each cell will be converted to an HTML expression like:


<img src='http://localhost:2990//secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype' title='Task'/>

Issue 3: Colum Order

Rearrange the column order: Select the Table item on the Outline view, then the Issue column on the Layout and right click on the Column Table Header to Insert  > Column to the Left:


Image Added

Then drag and drop the Dynamic Text item into the new empty cell on the Outline view:

Image Added

and remove the older TypeUrl column:

Image Added


Run the BIRT report and check that the status icons are displayed. If something is wrong you can inspect the BIRT report HTML code from your browser's debugger:

Image Added