Purpose of this Module Type
A report plugin module defines a report within JIRA. A JIRA report can display statistical information based on all elements within JIRA - e.g. issues, projects, users, issue types, etc.Reports have HTML results and (optionally) Excel results as well. These results are rendererd by Velocity templates included with the plugin. A report can also accept parameters selected by the user before running.
The root element for the report plugin module is
report. It allows the following attributes and child elements for configuration:
The class which implements this plugin module. The class you need to provide depends on the module type. For example, Confluence theme, layout and colour-scheme modules can use classes already provided in Confluence. So you can write a theme-plugin without any Java code. But for macro and listener modules you need to write your own implementing class and include it in your plugin. See the plugin framework guide to creating plugin module instances. The Java class of the component. The class must implement
In the example,
|The localisation key for the human-readable name of the plugin module.|
The human-readable name of the plugin module. That is, the human-readable name of the component.
The plugin key.
A human-readable description of this report module. May be specified as the value of this element for plain text or with the
The user-visible name of this report. May be specified as the value of this element for plain text or with the
Used to render the report results. The results format is whatever the template can output.
A Java properties file within the plugin that specifies internationalization values.
Used to generate the report's configuration parameters (see Configuring Plugins with Object Configurable Parameters for details on these properties). Note: In JIRA 5.2.3 or later, when navigating to this report via Browser Project, there is are additional URL parameters of projectOrFilterId (project id prefixed with 'project-') and projectOrFilterName (which in this case is the project name). If you have a custom project picker inside your properties / configure page, you should respect these URL parameters pre-select the project.
In order to make a custom report available within JIRA, it is necessary to create a report plugin module. As with all plugin modules, the report plugin will consist of the following components:
- Java classes encapsulating report logic
- Resource templates for display of the report
- Plugin descriptor to enable the report module in JIRA
all contained within a single JAR file.
The Java classes include the necessary logic to retrieve the data used in configuring and displaying the report. The module class can implement the Report interface or it can extend AbstractReport . The main methods of interest are:
- generateReportHtml - generate HTML view of report
- generateReportExcel - generate Excel view of report
- getParams - retrieve the required data to be passed to the view template
- validate - validate any parameters used in configuring the report
The second component consists of Velocity templates used to render the report. The templates include:
- Report view - the actual report view
- Excel view - an Excel view for the report (optional)
The plugin system parses the atlassian-plugin.xml file for any configuration parameters associated with the report - parameters required in order to display the report. The plugin system constructs a suitable configuration screen requesting the user to specify values for these parameters.
If an Excel view template is provided, users have the ability to view and further manipulate the data through Excel. If the Excel template is provided please ensure that your report also implements the following method:
It is also possible to include i18n property files to allow other users to easily translate the strings used in the report for different languages.
This example is taken from JIRA's internal time tracking report.
In this example, the report logic is encapsulated in the TimeTrackingReport Java class, the view template location is specified in the templates/plugins/jira/reports/time-tracking-report.vm directory and the internationalisation property files are located at com.atlassian.jira.plugins.reports.timetracking. Following that, the parameters required to configure the report are specifed - in this case, the version, the sort order and a filter.
For more details, see the tutorial on creating a JIRA report.