Try OpenEdge Now
skip to main content
BPM Events User's Guide
Understanding BPM Events : The event model : Attributes
 

Attributes

The following sections explain various attribute types, and describe how to test for the presence of an attribute.

Attribute types

Event attributes are found in each element of the context attribute, plus the standard attributes type and value. Events have a very basic but versatile structure: their context is a list of name/value pairs, which is unordered (implemented as hashtable, the elements of which are always accessed by their names in the rule language). Each element of the context list must be of atomic value, mapped to a string value in the rule language.
In other words, when writing rules, any event attribute is handled as a string value, except for the date attribute, which is handled as a date type. In case the attribute is handled as a different type, it is safer to use explicit conversion functions. However, implicit conversion is performed when the expected type is automatically inferred at compile time. In the following example, the function: toInt() converts the attribute Age into an integer, suitable for the comparison.
rule claim_dispatch
activated by event1 of insurance_claim::Car
if (toInt(event1.Age) <= 25)
and (event1.date < YEAR:2001/MONTH:6)
...
Yet, because the compiler knows that the other operand is an integer constant, it automatically enforces the conversion to integer. The rule above can also be written as:
rule claim_dispatch
activated by event1 of insurance_claim::Car
if (event1.Age <= 25)
...
However, in case the type of the condition operands cannot be inferred at compile time, these operands must be explicitly converted if they are handled other than as string values. In the following rule, the compiler does not know if it should make a comparison of strings or a comparison of numbers. In this case, explicit conversion functions are used:
rule claim_dispatch
activated by event1 of insurance_claim::Car,
        event2 of insurance_claim::general_policy
if (toInt(event1.Age) <= toInt(event2.agelimit))
....

Testing the presence of an attribute

In some cases, we may require testing inside a rule whether an event context contains an attribute or not. This is done by using a condition comparing this attribute with "nil" value (null value).
*The condition: (EVT_1.context.attr = nil) is true only if the attribute "attr" is not part of the context of the event EVT_1.
*The condition: (EVT_1.context.attr != nil) is true only if the attribute "attr" is part of the context of the event EVT_1, regardless of its value.