<div>Thanks Greg\Barton. I will try it out and get back to you.</div>
<div> </div>
<div>Regards,</div>
<div>cabear<br><br></div>
<div class="gmail_quote">2009/11/8 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Another proposal, with perhaps more emphasize on "rulishness".<br><br>Given <br> class Item { T1 s1;... Tn sn;... }<br>
let's add<br> enum Criterium { C1, C2,... Cn; }<br> class Request { EnumSet<Criterium> criteria; HashSet<Item> 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 "Check C1"<br>when<br> $request : Request( criteria contains Criterium.C1 )<br> $item : Item( s1 <op> <value> ) # the constraint defining "valid"<br>then<br> $request.getResults().add( $item ); # no modify!<br>
end<br><br>//...same for C2 ... Cn<br><br>rule "Return results"<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'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"><<a href="mailto:wishing.carebear@gmail.com" target="_blank">wishing.carebear@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div>
<div></div>
<div class="h5">
<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></div></div>
<div class="im">_______________________________________________<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><br>
<br></div></blockquote></div><br><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>