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@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@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