Skip Headers
Oracle® Fusion Middleware User's Guide for Oracle Business Rules
11g Release 1 (11.1.1.4.0)

Part Number E10228-05
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

F Working with Rule Reporter

This appendix includes the following sections:

F.1 Introduction to Working with Rule Reporter

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:

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.

F.1.1 What You Need to Know About Rule Reporter HTML Style Sheets

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.

F.1.2 What You Need to Know About RuleReporter API

For complete details on the RuleReporter API, see the Oracle Fusion Middleware Java API Reference for Oracle Business Rules.

F.1.3 What You Need to Know About Rule Reporter Dependent Jar Files

The command-line or Java API use of Rule Reporter needs to have the classpath include all required JAR files.

F.2 Using Rule Reporter Command Line Interface

You can execute a command line script to use Rule Report to list the contents of a dictionary.

F.2.1 How to List the Contents of a Dictionary with Rule Reporter Command Line

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:

  1. Open a terminal shell window on your system.

  2. 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".

  3. 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
    
    
  4. 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

    Description of Figure F-1 follows
    Description of "Figure F-1 RuleReporter report.html with style.css"

F.3 Using Rule Reporter with Java

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.

F.3.1 How to List the Contents of a Dictionary Using Rule Reporter with Java

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:

  1. Start Oracle JDeveloper, this displays the Oracle JDeveloper start page.

  2. 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.

  3. In the Create Application wizard, enter the name and location for the application:

    1. In the Application Name field, enter an application name. For example, enter ReportApplication.

    2. Enter or browse for a directory name, or accept the default.

    3. 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.

    4. For this Oracle Business Rules project, select Generic Application for the application template, as shown in Figure F-2.

    Figure F-2 Adding the Report Application

    Description of Figure F-2 follows
    Description of "Figure F-2 Adding the Report Application"

  4. Click Next.

  5. 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

    Description of Figure F-3 follows
    Description of "Figure F-3 Specifying Technologies in a Project"

  6. Click Finish.

  7. In Oracle JDeveloper, select the project named ReportProject.

  8. Right-click and from the list select Project Properties.

  9. Select the Libraries and Classpath item.

  10. Add the libraries Adfm Designtime API, JAXB, ADF Model Runtime, Oracle XML Parser v2, Oracle JDBC, and Oracle Rules.

  11. Click OK.

  12. In Oracle JDeveloper, select the project named ReportProject.

  13. Right-click and from the list select New.

  14. In the New Gallery, in the Categories area, select General.

  15. In the New Gallery, in the Items area, select Java Class.

  16. Click OK.

  17. In the Create Java Class window, configure the following properties as shown in Figure F-4:

  18. Click OK.

    Oracle JDeveloper displays the Java Class, as shown in Example F-2.

    Example F-2 Code Created for New Report.java Class

    package com.example;
    
    public class Report {
        public static void main(String[] args) {
            Report report = new Report();
        }
    }
    
  19. 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();
      }
    }
    
  20. In the Application Navigator, right-click ReportProject and select Make.

  21. 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

  22. 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

    Description of Figure F-5 follows
    Description of "Figure F-5 RuleReporter report.html with style.css"