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.
[]s
Edson
2008/9/12 Nicola Benaglia <nicola.benaglia(a)tecno-progetti.eu>
Hi,
I am moving my first steps with Drools 4.0.7.
In my case I have an exam result to valuate.
I can pass an ExamDetailas fact containing (value, authLimit, lawLimit)
where authLimit may or may not be present.
How can I force to valuate a rule only if a property exists?
Here an example:
rule "Rule n.1"
dialect "mvel"
no-loop true
salience 10
when
exists ExamDetail(authLimit);
$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 exists ExamDetail(authLimit);
ExamDetail( $value: value < lawLimit);
then
System.out.println( "2 Exam passed! + $value);
end
With these 2 rules I expected to cover my 2 cases:
1) When I have authLimit --> rule #1
2) When authLimit is absent --> rule #2
But I get this error (when I don't have authlimit):
Exception in thread "main" org.drools.rule.InvalidRulePackage: [14,21]:
unknown:14:21 Unexpected token 'authLimit'[25,6]: unknown:25:6
Unexpected token 'exists'[25,24]: unknown:25:24 Unexpected token
'authLimit'
at org.drools.rule.Package.checkValidity(Package.java:424)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:394)
at eu.tecnoprogetti.rules.seam.ExamCheck.main(ExamCheck.java:23)
Any suggestions?
Thank you for your time.
Nico
_______________________________________________
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, a division of Red Hat @
www.jboss.com