<br>   In order to keep the rules cleaner and easier to maintain, I prefer to hide the details of the database loading (query, etc) behind a helper method with a clear contract. But up to you. <br><br>   []s<br>   Edson<br>
<br><div class="gmail_quote">2009/6/2 Bhushan Bhangale <span dir="ltr">&lt;<a href="mailto:bhushan_bhangale@kaleconsultants.com">bhushan_bhangale@kaleconsultants.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">












<div link="blue" vlink="blue" lang="EN-US">

<div>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">Thanks Edson</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">I read about “from” CE and understand
that it can call any external method. In the external method I can write the code
to extract the data from database.</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">I googled and found this, where its using
hibernate session and that way giving complete flexibility in writing rule on
any data set. Do you think it’s a good idea?</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">global org.hibernate.Session hibernateSession;</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">rule &quot;hibernate_from&quot;</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">            when</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">                        game:Game()
from hibernateSession.createQuery(&quot;select games from Player p where p.age
&gt;= :age&quot;).setProperties( {&quot;age&quot; : 18 }).list()</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">            then</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">                        System.out.println(&quot;The
game &quot;+game.getName() +&quot;is owned by &quot;+game.getPlayers());</span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;">end</span></font></p><div><div></div><div class="h5">

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;">-----Original Message-----<br>
<b><span style="font-weight: bold;">From:</span></b>
<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b><span style="font-weight: bold;">On
Behalf Of </span></b>Edson Tirelli<br>
<b><span style="font-weight: bold;">Sent:</span></b> </span></font><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;">Monday, June
 01, 2009</span></font><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;"> </span></font><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;">6:48 PM</span></font><font size="2" face="Tahoma"><span style="font-size: 10pt; font-family: Tahoma;"><br>

<b><span style="font-weight: bold;">To:</span></b> Rules Users List<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [rules-users] rule
using sliding window</span></font></p>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

<p style="margin-bottom: 12pt;"><font size="3" face="Times New Roman"><span style="font-size: 12pt;"><br>
   Hi<br>
<br>
   The description you have bellow is ambiguous, so I can&#39;t give you
a definitive answer. But it seems to be that you don&#39;t need sliding windows for
that. Simple temporal operators will do.<br>
<br>
&gt; </span></font><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Secondly if the window is large and number of records coming
in is high then could there be a memory issue?<br>
   Yes, Drools does not manages persistence by itself. So, if your
design must support more data than it would fit in your running environment
memory, you need to design a solution that comprises persistence.<br>
<br>
&gt; Also since every record is getting stored in database, can I not use the
database directly instead of sliding window?</span></font><br>
   Yes, you can fetch data on demand from external sources, be it
databases or anything else. Look at the &quot;from&quot; CE.<br>
<br>
    []s<br>
    Edson<br>
<br>
</p>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;">2009/6/1 Bhushan Bhangale &lt;<a href="mailto:bhushan_bhangale@kaleconsultants.com" target="_blank">bhushan_bhangale@kaleconsultants.com</a>&gt;</span></font></p>


<div link="blue" vlink="purple">

<div>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I
am using Drools 5. I am struggling to write rule for this logic -</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">If
a stock price changes more than 10% within an hour then report the change.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I
understand I have to use sliding window feature but unable to write the rule.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">For
example I got an update for IBM stock @ 12:30 for price 100 and then another
update IBM stock @ 12:35 for price 111. Since the time difference is within an
hour and the change is also greater than 10% I want to report this price
change.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Stock
class -</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Public
class Stock {</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">  
Private String stock;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">  
Private double price;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">  
Private Date time;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">  
Private double priceChange;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">  
Private Boolean highlight;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">}</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">rule
&quot;Stock Price change more than 10% within an hour&quot;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">when</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">then</span></font></p>

<p style="text-indent: 0.5in;"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">set the priceChange attribute of Stock object</span></font></p>

<p style="text-indent: 0.5in;"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">set highlight to true     </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">end</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Secondly
if the window is large and number of records coming in is high then could there
be a memory issue?</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Also
since every record is getting stored in database, can I not use the database
directly instead of sliding window?</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Thanks</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<table style="width: 240pt;" border="0" cellpadding="0" cellspacing="0" width="320">
 <tbody><tr>
  <td style="padding: 0in;">
  <p><b><font color="#4e81c4" size="1" face="Verdana"><span style="font-size: 8pt; font-family: Verdana; color: rgb(78, 129, 196); font-weight: bold;">Mr. Bhangale Bhushan</span></font></b><font color="#4e81c4" size="1" face="Verdana"><span style="font-size: 8pt; font-family: Verdana; color: rgb(78, 129, 196);"><br>

