You&#39;ll have to establish individual String objects to select type. There&#39;s two ways to do that.<br><br>1. You know all possible type values and insert them as facts. This is the most efficient way. (Perhaps wrap<br>
the string into a fact type ItemType{ String type; }.)<br><br>rule  &quot;StoreABC&quot;



<p class="MsoNormal">                when</p>

<p class="MsoNormal">                                #conditions</p><p class="MsoNormal">                                $type: String()<br></p>

<p class="MsoNormal">                                Number(
$TotalSalesAmount : intValue, intValue &gt; 100)</p>

<p class="MsoNormal">                                from
accumulate ( Sale(type == $type, $amount : amount, $quantity : quantity)</p>

<p class="MsoNormal">                                from
entry-point StoreABC,sum($amount * $quantity))</p>

<p class="MsoNormal">                then</p>

<p class="MsoNormal">                                System.out.println(&quot;StoreABC
sale exceeds 100…&quot;);</p>

<p class="MsoNormal">End</p><br>2. You can, e.g. by using some attribute order, select one Sale for each type from a store.<br><br>rule  &quot;StoreABC&quot;



<p class="MsoNormal">                when</p>


<p class="MsoNormal">                                #conditions</p>
<p class="MsoNormal">                               Sale( $pos: pos, $type: type )</p><p class="MsoNormal">                               not Sale( pos &lt; pos, type == $type ) </p><p class="MsoNormal">                               // same as before</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">HTH</p><p class="MsoNormal">-W<br></p><br><br><div class="gmail_quote">2011/1/3 Kiran Ananthpur Bacche (kbacche) <span dir="ltr">&lt;<a href="mailto:kbacche@cisco.com">kbacche@cisco.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="purple" lang="EN-US">

<div>

<p class="MsoNormal">Hi,</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I have a event processing rule as follows</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">declare Sale</p>

<p class="MsoNormal">                @role(event)</p>

<p class="MsoNormal">end</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">rule &quot;StoreABC&quot;</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">                when</p>

<p class="MsoNormal">                                #conditions</p>

<p class="MsoNormal">                                Number(
$TotalSalesAmount : intValue, intValue &gt; 100)</p>

<p class="MsoNormal">                                from
accumulate ( Sale($amount : amount, $quantity : quantity)</p>

<p class="MsoNormal">                                from
entry-point StoreABC,sum($amount * $quantity))</p>

<p class="MsoNormal">                then</p>

<p class="MsoNormal">                                System.out.println(&quot;StoreABC
sale exceeds 100…&quot;);</p>

<p class="MsoNormal">End</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">The POJO Sale has a attribute “String type;”. The
above rule actually ignores the type, and does the accumulation for all types
put together. Now I want the rule to fire successfully only when the TotalSalesAmount
for <b>_<i>any</i>_</b> given type exceeds 100.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">And is it possible to access the “type” of Sale whose
sales exceeded 100, in the “Then” clause ?</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Example:</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Lets say the input events are  as below (Triplets –
Type, Quantity and Amount)</p>

<p class="MsoNormal"> </p>

<p><span>1.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">      
</span></span>Apple , 10, 5</p>

<p><span>2.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">      
</span></span>Orange, 10, 6</p>

<p><span>3.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">      
</span></span>Banana,  20, 4</p>

<p><span>4.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">      
</span></span>Orange, 10, 5</p>

<p><span>5.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">      
</span></span>Apple, 2, 5</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Now in the above rule, the event fires after Event 2 since
the total sales is &gt; 100. However I want the rule to fire after Event 4
since at that point the sale of one particular item, viz. “Orange”
exceeds 100 in this store. In the “THEN” clause of the rules, I
also want access to a variable that indicates that it was “Orange”
whose sale exceeded 100 in this store.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Is this possible in Drools Fusion ? If yes, can you please
let me know the changes to be made to the above rule ?</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Thanks</p>

<p class="MsoNormal">  Kiran</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> </p>

</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>