17 Using Oracle Business Rules

Get an overview of Oracle Business Rules and learn how to use Oracle Business Process Composer to create and edit business rules.

17.1 Introduction to Oracle Business Rules

Oracle Business Rules allow process analysts to change policies that are expressed as business rules, with little or no assistance from a process developer. Applications using Oracle Business Rules support continuous changes that allow the applications to adapt to new government regulations, improvements in internal company processes, or changes in relationships between customers and suppliers.

Use business rules to define key decisions and policies for a business, including:

  • Business policies such as spending policies and approval matrices.

  • Constraints such as valid configurations or regulatory requirements.

  • Computations such as discounts or premiums.

  • Reasoning capabilities such as offers based on customer value.

For example, a car rental company might use the following business rule:

IF
Rental_application.driver age < 21
THEN
modify Rental_application(status: "Declined")

An airline might use a business rule such as the following:

IF
Frequent_Flyer.total_miles > 10000
THEN
modify Frequent_Flyer (status : "GOLD")

A financial institution could use a business rule such as:

IF
Application_loan.income < 10000
THEN
modify Application_loan (deny: true)

These examples represent individual business rules. In practice, you can use Oracle Business Rules to combine many business rules or to use more complex tests.

Oracle Business Rules provides multiple approaches to writing rules:

  • IF/THEN rules - expressed as IF/THEN statements.

    There are two ways of modeling IF/THEN rules. General rules use a pseudo-code language to express rule logic. Verbal rules use natural language statements to express rule logic.

  • Decision Tables, which display multiple related rules in a single spreadsheet-style view.

Business phrases are used to provide a natural language vocabulary for the construction of verbal rules' tests and actions. They are not used in general rules.

General rules, verbal rules, and Decision Tables are grouped in an Oracle Business Rules object called a ruleset. (See Working with Rulesets.)

You group one or more rulesets and their facts and valuesets in an Oracle Business Rules object called a dictionary.

For a complete discussion of the concepts behind general and verbal rules, Decision Tables, and business phrases, see the "Working with Rulesets and Rules" chapter in Designing Business Rules with Oracle Business Process Management

Rules

Rules follow an IF-THEN structure and consist of two parts:

  • IF part: A condition or pattern match.

    The rule IF part is composed of conditional expressions and rule conditions that refer to facts. For example:

    IF Rental_application.driver age < 21
    

    The conditional expression compares a business term (Rental_application.driver age) to the number 21 using a less than comparison.

    The rule condition activates the rule whenever a combination of facts makes the conditional expression true. In some respects, the rule condition is like a query over the available facts in the Rules Engine, and for every row returned from the query the rule is activated.

  • THEN part: A list of actions.

    The rule THEN part contains the actions that are run when the rule is fired. A rule is fired after it is activated and selected among the other rule activations using conflict resolution mechanisms such as priority. A rule might perform several kinds of actions. An action can add facts, modify facts, or remove facts. An action can run a Java method or perform a function which may modify the status of facts or create facts.

    Rules fire sequentially, not in parallel. Rule actions often change the set of rule activations and therefore change the next rule to fire.

Decision Tables

A Decision Table is an alternative business rule format that is more compact and intuitive when many rules are required to analyze many combinations of property values. You can use a Decision Table to create a set of rules that covers all combinations or where no two combinations conflict.

For more information about decision tables, see Working with Decision Tables. and the "Working with Rulesets and Rules" chapter in Designing Business Rules with Oracle Business Process Management

17.2 Working with Oracle Business Process Composer Rules Editor

The Business Rules Editor allows you to create, view and edit facts, functions, globals, value sets, links, decision functions, and business phrases within a business rules dictionary.

From the Project Welcome Page, go to the Components pane and select Rules. Click the name of the dictionary you want to open.

When you open a business rules dictionary, Oracle Business Process Composer displays the Rulesets page, as shown in Figure 17-1.

A ruleset is an Oracle Business Rules container for rules and Decision Tables. A ruleset provides a namespace, similar to a Java package, for rules and Decision Tables. In addition you can use rulesets to partially order rule firing.

Figure 17-1 Business Rules Editor - Rulesets

Description of Figure 17-1 follows
Description of "Figure 17-1 Business Rules Editor - Rulesets"

The Business Rules Editor page provides the tools for you to view rulesets and the data model, including:

  • Value Sets

  • Globals

  • Business Phrases

  • Explorer

  • Facts

  • Decision Functions

  • Links

  • Translations

To edit elements such as the value sets, and globals contained within the opened business rule dictionary, ensure that the project is in edit mode.

The Business Rules Editor page also provides the tools for you to perform the following actions:

These are accessed from the Actions menu, shown in Figure 17-2

