Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 19 Rule Language Grammar : Working with Concept and Event Properties

Working with Concept and Event Properties
This section describes how to access concept properties and event properties using the TIBCO BusinessEvents language.
Accessing a Concept Property Atom
This is the syntax for accessing a concept property atom:
 
instanceName.propertyName
where instanceName is the identifier of the concept instance, and propertyName is the name of the concept property that you want to access.
For example to get the current value of the cost propertyAtom:
 
int x = instanceA.cost;
For example, to set a value with the current system timestamp:
 
instanceA.cost = value;
Get and Set PropertyAtom Value With User-Specified Time
You can get and set PropertyAtom values as follows:
   type Instance.PropertyAtom.gettype(PropertyAtom propertyAtomName, \
                                  long time)
where type is the type of the PropertyAtom and propertyAtomName is the name of the PropertyAtom, and time is the time from which you want to retrieve the value.
   Instance.PropertyAtom.settype(PropertyAtom propertyAtomName, \
                               type value, long time)
where type is the type of the PropertyAtom and the type of the new value, propertyAtomName is the name of the PropertyAtom, value is the value to store in the ring buffer, and time is the timestamp for the new entry.
TIBCO BusinessEvents manages these requests as follows:
If the ring buffer has vacancies, TIBCO BusinessEvents inserts the new entry into the correct place based on its timestamp, shifts the older values out one place, and returns True.
If the ring buffer is full, and the new value has a more recent timestamp than the oldest value, TIBCO BusinessEvents inserts the new value into the correct place, shifts older values if necessary, drops the oldest value, and returns True.
If the ring buffer is full, and the new value has a timestamp that is older than the oldest value in the ring buffer, TIBCO BusinessEvents does not insert the new value into the ring buffer, and it returns False.
Working with Concept Property Arrays
Accessing a Concept Property Array
This is the syntax for accessing a concept property array:
 
instanceName.propertyName
where instanceName is the identifier of the concept instance, and propertyName is the name of the concept property that you want to access.
Accessing a Value in a Concept Property Array
To access a value in a property array, identify the position in the array of the value as shown:
 
instanceName.propertyName[indexPosition]
For example:
 
String x = instanceA.lineItem[0];
This gets the current value of the first property atom in the array, lineItem, and assigns it to the local variable, x.
Array index difference  In the TIBCO BusinessEvents language, array indexes start from zero (0). However, in XSLT and XPath languages, they start from one (1). It’s important to remember this difference when using the rule language in the rule editor, and when working in the XSLT mapper and the XPath builder.
Setting the Value for an Existing Concept Property Array Position
You can set the value of an existing position in an array. For example:
int[] ii = {1,2,3};
ii[2] = 1;
Adding a Value to a Concept Property Array
You can append a value to the end of a property array. You cannot, however, add a value to any other position in an array. This is the syntax:
 
instanceName.propertyName[indexPosition] = value
To use the syntax shown above you must know the index position of the end of the array. You can append a value to the end of an array without knowing the index position of the end of the array using the @length attribute as shown:
 
instanceName.propertyName[instanceName.propertyName@length] = value
Deleting Values in a Property Array
This is the syntax for deleting an array property:
Instance.PropertyArray.delete(instanceName.propertyName, indexPosition);
When history is not tracked
Array identifier numbers are positional. When history is not tracked and you delete multiple items in an array (using a for loop), delete higher position numbers before lower position numbers to ensure the correct entries are deleted. For example, if you want to delete items in positions 1, 2, and 4, delete them in this order: 4, 2, and then 1.
The reason is as follows. The array entry that held a deleted concept is removed, reducing the array size by one, and reducing by one the index of every entry in the array at a higher index than the deleted one. If you delete entries with lower position numbers first, the remaining lower numbers are then occupied by different items. For example, if you delete the item in position 1, then the item that was in position 2 is now in position 1.
Event Property
This is the syntax for accessing an event property:
 
eventName.propertyName
For example:
 
String x = eventA.customer;
where eventName is the identifier of the concept instance and propertyName is the name of the event property that you want to access.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved