Hi
All,
I've
recently started using Drools and Guvnor, and so far really like
it!
I
have one problem however, to do with Java enums in Guvnor.
I
have a simple enum as follows:
public
enum STPRuleAction
{
UNKNOWN, ACCEPT, REJECT
}
I can
hand write a rule that works fine with this enum as
follows:
rule
"Retract rejected"
dialect "mvel"
when
o : CtasOrder( stpRuleAction == STPRuleAction.REJECT
)
then
o.setStatus( 1 );
retract( o );
end
However, if I create a rule with Guvnor, it always puts quotes around the
condition, so seems to treat it as a string and it is never triggered. I
have created a Guvnor enumeration as follows:
'CtasOrder.stpRuleAction' : ['STPRuleAction.UNKNOWN=UNKNOWN',
'STPRuleAction.ACCEPT=ACCEPT',
'STPRuleAction.REJECT=REJECT']
Which
gives me the correct drop down values in the Business Rule editor, but the
source of the rule looks like:
rule "Retract rejected"
dialect "mvel"
when
o : CtasOrder( stpRuleAction == "STPRuleAction.REJECT")
then
o.setStatus( 1 );
retract( o );
end
I've tried without the mapping in the enumeration (e.g ... : ['STPRuleAction.UNKNOWN',
...) and even removing the enumeration and adding the text manually
as a literal value. I can't see any way to specfy a enum/qualifiedIdentifier as
a condition in Guvnor. It works fine as a consequence and produces a rule
without quotes around (e.g. o.setStpRuleAction( STPRuleAction.REJECT
)...)
Many
thanks for any assistance you can give.
Regards,
Ian