<br> Bryan,<br><br> I'm not sure I completely understood your scenario, but Drools supports FOL and your scenario can be implemented whatever it is.<br><br> I think the best way is giving you some examples:<br><br>
rule "Fires FOR EACH fact that does not have a corresponding Exception Range"<br> when<br> Fact1($number : number)<br> not ExceptionRange(startRange <= $number, stopRange >= $number)<br> then<br> // do something
<br>end<br><br>rule "Fires only IF ALL Facts have a corresponding Exception Range (this rule will fire only once)" <br>
when<br>
not ( <br> Fact1($number : number) and<br> not ExceptionRange(startRange <= $number, stopRange >= $number)<br> )<br>
then<br>
// do something<br>
end<br>
<br>rule "SAME AS ABOVE: Fires only if all Facts have a corresponding Exception Range (this rule will fire only once)" <br>
when<br>
forall( Fact1($number : number)<br>
ExceptionRange(startRange <= $number, stopRange >= $number) )<br>
then<br>
// do something<br>
end<br>
<br>rule "Fires only if THERE IS ANY Fact that does not have a corresponding Exception Range (this rule will fire only once)" <br>
when<br>
not( forall( Fact1($number : number)<br>
ExceptionRange(startRange <= $number, stopRange >= $number) ) )<br>
then<br>
// do something<br>
end<br>
<br>rule "fires FOR EACH PAIR [fact, exception range] (cross product)"<br> when<br> Fact1($number : number)<br> ExceptionRange(startRange <= $number, stopRange >= $number)<br> then<br> // do something
<br>
end<br><br>rule "fires if THERE ARE NO facts that have a corresponding exception range (fires only once)"<br>
when<br>
not ( <br> Fact1($number : number) and<br> ExceptionRange(startRange <= $number, stopRange >= $number)<br> )<br>
then<br>
// do something<br>
end<br>
<br> Take a look at the "exists" qualifier that is the same as "not( not( ... ) )".<br> Hope it helps. <br><br> []s<br> Edson<br>
<br><br><div><span class="gmail_quote">2007/9/19, wasabifan <<a href="mailto:bryan.rickman@kewill.com">bryan.rickman@kewill.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>I have several rules I am working on that I am having problems implementing.<br>Most of our tests are composed of at least one "pass" and one "fail" rule.<br>Basically, there are some tests where exceptions need to be thrown based on
<br>a date or number being inside a range where these exceptions occur (causing<br>a possible failure).<br><br>The problem is that we are testing several objects, so using the existensial<br>not, is problematic.<br><br>For example, in the pass, if we write:
<br><br>rule "pass example"<br> when<br> Fact1($number : number)<br> not ExceptionRange(startRange <= $number, stopRange >= $number)<br> then<br> System.out.println("Pass" + $number);<br>
end<br><br>For the fail, it would be like:<br><br>rule "fail example"<br> when<br> Fact1($number : number)<br> ExceptionRange(startRange <= $number, stopRange >= $number)<br> then<br> System.out.println
("Fail" + $number);<br>end<br><br>Is there a way to rewrite the pass rule, so that it checks the existence of<br>a range satisfying each number from Fact1? If I understand not correctly,<br>it will either pass once, and only once if ANY range matches at least one
<br>number from Fact1. Or it would pass for all Fact1's if any Fact1's match<br>any exception range.<br><br>A little clarification here would be appreciated, and if you know of a<br>workaround to actually test for getting exactly one and only one pass or
<br>fail (exclusively) for each Fact1 asserted.<br><br>Thanks,<br>Bryan Rickman<br><br><br>--<br>View this message in context: <a href="http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641">http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641
</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli
<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>