Hello,
I think you understood me. Your solution is to validate facts in the rule. OK - I think this is a good idea, but... What if rules are created by no-IT (no-Math-aware ;) ) people? I can imagine situation where they do not validate this issue (div by 0). What then? If I send 1000 facts to ksession, and 901 has value set to 0? I want my 900 correct facts back. How can I know, how many have been processed?

P.S. I don't want to use globals to count this.

Thanks,
tom.

2010/8/31 Edson Tirelli <tirelli@post.com>
   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@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




--
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users