<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(...).<br></div><div>-W<br>
</div></div><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">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>