Thanks, that was very useful.
For others looking to use decision tables, I found some useful code
for converting the excel spreadsheet to rules
which aids deciphering the error messages that come out when you don't
quite get your spreadsheet just right...
DecisionTableConfiguration dtableconfiguration =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtableconfiguration.setInputType(DecisionTableInputType.XLS);
Resource spreadsheet =
ResourceFactory.newClassPathResource("myspreadsheet.xls",
getClass());
String rules =
DecisionTableFactory.loadFromInputStream(spreadsheet.getInputStream(),
dtableconfiguration);
System.out.println("rules = " + rules);
2011/2/5 Wolfgang Laun <wolfgang.laun(a)gmail.com>:
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(a)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(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users