[rules-users] Java Enums in Guvnor

Ian-D.Jones at ubs.com Ian-D.Jones at ubs.com
Wed May 19 12:36:06 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100519/c58eb05f/attachment.html 
-------------- next part --------------
Visit our website at http://www.ubs.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.
	
E-mails are not encrypted and cannot be guaranteed to be secure or 
error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses.  The sender 
therefore does not accept liability for any errors or omissions in the 
contents of this message which arise as a result of e-mail transmission.  
If verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities 
or related financial instruments.

UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.

UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.

UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
 
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.


More information about the rules-users mailing list