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
- Log in to Decision Central.
-
Click Menu
Design Projects, then Driver_department_traffic_violations. Click Add Asset
Guided Decision Table, then enter: -
Guided Decision Table:
SpeedViolationRule
-
Package:
com.myspace.driver_department_traffic_violations
-
Guided Decision Table:
- Select Unique Hit from the Hit Policy menu.
- Select Extended entry, values defined in table body in the Table format section.
Click Ok to open the Guided Decision Tables designer.
Figure 4.1. Guided Decision Tables designer
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
Click Columns
Insert Column and then select Include advanced options. Figure 4.2. Column tab
Select Add an Attribute column and click Next.
Figure 4.3. Add a new column window
- Select Ruleflow-group and click Finish.
Expand Attribute columns and enter
trafficViolation
in the Default value field.Figure 4.4. Attribute columns window
-
Click Insert Column, select Add a Condition
Pattern +Create a new Fact Pattern. 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
Select Calculation type
Literal value. Figure 4.6. Calculation type options
- Select Field and then select type from the Field menu.
- Select Operator and then equal to from the Operator menu.
-
Select Value options and enter
Speed,Driving while intoxicated,DWI=Driving while under the influence of drugs
in the Value list (optional) field. Select Additional info, enter
Violation Type
in the Header (description) field, and click Finish.Figure 4.7. Violation Type header
-
Click Insert Column, select Add a Condition
Pattern, and select Violation[v] from the Pattern menu. -
Select Calculation type
Predicate Field and enter actualSpeed-speedLimit > $param
. -
Select Value options, then select Additional info and enter
Speed Limit (MPH) >
in the Header (description) field. Click Finish.
Figure 4.8. Speed Limit (MPH) > header
-
Click Insert Column, select Add a Condition
Pattern, and select Violation[v] from the Pattern menu. -
Select Calculation type
Predicate. -
Select Field and enter
actualSpeed-speedLimit < $param
in the Field field. - Select Operator, select Value options, then select Additional info.
Enter
Speed Limit (MPH) <
in the Header (description) field and click Finish.Figure 4.9. Condition 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
-
Click Insert Column, select Set the value of a field
Pattern, and select Violation[v] from the Pattern menu. - Select Field and then fineAmount from the Field menu.
-
Select Value options, and then select Additional info, and enter
Fine Amount
in the Header (description) field. Select the Update engine with changes option and click Finish.
Figure 4.10. Fine Amount header
-
Click Insert Column, select Set the value of a field
Pattern, and select Violation[v] from the Pattern menu. - Select Field and then points from the Field menu.
-
Select Value options, then select Additional info and enter
Points
in the Header (description) field. Select the Update engine with changes option and click Finish.
Figure 4.11. Action columns
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
-
Click Editor
Insert Append row. Repeat this step to add a total of five table rows. Fill out the table as shown in the following example:
Figure 4.12. Populated data fields
- Click Save, and then click Save to confirm your changes.