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