Design for Object cardinality in DMN

Hi ,
As per my project requirement, I need to compare data from parent object with a child object.For e.g, I have employee as my parent entity and his list of accounts as child entity, then i just want to compare data between employee object and account object.

As a simple example based on employee first name starts with “John” and account type is “Current Account”, i need to pass a boolean true or false as DMN output.

I am trying to figure out how to pass employee object along with list of its associated accounts to DMN engine to evaluate the rules and get this as an output.(Without using any Expression language inside the rule)

If i need to use for sure expression language to evaluate above said rule, any suggestions to make it generic so that if need add new elements to employee object or account object without any code change.

Below is the input object relationship passed to camunda DMN with parent and child relationship.
Employee object as parent and having list of Accounts and Projects

Application is sending the complete json request like below.

{
“firstName” : “XXX”

"accountDTOs": [
					{
						"accountNumber": "1233"
					},
					{
						"accountNumber" : "3456"
					}
				]
"projectDTOs":[
					{
						"projectName" : "test1"
					},
					{
						"projectName" : "test2"
					}
				]

}

How to apply the object cardinality through DMN rules

Employee:
{
employeeId
email
firstName
lastName
.
.

}
Account{
accountId
accountNumber

.
.
.

}
Project{
projectId
projectName
.
.
.

}

Rule 1: Employee name starts with “John” and account type =“Current account”(Where my hit policy is C Collect)
Rule 2: firstName= “XXX” and accountNumber=“1233” and projectName=“test1” :: Output score=80% and status=“Good”.

Thanks
Vemula

Hi @vemulabujji,

using the FEEL extension, you can write the following conditions

starts with(employee.firstName, "John")

some account in employee.accountDTOs satisfies account.type = "Current account"

Does this help you?

Best regards,
Philipp

Thanks Dear,

Can we get the any samples from github for these kind of requirements?

And how we can get the values from list?

Thanks
Vemula

Hi Dear,

Can I get any sample DMN and input Json for same example?

Hi,

This solution not working. Please let me know if any other solution for this.

What exactly is not working?
Please share what you have so far.

One account have multiple employees , we cant write this expression.
starts with(employee.firstName, “John”).

For me, it’s a bit hard to follow the topic. Please share the input JSON again and the conditions that you want to check.

JSON:

{
“firstName” : “XXX”
“accountDTOs”: [
{
“accountNumber”: “1233”
},
{
“accountNumber” : “3456”
}
]
“projectDTOs”:[
{
“projectName” : “test1”
},
{
“projectName” : “test2”
}
]

}

And my rules:

Rule 1: firstName= “XXX” and accountNumber=“1233” and projectName=“test1” :: Output score=80% and status=“Good”

In the JSON, I don’t see that one account has multiple employees. Do I oversee something?

Sorry,

One employee having multiple accounts and multiple projects.

So please share the idea, how to fill the below rule in the DMN

Rule 1: firstName= “XXX” and accountNumber=“1233” and projectName=“test1” :: Output score=80% and status=“Good”

Okay. The FEEL expressions could look like this:

some account in employee.accountDTOs satisfies account.accountNumber = "1233"

and

some project in employee.projectDTOs satisfies project.projectName = "test1"

Does this work for you?

Thanks,

If possible, can i get the sample DMN file based on above exmaple.how we can design the DMN?

Nope. With the given expressions, you should be able to model the DMN yourself :laughing:

But feel free to ask more questions if you’ve any concrete issue :slight_smile:

@Philipp_Ossler ,

I m not able to figure out , how to prepare the DMN for this JSON. Please kindly help to give one sample dmn,which will suit this sample JSON.

JSON:

{
“firstName” : “XXX”
“accountDTOs”: [
{
“accountNumber”: “1233”
},
{
“accountNumber” : “3456”
}
]
“projectDTOs”:[
{
“projectName” : “test1”
},
{
“projectName” : “test2”
}
]

}

And my rules:

Rule 1: firstName= “XXX” and accountNumber=“1233” and projectName=“test1” :: Output score=80% and status=“Good”

Thanks
Vemuladiagram_1.dmn (2.4 KB)