Creating and Managing Decision Tables

Decision Tables are provided to easily manage business rules in a familiar spreadsheet format. Decision tables exist within the context of a Rules Set. Multiple decision tables may exist within a Rules Set, which may also contain Rules. In the Decision Table Editor you can create and manage decision tables.

The tables may be created directly in the editor or imported into the editor from a spreadsheet format.

Table Content

A Decision table may contain the following entries:

The headers for individual Attribute, Condition and Action columns have an additional label containing the name of primitive used. The operator used in each condition is displayed next to it. Hovering over the header displays the entire path of the data.

Header Tooltip
Figure: Header Tooltip

These columns can be reordered via drag-and-drop, but only in relation to columns of the same type.

Available Rule Attributes

The following rule attributes are available:

Attribute Type Cell Type Default Value DRL Code Example Description (available via tooltip)
salience integer Number 0 salience -100 Salience is a form of priority where rules with higher salience values are given higher priority when ordered in the Activation queue. Salience defaults to zero, and can be negative or positive.

Drools also supports dynamic salience: salience( -$rank )

enabled boolean Checkbox false enabled true A rule cannot activate if enabled is set to false.
date-effective string Date NA date-effective  "20-Sep-2013" A rule can only activate if the current date and time is after date-effective attribute.
date-expires string Date NA date-expires  "24-Sep-2013" A rule cannot activate if the current date and time is after the date-expires attribute.
no-loop boolean Checkbox false no-loop true Setting no-loop to true will skip the creation of another Activation for the rule with the current set of facts.
agenda-group string Text Box MAIN agenda-group  "alpha" Agenda groups allow the Agenda to be partitioned providing more execution control. Only rules in the agenda group that has acquired the focus are allowed to fire.
activation group string Text Box NA activation-group  "beta" Rules that belong to the same activation-group, identified by this attribute's string value, will only fire exclusively. More precisely, the first rule in an activation-group to fire will cancel all pending activations of all rules in the group, i.e., stop them from firing.
duration long Number no default value duration 10000 The duration dictates that the rule will fire after a specified duration, if it is still true. (deprecated)
auto-focus boolean Checkbox false auto-focus true When a rule is activated where the auto-focus value is true and the rule's agenda group does not have focus yet, then it is given focus, allowing the rule to potentially fire.
lock-on-active boolean Checkbox false lock-on-active true

Whenever a ruleflow-group becomes active or an agenda-group receives the focus, any rule within that group that has lock-on-active set to true will not be activated any more; irrespective of the origin of the update, the activation of a matching rule is discarded.
Per default, the lock-on-active attribute column is added to all new decision tables by default and is true for the whole table.

ruleflow-group string Text Bob NA ruleflow-group  "omega" Rules that are assembled by the same ruleflow-group identifier fire only when their group is active.
dialect string Auto-complete As specified by the "package" dialect  "mvel" Specifies the language to be used for any code expressions in the LHS or the RHS code block, i.e., Java or MVEL.

Lock-on-active Attribute Column

The lock-on-active attribute column exists per default with the value true for the whole table. This allows each rule to only fire once by default.

Note
Take attention when disabling the lock-on-active attribute. This can easily lead to infinite loops!

The following warning is displayed above the decision table in case of any change of the lock-on-active column:

Lock-on-active Warning
Figure: Warning message

Disabling the attribute is only necessary in a scenario where one rule should fire as result of another rule, as in the following example:

A rule sets Person.age to 18. A second rule should react to Person.age >= 18 and set driversLicense = true. In that case the second rule needs to fire as result of the first rule.

Example
Figure: Exception example for using disabled lock-on-active attribute

Adding Decision Tables

To add a decision table, right-click a Rules Set node in the Outline and select Create Decision Table.

Adding a Decision Table
Figure: Adding a Decision Table

A new decision table node is added to the Rules Set and the Decision Table Property view opens.

New Decision Table
Figure: New Decision Table

The view displays the following entries:

Editing Decision Tables

If a new Decision Table is added, the properties view of the Decision table opens automatically. To edit an existing Decision Table, click the according Decision Table node in the My Rule Sets tree.

Adding Columns

To add a column, click the Add column Add Column Icon icon in the Decision Table toolbar.

Add a Column
Figure: Adding a column from the toolbar

The Add Column dialog opens. You can add attributes, conditions and actions.

A search facility is provided to find attributes, Structured Types and Primitives in the tree. All search hits are highlighted, and the tree is auto-expanded to reveal search hit nodes that may be hidden.

Search Facility
Figure: Searching in the tree

Adding attributes

To add rule attributes to a Decision table, expand the Attributes node in the Add Column dialog and select one of the provided attributes, which are described in section Available Rule Attributes.

A tooltip is displaying the description for a specific attribute, e.g.:

Attribute Tooltip
Figure: Tooltip showing description for attribute

For details on rule attributes in general, you can refer to the JBoss Rule Language documentation.

A separate attribute column is created for each attribute selected from the list. Note that only one attribute can be selected for a table. An already added attribute is grayed out in the tree and not selectable again.

Adding conditions

To add conditions to the decision table, expand the Conditions node in the Add Column dialog and select the conditions that you want to add. Optionally, you may search for the conditions you want to add in the search box, as described in section Searching for Structured Types and Primitives and select them from the highlighted search results.

All IN data defined in the containing Rule Set are displayed in a tree structure under the Conditions node. Structured Types are represented with the Structured Data Icon icon, may be expanded to display their primitive leaf nodes.

Adding Conditions
Figure: Adding Conditions

The following rules apply to selecting Conditions:

  1. Only primitives (represented with the Primitive Data Icon icon) can be selected
  2. Multi-cardinality fields cannot be selected, these are hidden
  3. The same primitive can be added multiple times

Adding actions

To add actions to the decision table, expand the Actions node in the Add Column dialog and select the actions that you want to add. Optionally, you may search for the actions you want to add in the search box, as described in section Searching for Structured Types and Primitives and select them from the highlighted search results.

All OUT data defined in the containing Rule Set are displayed under the Actions node in the tree.

Adding Actions
Figure: Adding Actions

The following rules apply to selecting Actions:

  1. Only primitives (represented with the Primitive Data Icon icon) can be selected
  2. Multi-cardinality fields cannot be selected, these are hidden
  3. Only primitives that are not used in the decision table in scope are visible
  4. Primitives are enabled in the tree once they are added to the table

When a primitive is selected, a new action column is immediately added to the decision table for that primitive.

Hiding Description and Attributes

To hide the Description and Attributes columns in a Decision table, click the Hide Description and Attributes Show/Hide icon in the table toolbar.

Searching for Text Occurrence in the Table

To search for a text occurrence in the decision table, enter a text snippet in the Search entry field in the toolbar. All fields in the table that match are highlighted.

Search Result
Figure: Searching for Text in the Table

Setting Operators in the Table Header

For Condition columns, the operator can be changed by clicking the operator label. A drop list is populated with the operators specific to the column primitive data type.

Choosing an operator
Figure: Choosing an operator

The following operators are provided according to the data type:

Operator Icon Description Code Usage Example Supported for Type
Boolean String Numeric Date
== Equal To == X X X X
!= Not Equal To != X X X
> Greater Than > X X X
< Less Than < X X X
<= Less Than or Equal To <= X X X
>= Greater Than or Equal To >= X X X
matches Matches matches X
sounds like Sounds Like sounds like X
null Null = null X X X
not null Not Null != null X X X
In List in ( "a", "b", "c" ) X X X
not in list Not In List not in ( "a", "b", "c" ) X X X
after After Date after "19-Sep-2013" X
before Before Date before "19-Sep-2013" X
coincides Coincides Date coincides "19-Sep-2013" X

Managing Rows and Columns

Rows and columns can be managed by a context-menu that appears when right-clicking in the according table cell.

Removing Columns

To remove a column, right-click in the column and select Remove Column.

Deleting a Column
Figure: Deleting a Column

Moving Rows

To move a row up or down in the table, right-click the according row and select Move Row Up or Move Row Down accordingly.

Moving a Row inside the Table
Figure: Moving a Row inside the Table

Removing Rows

To remove a row, right-click the according row and select Remove Row.

Deleting a Row
Figure: Deleting a Row

Inserting Rows

You can insert rows in the table directly. Right-click a row in the table and select one of the following options:

Insert a Row
Figure: Insert a Row

To append a row at the end of the table, click the Add Row Add Row Icon icon in the table toolbar.

Add a Row
Figure: Adding a row from the toolbar

Renaming Decision Tables

You can rename a Decision table by one of the following actions:

Deleting Decision Tables

To delete a Decision Table from a rule set right-click the table in the My Rule Sets tree and select Delete.

Deleting a Decision Table
Figure: Deleting a Decision Table

A confirmation dialog opens to confirm the deletion of the table.

Deletion Confirmation Dialog
Figure: Deletion Confirmation Dialog

All open views respective to the deleted Decision Table will be closed.