Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list contains for structure data type in DMN decision table

I am planning to use Drools for executing the DMN models. However I am having trouble to write a condition in DMN Decision table where the input is an array of objects with structure data type and condition is to check if the array contains an object with specific fields. For ex: Input to decision table is as below:

[
  {
    "name": "abc",
    "lastname": "pqr"
  },
  {
    "name": "xyz",
    "lastname": "lmn"
  },
  {
    "name": "pqr",
    "lastname": "jkl"
  }
]

Expected output: True if the above list contains an element that match {"name": "abc", "lastname": "pqr"} both on the same element in the list.

I see that FEEL has support for list contains, but I could not find a syntax where objects in array are not of primitive types like number,string etc but structures. So, I need help on writing this condition in Decision table.

Thanks!


Edited description:

I am trying to achieve the following using the decision tableenter image description here wherein details is list of info structure. Unfortunately as you see I am not getting the desired output wherein my input list contains the specific element I am looking for.

Input: details = [{"name": "hello", "lastname": "world"}]

Expected Output = "Hello world" based on condition match in row 1 of the decision table.

Actual Output = null

NOTE: Also in row no 2 of the decision table, I only check for condition wherein I am only interested in the checking for the name field.

Content for the DMN file can be found over here

like image 817
Naman Parakh Avatar asked Jan 20 '26 20:01

Naman Parakh


1 Answers

In DMN, there are multiple ways to achieve the same result.

If I understand the real goal of your use case, I want to suggest a better approach, much easier to maintain from a design point of view.

First of all, you have a list of users as input so those are the data types:

Data types

Then, you have to structure a bit your decision:

DG

The decision node at least one user match will go trough the user list and will check if there is at least one user that matches the conditions inside the matching BKM.

at least one user match can implemented with the following FEEL expression:

some user in users satisfies matching(user)

The great benefit of this approach is that you can reason on specific element of your list inside the matching BKM, which makes the matching decision table extremely straightforward:

decisin table

like image 70
dmarrazzo Avatar answered Jan 23 '26 19:01

dmarrazzo