[rules-users] Matching items based on values in lists
Wolfgang Laun
wolfgang.laun at gmail.com
Tue Aug 10 12:50:50 EDT 2010
Seems you are missing the keyword "when":
rule "example"
when
RqTargerType(...
-W
On 10/08/2010, cortlander <cortlander at gmail.com> wrote:
>
> I am new to drools and have been struggling with this rule.
>
> $subject: RqTargetType contains a list of RqAttrib objects
> $resource: RqTargetType also contains its own list of RqAttrib objects
>
> $subject in a certain role has to be selected based on (attribType ==
> "subject", designator == "subject.role", attribValue == "patient")
> $subjectId is to be extracted from another attribute (attribType ==
> "subject", designator == "subject.id", $subjectId: attribValue)
>
> We then need to select a resource that has an attribute to match this
> $subjectId (attribType == "resource", designator == "resource.patient",
> attribValue == $subjectId )
>
> Here is the rule I wrote:
>
> rule "Patient Access Rule"
> #conditions
> RqTargetType( $subjectAttribs : rqAttribs )
> RqAttrib (attribType == "subject", designator == "subject.role",
> attribValue == "patient") from $subjectAttribs
> RqAttrib (attribType == "subject", designator == "subject.id",
> $subjectId: attribValue) from $subjectAttribs
>
> $resource: RqTargetType( )
> RqAttrib (attribType == "resource", designator == "resource.patient",
> attribValue == $subjectId ) from $resource.getRqAttribs()
> RqAttribute (attribType == "resource", designator == "resource.id",
> $resourceId: attribValue ) from $resource.getRqAttribs
> then
> #actions
> System.out.println( "resource: " + $resourceId );
> System.out.println( "subject: " + $subjectId );
> System.out.println( "Patient Access rule decision: Permit" );
> decisions.add("Permit");
> retract($subject);
> end
>
> I keep on getting "no viable alternative at input" error.
> Tried stripping the code so that only the following was left and still got
> the error:
> RqTargetType( $subjectAttribs : rqAttribs )
> RqAttrib (attribType == "subject", designator == "subject.role",
> attribValue == "patient") from $subjectAttribs
> [ERR 101] Line 25:2 no viable alternative at input 'RqTargetType' in rule
> "Patient Access Rule"
>
> Then tried this with similar results.
> $subject: RqTargetType()
> $subjectAttrib: RqAttrib (attribType == "subject", designator ==
> "subject.role",
> attribValue == "patient") from $subject.getRqAttribs()
> no viable alternative at input '$subject' in rule "Patient Access Rule"
>
> Any help will be much appreciated.
> Thank you and have a great day.
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Matching-items-based-on-values-in-lists-tp1075556p1075556.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list