[rules-users] Define a time event

Edson Tirelli tirelli at post.com
Wed May 7 10:38:18 EDT 2008


    That is a tricky question. :) Drools 4 has no special semantics for date
and time, and so, the only date and time you can get is the Java date/time,
and for that you need to use an eval() to call a function (or API) to return
current date and time:

eval( currentDateFunction() == $someOtherDate )

    Drools 5, on the other hand, has the concept of session clock, as part
of the incoming support for events. The session clock can be used to write
rules against it, as well as add temporal constrainst to events. For
instance:

$aPhoneCall : PhoneCall( )
$anotherCall : PhoneCall( this after[10,60] $aPhoneCall )

    The above constraint will be true, when $anotherCall happens 10 to 60
time units after $aPhoneCall. But when did the calls occurred? that is
determined by the clock abstraction chosen for the given session, that may
be either a system synchronized clock, as well as a pseudo-clock
implementation (that enables session re-executions and scenario
simulations), or an externally stamped timestamp (that keeps the events
timestamps frozen), etc.

    It will also allow for the explicit definition of time windows (see our
presentation at JBoss World, etc).

    All the above, just to tell you all users that time is not a simple
concept to support. Drools 4 didn't tried to do it, but Drools 5 will bring
some interesting modeling power to the table.

   Edson



2008/5/7 Christine <christine at christine.nl>:

>
> Talking about date and time, how do I get current date in a when
> condition?
>
> dagdag
> Christine
>
>
> >    Exactly. Also, you need to make sure you "tell the engine" everytime
> > your
> > Time object change, as well as ensure that fireAllRules will be called
> at
> > the exact time: 22:00, because if it is called 1 minute later or before,
> > the
> > constraint will evaluate to false.
> >
> >    Edson
> >
> >
> > 2008/5/7 Christine <christine at christine.nl>:
> >
> >> > Hi everyone,
> >>
> >> > For example:
> >> >  when Time(hour==22,minute==0)   Lamp(status==1)
> >> > then
> >> > Console.Writeline("It's late,turn off the light and go to bed")
> >> > where time is a class that return the current hour;
> >>
> >> Claudio, this would probably work if you fire the rules every hour or
> >> every minute or every time your Time object changes. Just having the
> >> rules
> >> sitting in your rulebase doesn't mean they get executed.
> >>
> >> Christine
> >>
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
> >
> >
> > --
> > Edson Tirelli
> > JBoss Drools Core Development
> > Office: +55 11 3529-6000
> > Mobile: +55 11 9287-5646
> > JBoss, a division of Red Hat @ www.jboss.com
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080507/18801745/attachment.html 


More information about the rules-users mailing list