Search code examples
drools

How to avoid Extra condition while Drools rule sheet is converted in rules?


In this Drools sheet I am comparing a class variable with a variable of another class variable but the rule converted are not as expected. Is there a way to do this...

enter image description here

One thing is creating a problem and it is when this excel sheet is converted into rules the condition where I check stdId in college class is equals to id of Student class i.e. third column, the rule is generated as follows-

$c2: College(stdId == $s.id == "x")

The =="x" part is undesirable and creating trouble while running the rules. What should be done to remove the extra undesired part.


Solution

  • The third column can be written as

    CONDITION
    $c2: College(stdId==$s.id)/*$param*/
    match student id
    x
    x
    ...
    

    The x is required to trigger insertion of the conditional expression from row 2.