Hi All,

 

I am seeking some kind of filtering (if statement) inside the LHS.

I have the following example rule (note: $attributeFilteredSentences and $cmdescriptor are defined in the extends rule which is not presented):

 

rule " choose message sentence example" extends " attributeFilteredSentences  collection"

      when                                           

                                                                                         

                              SContextState(state == SContextState.ONE)

                                   

            $sentences:       ArrayList()

                                    from collect (Sentences.Sentence(

                                                                     descriptor.meanings.meaning == $cmdescriptor.meanings.meaning

                                                                     ) from  $attributeFilteredSentences)                                                                             

           

      then

            logger.info("RULE: entered rule: "+drools.getRule().getName());

 

//some logic…

 

end

 

as can be seen I am filtering sentences based on the meanings, and the meaning collection must be identical as in $cmdescriptor (this is the case when SContextState.ONE)

 

Now to my question: I have cases ((this is the case when SContextState.TWO) where I do not need exact validation but rather superset of (for this I have a supersetOf operator implemented)

I would like to avoid duplicating  this rule (as I have similar condition in many other rules) and being able to filter once with “==” and once with “supersetOf” depending on the SContextState.

 

Any ideas how to do this?

 

Thanks,

Hezi