Hi Edison,
I tried your suggestion but I received an exception when I pass a null
value.
The exception is:
Exception in thread "main" java.lang.NullPointerException
at java.math.BigDecimal.compareTo(BigDecimal.java:2461)
at
org.drools.base.evaluators.BigDecimalFactory$BigDecimalLessEvaluator.evaluate(BigDecimalFactory.java:235)
at
org.drools.rule.VariableRestriction.isAllowed(VariableRestriction.java:73)
at
org.drools.rule.VariableConstraint.isAllowed(VariableConstraint.java:67)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
I attach some file to test this.
Thank you
Nicola
Edson Tirelli ha scritto:
You syntax is wrong. Fixing your syntax is as easy as saying:
exists ExamDetail( authLimit != null )
But I think that your rules can be simplified by simply writing:
rule "Rule n.1"
dialect "mvel"
no-loop true
salience 10
when
$examDetail : ExamDetail( $value: value < authLimit);
then
System.out.println( "1 Exam passed!" + $value);
end
rule "Rule n.2"
dialect "mvel"
no-loop true
salience 10
when
not ExamDetail( value < authLimit );
then
System.out.println( "2 Exam passed! + $value);
end
This should cover both of your scenarios.
import ExamDetail;
rule "Rule n.1"
dialect "mvel"
no-loop true
salience 20
when
exists ExamDetail( authLimit != null );
$examDetail : ExamDetail( $value: value < authLimit);
then
System.out.println( "Rule 1: exam PASSED!" + $value);
end