How to Display and Edit Java Facts What You Need to Know About Java Facts

3-10 Oracle Fusion Middleware Users Guide for Oracle Business Rules Java classes in the project should appear in the Classes importer. If they do not appear, execute the Build action for the project.

6. Click Open. This adds the classpath or jar file and updates the Classes area.

7. In the Create Java Fact dialog, in the Classes area select the packages and classes

to import as shown in Figure 3–7 . Figure 3–7 Selecting Java Classes for Java Facts

8. Click OK. This updates the Java Facts table in the Java Facts tab.

3.3.2 How to Display and Edit Java Facts

To display or edit Java Facts after you import the Java Facts, use the Edit Java Fact dialog. To display and edit Java facts: 1. In Rules Designer, click the Facts navigation tab. 2. Select the Java Facts tab in the Facts navigation tab. 3. In the Java Facts table, double-click the Java Fact you want to edit. This displays the Edit Java Fact dialog as shown in Figure 3–8 . Working with Facts and Bucketsets 3-11 Figure 3–8 Edit Java Fact Dialog The Edit Java Fact dialog includes the fields shown in Table 3–2 .

3.3.3 What You Need to Know About Java Facts

When you define Java Facts you need to know the following: ■ On Windows systems, you can use a backslash \ or a slash to specify the classpath in the Classpath area. Rules Designer accepts either path separator. ■ Classes and interfaces that you use in Rules Designer must adhere to the following rules: If you are using a class or interface, only its superclass or one of its implemented interfaces may be made visible. ■ When you specify the classpath you can specify a JAR file, a ZIP file, or a full path for a directory. ■ When you specify a directory name for the classpath, the directory specifies the classpath that ends with the directory that contains the root package the first package in the full package name. Thus, if the classpath specifies a directory, Table 3–2 Edit Java Fact Dialog Fields Field Description Class Displays the Java Fact class for the source associated with the Java Fact. Alias Enter the Java Fact alias. Super Class Displays Java super class associated with this fact. Description Enter the Java Fact description. Visible Select to show the Java Fact in lists in Rules Designer. Attributes area Select the available class properties, constructors, methods, or fields associated with the Java class for the Java Fact act to display or edit. 3-12 Oracle Fusion Middleware Users Guide for Oracle Business Rules Rules Designer looks in that tree for directory names matching the package name structure. For example, to import a class cool.example.Test1 located in c:\myprj\cool\example\Test1.class , specify the classpath value, c:\myprj . ■ You should reimport facts if you change the classes. After the reimport operation you may see validation warnings due to class changes. You should correct any validation warnings that may be caused by incompatible changes for example, removing a property that is referenced by a rule.

3.4 Working with RL Facts

RL Facts are the only kind of facts that you can create directly and do not have an external source. All other types of Oracle Business Rules facts are imported. An RL Fact is similar to a relational database row or a JavaBean without methods. An RL Fact contains a list of properties of types available in the data model, either RL Fact, Java Fact, or primitive types. You can use an RL Fact to extend a Java application object model by providing virtual dynamic types. For example: IF customer spent 500 within past 3 months THEN customer is a Gold Customer This rule might use a Java Fact to specify the customer data and also use an action that creates an RL Fact, Gold Customer. A rule might be defined to use a Gold Customer fact, as follows: IF customer is a Gold customer THEN offer 10 discount This rule uses the RL Fact named Gold Customer. This rule then infers, using the Gold Customer fact, that if a customer spent 500 within the past 3 months, then the customer is eligible for a 10 discount. In addition rules could specify other ways that a customer becomes a Gold Customer. For testing and prototyping with Rules Designer you can create RL Facts and use the RL Facts to write and test rules before you import a schema and switch to XML Facts you might need to wait for an approved XML schema to be created or to be made available. Switching from RL Facts to corresponding XML Facts involves the following steps: 1. Delete the RL Facts this action shows validation warnings in the rules or Decision Tables you created that use these RL Facts. 2. Import the XML Facts and give the facts and their properties aliases that match the names of the RL Facts and properties you deleted in step 1. 3. This process should remove the validation warnings if the XML Fact and property aliases and types match those of the RL Facts that you remove.

3.4.1 How to Define RL Facts

You add RL Facts from the Facts navigation tab. To define RL facts:

1. In Rules Designer, select the Facts navigation tab.