Figure 17-2 Business Rules Editor - Actions

Description of Figure 17-2 follows
Description of "Figure 17-2 Business Rules Editor - Actions"

17.2.1 Introduction to Decision Points

Oracle Business Rules SDK (Rules SDK) provides APIs for writing applications that access, create, modify, and run rules in Oracle Business Rules dictionaries (and all the contents of a dictionary). The Rules SDK provides the Decision Point API to access and run rules or Decision Tables from a Java application.

17.3 Working with Business Rule Dictionaries

A business rule dictionary is an Oracle Business Rules container for facts, functions, globals, value sets, links, decision functions, and rulesets. A business rule dictionary is an XML file that stores the application's rulesets and the data model.

Dictionaries can link to other dictionaries. Using Oracle Business Process Composer you can create as many dictionaries as you require. A dictionary may contain any number of rulesets.

17.3.1 How to Create a New Business Rule Dictionary

Using Oracle Business Process Composer you can create as many business rule dictionaries as you require.

To create a new business rule dictionary:

  1. From the Project Welcome Page, go to the Components pane and select Rules.

  2. Click the new icon to display the New Business Rule dialog, as shown in Figure 17-3.

    Figure 17-3 New Business Rule Dialog

    Description of Figure 17-3 follows
    Description of "Figure 17-3 New Business Rule Dialog"
  3. Enter a name and a package for the business rule dictionary.

    These fields are required fields.

  4. Select the Expose Composite Service check box if required.

  5. Define the input and output data objects.

    1. Click the Add data object button.

    2. Select Input from the drop down list on the right side of the window.

    3. Enter a name for the data object.

    4. From the drop down list, select a data type.

      The data type must not be a simple type, it must be a type defined as a business object.

    5. Click Add.

      The data object appears in Input and Output Data Objects table.

    6. Click the Add data object button and then select Output from the drop down list.

    7. Enter a name for the data object.

    8. From the drop down list, select a data type.

      The data type must not be a simple type, it must be a type defined as a business object.

    9. Click Add.

      The data object appears in Input and Output Data Objects table.

  6. Click OK.

17.3.2 Viewing and Editing Dictionary Settings

You can view and edit dictionary settings using the Dictionary Settings dialog The Settings dialog has three areas: Execution, Choices, and Data Model, as shown in Figure 17-4.

Figure 17-4 Actions - Dictionary Settings

Description of Figure 17-4 follows
Description of "Figure 17-4 Actions - Dictionary Settings"

Use the Execution area to select the execution algorithm. Select either RETE or Non-RETE.

Oracle Business Rules uses the Rete algorithm to optimize the pattern matching process for rules and facts. The Rete algorithm stores partially matched results in a single network of nodes in working memory.

By using the Rete algorithm, Oracle Business Rules avoids unnecessary rechecking when facts are deleted, added, or modified. To process facts and rules, the Rete algorithm creates and uses an input node for each fact definition and an output node for each rule.

The Rete algorithm provides the following benefits:

  • Independence from rule order: Rules can be added and removed without affecting other rules.

  • Optimization across multiple rules: Rules with common conditions share nodes in the Rete network.

  • High performance inference cycles: Each rule firing typically changes just a few facts and the cost of updating the Rete network is proportional to the number of changed facts, not to the total number of facts or rules.

The Non-Rete algorithm (NRE) is an alternative to the Rete algorithm that consumes less memory than the Rete algorithm. For many business rules use cases it also results in improved performance. The core of NRE algorithm is a new rule condition evaluation approach.

Use the Choices area to specify phrase suggestions that appear when you are using Verbal Rules. You can choose to see auto suggestions only, business phrases only, or both.

Use the Data Model area to specify the global qualifier pattern, also for Verbal Rules. The pattern must contain two fragments: {member}, {fact}. For example, {member} of {fact}.

To view or edit dictionary settings:

  1. Open the business rule dictionary where you want to view or edit the dictionary settings.
  2. Go to the toolbar and click Actions, Dictionary Settings, as shown in Figure 17-4.
  3. Make the required changes and then click Save.

17.3.3 Synchronizing Business Objects

If you change one of the business objects you used when you created your business rule dictionary then you must refresh or synchronize the business object in the Business Rules Editor for the changes to take effect.

To synchronize business objects:

  1. Open the business rule dictionary where you want to synchronize business objects.
  2. Go to the toolbar and click Actions, Sync Business Objects, as shown in Figure 17-2.

    The system automatically synchronizes the business objects used in the selected business rules dictionary.

17.4 Working with Dictionary Links

