Multiple boolean conditions in a rule in drools?

 ̄綄美尐妖づ 提交于 2020-01-01 19:01:31

问题


I have created a rule whose "when" condition is as follows :-

when
    $map: Map(this["key1"].equals("value1")) and Map(this["key2"].equals("value2"))  
then
...

The above condition is working fine. Now how do I add multiple boolean conditions in a rule? For eg. The above rule could be summarized as : a and b so if I want to create a rule : (a and b) or c then what would be actual drl syntax for it. I am new to drools so kindly help me with the syntax of the rule (a and b) or c.

I did create a syntax

when
    $map: Reindexing((Map(this["key1"].equals("value1")) and Map(this["key2"].equals("value2"))) or  Map(this["key3"].equals("value3"))) 
then

But I got the following exception

Error Messages: Message [id=1, level=ERROR, path=mapIterationRules.drl, line=13, column=0 text=[ERR 101] Line 13:21 no viable alternative at input '(' in rule "first rule"]

Thanks


回答1:


Figured out the syntax for the above rule. thanks laune and toni for the help.

here is the syntax

when
    $map: Map( this["data1"].equals("dataOutput1") ) || Map( this["data2"].equals("dataOutput2") && this["data3"].equals("dataOutput3") )

when inside the same bracket, it is not required to type the class name again.



来源:https://stackoverflow.com/questions/37879457/multiple-boolean-conditions-in-a-rule-in-drools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!