I should have added that an imported variable cannot be used just like a
literal;
it'll have to be parenthesized, e.g.
$sale : Sale( amount > (MAX_AMOUNT) )
Another way of getting named constants would be through one fact (or a few
facts)
containing the values as members. Then you could write
SaleParams( $ma : maxAmound )
$sale : Sale( amount > $ma )
-W
On 8 October 2010 13:17, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
You could do public final static MAX_AMOUNT in some class foo.Bar and
then,
in DRL:
import function foo.Bar.*;
and use MAX_AMOUNT as usual.
-W
On 8 October 2010 12:52, Evert Penninckx <evert.penninckx(a)gmail.com>wrote:
>
> Hi
>
> I've got the following rule:
>
> when
> $sale : Sale( amount > 300 )
> then
> modify($sale) { amount = 300; }
> end
>
> First problem: I don't like putting the constant value "300" two times
in
> my
> rule.
>
> Second problem: amount is a BigDecimal. I read that mvel2 supports
> BigDecimal literals like 300.00B, but drools won't compile this.
>
> An ideal solution would look like something like this:
>
> when
> $maxAmount : 300.00B
> $sale : Sale( amount > $maxAmount )
> then
> modify($sale) { amount = $maxAmount; }
> end
>
>
> 1. Is it possible to attribute values to a variable?
>
> 2. If not, is it possible to use mvel's BigDecimal support? Because
> amount
> > 300.00B says a lot more than eval(amount.compareTo(new
> BigDecimal("300.00")) > 0).
>
>
>
> Evert
> --
> View this message in context:
>
http://drools-java-rules-engine.46999.n3.nabble.com/Constants-and-BigDeci...
> Sent from the Drools - User mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>