This was fixed recently for 5.3.0.Final.... <br><br>You can use either "multiple field constraints" or "Add more options to this fields values" (the icon at the end of a field constraint).<br><br><div class="gmail_quote">
On 5 October 2011 16:43, enkidu <span dir="ltr"><<a href="mailto:paul_blampied@yahoo.co.uk">paul_blampied@yahoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I've been playing with Drools and Guvnor and think I've encountered a problem<br>
with Java enums in Guvnor. I've searched for previous enum bugs and seen<br>
that a lot have been fixed, but I've tried Guvnor 5.2.0 and 5.3.0.CR1 and it<br>
happens in both.<br>
<br>
The problem seems to happen when you use enums in a "multiple field<br>
constraint" on a fact, eg:<br>
<br>
There is a Person with:<br>
any of the following:<br>
role equal to Role.TEACHER<br>
role equal to Role.PARENT<br>
<br>
Then using "view source" to see the generated DRL, the enum values are<br>
enclosed in double quotes, ie:<br>
<br>
rule "test"<br>
dialect "mvel"<br>
when<br>
Person( role == "Role.TEACHER" || role == "Role.PARENT" )<br>
then<br>
end<br>
<br>
If I just do a single field constraint then it comes out fine, eg. Person(<br>
role == Role.TEACHER )<br>
<br>
Is this a bug or am I doing something stupid? I've seen posts recommending<br>
the use of string constants rather than enums - is this the workaround?<br>
<br>
Below is my simple Java model for completeness:<br>
<br>
public enum Role {<br>
TEACHER,<br>
STUDENT,<br>
PARENT<br>
}<br>
<br>
public class Person {<br>
<br>
private String name;<br>
private Role role;<br>
<br>
public Person( String name, Role role ) {<br>
<a href="http://this.name" target="_blank">this.name</a> = name;<br>
this.role = role;<br>
}<br>
<br>
public String getName() { return name; }<br>
<br>
public Role getRole() { return role; }<br>
}<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Problem-with-Java-enums-in-Guvnor-multiple-field-constraints-tp3396901p3396901.html" target="_blank">http://drools.46999.n3.nabble.com/Problem-with-Java-enums-in-Guvnor-multiple-field-constraints-tp3396901p3396901.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>