Using a dictionary with links to another dictionary is useful for data model sharing.

  • Data Model Sharing: Share portions of a data model within a project. When you link to a dictionary in another project it is copied to the local project.

    For example, consider a project where you would like to share some Oracle Business Rules functions. You can create a dictionary that contains the functions, and name it DictCommon. Then, you can create two dictionaries, DictApp1 and DictApp2 and link them both to DictCommon. Both can use the same Oracle Business Rules functions and when you want to change one of the functions, you only change the version in DictCommon. Both dictionaries uses the updated function the next time RL Language is generated from either DictApp1 or DictApp2.

In Oracle Business Rules a fully qualified dictionary name is called a DictionaryFQN and this consists of two components:

  • Dictionary Package: The package name.

  • Dictionary Name: The dictionary name

A dictionary refers to a linked dictionary using its DictionaryFQN and an alias. Oracle Business Rules uses the DictionaryFQN to find a linked dictionary.

The following are the naming constraints for combined dictionaries:

  • The full names of the dictionaries, including the package and name, must be distinct.

    In addition, the dictionary aliases must be distinct.

  • The aliases of data model definitions of a particular kind, for example, function, Oracle RL class, or value set, must be unique within a dictionary.

  • A definition may be qualified by the alias of its immediately containing dictionary.

    Definitions in the top and built-in dictionaries do not have to be qualified. Definitions in other dictionaries must be qualified and this qualification is controlled by the prefix linked names property of the dictionary link.

  • Ruleset names must be unique within a dictionary.

    When RL Language for a ruleset is generated, the dictionary alias is not part of any generated name. For example, if the dictionary named DictApp1 links to DictApp2 to create a combined dictionary, and DictApp1 contains ruleset_1 with rule_1 and DictApp2 also contains ruleset_1 with rule_2, then in the combined dictionary both of these rules, rule_1 and rule_2 are in the same ruleset (ruleset_1).

  • All rules and Decision Tables must have unique names within a ruleset.

    For example, within a combined dictionary that includes dictionary DictApp1 links to DictApp2, dictionary DictApp1 may have a ruleset named Ruleset_1 with a rule rule_1. If dictionaryDictApp2 also has a ruleset named Ruleset_1 with a rule_2, then when Oracle Business Rules generates RL Language from the combined, linked dictionaries, both rules rule_1 and rule_2 are in the single ruleset named Ruleset_1. If you violate this naming convention and do not use distinct names for the rules within a ruleset in a combined dictionary, a validation warning is reported, similar to the following:

    RUL-05920: Rule Set Ruleset_1 has two Rules with name rule_1

To view linked dictionaries:

  1. Open the business rule dictionary where you want to view dictionary links.

  2. Go to the toolbar and click Links, as shown in Figure 17-5.

    Figure 17-5 Business Rules Editor - Links

    Description of Figure 17-5 follows
    Description of "Figure 17-5 Business Rules Editor - Links"

17.5 Working with Rulesets

Using Oracle Business Process Composer you can edit, add, and delete rulesets.

Note that when you create a new business rule dictionary, a default ruleset is automatically created

17.5.1 How to Add General Rules and Verbal Rules to a Ruleset

Use the Business Rules Editor to add, edit, and delete rules in a ruleset.

You author general rules, verbal rules and business phrases in Business Process Composer in the same fashion as in Oracle Business Process Management Studio. There are some differences in the way you interact with the GUI, such as the use of the keyboard when creating business phrases.

For a complete description of the concepts behind the configuration of general rules and verbal rules, see "Working with Rules" in Designing Business Rules with Oracle Business Process Management.

17.5.1.1 Adding a Rule to a Ruleset

To add a rule to a ruleset:

  1. Open the business rule dictionary containing the ruleset where you want to add a rule.
  2. Go to the toolbar and click Rulesets, then select the required ruleset from the listing of rulesets defined for this business rule.
  3. Click the New Rule icon and select to add either a General Rule, or Verbal Rule.
17.5.1.2 Adding a General Rule

To add a general rule:

  1. Click the Advanced Property Editor icon located to the right of the rule name to edit the name for this new rule, as shown in Figure 17-6.

    Figure 17-6 Business Rules Editor: Rulesets - New General Rule

    Description of Figure 17-6 follows
    Description of "Figure 17-6 Business Rules Editor: Rulesets - New General Rule"
  2. In the IF area, use the controls, icons, and selection boxes, including the Left Value expression icon, drop-down list for an operator, and Right Value expression icon to modify the condition.
  3. In the THEN area for the rule, next to the rule action click Add Action.
17.5.1.3 Adding a Verbal Rule

To add a verbal rule:

  1. Click the Advanced Property Editor icon located to the right of the rule name to edit the name for this new rule, as shown in Figure 17-7

    Figure 17-7 Business Rules Editor: Rulesets - New Verbal Rule

    Description of Figure 17-7 follows
    Description of "Figure 17-7 Business Rules Editor: Rulesets - New Verbal Rule"
  2. In the IF area, click Add Test. specify tests by entering business phrases.
  3. In the THEN area for the rule, click Add Action to add the required action for this rule.

