From: Wolfgang Laun <wolfgang.laun@gmail.com>
To: Michiel Vermandel <mvermand@yahoo.com>; Rules Users List <rules-users@lists.jboss.org>
Sent: Tuesday, February 19, 2013 5:29 PM
Subject: Re: [rules-users] How can I select planning-entities in the accumulate source-pattern based on a list of planning-variables?
Assuming you want to deal with one PeopleMatch at a time:
when
$match : PeopleMatch( $people: people )
$match: Number( intValue < 0 )
from accumulate( $task : Task(handler memberOf $people), ...
I have some misgivings due to "intValue<0" and Matcher not being
assignment-compatible with java.lang.Number, but that's for you to
resolve.
-W
On 19/02/2013, Michiel Vermandel <
mvermand@yahoo.com> wrote:
> Hi,
>
> I am kind of stuck in writing a rule :
>
>
> I have PeopleMatch facts in working memory.
> Each PeopleMatch has a number of persons: PeopleMatch().getPeople =
> List<Person>
>
>
> I have planning-entities (Tasks) which have a planning-variable
Person.
>
> Now I would like to create a rule to loop over the PeopleMatch objects,
> gather all Tasks for the people of this match and do some calculation with
> all tasks.
>
> This is what I have for the moment:
>
> rule "matchPeopleTasks"
> when
>
> $match : PeopleMatch()
> $people : List() from $match .people
>
> $match: Number( intValue < 0 )
> from accumulate( $task : Task(handler == $people),
> init( Matcher matcher =
> $match.getMatcher()),
>
action( matcher.addTask( $task ); ),
> reverse( matcher.removeTask( $task ); ),
> result( matcher.getMatch() ) );
> then
> ...
> end
>
>
> The problem area is of course the "accumulate( $task : ProjectTask(handler
> == $people),"
> How do I select all tasks in the accumulate function, based on a list of
> people?
>
> Thanks,
>
> Michiel
>
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials