[rules-users] Multipattern collect
Edson Tirelli
tirelli at post.com
Sat Nov 17 12:53:54 EST 2007
Geoffrey,
What you want is simply to constrain the inner pattern:
rule "calculateTopicConflict"
when
$leftTopic : Topic($id : id);
$rightTopic : Topic(id > $id);
$studentSet : HashSet( size > 0 )
from collect(
$student : Student( this memberOf $leftTopic.studentList,
this memberOf $rightTopic.studentList ) );
then
insertLogical(new TopicConflict($leftTopic , $rightTopic ,
$studentSet));
end
[]s
Edson
2007/11/17, Geoffrey De Smet <ge0ffrey.spam at gmail.com>:
>
> Is a multipattern collect supported?
>
> I have a rule which finds all 2 topics and all the students they share
> if there is at least 1 such student:
>
> rule "calculateTopicConflict"
> when
> $leftTopic : Topic($id : id);
> $rightTopic : Topic(id > $id);
> $studentSet : HashSet( size > 0 )
> from collect(
> $student : Student(),
> $leftTopic.studentList contains $student,
> $rightTopic.studentList contains $student
> );
> then
> insertLogical(new TopicConflict($leftTopic , $rightTopic ,
> $studentSet));
> end
>
>
> This won't compile:
> Caused by: org.drools.rule.InvalidRulePackage: [29,36]: unknown:29:36
> mismatched token: [@370,1504:1504=',',<11>,29:36]; expecting type
> RIGHT_PAREN[30,39]: unknown:30:39 mismatched token:
> [@376,1545:1552='contains',<49>,30:39]; expecting type
> LEFT_PAREN[30,48]: unknown:30:48 Unexpected token '$student'
> at org.drools.rule.Package.checkValidity(Package.java:424)
>
>
> Is a multipattern collect supported?
>
> Thanks for your help :)
>
> --
> With kind regards,
> Geoffrey De Smet
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071117/c65917c0/attachment.html
More information about the rules-users
mailing list