Decision Table Syntax for Building Rules


Table of Contents
Overview
Conditions and Actions in Decision Tables
Condition and Action Cell Syntax

This topic explains the business rule syntax used to build decision table artifacts.

Overview

The AMS web client provides the Artifact Editor to build rules, where you define threshold value conditions and actions in the cells of a table. In AMS, these tables are referred to as decision table artifacts, which are analogous to TIBCO StreamBase decision tables.

Each row can be thought of as a single rule in a decision table. The individual rules are often straightforward, as shown in the examples below. Artifacts stored in AMS repository can be deployed to a TIBCO StreamBase EventFlow module, when that module's configuration includes a StreamBase Decision Table operator.

For artifact deployment information using, see Artifact Deployment Overview.

The TIBCO StreamBase® Add-in for Microsoft Excel is a supported decision table editor. Microsoft Excel Add-in releases 2.7.0 and above also support upload and download artifacts to and from AMS. The Excel Add-in is a separately installed product and its documentation can be found here.

Conditions and Actions in Decision Tables

A decision table is comprised of columns where each column represents one condition or one action.

A condition is a predicate test that must evaluate to true for the associated action to be executed. If a decision table rule uses multiple conditions, all conditions for a row must evaluate to true for the action to execute. Condition tests might be looking to match the exact value of an incoming field's value, or might be comparing an incoming value for whether it is greater than, less than, greater than or equal to, or less than or equal to a specified value.

In each rule's row, you define the specific conditions and actions that comprise that rule. For example, if a condition column is Age (comparing to an incoming tuple field of that name), then each row can define a different age range. The action for each row would define what action to take if an incoming tuple contains an Age value within the specified range.

If you add a second condition column called Name, then before the action is taken, the running StreamBase Decision Table operator tests both conditions to check whether both the incoming Age and Name field values are within the ranges specified in the rules.

TIBCO StreamBase decision table support:

  • StreamBase Condition Columns that supports StreamBase expressions, including most StreamBase expression language functions, and supports data in the scope of the function at runtime. A StreamBase condition column can also contain complex formulas.

  • StreamBase Action Columns that support StreamBase expressions and functions, plus data in the scope of the function at runtime. StreamBase action columns can also contain complex formulas.

Decision Tables support two types of expression syntax for condition and action columns: TIBCO StreamBase expression or TIBCO BusinessEvents expression syntax. When editing decision tables with the Artifact Editor and you click the Add Column button, you can specify whether to add a Condition or Action column (which use BusinessEvents syntax) or a StreamBase Condition or StreamBase Action column (which use StreamBase syntax).

For further information, see the TIBCO Streaming or TIBCO BusinessEvents documentation at docs.tibco.com, and logging in with your customer account credentials.

TIBCO StreamBase Condition Column Features:

  • Column is not necessarily associated with a specific field in the incoming tuple.

  • Cell content contains full StreamBase expressions that resolve to a boolean value.

  • Cell content can reference other fields in the incoming tuple.

  • String literals must be enclosed in double quotes.

TIBCO BusinessEvents Condition Column Features:

  • Column is associated with a specific field in the incoming tuple, the field with the same name as the column.

  • Left side of cell expression is derived from the field associated with the column. For example, < 10 becomes FieldName < 10.

  • Cell content cannot reference other fields in the incoming tuple.

  • Cell content in string columns does not need to be enclosed in double quotes.

TIBCO StreamBase Action Column Features:

  • Column is associated with a specific field in the outgoing action tuple.

  • Cell content can contain full StreamBase expressions that must evaluate to the type of the corresponding action tuple field.

  • Cell content can reference incoming tuple fields.

  • String literals must be enclosed in double quotes.

TIBCO BusinessEvents Action Column Features:

  • Column is associated with a specific field in the outgoing action tuple.

  • Cell content is interpreted as a literal value.

  • Cell content cannot reference incoming tuple fields.

  • Cell content in string columns need not be enclosed in double quotes.

Condition and Action Cell Syntax

The syntax for decision table cell content depends on the type of column the cell is in, as explained below.

TIBCO StreamBase Condition Columns:

Cells within StreamBase condition columns can contain arbitrary StreamBase expressions ― with a few limitations ― that evaluate to boolean values. Expressions can reference one or more fields in the Decision Table operator's input schema. The limitations include:

  • No references to dynamic variables

  • No references to constants defined in .sbapp and .sbint files

  • Simple expression language functions only (no aggregate functions)

TIBCO BusinessEvents Condition Columns:

Cells within BusinessEvents condition columns conform ― with a few limitations ― to the shorthand syntax supported by BusinessEvents in which the left-hand side of the expression is implied from the column name and is there omitted in cell value. Cells can contain a combination of literal values, logical and relational operators, spaces, single and double quotes, and parentheses. The limitations include:

  • No references to list field elements

  • No references to dynamic variables

Literal types include:

TypeExampleNotes
Integer123 
Long1234llowercase "L" suffix
Double123.456 
String"This is a string"Single or double quotes are required if the string contains embedded space or single or double quotes. Use \' or \" to embed a single or double quote, respectively.
Timestamp2016-06-03 10:00:00.000-0400The hours, minutes, seconds, milliseconds, and timezone values are optional. An optional value must be present if any optional values to the right of it are present. That is, trim values from right to left.

The valid logical operators include:

TypeOperator
Logical AND&&
Logical OR||

The valid relational operators include:

TypeExampleNotes
Less than< 
Less than or equal<= 
Greater than> 
Greater than or equal>= 
Equal==This operator is implied when no operator is present.
Not equal!= 

The following table provides alternatives to the examples above using one or more BusinessEvents condition columns:

StreamBase ExpressionBusinessEvents Condition Column Name(s)BusinessEvents Condition Column Value(s)Notes
Name == "Peter"NamePeter 
length(Name) > 10  Not possible to express using BusinessEvents condition columns.
Age >= 18 && Age <= 21Age>= 18 && <= 21 
length(MyListOfDouble) > 0 && MyListOfDouble [0] == 3.14159  Not possible to express using BusinessEvents condition columns.
MyTuple.MyBoolMyTuple.MyBooltrue 
MyTuple.MyInt == 5MyTuple.MyInt5 
MyTuple.MyString == "Paul" && Age > 21

MyTuple.MyString

Age

Paul

>21

 
length(MyTuple.MyListOfString) > 2 && MyTuple.MyListOfString[2] == "Mary"  Not possible to express using BusinessEvents condition columns.
MyTuple.MyTimestamp > '2016-06-03 10:00:00.000-0400'MyTuple.MyTimestamp> 2016-06-03 10:00:00.000-0400 
Age == 17 && Name == "Peter" && MyTuple.MyString == "Paul" && length(MyTuple.MyListOfString) > 2 && MyTuple.MyListOfString[2] == "Mary"  Not possible to express using BusinessEvents condition columns.

TIBCO StreamBase Action Columns:

Cells within StreamBase action columns can contain arbitrary StreamBase expressions that evaluate to the data type of the corresponding field in decision table's action schema. Expressions can reference one or more fields in the decision table operator's input schema. StreamBase action column expressions have the same limitations as StreamBase condition column expressions.

TIBCO BusinessEvents Action Columns:

Cells within BusinessEvents action columns contain literals whose types match those of the corresponding field in the decision table operator's action schema. See the BusinessEvents Condition Columns section above for a list of the supported literal types. BusinessEvents action column values have the same limitations as BusinessEvents condition column values.