Yes :)<br><br><div class="gmail_quote">2011/5/9 Abhay B. Chaware <span dir="ltr">&lt;<a href="mailto:Abhay.Chaware@kpitcummins.com">Abhay.Chaware@kpitcummins.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">










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

<div>

<div>

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

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

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">What I meant was, There are say 10 objects of RAM in memory whose type
is DDR.  Now my “Product” object has a member variable named “compatibleRAMs”,
and I would like to set an arraylist containing these 10 objects to the “compatibleRAMs”
variable of “Product” object in memory.</span></font></p>

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

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">I am reading about the “collect” which can be used to create
collections from fact objects in memory.   Something like.</span></font></p>

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

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

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">            $prod
: Product (type==’laptop’)</span></font></p>

<p class="MsoNormal" style="text-indent: 0.5in;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">$compatibleRAMs : ArrayList() from collect (RAM (type
== ‘DDR’)) </span></font></p>

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

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">            $prod.setCompatibleRAMs($compatibleRAMs);</span></font></p>

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

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Am I on the right track ?</span></font></p>

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

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

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

<div class="MsoNormal" style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr size="2" width="100%" align="center">

</span></font></div>

<p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">
<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>Michael Anstis<br>
<b><span style="font-weight: bold;">Sent:</span></b> Monday, May 09, 2011 3:52 PM<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] FW:
Basic rules question</span></font></p>

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

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

<p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Abhay,<br>
<br>
Do you need a list?<br>
<br>
You can assign RAM to COMPUTERS with this:-<br>
<br>
</span></font><font face="Courier New"><span style="font-family: &quot;Courier New&quot;;">when<br>
    $c : Computer( $type : type )<br>
    $r : RAM( compatibleWith == $type )<br>
then<br>
   $c.addRAM( $r );<br>
end<br>
</span></font><br>
This would add all RAM (in Working Memory) compatible with COMPUTER to computer.<br>
<br>
You could use a list of RAM as a Fact in WM and change your rule to use that:-<br>
<br>
<font face="Courier New"><span style="font-family: &quot;Courier New&quot;;">when<br>
    $l : MyList( )<br>
    $c : Computer( $type : type )<br>
    $r : RAM( compatibleWith == $type ) from $l<br>
then<br>
    $c.addRAM( $r );<br>
end<br>
</span></font><br>
Or you can define a rule to construct the list too:-<br>
<br>
<font face="Courier New"><span style="font-family: &quot;Courier New&quot;;">when<br>
    $l : MyList( $t : typeRAM )<br>
    RAM( $c : $t )<br>
then<br>
    $l.add( $r )<br>
end</span></font><br>
<br>
I assume you&#39;d need to differentiate different lists for different types; so I
have shown use of &quot;MyList&quot; which could subclass ArrayList and have a
&quot;Type of RAM&quot; attribute. Drools doesn&#39;t &quot;do&quot; generics.<br>
<br>
With kind regards,<br>
<br>
Mike</p>

<div>

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">2011/5/9 Abhay B. Chaware &lt;<a href="mailto:Abhay.Chaware@kpitcummins.com" target="_blank">Abhay.Chaware@kpitcummins.com</a>&gt;</span></font></p>


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

<div>

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

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

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

<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Thanks for helping me out so far. </span></font></p>

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

<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">I have another question. What if I have all my “RAM”
objects inserted into working memory.   How should I write my
rule’s “when” portion to get a collection of all the RAM
objects matching type “DDR” ?  In other words, can I get
collection of facts assigned to a variable and use it in the “then”
part ?</span></font></p>

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

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

<div>

<div>

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

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

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

<p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> <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>Wendy Mungovan<br>
<b><span style="font-weight: bold;">Sent:</span></b> Friday, May 06, 2011 5:47 PM<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] Basic
rules question</span></font></p>

<p class="MsoNormal"><font color="black" face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial; color: black;"> </span></font></p>

<p class="MsoNormal"><font color="black" face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial; color: black;"> </span></font></p>

<p class="MsoNormal"><font color="black" face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial; color: black;">Q2:<br>
  So the rule would be something like:<br>
<br>
rule &quot;RAM type&quot;<br>
  when<br>
     $product: Product(type == &quot;laptop&quot;);<br>
 then<br>
     //you are looking for the best way to set valid RAM
types in the then part of the rule?<br>
    $product.setRamType(&quot;DDR&quot;);<br>
    //or<br>
   $product.setValidRamOptions( getValidRamOptions(&quot;DDR&quot;));<br>
 end<br>
<br>
where getValidRamOptions would be a custom function included through &#39;import
function&#39; so you can then load the choices from some where else.  Or if
RamOptions were an object in memory you could have a rule like:<br>
<br>
rule &quot;RAM type&quot;<br>
  when<br>
     $product: Product(type == &quot;laptop&quot;);<br>
     $ramOptions: RAMOptions(type == &quot;DDR&quot;);<br>
<br>
 then<br>
   $product.setValidRamOptions( $ramOptions.getList());<br>
 end<br>
<br>
<br>
<br>
<br>
Wendy</span></font></p>

<p class="MsoNormal"><font color="black" face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial; color: black;"> </span></font></p>

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

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

<div>

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

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

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