17.6 Working with Decision Tables

A Decision Table displays multiple related rules in a single spreadsheet-style view. In Business Rules Editor, a Decision Table presents a collection of related business rules with condition rows, rules, and actions presented in a tabular form that is easy to understand. Business users can compare cells and their values at a glance and can use Decision Table rule analysis features by clicking icons and selecting values in Business Rules Editor to help identify and correct conflicting or missing cases.

To help understand Decision Table concepts, consider a set of IF/THEN rules that determine if a loan application is approved or rejected.

The IF/THEN rules follow:

if loanAmount < 10,000 and creditRating = poor then loanApprovalStatus = manual_approval
if loanAmount < 10,000 and creditRating = good then loanApprovalStatus = auto_approved
if loanAmount [100,000..500,000] and creditRating = poor then loanApprovalStatus = auto_rejected

Figure 17-8 shows a Decision Table representation that includes these rules and shows areas for Decision Table conditions and actions.

Figure 17-8 Sample Decision Table with Conditions and Actions

Description of Figure 17-8 follows
Description of "Figure 17-8 Sample Decision Table with Conditions and Actions"

A ruleset contains a Decision Table; this provides a way to group the Decision Table along with IF/THEN rules. When rules and Decision Tables are grouped in a ruleset, the IF/THEN rules and the Decision Table rules all execute as a set of interrelated rules.

A rule in a Decision Table is not named. Although Business Rules Editor shows rules in a Decision Table with labels, for example, R1, R2, and R3, these rule labels are not names for individual rules but are labels derived from the current ordering of the rules in the Decision Table. Therefore, a rule with the label R1 can be moved to position 3 and then Business Rules Editor relabels this rule R3.

Decision Table Conditions

The Conditions area in a Decision Table includes one or more condition rows. Each condition row has a condition expression and, for each rule, a condition cell. A condition expression is an expression that you build in Business Rules Editor. The condition expression is often a fact property or a function result, but it can be any expression that has a type that can be associated with a value set. The value or the range for a given condition cell takes its value or its range from one or more values or ranges in the associated LOV or Ranges value set.

Decision Tables show rules in value order, and to change the order of rules you must change the order of values in the value sets. Therefore, the order of the values in the value set associated with a condition row determines the order of the condition cells, and therefore the order of the rules. You can control rule ordering in a Decision Table by changing the relative position of the values in an LOV value set associated with a condition row; however, you cannot reorder range values.

By default, when you create a condition row, Business Rules Editor creates a single condition cell and assigns the "?" value to the cell. A condition cell with the value "?" indicates that the value of the cell is undefined in the value set.

Decision Table Actions

Actions are associated with rules in a Decision Table. At runtime, when facts match for condition cells, the Rules Engine prepares to run the actions associated with the rule.

Table 17-1 shows the types of actions you can choose in the Actions area. Therefore, in an action you can call a function, assert a new fact, retract a fact, or modify a fact, and so on. In the Actions area the cells corresponding to an individual action for a rule are called action cells.

Table 17-1 Decision Table Actions

Action Description

assert new

Assert a new fact

assign

-

call

Call a function

modify

Modify a data value associated with a matched fact

retract

Retract a fact

assert

-

assert tree

-

assign new

-

expression

-

return

-

throw

-

When you add multiple actions the actions that you add in the Actions area are ordered; actions appearing in the higher rows run before actions in the following rows.

The Decision Table actions such as modify can refer to facts matched in the condition cells. Certain types of actions in the Actions area include a Parameterized check box. This check box specifies that a property from the action can have its value set in the action cell associated with a rule in the Decision Table. When the parameterized check box is selected, the value you supply for the expression value in the action, in the Actions area, becomes the default value for the property if a value is not supplied in the action cell. For example, see Figure 17-9 where the value GOOD is assigned as the default value for the action property loanApprovalStatus.

Figure 17-9 Action Editor Showing Paramaterized Action with Default Value

Description of Figure 17-9 follows
Description of "Figure 17-9 Action Editor Showing Paramaterized Action with Default Value"

In the Decision Table Actions area you can specify that an action cell do nothing. In this case, clear the action cell. When the action cell check box is cleared, this means do not perform this action when the pattern matches for the specified condition values in the Decision Table. Therefore, for each action cell you can specify whether the rule associated with the action cell should activate the action, or do not perform the action.

17.6.1 How to Add a Decision Table to a Ruleset

