[rules-users] Temporal operator "after"

Edson Tirelli tirelli at post.com
Fri Aug 13 16:24:32 EDT 2010


   Hi Wolfgang,

   I will explain why it happens and we can discuss how to improve that (at
least improving the error message).

   All temporal operators work when used against either an event, a date
attribute or a long attribute (interpreted as a timestamp).

   In your example:

   Wrapper( $eventA : foo )
   $eventB : Bar( this after[0ms,1h] $eventA )

    The engine has no idea that $eventA is an event in the working memory.
>From the engine's point of view, it is just a "foo" attribute from the
Wrapper fact. So it checks if event A is a Date (nope), a long (nope) and
finally tries to use it as an event raising the exception you see.

    On your last example:

$eventA : Foo( this == $foo )

    $eventA is an event in the working memory with all the internal metadata
required to handle events. So, in this case, the engine knows how to deal
with it.

    Suggestions on how to improve that are welcome.

    Edson

2010/8/13 Wolfgang Laun <wolfgang.laun at gmail.com>

> According to the Fusion manual, "after" is used like this:
>
>    $eventA : Foo(...)
>    $eventB : Bar( this after[0ms,1h] $eventA )
>
> provided Foo and Bar have @role(event).
>
> This works.
>
> But, given a class Wrapper( Foo foo ), the pattern combination
>    Wrapper( $eventA : foo )
>    $eventB : Bar( this after[0ms,1h] $eventA )
> results in a class cast exception at runtime, telling me that a Foo cannot
> be cast to a org.drools.common.EventFactHandle.
>
> Working around this by doing
>   Wrapper( $foo: foo )
>   $eventA : Foo( this == $foo )
>   $eventB : Bar( this after[0ms,1h] $eventA )
>
> solves the problem, but is this really necessary and intentional? (The
> documentation doesn't even hint at such a restriction.)
>
> -W
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100813/ad486ef5/attachment.html 


More information about the rules-users mailing list