[rules-users] Drools: Compound Value Restriction in Decision Table

Wolfgang Laun wolfgang.laun at gmail.com
Sat Feb 5 06:56:08 EST 2011


This is straightforward: You use $param, as usual, in the code snippet, and
the list in the cell below:

Data
coverType in ( $param )

"A","B", "C", "D"
"X","Y","Z"

To obtain the actual value from the fact, use a binding variable and refer
to this in the action.

Data
$ct: coverType in ( $param )
--------------------
result
add( $ct )

and an 'x' in the cells below, where required.

-W


2011/2/5 David Smith <mail at davesmith.me.uk>

> Hi,
>
> I am pocing/learning drools and I am trying to implements Compound Value
> Restrictions using 'In' in a decision table.
>
> I can do this in a rule like
>
> rule "CoverType Example"
> when
>     $risk : Data( coverType in ("A","B", "C", "D"))
> then
>     result.add("CoverType was one of A, B C or D");
> end
>
> I can also implement this in a decision table in a long winded fashion
> Condition, Action
> Data,        result
> coverType, add("$param")
> A,              CoverType was one of A, B C or D
> B,              CoverType was one of A, B C or D
> C,              CoverType was one of A, B C or D
> D,              CoverType was one of A, B C or D
>
> Is there a compact way to do this using a Compound Value Restriction using
> in?
> Something like:
>
> Condition, Action
> Data,        result
> coverType in, add("$param")
> "A,B,C,D",              CoverType was one of A, B C or D
>
> What goes in the script part "coverType in"?
>
> The number of items in the list can be variable, so don't want to write
> something that has $1, $2, $3, $4
>
> Thanks
> David
>
> _______________________________________________
> 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/20110205/fe9204ea/attachment.html 


More information about the rules-users mailing list