Hi,
I am new to Drools and working with 4.0.1 version.
I am playing with DSL and having trouble with conditional field
constraints.
I really appreciate any help, i like drools a lot and would love to use
it.
Here is the simple rule i have:
rule "Credit Approved"
salience 5
when
//notice here we are using our own domain specific language that's
defined within
#credit.dsl file
There is a person with
#-must has a name
-age is at least 18 years old
then
System.out.println( "[ALLOW] Credit approved for " +
person.getName
());
end
Here is my dsl definition:
[when]There is a person with=person:Person()
[when]-age is at least {age} years old=(age >= {age})
[when]-age is less than {age} years old=(age < {age})
[when]-must has a name=(name != "" && name != null)
[when]-id must be positive integer=id > 0
Everything works fine if i use only 'age is least 18 years old' or 'must has
a name'.
However, if i try to do a connective and between these two constraints, i am
getting
package build errors:
Package build error found:
[13,43]: unknown:13:43 mismatched token: [@59,331:331=',',<11>,13:43];
expecting type RIGHT_PAREN[13,59]: unknown:13:59 mismatched token:
[@71,347:347=')',<12>,13:59]; expecting type THEN
Exception in thread "main" org.drools.rule.InvalidRulePackage: [13,43]:
unknown:13:43 mismatched token: [@59,331:331=',',<11>,13:43]; expecting
type
RIGHT_PAREN[13,59]: unknown:13:59 mismatched token:
[@71,347:347=')',<12>,13:59]; expecting type THEN
at org.drools.rule.Package.checkValidity(Package.java:419)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java
:292)
at com.trg.play.rules.PersonTest.readRule(PersonTest.java:103)
at com.trg.play.rules.PersonTest.main(PersonTest.java:51)
I have attached my test program for your review.