[rules-users] Problem evaluating with Enum

Hezi Stern hezis at delegatecom.com
Tue Sep 13 16:54:55 EDT 2011


I have encountered the following problem using enums in drools.

 

I have an enum defined called ETimeConstraint, something of the sort:

 

public enum ETimeConstraint {

      NO_CONSTRAINT,

      TODAY,

TOMORROW,

;

}

 

Now I wish to filter sentences which reside in the working memory based on a
time constraint which is of this enum type.

I created the following test rule

 

rule "My Test"    

      when                                            

            $sentences:       ArrayList() 

                                    from collect (IPhoneSentences.Sentence(

 
descriptor contains ETimeConstraint

 
))

      then

            //something

end

 

this does not work meaning no sentence are selected although I know that
there are sentences in the working memory. 

but when I add ETimeConstraint.name it does:

 

rule "My Test"    

      when                                            

            $sentences:       ArrayList() 

                                    from collect (IPhoneSentences.Sentence(

 
descriptor contains ETimeConstraint.name  

 
))

      then

            //something

end

 

I can stick to this workaround but it becomes very problematic to work this
way. Furthermore once I wish to define a variable for example defining
$timeConstraint :

 

rule "My Test"    

      when                                            

                  $cm:              Condition(

                                                $timeConstraint:
contextIntention,                                                        

                                    )

                  

 

$sentences:       ArrayList() 

                                    from collect (IPhoneSentences.Sentence(

 
descriptor contains $timeConstraint

 
))

      then

            //something

end

 

 

this will not work because I can't put $timeConstraint.name

 

any suggestions?

 

I am running:

-          Drools 5.2.0

-          Eclipse Helios 

-          JBoss 5.1.0

 

 

Thanks

Hezi

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110913/6a40c7e6/attachment.html 


More information about the rules-users mailing list