Just to add to what Wolfgang said, the left hand side of a constraint is always the field name on the fact you are matching. In your care the 1st constraint "type == Class.ALPHA", type is the field, the 2nd constraint again would be type, but written using memberOf instead of contains
AlphaWrapperClass(type == Class.ALPHA && type memberOf alphaList) dave 2009/5/14 Wolfgang Laun <[email protected]> > The list that might contain the value of type is alphaList, not $test, > which is the reference to the object containing the list as a field. > -W > > 2009/5/14 Armaghan Mahmud <[email protected]> > >> Hi, >> >> I need help with constructing rules for my scenario. >> >> I started off by creating enum values in the main java file and comparing >> them with the rules to get different responses for different enum values. >> That was easy. >> >> This time, I'm constructing a list of enum values and passing them into >> the rules engine as well. I would like to configure my rules in such a way >> that when they look for the different enum values, they should also look in >> the list to test if the enum value passed into the rules engine is a member >> of the list or not. My old rules looked like this: >> >> rule "Testing for Alpha" >> salience 100 >> when >> alpha : AlphaWrapperClass(type == Class.ALPHA) >> then >> System.out.println("Found Alpha"); >> alpha.isFound(true); >> end >> >> I tweaked the above rule to : >> >> rule "Testing for Alpha" >> salience 100 >> when >> $test: AlphaEnumCollectionsWrapperClass(alphaList : alphaList) >> alpha : AlphaWrapperClass(type == Class.ALPHA && $test contains type ) >> then >> System.out.println("Found Loudspeaker Equipment. Who wants to jam >> that? Must resist... Jamming sequence in progress... "); >> materiel.setJam(true); >> end >> >> But I'm seeing the following error: >> >> org.drools.rule.InvalidRulePackage: Unable to create Field Extractor for >> '$test' of '[ClassObjectType classAlphaEnumCollectionsWrapperClass]' in rule >> "Testing for Alpha": [Rule name=Testing for Alpha, agendaGroup=MAIN, >> salience=100, no-loop=false] >> >> I'd greatly appreciate your help. >> >> Thanks, >> Armaghan >> >> >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
