OK, here is the problem:
I currently have this:
rtvHeader : RtvHeader( status != StatusConstants.MATCHED | !=
StatusConstants.APPROVAL )
but if I switch it to use a quoted string value like the following:
rtvHeader : RtvHeader( status == "Matched" | == "Approval" )
It works...Is this a bug?
On 7/7/07, Ronald R. DiFrango <ron.difrango(a)gmail.com> wrote:
OK, this does not looked correct syntax or that it is supported. Here is
the exception I get:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.circuitcity.rtvcrms.test.MainBasedTester.testRules (
MainBasedTester.java:31)
at com.circuitcity.rtvcrms.test.MainBasedTester.main(
MainBasedTester.java:23)
Caused by: java.lang.RuntimeException: Failure loading the Rules
at com.circuitcity.rtvcrms.rules.RtvDecisionEngine .<clinit>(
RtvDecisionEngine.java:48)
... 2 more
Caused by: org.drools.rule.InvalidRulePackage: [22,59]: unknown:22:59
Unexpected token '|'[22,89]: unknown:22:89 mismatched token:
[@162,707:707=')',<13>,22:89]; expecting type LEFT_PAREN[33,59]:
unknown:33:59 Unexpected token '|'[33,89]: unknown:33:89 mismatched token:
[@263,1112:1112=')',<13>,33:89]; expecting type LEFT_PAREN[44,59]:
unknown:44:59 Unexpected token '|'[44,89]: unknown:44:89 mismatched token:
[@364,1510:1510=')',<13>,44:89]; expecting type LEFT_PAREN[55,59]:
unknown:55:59 Unexpected token '|'[55,89]: unknown:55:89 mismatched token:
[@465,1924:1924=')',<13>,55:89]; expecting type LEFT_PAREN
at org.drools.rule.Package.checkValidity(Package.java:409)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java
:262)
at com.circuitcity.rtvcrms.rules.RtvDecisionEngine.<clinit>(
RtvDecisionEngine.java:44)
... 2 more
And here is my rules:
#created on: Jul 7, 2007
package com.circuitcity.rtvcrms.rules
#list any import classes here.
import java.math.BigDecimal;
import java.math.BigInteger;
import com.circuitcity.rtvcrms.bw.Constants;
import com.circuitcity.rtvcrms.bw.DocumentTypes;
import com.circuitcity.rtvcrms.bw.StatusConstants;
import com.circuitcity.rtvcrms.EffectivePrice ;
import com.circuitcity.rtvcrms.RtvHeader;
#declare any global variables here
rule "Line Set Open #1"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.OPEN)
rtvHeader : RtvHeader( status == StatusConstants.MATCHED | ==
StatusConstants.APPROVAL )
then
System.out.println("Line Set Open #1");
rtvHeader.setStatus (StatusConstants.PARTIALLY_MATCHED);
update(rtvHeader);
end
rule "Line Set Open #2"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.OPEN)
rtvHeader : RtvHeader( status != StatusConstants.MATCHED | !=
StatusConstants.APPROVAL )
then
System.out.println("Line Set Open #2");
rtvHeader.setStatus (StatusConstants.OPEN);
update(rtvHeader);
end
rule "Line Set Matched #1"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.MATCHED)
rtvHeader : RtvHeader( status != StatusConstants.MATCHED | !=
StatusConstants.APPROVAL )
then
System.out.println("Line Set Matched #1");
rtvHeader.setStatus (StatusConstants.PARTIALLY_MATCHED);
update(rtvHeader);
end
rule "Line Set Matched #2"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.MATCHED)
rtvHeader : RtvHeader( status == StatusConstants.MATCHED | ==
StatusConstants.APPROVAL )
then
System.out.println("Line Set Matched #2");
rtvHeader.setStatus (StatusConstants.MATCHED);
update(rtvHeader);
end
rule "Line Set Approval #1"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.APPROVAL)
rtvHeader : RtvHeader( status == StatusConstants.MATCHED )
then
System.out.println("Line Set Approval #1");
rtvHeader.setStatus(StatusConstants.APPROVAL );
update(rtvHeader);
end
rule "Line Set Approval #2"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.APPROVAL)
rtvHeader : RtvHeader( status == StatusConstants.OPEN )
then
System.out.println("Line Set Approval #2");
rtvHeader.setStatus(StatusConstants.PARTIALLY_MATCHED );
update(rtvHeader);
end
rule "Line Set Approval #3"
salience -10
when
rtvDetailLine : DetailLine(rtvNumber != null, rtvNumber ==
cmRtvNumber, lineNumber != null, status == StatusConstants.APPROVAL)
rtvHeader : RtvHeader( status != StatusConstants.OPEN )
then
System.out.println("Line Set Approval #3");
rtvHeader.setStatus(StatusConstants.PARTIALLY_MATCHED );
update(rtvHeader);
end
As another note, the JBoss Rules IDE is NOT reporting any errors with the
syntax.
On 7/7/07, Ronald R. DiFrango <ron.difrango(a)gmail.com> wrote:
>
> Answered my own question:
>
> MyObject (status == StatusConstants.MATCHED | ==
> StatusConstants.APPROVAL)
>
> On 7/7/07, Ronald R. DiFrango < ron.difrango(a)gmail.com> wrote:
> >
> > All,
> >
> > If I remember correctly, in the 4.x version of Drools you were adding
> > an or type syntax where you could compare a value against multiple values.
> > What is the new syntax for it?
> >
> > I am looking to do something logically like:
> >
> > MyObject (status in ("Open" or "Matched")
> >
> > Ron
> >
>
>