Rule Builder > Setting Up the Execution Object Model > Working With the Deployer > Setting a Ruleset Extractor Class

The Rule Builder allows you to specify the repository elements that are extracted in your ruleset in one of the following ways:

This section has the following subsections:

The Default Ruleset Extractor

The default ruleset extractor uses the working version of all the rules in the project. With this extraction behavior, the working version is seen as the "active" version of a rule. The rules are placed in a ruleset per top rule package. The packetAsPackage property can be used to specify rule packets in the ruleset based on the package structure.

Some applications may require different behavior and a custom ruleset extractor. A custom ruleset extractor could, for example, take the last nonworking version of a rule corresponding to an "approved" version, while the working version could represent the "currently being developed" version. When you start the Rule Builder, the current default ruleset extractor is automatically set and displayed in the lower part of the Deployer Settings dialog box as shown in Figure 18.5. There are no operations to carry out unless you want to change the default value.

images/deployer_settings.png

Figure 18.5    Default Rule Extractor

Setting a New Ruleset Extractor Class

The package structure enables business rules to be organized into a logical structure for the rule writers. This is not necessarily the same organization of the execution rules in a ruleset. This means that there is not always a one-to-one correspondence between packages and rulesets, and sometimes you must explicitly specify the mapping of a project to a ruleset. Ruleset extraction is typically based on the value of custom properties, such as the expiration date or the status.

The rules of a ruleset can be grouped into tasks that are contained in a ruleflow, and which set the execution order based on properties.

The Rule Builder uses the project ruleset extractor for all the operations that require a ruleset to be generated. These are:

When you create a project in the Rule Builder, this project is automatically associated with the default ruleset extractor. There is only one ruleset extractor per project, as shown in Figure 18.6.

The default ruleset extractor directly maps the top-level package to a ruleset, that is, to a set of execution rules. For compatibility reasons, the name of the generated ruleset is the name of the top-level package, and the name of an execution rule in the ruleset is the fully qualified name of the original business rule, without the name of the top-level package.

In the case where rules from different top-level packages are mixed into one ruleset, you can allow execution rules to be generated with a fully qualified name including the name of the top-level package, by customizing IlrDefaultIRLExtractor.

To define a ruleset extractor, you need to write a Java class that implements the IlrIRLExtractor interface with methods that take the repository as an argument and return the information needed to build a ruleset: ruleset name, list of rules, and so on. For more information, refer to the Java API Reference Manual.

In the Ruleset Extractor Class panel of the Deployer Settings dialog box:

  1. Click your custom extractor class and then click the arrow at the bottom of the Ruleset Extractor Class dialog box to replace the IlrDefaultIRLExtractor class.
  2. Click the Set Default button to set your custom extractor class as the default ruleset extractor for the current project in the repository (see Figure 18.6).

  3. images/deploy_03.png
  4. Figure 18.6    Ruleset Extractor Class Panel

Using Query-Based Extraction

A query can be used to specify the rules to be extracted. If the query condition is true and the action "insert as query result" is set when you extract rules, only the rules that match the query elements are extracted into a ruleset for deployment.

This operation requires the Query plug-in installed.

To extract rules, proceed as follows (a sample query is provided):

  1. Click Options on the File menu to open the Options dialog box. Install the Query plug-in, and click the OK button.
  2. Click Query Editor on the View>Query Panel menu or click the images/queryEditor_buttona.png button to open the Query Editor.
  3. Click the images/addquery_icona.png button in the Query Editor to add a new query.
  4. Rename the query to Rules to Extract in the Property Sheet as shown in Figure 18.7.

  5. images/rulestoextract.png
  6. Figure 18.7    Renaming the Rule Query
  7. Write the following rule query:
  8.  For each business rule
    
  9.  such that priority is high
    
  10.  Do
    
  11.  Insert as query result
    

Your query should look like Figure 18.8.

images/query_panel5.png

  • Figure 18.8    Creating a Query to Extract Rules
    1. In the Project Explorer, click Deployer and set the extractionQuery field to Rules to Extract in the Property Sheet as shown in Figure 18.9.

    2. images/rulestoextract1.png
    3. Figure 18.9    Setting the Deployer extractionQuery Field
    4. In the Project Explorer, click your top-rule package and then click the images/execute_buttona.png button to execute it. The Engine Explorer displays the rules deployed, which match the defined query, see Figure 18.10.

    5. images/enginequerylist.png
    6. Figure 18.10    Engine Explorer with Extracted Rules

    See Also

    Engine Explorer | Project Explorer | Queries | Ruleflows | Setting Up Ruleset Imports | Exporting a Ruleset | Business Rule Checks | Rule Editor Shortcuts | Testing the Execution of a Ruleset | Setting the Classpaths | Setting a Ruleset Extractor Class | Exporting a Ruleset


    Customer Support | Copyright © 1987-2004 ILOG S.A. All rights reserved. Legal terms. PREVIOUS   NEXT