0

I have the below DMN, that has text value as an input and has a constraint to use only specific values as enumeration constraint.

<?xml version="1.0" encoding="UTF-8"?>
<semantic:definitions xmlns:semantic="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:triso="http://www.trisotech.com/2015/triso/modeling" xmlns:trisodmn="http://www.trisotech.com/2016/triso/dmn" xmlns:feel="https://www.omg.org/spec/DMN/20191111/FEEL/" xmlns:tc="http://www.omg.org/spec/DMN/20160719/testcase" xmlns:drools="http://www.drools.org/kie/dmn/1.1" xmlns:openapi="https://openapis.org/omg/extension/1.0" xmlns:boxedext="https://www.trisotech.com/spec/DMN/20191111/EXT/" xmlns:i18n="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0" xmlns:rss="http://purl.org/rss/2.0/" xmlns:trisofeed="http://trisotech.com/feed" xmlns:kie="http://www.drools.org/kie/dmn/1.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="https://kiegroup.org/dmn/_BB262EB7-6657-4120-9DB1-2AEB663750A3" id="_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719" name="RoundOffTax" namespace="https://kiegroup.org/dmn/_BB262EB7-6657-4120-9DB1-2AEB663750A3" exporter="Decision Modeler" exporterVersion="7.11.1" triso:translationLanguages="" triso:logoChoice="Default">
  <semantic:extensionElements />
  <semantic:itemDefinition id="_5584EF47-9227-47A7-A879-512B81063E87" label="income" name="income" isCollection="false">
    <semantic:itemComponent id="_F4B5BE6A-CADD-4BD8-8469-B0D58D37FBB1" name="creditRating" isCollection="false">
      <semantic:typeRef>creditRating</semantic:typeRef>
    </semantic:itemComponent>
  </semantic:itemDefinition>
  <semantic:itemDefinition id="_10A58E93-234F-43AA-B53B-D80596CFB853" label="creditRating" name="creditRating" isCollection="false">
    <semantic:typeRef>string</semantic:typeRef>
    <semantic:allowedValues id="_D53F2095-E2F5-4E6C-8386-C6D94370EC71" kie:constraintType="enumeration" triso:constraintsType="enumeration">
      <semantic:extensionElements>
        <triso:constraintDetails>
          <triso:display>"EXCELLENT", "GOOD", "BAD", "POOR"</triso:display>
          <triso:choices>
            <triso:value>"EXCELLENT"</triso:value>
            <triso:display>"EXCELLENT"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"GOOD"</triso:value>
            <triso:display>"GOOD"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"BAD"</triso:value>
            <triso:display>"BAD"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"POOR"</triso:value>
            <triso:display>"POOR"</triso:display>
          </triso:choices>
        </triso:constraintDetails>
      </semantic:extensionElements>
      <semantic:text>"EXCELLENT", "GOOD", "BAD", "POOR"</semantic:text>
    </semantic:allowedValues>
  </semantic:itemDefinition>
  <semantic:itemDefinition id="_B8583894-DC3B-426C-BF11-6903BD0E8258" label="loanQualification" name="loanQualification" isCollection="false">
    <semantic:typeRef>string</semantic:typeRef>
    <semantic:allowedValues id="_BF9D6514-2016-460E-843F-7F80014BE81B" kie:constraintType="enumeration" triso:constraintsType="enumeration">
      <semantic:extensionElements>
        <triso:constraintDetails>
          <triso:display>"QUALIFIED", "DISQUALIFIED"</triso:display>
          <triso:choices>
            <triso:value>"QUALIFIED"</triso:value>
            <triso:display>"QUALIFIED"</triso:display>
          </triso:choices>
          <triso:choices>
            <triso:value>"DISQUALIFIED"</triso:value>
            <triso:display>"DISQUALIFIED"</triso:display>
          </triso:choices>
        </triso:constraintDetails>
      </semantic:extensionElements>
      <semantic:text>"QUALIFIED", "DISQUALIFIED"</semantic:text>
    </semantic:allowedValues>
  </semantic:itemDefinition>
  <semantic:decisionService id="_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719_DS" name="Whole Model Decision Service" triso:dynamicDecisionService="true" triso:wholeModelService="true">
    <semantic:variable id="_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719_DS_VAR" name="Whole Model Decision Service" typeRef="Any" />
    <semantic:outputDecision href="#_34A43DC3-8C75-4086-BB6E-92FF452816DF" />
    <semantic:inputData href="#_E31C6DD8-5B9D-4B64-965A-3C2617455441" />
  </semantic:decisionService>
  <semantic:decisionService id="_D0D3E0DE-8B13-43BD-861D-ED71DE946AFF_DS" name="Diagram DRG" triso:dynamicDecisionService="true">
    <semantic:variable id="_D0D3E0DE-8B13-43BD-861D-ED71DE946AFF_DS_VAR" name="Diagram DRG" typeRef="Any" />
    <semantic:outputDecision href="#_34A43DC3-8C75-4086-BB6E-92FF452816DF" />
    <semantic:inputData href="#_E31C6DD8-5B9D-4B64-965A-3C2617455441" />
  </semantic:decisionService>
  <semantic:inputData id="_E31C6DD8-5B9D-4B64-965A-3C2617455441" name="income">
    <semantic:variable id="_350BFB47-AC97-4849-BC92-523F08758BAF" name="income" typeRef="income" />
  </semantic:inputData>
  <semantic:decision id="_34A43DC3-8C75-4086-BB6E-92FF452816DF" name="ActionableDecision" triso:useOutputTypeAsAnswer="false">
    <semantic:variable id="_7C0BC007-B74F-44E4-9C86-20DF025B5118" name="ActionableDecision" typeRef="Any" />
    <semantic:informationRequirement id="_9BA92A1F-CB9C-4E6B-9103-EA8DA6AF26DB">
      <semantic:requiredInput href="#_E31C6DD8-5B9D-4B64-965A-3C2617455441" />
    </semantic:informationRequirement>
    <semantic:decisionTable id="_C8CC4E93-90A7-40AF-99F9-EB83930C05A6" typeRef="Any" outputLabel="ActionableDecision" triso:descriptionVisible="false" triso:expressionId="_745442c9-b5b3-4dcd-821f-e0c16ac5dcf3">
      <semantic:input id="_89815BA9-91F5-47D2-9CFF-64491676F72C" label="income.creditRating">
        <semantic:inputExpression id="LiteralExpression_1fb8mb4" typeRef="creditRating">
          <semantic:text>income.creditRating</semantic:text>
        </semantic:inputExpression>
        <semantic:inputValues id="UnaryTests_0nl8r4o" triso:constraintsType="enumeration">
          <semantic:text>"EXCELLENT", "GOOD", "BAD", "POOR"</semantic:text>
        </semantic:inputValues>
      </semantic:input>
      <semantic:output id="_E18626D3-6BE9-4719-B87B-CB61F97DA26E" name="action" typeRef="string" />
      <semantic:output id="_4CB7D793-79CB-4B34-9FC4-42E9D09EA110" name="loanQualification" typeRef="loanQualification">
        <semantic:outputValues id="UnaryTests_0xe8kad" triso:constraintsType="enumeration">
          <semantic:text>"QUALIFIED", "DISQUALIFIED"</semantic:text>
        </semantic:outputValues>
      </semantic:output>
      <semantic:annotation name="annotation-1" />
      <semantic:rule id="_AB9F6F1E-4586-427C-B328-EB9E935CDEF8">
        <semantic:inputEntry id="_29D9C278-B794-47DB-B898-292244377500">
          <semantic:text>"EXCELLENT"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_6C6E32F9-0B86-4BBD-806D-2B633DCF078C">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_26F433BA-CE54-4575-B9A4-088BF7C1977C">
          <semantic:text>"QUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
      <semantic:rule id="_35B43044-13A4-4D75-AB1C-B004E4103508">
        <semantic:inputEntry id="_4B3851A4-9C20-457B-92BB-E98D164D2EF3">
          <semantic:text>"GOOD"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_AFEC591A-E0CA-4CE3-85B9-D295DE137198">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_0C484B49-7407-45F6-A519-7A49A80D713F">
          <semantic:text>"QUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
      <semantic:rule id="_701E4453-3CF2-45DE-9F5D-451B418287C3">
        <semantic:inputEntry id="_52DDDDFA-A2E3-4E56-9117-7B49291104A3">
          <semantic:text>"BAD"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_15EB382E-0607-435A-B2EF-74DA2CB441EA">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_EDC7AE5A-FECE-48FB-B674-39AA7DE23B76">
          <semantic:text>"DISQUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
      <semantic:rule id="_B16CD70F-F03D-4EE1-8960-D7B5939BD759">
        <semantic:inputEntry id="_18A6636C-1115-4494-B5E7-83F90FBC549D">
          <semantic:text>"POOR"</semantic:text>
        </semantic:inputEntry>
        <semantic:outputEntry id="_06508A1E-F30A-46FD-A1A2-BF62383CF688">
          <semantic:text>"loan_qualification"</semantic:text>
        </semantic:outputEntry>
        <semantic:outputEntry id="_46DBD47B-5E20-47B6-856E-C722D96AE9BB">
          <semantic:text>"DISQUALIFIED"</semantic:text>
        </semantic:outputEntry>
        <semantic:annotationEntry>
          <semantic:text></semantic:text>
        </semantic:annotationEntry>
      </semantic:rule>
    </semantic:decisionTable>
  </semantic:decision>
  <dmndi:DMNDI>
    <dmndi:DMNDiagram id="_D0D3E0DE-8B13-43BD-861D-ED71DE946AFF" name="DRG" triso:modelElementRef="_5e579375-23fb-4af7-a1ce-a9a67376ac77">
      <dmndi:Size width="1485" height="1050" />
      <dmndi:DMNShape id="dmnshape-drg-_E31C6DD8-5B9D-4B64-965A-3C2617455441" dmnElementRef="_E31C6DD8-5B9D-4B64-965A-3C2617455441">
        <dc:Bounds height="50" width="100" x="380" y="253" />
        <dmndi:DMNLabel trisodmn:defaultBounds="true" />
      </dmndi:DMNShape>
      <dmndi:DMNShape id="dmnshape-drg-_34A43DC3-8C75-4086-BB6E-92FF452816DF" dmnElementRef="_34A43DC3-8C75-4086-BB6E-92FF452816DF">
        <dc:Bounds height="50" width="100" x="380" y="117" />
        <dmndi:DMNLabel trisodmn:defaultBounds="true" />
      </dmndi:DMNShape>
      <dmndi:DMNEdge id="dmnedge-drg-_9BA92A1F-CB9C-4E6B-9103-EA8DA6AF26DB" dmnElementRef="_9BA92A1F-CB9C-4E6B-9103-EA8DA6AF26DB" sourceElement="dmnshape-drg-_E31C6DD8-5B9D-4B64-965A-3C2617455441" targetElement="dmnshape-drg-_34A43DC3-8C75-4086-BB6E-92FF452816DF">
        <di:waypoint x="430" y="253" />
        <di:waypoint x="430" y="167" />
        <dmndi:DMNLabel />
      </dmndi:DMNEdge>
    </dmndi:DMNDiagram>
    <dmndi:DMNStyle id="LS_98D1D9BB-A096-4D57-9BF1-1AD1D2D72719_0" fontSize="11" fontFamily="arial,helvetica,sans-serif" fontItalic="false" fontBold="false" fontUnderline="false" fontStrikeThrough="false" />
  </dmndi:DMNDI>