You add a Decision Table by performing several steps. These steps include:

  • Create a Decision Table.

  • Add conditions to the Decision Table.

  • Add actions to the Decision Table.

  • Use Decision Table operations to validate, correct, and modify the Decision Table.

To add a Decision Table:

A Decision Table displays multiple related rules in a single spreadsheet-style view.

  1. Open the business rule dictionary containing the ruleset where you want to add a Decision Table.
  2. Go to the toolbar and click Rulesets, then select the required ruleset from the listing of rulesets defined for this business rule.
  3. Click the New Rule icon and select to add a Decision Table.
  4. Click the Advanced Property Editor icon located to the right of the rule name to edit the name for this new rule.
  5. Use the controls, icons, and selection boxes to create your decision table when many rules are required, as shown in Figure 17-10.

    Figure 17-10 Business Rules Editor: Rulesets - New Decision Table Rule

    Description of Figure 17-10 follows
    Description of "Figure 17-10 Business Rules Editor: Rulesets - New Decision Table Rule"

For more detailed information about how to create Decision Tables and the tools available, see Designing Business Rules with Oracle Business Process Management, "Working with Decision Tables".

17.7 Working with Facts

In Oracle Business Rules, facts are the objects that rules reason on. Each fact is an instance of a fact type. You must import or create one or more fact types before you can create rules. Facts are created and edited in BPM Studio. You can view facts in Composer.

In Oracle Business Rules a fact is an asserted instance of a class. The Oracle Business Rules runtime or a developer writing in the Oracle Rule Language (RL) uses the RL Language assert function to add an instance of a fact to the Oracle Business Rules Engine.

Note:

Oracle Rule Language (RL) is the native language for Oracle Business Rules

Using the Business Rules Editor you can view facts, as shown in Figure 17-11.

Figure 17-11 Business Rules Editor - Facts

Description of Figure 17-11 follows
Description of "Figure 17-11 Business Rules Editor - Facts"

Fact types can be based on the following:

  • XML Facts: XML Facts are imported from existing sources by specifying XML Schema.

    In BPM Studio, you can add aliases to imported XML Facts or use XML Facts with RL Facts to change the data model according to your business requirements.

  • Java Facts: Java Facts are imported from existing sources.

    In BPM Studio, you can add aliases to Java Facts or use them with RL Facts to target the data model to business requirements. Java Facts are also used to import supporting Java classes for use with the rules or Decision Tables that you create.

  • 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 with properties. An RL Fact contains a set of named, typed properties. Property values can be primitives such as String, another structured fact, or a list. RL Facts are useful for rapid and independent development and testing of decision logic. Input data that ultimately comes from an imported fact type (for example, an XML Schema) can be modeled using RL Facts before the imported schema is available or stable. Intermediate decisions that should not be returned to the application (for example, sub-decisions that categorize a customer as GOOD or BAD). It is usually best to import the fact types that are used for the input and output data of a decision. You can use RL Facts to extend a Java application object model by providing virtual dynamic types.

  • ADF Business Components Facts: ADF Business Components Facts allow you to use ADF Business Components as Facts in rules and in Decision Tables.

    By using ADF Business Components Facts you can assert view object graphs representing the business objects upon which rules should be based, and let Oracle Business Rules deal with the complexities of managing the relationships between the various related view objects in the view object graph.

In the Oracle Business Rules runtime such fact type instances are called facts.

17.8 Working with Value Sets

You can create value sets to define a list of values or a range of values of a specified type. After you create a value set you can associate the value set with a fact property of matching type. Oracle Business Rules uses the value sets that you define to specify constraints on the values associated with fact properties in rules or in Decision Tables.

You can also use value sets to specify constraints for variable initial values and function return values or function argument values.

Using Business Rules Editor you can add, edit, or delete value sets to a business rule dictionary.

17.8.1 How to Add a Value Set

Using the Business Rules Editor, you can edit, add, or delete value sets contained in a business rule dictionary

To add a new value set:

  1. From the Project Welcome page, go to the Components pane and select Rules.
  2. Click the name of the dictionary you want to open.

    The dictionary appears in the Business Rules Editor, as shown in Figure 17-1. Ensure that the project is in edit mode.

  3. Go to the toolbar and click Value Sets.

    This displays a table listing the value sets in the selected business rule, as shown in Figure 17-12.

    Figure 17-12 Business Rules Editor - Value Sets

    Description of Figure 17-12 follows
    Description of "Figure 17-12 Business Rules Editor - Value Sets"
  4. Click the Add Value Set drop-down list, then select the type of value set you want to create.
    • Value Set

    • Range Value Set

  5. Select the value set from the list, then edit the value set as required.

    Depending on the type of the value set, this displays a corresponding Edit value set page. Figure 17-12 shows an example of a range value set.

