Red Hat Training

A Red Hat training course is available for Red Hat Decision Manager

Chapter 4. Guided decision tables

Guided decision tables are a wizard-led alternative to uploaded decision table spreadsheets for defining business rules in a tabular format. With guided decision tables, you are led by a UI-based wizard in Decision Central that helps you define rule attributes, metadata, conditions, and actions based on specified data objects in your project. After you create your guided decision tables, the rules you defined are compiled into Drools Rule Language (DRL) rules as with all other rule assets.

All data objects related to a guided decision table must be in the same project package as the guided decision table. Assets in the same package are imported by default. After you create the necessary data objects and the guided decision table, you can use the Data Objects tab of the guided decision tables designer to verify that all required data objects are listed or to import other existing data objects by adding a New item.

4.1. Creating a traffic violation guided decision table

Use the Guided Decision Table designer to create the traffic violation guided decision table, which specifies the driver’s specific violation and the resulting fine and points.

Prerequisite

You have created both the Violation and Driver data objects.

Procedure

  1. Log in to Decision Central.
  2. Click MenuDesignProjects, then Driver_department_traffic_violations.
  3. Click Add AssetGuided Decision Table, then enter:

    • Guided Decision Table: SpeedViolationRule
    • Package: com.myspace.driver_department_traffic_violations
  4. Select Unique Hit from the Hit Policy menu.
  5. Select Extended entry, values defined in table body in the Table format section.
  6. Click Ok to open the Guided Decision Tables designer.

    Figure 4.1. Guided Decision Tables designer

    dec table

4.1.1. Inserting Violation Type columns

The Violation Type column contains the violation details such as the the driver’s speed and if the driver was under the influence of drugs or alcohol.

Prerequisite

You have created the traffic violation guided decision table.

Procedure

  1. Click ColumnsInsert Column and then select Include advanced options.

    Figure 4.2. Column tab

    column tab
  2. Select Add an Attribute column and click Next.

    Figure 4.3. Add a new column window

    new column
  3. Select Ruleflow-group and click Finish.
  4. Expand Attribute columns and enter trafficViolation in the Default value field.

    Figure 4.4. Attribute columns window

    attrib column
  5. Click Insert Column, select Add a ConditionPattern+Create a new Fact Pattern.
  6. Select Violation from the Fact type menu, enter v in the Binding field, and click OK.

    Figure 4.5. Create a new fact pattern window

    fact pattern
  7. Select Calculation typeLiteral value.

    Figure 4.6. Calculation type options

    literal value
  8. Select Field and then select type from the Field menu.
  9. Select Operator and then equal to from the Operator menu.
  10. Select Value options and enter Speed,Driving while intoxicated,DWI=Driving while under the influence of drugs in the Value list (optional) field.
  11. Select Additional info, enter Violation Type in the Header (description) field, and click Finish.

    Figure 4.7. Violation Type header

    violation columns
  12. Click Insert Column, select Add a ConditionPattern, and select Violation[v] from the Pattern menu.
  13. Select Calculation typePredicateField and enter actualSpeed-speedLimit > $param.
  14. Select Value options, then select Additional info and enter Speed Limit (MPH) > in the Header (description) field.
  15. Click Finish.

    Figure 4.8. Speed Limit (MPH) > header

    speed header
  16. Click Insert Column, select Add a ConditionPattern, and select Violation[v] from the Pattern menu.
  17. Select Calculation typePredicate.
  18. Select Field and enter actualSpeed-speedLimit < $param in the Field field.
  19. Select Operator, select Value options, then select Additional info.
  20. Enter Speed Limit (MPH) < in the Header (description) field and click Finish.

    Figure 4.9. Condition columns

    cond columns

4.1.2. Inserting Fine Amount and Points columns

The Fine Amount* and Points columns contain the fines and points based on the corresponding Violation Type field values.

Prerequisite

You have inserted the Violation Type column in to the traffic violation guided decision table.

Procedure

  1. Click Insert Column, select Set the value of a fieldPattern, and select Violation[v] from the Pattern menu.
  2. Select Field and then fineAmount from the Field menu.
  3. Select Value options, and then select Additional info, and enter Fine Amount in the Header (description) field.
  4. Select the Update engine with changes option and click Finish.

    Figure 4.10. Fine Amount header

    fine amount
  5. Click Insert Column, select Set the value of a fieldPattern, and select Violation[v] from the Pattern menu.
  6. Select Field and then points from the Field menu.
  7. Select Value options, then select Additional info and enter Points in the Header (description) field.
  8. Select the Update engine with changes option and click Finish.

    Figure 4.11. Action columns

    point amount

4.1.3. Inserting guided decision table rows

After you have created your columns in the guided decision table, you can add rows and define rules within the decision table designer.

Prerequisite

You have created the Violation Type, Fine Amount, and Points columns in the traffic violation guided decision table.

Procedure

  1. Click EditorInsertAppend row. Repeat this step to add a total of five table rows.
  2. Fill out the table as shown in the following example:

    Figure 4.12. Populated data fields

    guided dt ds
  3. Click Save, and then click Save to confirm your changes.