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.
- Switch to the Report Design perspective.
- Open . Select Always use external browsers, and click OK.
- In the Navigator view, double-click .
The report template opens in the BIRT editor.
- Click to display the different ways of viewing the report.
- From the list, select In Web Viewer or the option you require.
- In the Parameter dialog, select Loan Validation Determination as the rule project name.
- 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 (see Consistency checking).
- In the Navigator view, double-click .
The report template opens in the BIRT editor.
- Click to display the different ways of viewing the report.
- From the list, select In Web Viewer or the option you require.
- Select the name of your rule project.
- 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.
- Select a rule project and an extractor if you created any in your rule project.
- Click OK.
Rule Designer generates the Consistency Checking Report and opens it in the viewer that you selected.
The Rule Completeness Report checks whether there are gaps in a set of rules.
- In the Navigator view, double-click .
The report template opens in the BIRT editor.
- Click to display the different ways of viewing the report.
- From the list, select In Web Viewer or the option you require.
- In the Parameter dialog, select the name of your rule project.
- Select a rule project and an extractor if you created any in your rule project.
- 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 by 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 that are defined in the library in several reports.
- ruleProjectName, checkTypeName, IncludeDecisionTables, extractor: report parameters.
- Sample Reporting Data Source: a scripted data source.
- Ruleset Parameters, Rule Artifacts, Ruleflows, Rule Projects, Check Types, Consistency Checks, and Extractor Types: data sets.
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.
- param name
- param direction
- param verbalization
- param type
- param init value
You use report parameters to filter the data that is 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 that are defined in the data sets. You use JavaScript to access all the classes of the plug-ins available to the BIRT report at run time. 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>
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 Platform class contains a static method, getBundle(), that returns a Bundle object. The argument to getBundle() is the name of the plug-in that contains the target class.
- The Bundle class contains a loadClass() method that returns a java.lang.Class object. The argument to loadClass() is a fully qualified class name, in this case ilog.rules.studio.model.IlrStudioModelPlugin, which is the central class for accessing the Rule Designer model.
- The java.lang.Class class represents the target class and contains a getMethod() method that returns a Method object. The argument to getMethod() is the name of a method from the ilog.rules.studio.model.IlrStudioModelPlugin class, in this case getRuleModel().
- The java.lang.reflect.Method class contains an invoke() method that calls the getRuleModel() static method that is represented by this method object, which returns the instance of the class IrlRuleModel.
- The IrlRuleModel class contains a getRuleProject() method. The argument to getRuleProject() is the name of a rule project. This method returns an object the class IrlRuleProject.
- The IrlRuleProject class contains a getParameters() method that returns the value of the Parameters containment reference list. The list contents are of type IlrParameter. This list shows the ruleset parameters of this rule project.
- The paramIterator variable returns an iterator over the elements in the list of ruleset parameters.
For each column in a data set, the data is retrieved from the Rule Designer API by using event handlers.
- The open event initializes variables. It is
called when BIRT first accesses the data set.
paramIterator = getRulesetParamFromProjects( params["ruleProjectName"] );The getRulesetParamFromProjects method returns a list of ruleset parameters.
- The fetch event implements the object-to-column
mapping from the Rule
Designer POJO
model to the columns defined in your data set. It is called to retrieve
each row of data from the data set.
param = paramIterator.next(); row["paramName"] = param.getName(); row["paramDirection"] = param.getDirection().getLiteral().toString(); row["paramVerbalization"] = param.getVerbalization(); row["paramType"] = param.getType(); row["paramInitValue"] = param.getInitialValue();
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.
This sample uses JavaScript to access the Rule Designer API and populate the output columns that are defined in the data sets.