Defining Globals and Bucketsets

This rule has a QuoteRequest as an input fact. This rule will check for the condition of Customer Type and Item Quality , and based on these conditions, chain of management approval, level of management approval, and discount offered will be decided.

For all the cases in the CheckCustomer rule, your condition will keep a check on the Customer Type. For example in first case, if the Input quote customer type is New and Quality is in the range of 0 to 10 then EffectiveDiscount will have a 10% increment and others values will be set as follows:

If Quote.CustomerType == New and Quote.Quantity Is Between 0-10
Then
Set ApprovalFlow.CustomerType = True
Set ApprovalFlow.newEffectiveDiscount = Quote.EffectiveDiscount+10
Set ApprovalFlow..Number of Level for approval = 0
Set ApprovalFlow.Tier1ApprovalNeeded = False
Set ApprovalFlow.Tier2ApprovalNeeded = False

You can have conditions which that are evaluated to give a fixed value (New as Customer Type) and/or a range of values. For a fixed value, you can define Globals, and for ranges you will define Bucketsets.

As you will keep evaluating the conditions to a fixed value, you will create a for Customer Type of the type Global with value New. And, as your rule will evaluate to range values too, you will create a Bucketset to be used in rule.

How to do it...

In this section, we will define Globals, as follows:

  1. Fill in the following values in the Globals dialog:

    Global Name

    Type

    Value

    Final

    CustomerType

    String

    New

    Checked

  2. Oracle Business Rules a Global is similar to a public static variable in Java. You will create a Global to hold Customer Type value, as follows:
    • Go to BPM Project Navigator | Rules and click CheckCustomer.rules. This will open rule designer2.
    • Click on Globals in Rule Designer3.
    • Click on the green plus icon (+) to create a Global4.
    • Enter details as described in the preceding table. In the Value field, click the Expression Builder icon to enter an expression and enter the value, New. Checking the option Final means the Global is Non-modifiable.
      How to do it...
    • When done, click OK.
  3. When you have finished this, click Save.
  4. When you select Final, this specifies that you can use the Globals in a test in a rule (a non-final Global 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.

Next, we define Bucketsets, as follows:

Bucketsets are created to define a list of values or a list of value ranges to limit the acceptable set of values for a fact or a property of a fact in Oracle Business rules. Bucketsets can be defined as Global Bucketsets and local Bucketsets. Global allows reuse, where a Bucketset is named and stored in the data model, and Local is specified when you define a Decision Table and only applies to one condition expression.

  1. Go to the Rule designer for CheckCustomer.rules and select the Bucketsets navigation tab.
  2. Click the green plus (+) icon to create Bucketsets and select List of ranges:
    How to do it...
  3. This will open the Edit Bucketset dialog.
  4. Enter QuantityBucket as the Bucketset Name and double as the Data Type.
  5. Click the "Add Bucket" icon repeatedly (three times) to add the number of buckets you need in the Bucketset, as shown in the following screenshot:
    How to do it...
  6. You will add three buckets:
    • Between 0 and 10
    • Between 10 and 50
    • Greater than 50

    And by default, you will get a negative Infinity (-Infinity) bucket, which is less than 0. In the Included Endpoint field, check the checkbox to include the bucket endpoint. In the Allowed in Actions field, select the checkbox as appropriate, to include the bucket in the Bucketset allowable values.

  7. Click OK.
  8. When you have finished these steps, Save.

How it works...

When you add a bucket to a List of Ranges Bucketset, the value is calculated based on the currently selected bucket value and the next highest bucket value. When you change the endpoint value, the value is automatically sorted in the Bucketset. In a Decision Table, a Bucketset defines value ranges, in the condition section. The Bucketset ranges determine, for each condition expression in a Decision Table, whether it has two or more possibilities. Using a Bucketset, each possibility in a condition expression is divided into groups or ranges where a cell specifies one Bucket of values from the Bucketset (or possibly multiple Buckets of values per cell).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.87