Another proposal, with perhaps more emphasize on &quot;rulishness&quot;.<br><br>Given <br>   class Item  { T1 s1;... Tn sn;... }<br>let&#39;s add<br>   enum Criterium { C1, C2,... Cn; }<br>   class Request { EnumSet&lt;Criterium&gt; criteria; HashSet&lt;Item&gt; results; }<br>
<br>To launch a request, insert a Request object with an appropriate setting for criteria. Then, match all Item facts against rules, one for each Ci:<br><br>rule &quot;Check C1&quot;<br>when<br>    $request : Request( criteria contains Criterium.C1 )<br>
    $item : Item( s1 &lt;op&gt; &lt;value&gt; )     # the constraint defining &quot;valid&quot;<br>then<br>    $request.getResults().add( $item );   # no modify!<br>end<br><br>//...same for C2 ... Cn<br><br>rule &quot;Return results&quot;<br>
salience -100<br>when<br>    $request : Request()<br>then<br>    ... send $request.getResults() back to User<br>    retract( $request );<br>end<br><br>You could have two rules here, one testing for success (getResults().size() == getCriteria().size()), the other one firing for failure, but it might be preferable to handle it in the presentation layer.<br>
<br>Although I&#39;ve used similar approaches, the code here is just off the cuff.<br>-W<br><br><div class="gmail_quote">2009/11/8 Wishing Carebear <span dir="ltr">&lt;<a href="mailto:wishing.carebear@gmail.com">wishing.carebear@gmail.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>Hello:</div>
<div>There are n selection criteria from s1 .. sn for each item i1.. in. Each item can have a subset of criteria which applies to them.</div>
<div> </div>
<div>The end user, can choose a subset of criteria like c1 and c5 and only the item that has c1 and c5 valid should be returned. For example: if item i1 and i2 have criterias valid for c1, c2, c5, c6, c8 since the request is only for criteria c1 and c5, i1 and i2 must be returned.</div>


<div> </div>
<div>Is it possible to write a rule using drools for this requirement. </div>
<div> </div>
<div>Thanks for your help and time,</div>
<div>cabear</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>