Search code examples
javapojodmnkogito

Changing POJO Object in DMN Kogito


I have bpmn2 file in which I use as a process data POJO application. To learn how to work with DMN I wanted to change 1 POJO property depending on smth inside the DMN. I manged to make DMN working when on the input I had application and on the output I had a string value. Now I want to hade in the input application on the input and modified application on the output: DMN Data I\O

Inside DMN I have the following structure:

DMN Structure

I have created data type tApplication with string algId field: DMN data type

So the aplication inside DMN is a tApplication data type, for decision I tried to use the decision table:

DMN Decision Table

My idea was- when application.algId == "101" change that value to "115", but for the input

{
  "application": {
    "algId":"101",
    ...
  }
}

I get following results:

{
    "id": "98b8a9ad-1c1d-4c4f-8525-6e5fe9a528c9",
    "application": {
        "algId":"101",
    ...
  }
}

What am I doing wrong? What is the best practice to change the POJO object inside the DMN?


Solution

  • A very relevant and similar use-case was described precisely in:

    before accessing the code, I would strongly recommend to watch the video or read the blog post first.

    It is important to remind that the DMN Specification mandates for a stateless and side-effect free model, so you can't mutate an existing InputData variable, per-se. However, you can make use of "data enrichment" strategies to fulfil your use-case, per the blog post and video.

    There are 2 main strategies you could follow, in short:

    • in the DMN model, you decide for the algId as its own Decision node named algId which later will be used in BPMN process Data I/O in order to update the process variable of type Application with the expected result
    • in the DMN model, you come up with a data enriched final decision which has the same structure of Application type, using the new DMN FEEL built-in such as context put() and you replace the process variable with that decision