I am not sure I understand your problem. The rule clearly should NOT
match facts with value 0, as it will raise division by zero error all the
time. So, the solution, in my mind is:
rule "r1"
when
p : CTestObj( value != 0 )
then
p.setValue( 1 / p.getValue() );
end
If you need to give a different treatment to objects with value == 0,
just add another rule for them.
[]s
Edson
2010/8/31 tom ska <tiberium.linux(a)gmail.com>
Hello,
I have a class and rule:
class CTestObj
{
private double value;
void setValue(double v) {
this.value = v;
}
double getValue() {
return this.value;
}
}
rule "r1"
when
p : CTestObj
then
p.setValue( 1 / p.getValue() );
end
As you can see, in this rule, there is risk, to put into stateFulSession
object with value set 0. I can't validate this, because, this problem has a
variation where I put into stateFulSession object with set no 0, but the
rule will modify it...
So - I can't validate this = fact with value 0 is correct.
But I process with stateFulSession many, many facts... For example 1000.
And, after 900 facts it occurs, that fact number 901 has value set on 0. In
effect I get an exception: org.drools.runtime.rule.ConsequenceException:
java.lang.ArithmeticException: / by zero. And ksession stops processing
facts. But, 900 facts are processed! I don't want to process them second
time.
And this is my question:
How can I know, which fact is first no-processed fact? Which one stoped
fireAllRules method?
Beacuse I don't want to process them another time.
Greetings :)
tom.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com