Donnie Y
Donnie Y

Reputation: 11

Test a list type data in Decision Table

I am trying to use a create a rule using a list type data in Drools.

I want to provide a list of numbers as an input data, and test it whether it contains a certain number in a decision table.

As in the following images, I created a input data, IntegerArr, and a decision table. Custom data type, IntegerArr, is defined as a list type of number.

I would like to get a result true, testing my input data which is ArrayList type data, Java.

ArrayList<Integer> arr = new ArrayList<Integer>();
arr.add(1);
arr.add(2);

Hashmap input = new HashMap();
input.put("IntegerArr", arr);

DRD

DecisionTable with Integer Array as an input

If I call a dmn function, list contains(IntegerArr, 1), as a result, it returns true which means the function is called without any problem.

But when I use it in the when statement, it seems to not pass, even though its result is true.

Additional Case - Success

This is the success case, which the primitive data type is used as an input data.

DecisitonTable with String data as an input

I am running a rule with an input data, groupName, with a string data, "javaClass".

If I write the same FEEL logic with String type input data, it passes the rule and gives the correct result.

I would like to know how to write a rule in a when column of decision table, using a list type data.

Upvotes: 1

Views: 475

Answers (0)

Related Questions