Multiple boolean conditions in a rule in drools?

Yatin picture Yatin · Jun 17, 2016 · Viewed 12.5k times · Source

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

Answer

Yatin picture Yatin · Jun 22, 2016

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.