[rules-users] Lists and enums in Drools

Armaghan Mahmud mahmud.armaghan at gmail.com
Thu May 14 05:56:18 EDT 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090514/77eb1b2b/attachment.html 


More information about the rules-users mailing list