  <i><span style="font-style: italic;">Associate Manager</span></i><br>
  <b><span style="font-weight: bold;">Kale Consultants Ltd.</span></b><br>
  <a href="mailto:bhushan_bhangale@kaleconsultants.com" target="_blank"><font color="#4e81c4"><span style="color: rgb(78, 129, 196); text-decoration: none;">bhushan_bhangale@kaleconsultants.com</span></font></a><br>
  tel: <a href="http://www.plaxo.com/click_to_call?lang=en&amp;src=jj_signature&amp;To=%2B91+%280%29206+608+3777&amp;Email=bhushan_bhangale@kaleconsultants.com" title="Click to call. Cheap rates &amp; no headset required!" target="_blank"><font color="#4e81c4"><span style="color: rgb(78, 129, 196); text-decoration: none;">+91 (0)206
  608 3777</span></font></a><br>
  <a href="http://www.kaleconsultants.com" target="_blank"><font color="#4e81c4"><span style="color: rgb(78, 129, 196); text-decoration: none;">http://www.kaleconsultants.com</span></font></a>
  </span></font></p>
  </td>
  <td style="padding: 0in;">
  <p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>
  </td>
 </tr>
 <tr style="height: 7.5pt;" height="10">
  <td colspan="2" style="padding: 0in; height: 7.5pt;" height="10">
  <p><font size="1" face="Times New Roman"><span style="font-size: 8pt;"> </span></font></p>
  </td>
 </tr>
 <tr>
  <td colspan="2" style="padding: 0in;">
  <p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>
  </td>
 </tr>
</tbody></table>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

<pre><font size="2" face="Courier New"><span style="font-size: 10pt;">Disclaimer: This email (including any attachments) is intended for the sole</span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;">use of the recipient/s and may contain material that is CONFIDENTIAL. Any</span></font></pre>
<pre><font size="2" face="Courier New"><span style="font-size: 10pt;">unauthorized disclosure / copying / distribution or forwarding of this message </span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;">or part is STRICTLY PROHIBITED. If you have erroneously received this message,</span></font></pre>
<pre><font size="2" face="Courier New"><span style="font-size: 10pt;">please delete it immediately and notify the sender. No liability is assumed for</span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;">any errors and/or omissions in the contents of this message. Information in </span></font></pre>
<pre><font size="2" face="Courier New"><span style="font-size: 10pt;">this message that does not relate to the official business of this Company</span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;">shall be understood as neither given nor endorsed by it. If verification is</span></font></pre>
<pre><font size="2" face="Courier New"><span style="font-size: 10pt;">required please request a hard-copy version. </span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;"> </span></font></pre>
<pre><font size="2" face="Courier New"><span style="font-size: 10pt;">To know more about Kale Consultants, visit <a href="http://www.kaleconsultants.com" target="_blank">www.kaleconsultants.com</a> </span></font></pre><pre>
<font size="2" face="Courier New"><span style="font-size: 10pt;"> </span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;">----------</span></font></pre><pre><font size="2" face="Courier New"><span style="font-size: 10pt;"> </span></font></pre>
<pre><font size="2" face="Courier New"><span style="font-size: 10pt;"> </span></font></pre>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>

</div>

<p style="margin-bottom: 12pt;"><font size="3" face="Times New Roman"><span style="font-size: 12pt;"><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></span></font></p>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"><br>
<br clear="all">
<br>
-- <br>
 Edson Tirelli<br>
 JBoss Drools Core Development<br>
 JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a></span></font></p>

</div></div></div><div><div></div><div class="h5">

<br><pre>Disclaimer: This email (including any attachments) is intended for the sole
use of the recipient/s and may contain material that is CONFIDENTIAL. Any
unauthorized disclosure / copying / distribution or forwarding of this message 
or part is STRICTLY PROHIBITED. If you have erroneously received this message,
please delete it immediately and notify the sender. No liability is assumed for
any errors and/or omissions in the contents of this message. Information in 
this message that does not relate to the official business of this Company
shall be understood as neither given nor endorsed by it. If verification is
required please request a hard-copy version. 

To know more about Kale Consultants, visit <a href="http://www.kaleconsultants.com" target="_blank">www.kaleconsultants.com</a> 

----------


</pre><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>
<br></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>