[rules-users] Using functions to derive values in "accumulate" (LHS)
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Jul 21 03:36:48 EDT 2011
2011/7/21 Christian Heupel <christian.heupel at fluidops.com>
> ----------------- ****
>
> rule "Total Costs" ****
>
> when ****
>
> $person : Person( eval ($person.maxMoney != null ) )
>
Although not relevant to your problem: stick with the JavaBean convention:
There should be private Integer maxMoney; Integer getMaxMoney(); etc. and
then you write
Person( maxMoney != null )
> ****
>
> ** **
>
> $totalCost : Number() ****
>
> from accumulate( $trip : Trip( $cost : $trip.getCost()
> ) from $person.getTrips(), ****
>
> sum( $cost ) ****
>
> )
>
Again: Trip should have private Integer cost; Integer getCost() etc. and
then you
do
Trip( $cost: cost ) ...
To call an arbitrary method you should be able to do
sum( $trip.getCost() )
All together:
$person: Person( $maxMoney: maxMoney != null, $trips: trips != null )
Number( $spent: intValue > $maxMoney )
from accumulate( Trip( $cost: cost ) from $trips, sum( $cost ) )
-W
> ****
>
> 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.
> ****
>
> ** **
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110721/d975f2c8/attachment.html
More information about the rules-users
mailing list