This appendix describes how to use the Rule reporter API to create lists or reports of the contents of a rules dictionary.
The appendix includes the following sections:
As the size and complexity of an Oracle Business Rules dictionary grows, documenting the dictionary and communicating with others about the contents of the rules dictionary can be important. Using the RuleReporter
class you can create lists or reports of the contents of a rules dictionary. You can use these reports to document your design and to communicate about the dictionary contents.
There are two ways to use Rule Reporter:
Execute RuleReporter
on the command line
Create custom reports using the RuleReporter
API in a Java program
Rule Reporter is written in the Groovy programming language using the MarkupBuilder class, making it easy to create custom reporters whether you simply want to have differently formatted HTML or use an entirely different markup language. Groovy is a Java-like dynamic language which runs on the JVM and interacts seamlessly with Java objects.
The JDEV_INSTALL
/jdeveloper/soa/modules/oracle.rules_11.1.1/reporter.jar
file contains style sheet oracle/rules/tools/reporter/style.css
. When you place this file in the same directory as the HTML output file that Rule Reporter generates, this provides definitions to render the page. You can modify the style sheet to change the HTML layout.
For complete details on the RuleReporter
API, see the Oracle Fusion Middleware Java API Reference for Oracle Business Rules.
The command-line or Java API use of Rule Reporter needs to have the classpath include all required JAR files.
You can execute a command line script to use Rule Report to list the contents of a dictionary.
You can execute a command line script to use Rule Report to list the contents of a dictionary.
To list the contents of a dictionary with Rule Reporter using the command line:
Open a terminal shell window on your system.
Update your classpath to include RuleReporter
dependencies as Example F-1 shows.
For more information, see Section F.1.3, "What You Need to Know About Rule Reporter Dependent Jar Files".
Run RuleReporter
with the following command line as Example F-1 shows:
java oracle.rules.tools.reporter.RuleReporter
DICT-NAME
DEST-FILE
LINK-PATHS
Where:
DICT-NAME
: the name of the rules dictionary you want to generate a report on.
For example: C:\JDeveloper\mywork\GradeApp\Grades\oracle\rules\grades\OracleRules1.rules
.
DEST-FILE
: the name of the destination file for the generated Rule Reporter output, usually suffixed with .html
.
For example: C:\Temp\report.html
.
LINK-PATHS
: a list of the locations on the file system which may contain dictionaries that DICT-NAME
links to.
For example: C:\Temp
.
If DICT-NAME
does not link to any dictionaries, you must still specify at least one path.
Example F-1 shows how to generate a report for a dictionary.
Example F-1 Executing RuleReporter on the Command Line
C:\> set CLASSPATH=%CLASSPATH%;C:\Oracle\Middleware\jdeveloper\modules\oracle.adf.model_ 11.1.1\adfm.jar;C:\Oracle\Middleware\jdeveloper\modules\oracle.adf.model_ 11.1.1\groovy-all-1.5.4.jar;C:\Oracle\Middleware\wlserver_ 10.3\server\lib\ojdbc6.jar;C:\Oracle\Middleware\jdeveloper\soa\modules\oracle.rules_ 11.1.1\rules.jar;C:\Oracle\Middleware\jdeveloper\modules\oracle.xdk_11.1.1\xmlparserv2.jar C:\> java oracle.rules.tools.reporter.RuleReporter C:\JDeveloper\mywork\GradeApp\Grades\oracle\rules\grades\OracleRules1.rules C:\Temp\report.html C:\Temp
Optionally, copy the JDEV_INSTALL
/jdeveloper/soa/modules/oracle.rules_11.1.1\reporter.jar
file oracle/rules/tools/reporter/style.css
to the same directory as the HTML output file. In this example, copy the style.css
file to C:/Temp
.
This causes a web browser to use the definitions to render the page. You can modify the style sheet to change the visual layout of the HTML as shown in Figure F-1.
Figure F-1 RuleReporter report.html with style.css
You can quickly and easily create a basic report of the contents of a dictionary using a Java application with the oracle.rules.tools.reporter.RuleReporter
class.
You can use the RuleReporter
class to list the contents of a dictionary. This class, oracle.rules.tools.reporter.RuleReporter
takes several arguments, as shown:
RuleReporter ruleReporter = new RuleReporter( DICT-NAME, DEST-FILE, LINK-PATHS );
Where:
DICT-NAME
: the name of the rules dictionary you want to generate a report on.
For example: C:\\JDeveloper\\mywork\\GradeApp\\Grades\\oracle\\rules\\grades\\OracleRules1.rules
.
DEST-FILE
: the name of the destination file for the generated Rule Reporter output, usually suffixed with .html
.
For example: C:\\Temp\\report.html
.
LINK-PATHS
: a list of the locations on the file system which may contain dictionaries that DICT-NAME
links to.
For example: new ArrayList<String>(Arrays.asList("C:\\Temp"))
.
If DICT-NAME
does not link to any dictionaries, you must still specify at least one path.
When you supply these arguments and call the RuleReporter.report()
method, this produces a dictionary report for the specified dictionary.
To list the contents of a dictionary using rule reporter with Java:
Start Oracle JDeveloper, this displays the Oracle JDeveloper start page.
In the Application Navigator, click New Application if no applications have been created, or if applications have been created, click Applications and from the list choose New Application.
In the Create Application wizard, enter the name and location for the application:
In the Application Name field, enter an application name. For example, enter ReportApplication
.
Enter or browse for a directory name, or accept the default.
Enter an application package prefix or accept the default, no prefix.
This should be a globally unique prefix and commonly uses a domain name owned by your company. The prefix, followed by a period, applies to objects created in the initial project of an application.
In this sample, you use the prefix com.example
.
For this Oracle Business Rules project, select Generic Application for the application template, as shown in Figure F-2.
Click Next.
In the Create Generic Application wizard - Name your Generic project page, enter the name and location for the project as shown in Figure F-3:
In the Project Name field, enter an application name. For example, enter ReportProject
.
Enter or browse for a directory name, or accept the default.
On the Project Technologies tab, in the Available list, select Java and click Add to add it to the Selected area.
Figure F-3 Specifying Technologies in a Project
Click Finish.
In Oracle JDeveloper, select the project named ReportProject.
Right-click and from the list select Project Properties.
Select the Libraries and Classpath item.
Add the libraries Adfm Designtime API, JAXB, ADF Model Runtime, Oracle XML Parser v2, Oracle JDBC, and Oracle Rules.
Click OK.
In Oracle JDeveloper, select the project named ReportProject.
Right-click and from the list select New.
In the New Gallery, in the Categories area, select General.
In the New Gallery, in the Items area, select Java Class.
Click OK.
In the Create Java Class window, configure the following properties as shown in Figure F-4:
Enter the Name value Report
.
Check the following check boxes:
Public
Main Method
Figure F-4 Creating the Report.java Class
Click OK.
Oracle JDeveloper displays the Java Class, as shown in Example F-2.
Use the RuleReporter
class as shown in Example F-3. Replace the first argument to the
RuleReporter
constructor with the location of your dictionary.
Example F-3 Report.java Completed
package com.example; import java.util.List; import java.util.Arrays; import java.util.ArrayList; import oracle.rules.sdk2.exception.SDKException; import oracle.rules.tools.reporter.RuleReporter; public class Report { public Report() throws SDKException { try { RuleReporter ruleReporter = new RuleReporter( "C:\\JDeveloper\\mywork\\GradeApp\\Grades\\oracle\\rules\\grades\\OracleRules1.rules", "C:\\Temp\\report.html", Arrays.asList("C:\\Temp") ); ruleReporter.report(); } catch (Exception e) { System.out.println(e); } } public static void main(String[] args) throws SDKException { Report report = new Report(); } }
In the Application Navigator, right-click ReportProject
and select Make.
In the Application Navigator, right-click Report.java
and select Run.
In this example, the Report.java
class generates the report in C:\Temp\report.html
Optionally, copy the JDEV_INSTALL
/jdeveloper/soa/modules/oracle.rules_11.1.1\reporter.jar
file oracle/rules/tools/reporter/style.css
style sheet to the same directory as the HTML output file. In this example, copy the style.css
file to C:/Temp
.
This causes a web browser to use the definitions to render the page. You can modify the style sheet to change the visual layout of the HTML as shown in Figure F-5.
Figure F-5 RuleReporter report.html with style.css