17.8.2 How to Edit an Existing Value Set

In the Business Rules Editor, selecting Value Sets shows you a table listing the value sets in the dictionary. To edit a value set, select the appropriate row and click the edit icon. Depending on the type of the value set, Range, Enum, or LOV, this displays a corresponding Edit value set page.

You can create a range value set by clicking Add in the menu bar and selecting a type. This adds a new row in the value sets table. Adding a value automatically adds an end point for a range value and a value for an LOV value based on the data type. You can modify the newly added value end point or value. Note that the alias is modified when an end point or value is changed.

To delete a value set, select a row and click Delete.

To edit a value set:

  1. Open the business rule dictionary where you want to edit the value set.
  2. Go to the toolbar and select Value Sets.

    This displays a table listing the value sets in the dictionary.

  3. Select the appropriate value set row and click the edit value set icon.
  4. Use the Value Set Editor to edit the appropriate fields in the value set.
  5. Click OK to confirm the changes.

17.9 Working with Global Variables

Using Business Rules Editor you can add, edit, or delete global variables to a business rule dictionary. You can use global definitions to share information among several rules and functions.

For example, if a 10% discount is used in several rules you can create and use a global Gold Discount, so that the appropriate discount is applied to all the rules using the global.

17.9.1 How to Add a Global Variable

Using the Business Rules Editor, you can edit, add, or delete global variables contained in a business rule dictionary

To add a new global:

  1. From the Project Welcome page, go to the Components pane and select Rules.
  2. Click the name of the dictionary you want to open.

    The dictionary appears in the Business Rules Editor, as shown in Figure 17-1. Ensure that the project is in edit mode.

  3. Go to the toolbar and click Globals.

    This displays a table listing the globals in the selected business rule dictionary, as shown in Figure 17-13.

    Figure 17-13 Business Rule Editor - Globals

    Description of Figure 17-13 follows
    Description of "Figure 17-13 Business Rule Editor - Globals"
  4. In the Name field, enter a name or accept the default value.
  5. In the Value field, enter a value, select a value from the list, or click the Expression Builder icon to enter an expression.

    For more information about using expressions, see Using Expressions to Control Data .

  6. Optionally, in the Value Set field, select a value from the list.
  7. In the Type field, select the type from the list.
  8. If the global is a nonfinal, then deselect the Final check box.

    When unselected, this option specifies that the global is modifiable, for instance, in an assign action.

  9. If the global is a constant, then select the Constant check box.

    When selected, this option specifies that the global is a constant value. For more information, see About Final and Constant Options.

17.9.1.1 About Final and Constant Options

The Globals variable includes the Constant and Final options that you can select. Consider the following when you use global variables:

  • When you deselect Final, this specifies that the global is modifiable, for instance, in an assign action.

  • When you select Final, this specifies that you can use the globals in a test in a rule (nonfinal globals cannot be used in a test in a rule).

  • When you select Final, this specifies that the global is initialized one time at runtime and cannot be changed.

When you select the Constant option, this specifies the global is a constant. In Oracle Business Rules a constant is a string or numeric literal, a final global whose value is a constant, or a simple expression involving constants and +, -, *, and /.

Selecting the Constant option for a global has three effects:

  • You do not have to surround string literals with double quotes.

  • Only constants appear in the expression value choice list.

  • The expression value must be a constant to be valid.

Selecting the Constant option is optional. Note that values, value range endpoints, and ruleset filter values are always constant.

17.9.2 How to Edit Globals

In the Business Rules Editor, selecting the Globals tab shows you a table listing the globals in the dictionary.

To edit a global variable, select the appropriate row and variables. You can edit the Name, Description, and Value fields. For the Value field, you can use the expression builder to set the value.

17.10 Working with Verbal Rules and Business Phrases

Verbal rules work hand in hand with business phrases to provide a flexible way author rules using natural language statements to express rule logic in domain specific sentences that are similar to spoken language. Business phrases provide the logic behind conditions that are used in the composition of the verbal rule.

You can write verbal rule tests and actions using derived business phrases as well as user-defined business phrases. Derived business phrases are automatically created using facts, globals and other information in the dictionary while user-defined phrases can be explicitly authored to augment derived phrases. Further, user-defined phrases can either be pre-created or created as required while composing the verbal rule.

As you write a verbal rule, you can use suggested business phrases, or instantiate your own on the fly and provide their implementation details later. Alternatively, you can create the business phrases you require for your verbal rule first, and then complete the verbal rule.

For more information about business phrases and how they work with verbal rules, as well as sample scenarios, see the "Working with Rulesets and Rules" chapter in Designing Business Rules with Oracle Business Process Management.

17.10.1 How to Create Business Phrases

