Understanding Oracle Business Rules ADF Business Components Fact Types

10 Working with Oracle Business Rules and ADF Business Components 10-1 10 Working with Oracle Business Rules and ADF Business Components Oracle Business Rules allows you to use Oracle ADF Business Components view objects as facts. By using ADF Business Components facts you can assert trees of view object graphs representing the business objects upon which rules should be based, and let Oracle Business Rules handle the complexities of managing the relationships between the various related view objects in the main view objects tree. This chapter includes the following sections: ■ Section 10.1, Introduction to Using Business Rules with ADF Business Components ■ Section 10.2, Using Decision Points with ADF Business Components Facts ■ Section 10.3, Creating a Business Rules Application with ADF Business Components Facts

10.1 Introduction to Using Business Rules with ADF Business Components

The ADF Business Components rule development process can be summarized as follows: 1. Create view object definitions. 2. Create action types. 3. Create rule dictionary. 4. Register view object fact types. 5. Register Java fact types for actions. 6. If you are invoking from Java: ■ If the view object is already instantiated at the Decision Point, code the Decision Point invocation passing the view object instance. ■ If the view object is not instantiated at the Decision Point, code the Decision Point invocation passing the view object key values.

10.1.1 Understanding Oracle Business Rules ADF Business Components Fact Types

When an ADF Business Components view object is imported into an Oracle Business Rules data model, an ADF Business Components fact type is created which has a property corresponding to each attribute of the view object, as shown in Figure 10–1 . 10-2 Oracle Fusion Middleware Users Guide for Oracle Business Rules Additionally, the ADF Business Components fact type contains the following: ■ A property named ViewRowImpl which points directly to the oracle.jbo.Row instance that each fact instance represents. ■ A property named key_values which points to an oracle.rules.sdk2.decisionpoint.KeyChain object. You can use this property to retrieve the set of key-values for this row and its parent rows. Figure 10–1 ADF Business Components Sample Fact Type Note the following: ■ Relationships between view object definitions are determined by introspection of attributes on the View Definition, specifically, those attributes which are View Link Accessors. The ADF Business Components fact type importer correctly determines which relationships are 1-to-1 and which are 1-to-many and generates definitions in the dictionary accordingly. For 1-to-many relationships the type of the property generated is a List which contains facts of the indicated type at runtime. ■ ADF Business Components fact types are not Java fact types and do not allow invoking methods on any explicitly created implementation classes for the view object. If you need to call such methods then add the view object implementation to the dictionary as a Java fact type instead of as an ADF Business Components fact type. In this case, all getters and setters and other methods become available but the Working with Oracle Business Rules and ADF Business Components 10-3 trade-off is that related view objects become inaccessible and, should related view object access be required, these relationships must be explicitly managed. ■ Internally in Oracle Business Rules, when you use ADF Business Components fact types these fact types are created as instances of RL fact types. Thus, you cannot assert ADF Business Components view object instances directly to a Rule Session, but must instead use the helper methods provided in the MetadataHelper and ADFBCFactTypeHelper classes. For more information, see Oracle Fusion Middleware Java API Reference for Oracle Business Rules.

10.1.2 Understanding Oracle Business Rules Decision Point Action Type