0

I've searched around the internet but could not find an solution for a problem we are currently facing with drools (6.2.0).

Suppose i have a rule like this:

when
    $list: ProductList()
    $product: Product() from $list
    $product2: Product(this != product) from $list
then
    // do something
end

if $list contains 2 products, A and B, this rule will fire for combinations:

  1. A-B
  2. B-A

For some reason I am not able to make the rule fire only once (either ONLY A-B or ONLY B-A)

Does anybody know if there is a standard way to achieve the desired result?

Many Thanks in advance!

Regards,

Kim

Kim Zeevaarders
  • 732
  • 1
  • 7
  • 21

1 Answers1

0

You need to have a Product attribute that is comparable and unique. I'm assuming a product number:

rule comp2prod
when
  $list: ProductList()
  $product: Product( $pn: productNumber ) from $list
  $product2: Product( productNumber > $pn ) from $list
then
  // do something
end
laune
  • 31,114
  • 3
  • 29
  • 42