In the Business Rules Editor, selecting the Globals tab shows you a table listing the globals in the dictionary.

To edit a global variable, select the appropriate row and variables. You can edit the Name, Description, and Value fields. For the Value field, you can use the expression builder to set the value.

To create a Business Phrase

  1. Open the business rule dictionary where you want to add a Business Phrase.
  2. Go to the toolbar and click Business Phrases.
  3. Click the Add Phrase icon to add a Test business phrase.

    Alternatively, you can create either a Test or Action business phrase from the dropdown.

  4. Enter the business phrase details as shown in Figure 17-14.

    Figure 17-14 Business Rule Editor - Business Phrases

    Description of Figure 17-14 follows
    Description of "Figure 17-14 Business Rule Editor - Business Phrases"
  5. In the Phrase panel, enter the definition of the business phrase.

    Placeholders for parameters that have not yet been defined can be included by typing their name wrapped in curly braces. For example:

    {customer} is single
    

    The corresponding parameters are added to the Parameters panel.

  6. Define parameters in the Parameters panel.

    Click Create (+) to add a new parameter. Specify its Name, Form, and Type. Optionally, specify a Value Set.

  7. To add a parameter to the business phrase value, click Insert Parameter in the Phrase panel, and select the parameter from the dropdown list.
  8. Define the mapping for the business phrase in the Mapping panel by adding Tests or Actions, depending on the type of business phrase.

    Mappings are constructed by searching for and specifying conditions, facts, operands and so on, in the same fashion to how you construct a general rule test or action in 34Business Process Composer. See "How to Add General Rules and Verbal Rules to a Ruleset".

  9. Mark the business phrase as draft if required.

17.10.2 Draft Business Phrases and Verbal Rules

Business phrases can be marked as being in draft status.

You can set or override the draft status of a business phrase by clicking Make Draft or Clear Draft.

The draft status of a verbal rule is derived from the business phrases it references and can not be manipulated directly. If a verbal rule contains business phrases marked draft, the rule is also marked draft. The verbal rule description panel indicates that the verbal rules is in draft mode. When all business phrases referenced by the verbal rule are no longer marked draft, the verbal rule is taken out of draft mode.

Draft business phrases and verbal rules are not validated and are not included in the dictionary for execution. This allows you to continue to use or test a dictionary as you refine your business phrases and verbal rules.

As you write a verbal rule you can compose business phrases that do not yet exist in the dictionary. These are automatically added to the list of business phrases and marked draft, and the verbal rule is marked draft as well.

17.10.3 Choosing or Adding Business Phrases in Verbal Rules

Verbal rules use business phrases to specify the IF and THEN tests and actions.

When defining a test or action in a verbal rule, you enter text which triggers a drop-down list of choices. From the list, you can select existing business phrases from the dictionary, automatically generated business phrases, or you can instantiate your a new business phrase based on what you typed, provide its implementation details later in the Business Phrases tab.

17.10.3.1 Instantiating New Business Phrases While Authoring a Verbal Rule

You can instantiate new business phrases while authoring a new verbal rule simply by typing them into a test or action and clicking <Add New Business Phrase>, instead of selecting one from the dropdown list. These business phrases are marked draft, and the verbal rules which use them are also marked as draft.

Click Goto Phrase to access the business phrase in the Business Phrases tab.

17.10.3.2 Choosing Business Phrases While Creating a Verbal Rule

A robust list including both previously user-defined and auto-generated derived business phrases, sorted by relevancy, is automatically provided as you author a test or action.

User-defined and derived business phrases are not visually distinguished from one another in the dropdown list.

You can refine the list if required. To display more choices, select a business phrase and press the right arrow key. The list is populated with business phrases related to the one you selected.

17.11 Working with Decision Functions

A decision function is a mechanism for publishing rules and rulesets as a reusable service that can be invoked from multiple business processes. It is the only gateway into the business logic held in business rules because neither business rules nor rulesets are accessible from the outside.

A decision function is a function that is configured declaratively. A decision function performs the following operations:

  • Asserts inputs as rule facts into the Oracle Business Rules Engine working memory.

  • Runs rulesets configured in the current decision function and in nested decision functions in order.

  • Returns output facts from the Oracle Business Rules Engine working memory.

A decision function provides a contract for invoking rules from Java or Service-Oriented Architecture (SOA) (from an SOA composite application or from a BPEL process). The contract includes input fact types, rulesets to run, and output fact types.

