[rules-users] Temporal operators for point-in-time events

Mike Melton mike.melton at gmail.com
Tue Dec 13 12:11:34 EST 2011


Apologies for the stupid question, but I haven't seen anything in the
documentation regarding this and I want to verify my solution. Say I
have a point-in-time event (i.e., duration of 0) that I want to
correlate to another point-in-time event. I want a rule that will
activate if the timestamp of one is greater than or equal to the
other, basically "after or coincides". I wrote a test using the
following rule and it seemed to work:

rule "Greater Than or Equal"
  when
    $e1 : TestEvent( $id : id )
    $e2 : TestEvent( id != id, this after[0ms] $e1 )
  then
    System.out.println($e2 + " is greater than or equal to " + $e1);
end

I realize this rule will fire twice if the event timestamps are equal,
but it's just for demonstration purposes; my question is specifically
about the "after[0ms]" part. Is this the way to go to accomplish what
I need? It seems so simple but I have this annoying feeling that I'm
missing something.

On a slightly related topic, is there an updated version of the
temporal operators image from the Drools Fusion homepage? It is a
great visual description of the operators and I want to print it out
and post it at my desk, but it doesn't include all of the operators.

Image: http://www.jboss.org/drools/drools-fusion/mainColumnParagraphs/02/imageBinary/temporal-operators.png
>From page: http://www.jboss.org/drools/drools-fusion.html

Thanks
Mike



More information about the rules-users mailing list