Murali
Murali

Reputation: 339

Create Accumulate function on Drools Decision table

I am trying to create accumulate function condition on Decision table. Please help me that How to create on Decision table.

My accumulate rule function is

when 

$i : Double(doubleValue >  1000 ) from accumulate( Product($productQty:quantity),sum($productQty))

then

System.out.println( "The quantity is exceeded more than 1000 and the total value is  " + $i );

Upvotes: 0

Views: 1425

Answers (1)

laune
laune

Reputation: 31290

You can create a column

rows
n      condition
n+1    $i : Double() from accumulate( Product($productQty:quantity),sum($productQty))
n+2    doubleValue > $param
n+3    add quantitities and check
n+4    1000

Two comments.

  1. This is not well-suited for decision tables unless you plan to check for different ranges of the accumulated value.
  2. Why do you use double for counting what is, most likely, integral quantities? I'd be surprise if the accumulated stock exceeds Integer.MAX_VALUE. In short: use Number in the pattern and intValue in the constraint.

Upvotes: 1

Related Questions