<div dir="ltr">Thanks a lot for the prompt reply and the detailed example!<div>It took me some time but I managed to convert it to a working xls decision table.</div><div><br></div><div>Now, I wanted to figure out how to automatically update the Current object regularly, in order to re-calculate the rules over time.</div>
<div>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?</div><div><br></div><div>Thanks again! </div></div><div class="gmail_extra">
<br clear="all"><div><div dir="ltr">Ευχαριστώ πολύ,<br>   Ιωάννης Χριστοδούλου</div></div>
<br><br><div class="gmail_quote">On Tue, Mar 11, 2014 at 8:50 PM, Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><div><div><div>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. <br>

</div><div><br>rule closest<br>when<br></div><div>    Current( $now: now )<br></div>    $level: Level( $value == 2, $date: date )<br></div>    not $x: Level( Math.abs( $x.getDate().getTimeInMillis() - $now.getTimeInMillis() ) &lt; Math.abs( $date.getTimeInMillis() - $now.getTimeInMillis() ) )<br>

</div>then<br></div>    // $level is the Level fact closest to Current with a level of 2<br></div>end<br><br></div><div>Untested. If the long expression gives you trouble, try enclosing it in eval(...).<span class="HOEnZb"><font color="#888888"><br>
</font></span></div><span class="HOEnZb"><font color="#888888"><div>-W<br>
</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 11 March 2014 18:14, JChrist <span dir="ltr">&lt;<a href="mailto:io.christod@gmail.com" target="_blank">io.christod@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone,<br>
I was messing with drools v6.0.1.Final the past week and I have not been<br>
able to completely understand how to integrate the rule engine to my<br>
specification.<br>
<br>
For the needs of my project, I want to regularly insert some data in the<br>
engine, similar to the following:<br>
class Level { double value;Calendar date; }<br>
this class contains some values at specific time points (both in the past<br>
and in the future).<br>
<br>
I would like to be able create a decision table based on the &quot;current&quot; time<br>
(plus or minus a variable offset) and the value of the closest Level to that<br>
time point.<br>
<br>
For example, assuming it is &#39;2014-11-03 19:10:00&#39; and the level objects in<br>
the session currently are:<br>
&#39;1.0 2014-11-03 18:00:00&#39; and &#39;2.0 2014-11-03 19:00:00&#39;,<br>
<br>
I would want a rule to say that if current level value is 2.0 then do some<br>
stuff and it would make a match.<br>
<br>
I would really appreciate any help on how to overcome this issue, as well as<br>
any good examples/tutorials regarding this.<br>
<br>
Kind regards.<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html" target="_blank">http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html</a><br>


Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br></div>