Information Technology Reference
In-Depth Information
@duration : This attribute receives one parameter, which should be the name of
a long value determining the number of milliseconds the event lasted. This is an
optional attribute, as events are considered punctual by default (that is, they only
existed in a specific moment). For example, if we consider a phone call to be an
event, the moment between answering the phone and hanging up are very import-
ant components to treat the phone call as a temporally defined object.
@expires : The "expires" annotation receives a time-based string to determine
that after a specific amount of time, events added to the rule memory should be
automatically evicted.
An example of the preceding annotations could be similar to the following code section:
declare PhoneCall
@role(event)
@timestamp(callStartDate)
@duration(callDuration)
@expires(4h30m)
end
The preceding code section defines that a PhoneCall object (that could be an imported
class) should be treated as an event, its callStartDate attribute should mark when it
started, its callDuration attribute should mark its duration, and it should be automat-
ically evicted after 4 hours and 30 minutes from the rule memory.
Once we define the events we are going to use, we will be able to compare them based on
the time of their occurrence. We can do so using the temporal operators provided by
Drools Fusion.
Temporal operators
Temporal operators are extensions to the DRL language that allow us to directly compare
the timestamp of objects that we have declared as events. James F. Allen defines 13 tem-
poral operators, some of which only make sense with interval events. These operators are
after , before , coincides , during , finishes , finishedby , includes ,
meets , metby , overlaps , overlappedby , starts , and startedby .
As an example, after is used to define, obviously, that the timestamp of one event is
after the other event's timestamp. Temporal operators can receive parameters within
brackets; in case of the after operator, they indicate that the first event happened at least
Search WWH ::




Custom Search