Hello,

 

I am trying to write a rule for my drools engine. It is (as far as i get it right), almost a total standard rule, however I'm having troubles with it and was hoping you could point me into the right direction (as i was surprised to see no similar question, I hope it is not too basic).

 

To give you an understanding of what i want to do: I want to calculate a number of costs a person had on a series of trips. For each trip, a function getCost() calculates the total amount of money spent (such as hotel, bar, ...). If the total amount of money spent is higher then the person's maximum money, we take action. I am trying to use the accumulate function, but it seems as if I'm not able to call the getCost() function there. The rule looks like this:

-----------------

rule "Total Costs"

when

$person : Person( eval ($person.maxMoney != null ) )

 

$totalCost : Number()

                from accumulate(    $trip : Trip( $cost : $trip.getCost()  ) from $person.getTrips(),

                                           sum( $cost )

                                      )

then

     // take action

end

-------------------

 

I have tried it with and without the $trip-variable (since I thought I might have to use it to call its function).

 

The error I get looks like this:

 

Error INTERNAL_ERROR: Error: unknown:70:54 Unexpected token ')'

java.lang.Exception: Error: unknown:70:54 Unexpected token ')'

        at com.fluidops.coremgmt.ruleengine.PolicyTask.readRule(PolicyTask.java:489)

        at com.fluidops.coremgmt.ruleengine.PolicyTask.readRule(PolicyTask.java:419)

 

I would be very thankful if one of you could help me out here :)

 

Best regards,

Christian

 

 

PS:  I already had this question in the drools forum, it was, however not forwarded to this mailing list, so please forgive me if it is a double post.