[rules-users] list operations in "then" part

Simon Chen simonchennj at gmail.com
Sat Jun 4 15:31:19 EDT 2011


"not memberOf" somehow worked for me...

My actual line of code was: router not memberOf $route.hops

I got around the addAll() issue by passing the list into the
constructor of fact1...

-Simon

2011/6/4 Wolfgang Laun <wolfgang.laun at gmail.com>:
> I cannot reproduce this error.
>
> Do NOT rely on the automatic substitution of getters for simple field
> accesses on a rule's right hand side, at least not for 5.2.0 CR.
>
> Moreover, I cannot compile the constraint
>    "jones" memberOf authors
> This should be written as
>    authors contains "jones".
>
> For further analysis full workable code reproducing the issue would be
> required.
>
> -W
>
>
> On 3 June 2011 22:47, Simon Chen <simonchennj at gmail.com> wrote:
>>
>> Can I maybe do a for loop in the "then" part? Is there a documentation
>> regarding what is possible/impossible in the "then" part?
>>
>> Thanks.
>> -Simon
>>
>> On Fri, Jun 3, 2011 at 3:23 PM, Simon Chen <simonchennj at gmail.com> wrote:
>> > No, this doesn't work...
>> >
>> > Drools-5.2 doesn't help either :-(
>> >
>> > 2011/6/2 Joe White <Joe.White at recondotech.com>:
>> >> If you cast $b on the RHS it will probably work. We’ve had to do this
>> >> in the
>> >> past for rules like this.
>> >>
>> >>
>> >>
>> >> ….
>> >>
>> >> then:
>> >>  Test fact = new Test();
>> >>
>> >> Book rhsBook = (Book)$b;
>> >>  fact.getList().addAll( rhsBook.authors );
>> >>  insert(fact);
>> >> end
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> From: rules-users-bounces at lists.jboss.org
>> >> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Mark Proctor
>> >> Sent: Thursday, June 02, 2011 8:52 AM
>> >> To: rules-users at lists.jboss.org
>> >> Subject: Re: [rules-users] list operations in "then" part
>> >>
>> >>
>> >>
>> >> On 02/06/2011 08:14, Wolfgang Laun wrote:
>> >>
>> >> On 1 June 2011 21:43, Simon Chen <simonchennj at gmail.com> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> I am always confused about what we can do in the "then" part of the
>> >> rule.
>> >>
>> >> In particular, I have problem duplicate a list. For example:
>> >>
>> >> when:
>> >>  $b: Book( "james" memberOf authors )
>> >> then:
>> >>  Test fact = new Test();
>> >>  fact.getList().addAll( $b.authors );
>> >>  insert(fact);
>> >> end
>> >>
>> >> The error message reads like this:
>> >>
>> >> BuildError: Unable to build expression for 'consequence': [Error:
>> >> Failed to compile: 2 compilation error(s):
>> >>  - (1,7) unqualified type in strict mode for: $b
>> >>  - (1,12) unqualified type in strict mode for: authors]
>> >>
>> >> What is the right way to do this?
>> >>
>> >> Granted - the error message is a puzzle in itself, but basically, the
>> >> RHS
>> >> must be written according to Java rules. Hence, if $b is an object of
>> >> type
>> >> Book, $b.authors depends on the (Java!) visibility of member authors.
>> >> If it
>> >> isn't public, you must use the getter.
>> >>
>> >> I believe he's using "mvel" judging by the error.
>> >>
>> >> mark
>> >>
>> >>
>> >> -W
>> >>
>> >>
>> >> Thanks.
>> >> -Simon
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >>
>> >> rules-users mailing list
>> >>
>> >> rules-users at lists.jboss.org
>> >>
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >>
>> >
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> 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