<p class="MsoNormal"><font color="navy" face="Arial" size="1"><span style="font-size: 7.5pt; font-family: Arial; color: navy;">Sr. Designer | KPIT Cummins Infosystems Ltd | Board: +91 020 6652
5000 | Extn: 2989  | <a href="mailto:abhay.chaware@kpitcummins.com" target="_blank">abhay.chaware@kpitcummins.com</a> |<a href="http://www.kpitcummins.com" target="_blank">www.kpitcummins.com</a> </span></font></p>

<p class="MsoNormal"><font color="green" face="Webdings" size="5"><span style="font-size: 18pt; font-family: Webdings; color: green;">P</span></font><font color="black" face="Webdings" size="2"><span style="font-size: 11pt; font-family: Webdings; color: black;"> </span></font><font color="green" face="Tahoma" size="1"><span style="font-size: 7.5pt; font-family: Tahoma; color: green;">Please consider the environment before printing this e-mail</span></font></p>


</div>

<div>

<div class="MsoNormal" style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr size="2" width="100%" align="center">

</span></font></div>

<p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> <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>Wendy Mungovan<br>
<b><span style="font-weight: bold;">Sent:</span></b> Friday, May 06, 2011 5:47 PM<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] Basic
rules question</span></font></p>

</div>

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

<div>

<p class="MsoNormal"><font face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial;">Abhay,<br>
  Q1:  I think that this will depend on how many different products you
have.  If there is a small number it is more straight forward to have a
rule for each one (so the 2nd option).  This allows all you logic to be in
one place.  If there are a large number of products and writing a rule for
each one is intractable you probably would want to look into some
generalizations of the rules.  Is that helpful?<br>
<br>
  Q2: I&#39;m not quite sure what you are getting at in Q2.  Are you
trying to write validation rules or rules that are modifying the facts?</span></font></p>

<div>

<p class="MsoNormal"><font face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial;"> </span></font></p>

</div>

<div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><font face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial;">Wendy</span></font></p>

<div>

<div class="MsoNormal" style="text-align: center;" align="center"><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">

<hr size="1" width="100%" align="center">

</span></font></div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Abhay B. Chaware &lt;<a href="mailto:Abhay.Chaware@kpitcummins.com" target="_blank">Abhay.Chaware@kpitcummins.com</a>&gt;<br>

<b><span style="font-weight: bold;">To:</span></b> &quot;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&quot;
&lt;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<br>
<b><span style="font-weight: bold;">Sent:</span></b> Fri, May 6, 2011 4:59:46 AM<br>
<b><span style="font-weight: bold;">Subject:</span></b> [rules-users] Basic rules
question</span></font></p>

<div>

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

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I am a
newbie to rule based applications and trying to get the concept of rules. I
have couple of questions about rules to start with, not specifically about
Drools though.</span></font></p>

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Q1 - Should
rules be data/model specific or can/should they be generic or both</span></font></p>

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

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">If selected
product “TYPE” is “laptop”, then category
“RAM” should have all “DDR” type items compatible (
selecting items matching certain property )</span></font></p>

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">If selected
product is “IBM T42”, then category “RAM” should have
“512MB DDR” , “1024MB DDR”, “2048MB
DDR”  compatible. ( assigning individual items in rules )</span></font></p>

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

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

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

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Q2 –
How should be the data modeled in above case</span></font></p>

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

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">in product
master, each item ( e.g. T40, T42 ) should have a “TYPE” ( e.g.
desktop or laptop ) , all items in category “RAM” should have a
“TYPE” ( e.g. DDR ) and then control the assignment of RAM options
to the PRODUCT through Rule using “DDR” type ?</span></font></p>

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">in product
master, each item ( e.g. T40, T42 ) should have a “TYPE” ( e.g.
desktop or laptop ) , all items in category “RAM”  should have
a “compatibleProduct” column ( e.g. desktop or laptop ) and control
the assignment of RAM to PRODUCT through “dynamic” rules by
selecting all the RAMs by passing the “TYPE” of the product to the
database handler.</span></font></p>

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

<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Am I making
my point clear ?</span></font></p>

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

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

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

</div>

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><br clear="all">
This message contains information that may be privileged or confidential and is
the property of the KPIT Cummins Infosystems Ltd. It is intended only for the
person to whom it is addressed. If you are not the intended recipient, you are
not authorized to read, print, retain copy, disseminate, distribute, or use
this message or any part thereof. If you receive this message in error, please
notify the sender immediately and delete all copies of this message. KPIT Cummins
Infosystems Ltd. does not accept any liability for virus infected mails. </span></font></p>

</div>

</div>

</div>

</div>

</div>

</div>

<div>

<div>

<p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><br clear="all">
This message contains information that may be privileged or confidential and is
the property of the KPIT Cummins Infosystems Ltd. It is intended only for the
person to whom it is addressed. If you are not the intended recipient, you are
not authorized to read, print, retain copy, disseminate, distribute, or use
this message or any part thereof. If you receive this message in error, please
notify the sender immediately and delete all copies of this message. KPIT
Cummins Infosystems Ltd. does not accept any liability for virus infected
mails. </span></font></p>

</div>

</div>

</div>

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

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

<br clear="all"> This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails.
</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>