Map List into a class

190 views
Skip to first unread message

Ivan Cordon

unread,
Mar 10, 2022, 1:07:08 PM3/10/22
to kogito-de...@googlegroups.com
Hi Team


I have a dmn that generates a list of strings in function of an input variable. I've created into the dmn a variable of List type:

image.png

image.png

image.png



image.png


My problem is Map Consents has as input a class like this:

public class ConsentList {

    private List<String> consentIds;

}


and when I launch a request to the api, always obtain an error 500: 

org.jbpm.workflow.instance.WorkflowRuntimeException: [consents:96928b41-f870-4e57-a764-42f59fd5b0ee - Generate Consent:3] -- value [type2, type3] does not match com.example.consents.model.ConsentList

If I launch directly to the dmn service I obtain:

{
  "Request": {
    "idenpn": "298329838B",
    "isclient": true
  },
  "ConsentList": [
    "type1",
    "type2"
  ]
}


What type of data or class should I use in "Map Consents" to receive the list from the dmn?


Regards



Jozef Marko

unread,
Mar 11, 2022, 12:33:34 AM3/11/22
to kogito-de...@googlegroups.com
Hello, I think you need to update your DMN structure and decision table in this way, to be able map to the java class.

--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/CA%2BksFCxgx6jk75p%2BZLmwg_ere8NLMyWT-tdFZ4B_izFM-Y2_GQ%40mail.gmail.com.


--
Regards, Jozef
RHBA Quality Engineer
Screenshot from 2022-03-11 06-32-05.png
Screenshot from 2022-03-11 06-32-12.png

Ivan Cordon

unread,
Mar 11, 2022, 1:28:32 AM3/11/22
to kogito-de...@googlegroups.com
Hi Jozef

That was the solution. Next step is to validate consents in a user task.

Thanks! 

Jozef Marko

unread,
Mar 11, 2022, 3:36:10 AM3/11/22
to kogito-de...@googlegroups.com
I Happy if I helped at least a little bit.

Matteo Mortari

unread,
Mar 11, 2022, 6:42:18 AM3/11/22
to Kogito development mailing list
Ivan,

The main problem you are facing relates to the Process engine, as you confirmed by yourself the DMN evaluation standalone already matches your expectations in your first original email, and it's the return-side of Data I/O mapping in the BPMN2 process which is giving an error.

Technical option1.
This problem, in my understanding, has root cause in the fact that https://issues.redhat.com/browse/JBPM-9774https://issues.redhat.com/browse/JBPM-9783 are NOT available on Kogito.

Technical option2.
Alternatively, I am not sure if there is ongoing work on the Process engine on Kogito to rely on "kogito incubation API" to ease the data mapping from/to other Kogito hosted engines.

In either case, requires some enhancement on the Kogito Process engine, so nothing which can be "solved" from (your) end-user side.

In either case, you are not "forced" to implement Jozef suggestion, your original ItemDefinition was just fine in DMN.
What you could do on the Java pojo is annotate its field with Jackson's @JsonValue annotation.

As a workaround of technical options 1/2, you could implement workaround similarly to what shown in the first part of this blog post:
  1. https://blog.kie.org/2022/01/data-enrichment-use-case-with-dmn-and-bpmn.html
  2. scroll to Details section
  3. first screenshot
  4. notice On Exit Action script.

If I were in your shoes, as a User, I would do the following.
  1. Raise a JIRA or GitHub issue for the Process Engine on Kogito with reference to this discussion, and highlighting the 2 technical options above.
  2. Revert the DMN model to your original version, which imho was just fine.
  3. Use @JSonValue annotation in the Java class, which would help with any Jackson serialization later down the line.
  4. Implement the workaround of the blog post
    1. on the Data I/O return side, store first the ConsentList (decision name) from the DMN, into a temporary process variable (not of type ContentList classname)
    2. on the On Exit Action script, take the value from the temporary variable, and store as appropriate process variable of type ConsentList (Java class name)
Hope this helps,
MM




--

Ivan Cordon

unread,
Mar 16, 2022, 6:32:05 PM3/16/22
to kogito-de...@googlegroups.com
Matteo

I've tried what you said. The only change I've had to make is to include the script on a task (script type) because On Exit Action is not supported by Kogito

image.png

image.png

But essentially it is the same and it works. The problem I'm running into now is that when the user's task state is persisted to mongo, the lists get cut off:

create new request:

{
"request" : {
"idenpn": "232jjjG",
"isclient": false
}
}

and the response shows the two consents (list):

{
"id": "bba52957-973b-4bf2-9232-cdc31adff736",
"request": {
"idenpn": "232jjjG",
"isclient": false,
"consentTypes": [
"c",
"d"
]
},
"consents": [
{
"type": "c",
"accepted": false
},
{
"type": "d",
"accepted": false
}
]
}


but when I get task, only receive one consent:

[
{
"id": "6fa308e5-fb9b-4f43-85ae-93f74ac6af0f",
"name": "accept",
"state": 0,
"phase": "active",
"phaseStatus": "Ready",
"parameters": {
"request": {
"idenpn": "232jjjG",
"isclient": false,
"consentTypes": [
"d"
]
},
"consents": [
{
"type": "d",
"accepted": false
}
]
},
"results": {}
}
]


I suppose mongo is the problem, but I don't know why...


Regards



Matteo Mortari

unread,
Mar 17, 2022, 4:24:28 AM3/17/22
to Kogito development mailing list
Hi Ivan,
glad to hear that solved the mapping issue between bpmn and dmn on kogito.

For the Process <-> MongoDB interaction problem, my best suggestion is to start a new thread on this mailing-list or on Zulip chat, highlighting in title the problem seems to be between Process and MongoDB.
If you can share a small reproducer (eg: just a .bpmn2 on a Kogito based project) that may help the Process team too.

Hope this helps,
MM

Reply all
Reply to author
Forward
0 new messages