</semantic:definitions>

This is working fine when testing in Trisotech. But when integrating with the service it is throwing errors as mentioned below.

2021-09-20 19:07:48.943 ERROR --- [ main] o.k.d.core.ast.DMNDTExpressionEvaluator : income.creditRating='EXCELLENT' does not match any of the valid values "EXCELLENT", "GOOD", "BAD", "POOR" for decision table 'ActionableDecision'.

I am using the below version of kie in the service. Can someone suggest what could be the reason for the issue?

<dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-dmn-core</artifactId>
      <version>7.57.0.Final</version>
</dependency>

Sample project can be found here

1 Answers1

0

You would need to share more details about how you are invoking the Drools DMN Engine; is it through Kogito or Kie Server? Are you using Drools as a library in embedded modre, are you using Kogito APIs, Kie v7 APIs, Kie Server Client (Java) API etc.

This is because as demonstrated by the below screenshot, which is based on the Kogito leveraging the Drools DMN Engine, everything works just fine and as expected: demo

So it must be something going wrong in the specific way you are interacting with the engine.

tarilabs
  • 2,178
  • 2
  • 15
  • 23
  • Kie Server Client (Java) API is being used in the project and I have built a sample application of how we use the service in https://github.com/scharles109/dmn-engine-test. Let me know if anything else is needed. Yeah, as you said it is validating and working fine in tools Trisotech/JBPM, but on working using Java Client API's somewhere it is breaking and causing the issue. – Charles Augustin Sep 22 '21 at 14:48
  • Your problem is here: https://github.com/scharles109/dmn-engine-test/blob/37d84c45359953dda9d11c9b8a955cfcc726e57c/src/main/java/com/scharles/dmnenginevalidation/Income.java#L10 as a POJO you are expected to give it a FEEL:string representation, not a Java Enum. You should adjust your POJOs to provide a Java String representation as expected say with using @FEELProperty annotation. – tarilabs Sep 22 '21 at 14:53
  • Alternatively you may subscribe to https://issues.redhat.com/browse/DROOLS-5973 for updates on an analogous issue, but we need first to understand some implications at the Standard body level; so I wouldn't hold my breath on it (at the Standard body level, there has been some discussion about enumerations, which may have direct implication on this type of engine enhancement). Hence providing a @FEELProperty annotation may be the quickest solution today. – tarilabs Sep 22 '21 at 14:55
  • I was trying out various different ways and was able to get it work by understanding a little more on how it was working internally. Updated the DMN with a different approach with slight modifications to the model, it can be found in https://github.com/scharles109/dmn-engine-test/blob/alternate-approach/src/main/resources/rules/LoanQualification.dmn. Would this approach work on a longer run or should we use @FEELProperty to handle it? – Charles Augustin Sep 23 '21 at 05:59
  • If you refer to the use of JDK Enum's name() in the DMN model, I don't think is a solid approach for the reasons we have already explored here: https://issues.redhat.com/browse/DROOLS-5973?focusedCommentId=15791952&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-15791952 – tarilabs Sep 23 '21 at 07:44
  • I would advise either to use the @FEELProperty on the containing pojo, or subscribe for an approach as detailed in https://issues.redhat.com/browse/DROOLS-5973 Don't hesitate to engage on the Kogito Mailing-List if easier than this small little comment section :) – tarilabs Sep 23 '21 at 07:45