Custom report generation sample details

You use Rule Designer to run this sample.

Running this sample

The Business Rules Report provides detailed information on the ruleset parameters, rule artifacts, and ruleflows in your project.

Note: You can also use the Rule Project Map to run your report (see Configuring the Rule Project Map for BIRT templates).

To run the Business Rules Report:

  1. Switch to the Report Design perspective.
  2. In the Navigator view, double-click the businessrulereport.rptdesign report template.

    The report template opens in the BIRT editor.

  3. Click Run > View Report to display the different ways of viewing the report.
  4. From the list, select In Web Viewer or the option you require.
  5. In the Parameter dialog, select the name of your rule project.
  6. Click OK.

    Rule Designer generates the Business Rules Report and opens it in the viewer you selected.

The Consistency Checking Report detects and troubleshoots conflicting business rules. For more information, see Consistency checking.

To run the Consistency Checking Report:

  1. In the Navigator view, double-click the consistencycheckingreport.rptdesign report template.

    The report template opens in the BIRT editor.

  2. Click Run > View Report to display the different ways of viewing the report.
  3. From the list, select In Web Viewer or the option you require.
  4. Select the name of your rule project.
  5. In the Parameter dialog, select the type of checks that you want to activate. Use Ctrl or Ctrl+Shift to select several checks.

    To check decision trees and decision tables, select the Include decision trees and decision tables in inter-rule checks check box.

    For more information about the checks available, see Consistency checking.

  6. Select a rule project and an extractor if you have created any in your rule project.
  7. Click OK.

    Rule Designer generates the Consistency Checking Report and opens it in the viewer you selected.

The Rule Completeness Report checks whether there are gaps in a set of rules. For more information, see Completeness analysis.

To run the Rule Completeness Report:

  1. In the Navigator view, double-click the rulecompletenessreport.rptdesign report template.

    The report template opens in the BIRT editor.

  2. Click Run > View Report to display the different ways of viewing the report.
  3. From the list, select In Web Viewer or the option you require.
  4. In the Parameter dialog, select the name of your rule project.
  5. Select a rule project and an extractor if you have created any in your rule project.
  6. Click OK.

    Rule Designer generates the Rule Completeness Report and opens it in the viewer that you selected.

How this sample works

You can customize the generated reports using BIRT which is loosely coupled in format to Rule Designer.

A report library is a collection of report components that you can use in a report. You can use the elements defined in the library in several reports.

The sample_reporting.rptlibrary library in this sample contains:

A link to the library is integrated in businessrulereport.rptdsign, consistencycheckingreport.rptdesign, and rulecompletenessreport.rptdesign automatically.

The XML Source tab displays the link in the BIRT editor as follows:

<list-property name="libraries">
      <structure>
          <property name="fileName"> sample_reporting.rptlibrary</property>
          <property name="namespace"> sample_reporting</property>
     </structure>
</list-property>

To access the Rule Designer API you use JavaScript as glue code between BIRT and Rule Designer. The scripted data source in this sample is defined in the library, and can be shared by several reports.

This sample uses seven scripted data sets which are defined in the library. The data sets correspond to rule artifacts, ruleset parameters, ruleflows, rule projects, check types, checks on consistency, and extractor types. Each data set contains output columns to define which elements are retrieved from the Rule Designer API.

For example, the Ruleset Parameter data set contains five output columns:

You use report parameters to filter the data displayed in the report. For example, you use the ruleProjectName report parameter to select the project for which you want to run a report. BIRT then generates the report for this specific rule project. You define report parameters in the library which you can then use in several reports.

This sample uses JavaScript to access the Rule Designer API and populate the output columns defined in the data sets. You use JavaScript to access all the classes of the plug-ins available to the BIRT report at runtime. The definition for the JavaScript code in this sample is in a separate file named utils.js. You can share utility functions across the open and fetch events.

You must include a link to the utils.js file in the report templates by manually integrating the link into the XML Source view of the report template as follows:

<list-property name="includeScripts">
      <property>/scripts/utils.js</property>
</list-property>
Note: When you map a parameter to a data set, you must include the JavaScript code directly in the event handler script.

The following JavaScript code shows you how to call a method of a Java™ class included in an Eclipse plug-in:

modelBundle = Packages.org.eclipse.core.runtime.Platform.getBundle( "ilog.rules.studio.reporting" );
modelClass = modelBundle.loadClass( "ilog.rules.studio.model.IlrStudioModelPlugin" );
method = modelClass.getMethod( "getRuleModel", null );
ruleModel = method.invoke( null, null );
ruleProject = ruleModel.getRuleProject( ruleProjectName );
paramIterator = ruleProject.getParameters().iterator();

The explanation of the code is as follows:

For each column in a data set, the data is retrieved from the Rule Designer API using event handlers.

This sample implements two essential event handlers on each data set:

You can access the open and fetch events by selecting a data set in the Outline view and clicking the Script tab in the report template.

Note: For more information about how to use BIRT and how to use scripting in a report design, refer to the BIRT Report Developer Guide.

This sample uses JavaScript to access the Rule Designer API and populate the output columns defined in the data sets.