apache / incubator-kie-issues

Apache License 2.0
12 stars 1 forks source link

Add “evaluationHitIds” to the response of jitexecutor-dmn’s “/dmnresult” route #1541

Closed gitgabrio closed 2 weeks ago

gitgabrio commented 3 weeks ago

Modify jitexecutor-dmn| so that the execution rest endpoint (/jitdmn/dmnresult) returns information about executed branches of the DMN model.

The format of returned json should be (e.g.)

{
    "namespace": "https://kie.org/dmn/_A3317FB1-7BF8-4904-A5F4-2CD63AF3AEC9",
    "modelName": "DMN_A77074C1-21FE-4F7E-9753-F84661569AFC",
    "dmnContext": {
        "Risk Score": 20,
        "DTI": 15,
        "Loan Pre-Qualification": "Qualified",
        "id": "_CD8A1707-4F28-4F99-9D07-340F8E1A82AC",
        "Credit Score": "Excellent"
    },
    "messages": [],
    "decisionResults": [
        {
            "decisionId": "_6C207FD6-14EA-4480-A90D-074ABC97B54B",
            "decisionName": "Risk Score",
            "result": 20,
            "messages": [],

"evaluationHitIds": [<rule_id1>, <rule_id2>],

            "evaluationStatus": "SUCCEEDED"
        },
        {
            "decisionId": "_A1236581-4334-43F1-82A0-72CE204F07F9",
            "decisionName": "Loan Pre-Qualification",
            "result": "Qualified",
            "messages": [],
            "evaluationHitIds": [<expression_id1>],
            "evaluationStatus": "SUCCEEDED"
        }
    ]
} 

where <rule_id1>, <rule_id2> referes to id of rows executed inside decision tables, and <expression_id1> refers to branches (then/else) of conditional element

e.g.

<rule id="_1578BD9E-2BF9-4BFC-8956-1A736959C937">
        <inputEntry id="_57DAA79A-4929-4D0C-A7D1-E7BA81674B8B">
          <text>&quot;Poor&quot;</text>
        </inputEntry>
        <inputEntry id="_E2D67EAF-9023-4657-A852-7AFF89DDFF26">
          <text>-</text>
        </inputEntry>
        <outputEntry id="_93601F57-F06C-4AD2-9BA0-6933AD8F6007">
          <text>30</text>
        </outputEntry>
        <annotationEntry>
          <text>// Your annotations here</text>
        </annotationEntry>
      </rule>

returned id: "_1578BD9E-2BF9-4BFC-8956-1A736959C937"

<conditional id="_A80832EF-8F9C-4638-B5FB-047210860DF2" label="Loan Pre-Qualification" typeRef="Loan Pre-Qualification">
      <if id="_3C702CE4-E5A0-4B6F-905D-C2621FFFA387">
        <literalExpression id="_CA44F978-C3A3-4D65-BABB-8BDA2FBB1074" label="Expression Name">
          <text>Risk Score &lt;= 30</text>
        </literalExpression>
      </if>
      <then id="_6481FF12-61B5-451C-B775-4143D9B6CD6B">
        <literalExpression id="_000EE7D4-6DAB-4BC1-8A5A-59E1E9E61B21" label="Expression Name">
          <text>&quot;Qualified&quot; </text>
        </literalExpression>
      </then>
      <else id="_2CD02CB2-6B56-45C4-B461-405E89D45633">
        <literalExpression id="_EDEFF23B-55B9-4D8C-AB04-8E49F642CB22" label="Expression Name">
          <text>&quot;Not Qualified&quot;</text>
        </literalExpression>
      </else>
    </conditional>

returned id: "_6481FF12-61B5-451C-B775-4143D9B6CD6B" (then) OR "_2CD02CB2-6B56-45C4-B461-405E89D45633" (else)

jomarko commented 3 weeks ago

Thank you for the ticket @gitgabrio . Maybe just for the record, the evaluationHitIds will be UUID? e.g. _A1236581-4334-43F1-82A0-72CE204F07F9 ?

tiagobento commented 3 weeks ago

@jomarko Depends on the DMN. If you write it manually, IDs can be any string that you want. Our DMN Editors always use UUIDs by default, though.