Armaghan,
I am no Drools expert but I ran into something similar to this. The way I
worked around this was that I used the *eval* expression to perform my
complex comparison.
I am quickly laying out the rule( I am not sure if this is the correct
syntac)
rule "Testing for Alpha"
salience 100
when
$test: AlphaEnumCollectionsWrapperClass(alphaList : alphaList)
alpha : AlphaWrapperClass( $type:type, type == Class.ALPHA )
*eval( $test contains &type ) *-- You can add a secondary eval
expression
then
System.out.println("Found Loudspeaker Equipment. Who wants to jam that?
Must resist... Jamming sequence in progress... ");
materiel.setJam(true);
end
I am not sure if this is the correct way of doing this. If there are some
more experienced Rules guys they may be able to help you with the syntax.
Shannon
2009/5/14 Armaghan Mahmud <mahmud.armaghan(a)gmail.com>
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
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users