Thanks a lot for the prompt reply and the detailed example! It took me some time but I managed to convert it to a working xls decision table.
Now, I wanted to figure out how to automatically update the Current object regularly, in order to re-calculate the rules over time. My application is a java ee one. Would creating a @schedule on a singleton method be a good solution, or is there another better advice for it? Thanks again! Ευχαριστώ πολύ, Ιωάννης Χριστοδούλου On Tue, Mar 11, 2014 at 8:50 PM, Wolfgang Laun <[email protected]>wrote: > As you have Level with a field date, you can access that point in time in > milliseconds, using getTimeInMillis(). For the current time, you might > insert an object of class Current with a member now of class Calendar. > > rule closest > when > Current( $now: now ) > $level: Level( $value == 2, $date: date ) > not $x: Level( Math.abs( $x.getDate().getTimeInMillis() - > $now.getTimeInMillis() ) < Math.abs( $date.getTimeInMillis() - > $now.getTimeInMillis() ) ) > then > // $level is the Level fact closest to Current with a level of 2 > end > > Untested. If the long expression gives you trouble, try enclosing it in > eval(...). > -W > > > On 11 March 2014 18:14, JChrist <[email protected]> wrote: > >> Hello everyone, >> I was messing with drools v6.0.1.Final the past week and I have not been >> able to completely understand how to integrate the rule engine to my >> specification. >> >> For the needs of my project, I want to regularly insert some data in the >> engine, similar to the following: >> class Level { double value;Calendar date; } >> this class contains some values at specific time points (both in the past >> and in the future). >> >> I would like to be able create a decision table based on the "current" >> time >> (plus or minus a variable offset) and the value of the closest Level to >> that >> time point. >> >> For example, assuming it is '2014-11-03 19:10:00' and the level objects in >> the session currently are: >> '1.0 2014-11-03 18:00:00' and '2.0 2014-11-03 19:00:00', >> >> I would want a rule to say that if current level value is 2.0 then do some >> stuff and it would make a match. >> >> I would really appreciate any help on how to overcome this issue, as well >> as >> any good examples/tutorials regarding this. >> >> Kind regards. >> >> >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html >> Sent from the Drools: User forum mailing list archive at Nabble.com. >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