To view and modify a Decision Function:

  1. Open the business rule dictionary.
  2. Go to the toolbar and click Decision Properties.
  3. Select a decision function, as shown in Figure 17-15.

    Figure 17-15 Business Rules Editor - Decision Functions

    Description of Figure 17-15 follows
    Description of "Figure 17-15 Business Rules Editor - Decision Functions"
  4. Enter a name for the Decision Function in Name field.
  5. If desired, modify a description in the Description field.
  6. Select unlimited or an integer value in the Rule Firing Limit field.

    In some cases when you are debugging a decision function, you may want to enter a value for the rule firing limit. The Rule Firing Limit can also be used in primary rules processing when you want the execution to stop after a specified number of rules fire.

  7. Enter the service name in the Service Name field if this decision function is to be invoked as a rule service.
  8. The following controls are not editable from Composer:
    • Name

    • Rule Firing Limit

    • Service Name

    • Invoke as a rule service: Is the decision function is to be invoked as a rule service.

    • Check rule flow: Verifies the following to generate validation warnings:

      Types required by rules executed by the decision function are either inputs to the decision function or asserted by other rules.

      Types generated by rules executed by the decision function are either inputs to other rules or outputs to the decision function.

      Note that rule flow checking might not identify rule flow issues spanning Java code that is used in rules. In such cases, the warnings can be ignored by turning off rule flow checking.

    • Stateless: Specifies that the decision function is stateless

      When this check box is selected, which indicates stateless operation. With stateless operation, at runtime, the rule session is released after each invocation of the decision function.

    • Rulesets are on stack once: If selected, Rulesets are not evaluated further once they are popped from the Ruleset stack. When this check box is selected, which indicates stateless operation. With stateless operation, at runtime, the rule session is released after each invocation of the decision function.

  9. In the Initial Actions tab, click Add to add initial actions for the decision function. Select from the list, which includes:
    • assertions

    • assignations

    • if, while, for, and so on

    • expression

    • synchronized

    • throw

  10. These tabs are not editable from Composer:
    • Inputs Enter an input name and press Enter or accept the default name.

    • Outputs Select the appropriate fact type from the list.

    • Rulesets Decision Fucntions

17.12 Working with Explorer

Use the Explorer tab to view business rules dictionary items.

To view items using Explorer:

  1. Open the business rule dictionary where you want to edit items.
  2. Go to the toolbar and click Explorer.

    The items included in the selected business rules dictionary are listed, as shown in Figure 17-16.

    Figure 17-16 Business Rules Editor - Explorer

    Description of Figure 17-16 follows
    Description of "Figure 17-16 Business Rules Editor - Explorer"
  3. Select the Show Hidden Items to include hidden items in the list.

17.13 Working with Translations

Use the Translations tab to view the phrases included in the selected dictionary and their translated strings.

Note that in order to work with additional languages for this project, they must be added to the project.

For more information about how to add languages to a project, see Introduction to the Project Information Panel.

To translate phrases:

  1. Open the business rule dictionary where you want to translate phrases.
  2. Go to the toolbar and click Translations.

    The phrases included in the selected dictionary are listed. The languages specified for this project are also listed, as shown in Figure 17-17.

    Figure 17-17 Business Rules Editor - Translations

    Description of Figure 17-17 follows
    Description of "Figure 17-17 Business Rules Editor - Translations"
  3. Click on the phrase that you want to translate and enter the translated sling in the appropriate language column.

17.14 Assigning a Rule to a Business Rules Task

The business rules task is an Oracle BPMN element enables you to incorporate Oracle Business Rules within a process model. When editing a project based on a project template containing business rules in the business catalog, you can assign business rules to business rules task.

To assign a business rule to a business rules task:

  1. Open the process containing the business rules task you want to edit.
  2. Right-click the business rules task, then select Properties.
  3. Select the Implementation tab.
  4. Click Change. The displays the business rules browser containing a table of available business rules.
  5. Double-click a rule from the table.
  6. Click OK.

17.15 Editing Oracle Business Rules at Run Time

You can use Business Process Composer to open deployed Oracle BPM projects. Opening a deployed project enables you to edit the Oracle Business Rules contained in the project and deploy your changes back to Oracle BPM runtime.

Note:

When editing a deployed project, you can only edit the Oracle Business Rules for that project. You can view other project resources, but cannot edit them.

To open a deployed project:

  1. From the Project menu select Open a Deployed Project.

    If you are currently editing a project, your changes are automatically saved.

  2. Select Deployed Projects, then select the project you want to open from the project list.
  3. Expand Repository, then select the deployed project you want to open.
  4. Click Ok.
  5. In the Project Navigator, expand Business Rules then expand the rules dictionary where whose Oracle Business Rules you want to edit.
  6. Click Edit in the rules editor.
  7. Edit the rules as required, then click Save.
  8. Click Validate to ensure the changes you made to the business s made are valid.
  9. Click Commit to commit the changes to Oracle BPM runtime.
  10. Click Yes.
  11. From the Project menu, select Close Project.