Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of DMN 1.5 for tracing-enabled applications inside maven plugin code-gen #3823

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
*/
package org.kie.kogito.codegen.decision;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;

import org.kie.kogito.KogitoGAV;
import org.kie.kogito.codegen.api.context.KogitoBuildContext;
Expand Down Expand Up @@ -134,16 +131,12 @@ private ObjectCreationExpr makeDecisionModelMetadata(DMNResource resource) {
}

private String extractModelVersion(DMNResource resource) {
Set<String> definitions = new HashSet<>(resource.getDmnModel().getDefinitions().getNsContext().values());
definitions.retainAll(Arrays.asList(org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_DMN,
org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_DMN,
org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase.URI_DMN));

if (definitions.size() != 1) {
String toReturn = resource.getDmnModel().getDefinitions().getTypeLanguage();
if (toReturn == null || toReturn.isEmpty()) {
LOGGER.error("Could not extract DMN version from DMN model {}", resource.getDmnModel().getName());
throw new IllegalStateException("The DMN model does not contain a unique model version in the metadata.");
}
return definitions.iterator().next();
return toReturn;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
Copy link
Contributor

@gitgabrio gitgabrio Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @porcelli
Thanks for PR!
As @jomarko pointed out, the
?xml tag has to be removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gitgabrio @porcelli @jomarko Indeed we need to investigate this, as far as I know, the prolog should be correctly validated. When creating a new dmn file in our editor, the prolog is automatically added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should be there. It is also part of e.g. DMN TCK test files, like e.g. here (1).

(1) https://github.com/dmn-tck/tck/blob/master/TestCases/compliance-level-3/0007-date-time/0007-date-time.dmn#L1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just double checked, the "?xml" tag should be before the license header, as very first line.

<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
Expand All @@ -16,9 +17,8 @@
~ specific language governing permissions and limitations
~ under the License.
-->

<dmn:definitions xmlns:dmn="http://www.omg.org/spec/DMN/20180521/MODEL/" xmlns="decision" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="http://www.drools.org/kie/dmn/1.2" xmlns:dmndi="http://www.omg.org/spec/DMN/20180521/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:feel="http://www.omg.org/spec/DMN/20180521/FEEL/" id="_9efe7fc6-f41b-422c-accd-95dcaaa67a39" name="Vacations" typeLanguage="http://www.omg.org/spec/DMN/20180521/FEEL/" namespace="decision">
<dmn:extensionElements/>
<dmn:definitions xmlns:dmn="https://www.omg.org/spec/DMN/20230324/MODEL/" xmlns="decision" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:kie="https://kie.org/dmn/extensions/1.0" xmlns:dmndi="https://www.omg.org/spec/DMN/20230324/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:feel="http://www.omg.org/spec/DMN/20180521/FEEL/" id="_9efe7fc6-f41b-422c-accd-95dcaaa67a39" name="Vacations" typeLanguage="https://www.omg.org/spec/DMN/20230324/FEEL/" namespace="decision">
<dmn:extensionElements />
<dmn:itemDefinition id="_77BCBBC4-3599-49B2-9C72-EF94037F83FC" name="tAddress" isCollection="false">
<dmn:itemComponent id="_2c4e3950-8304-4f47-b04a-3d440df9ef82" name="street" isCollection="false">
<dmn:typeRef>string</dmn:typeRef>
Expand Down Expand Up @@ -64,15 +64,22 @@
<dmn:typeRef>tEmployee</dmn:typeRef>
</dmn:itemComponent>
</dmn:itemDefinition>
<dmn:decisionService id="_fcf22829-0fd8-4f41-919e-3e909f01fbff" name="days">
<dmn:extensionElements />
<dmn:variable id="_8ea3497e-8969-4aa6-9a39-254e4e8edea5" name="days" typeRef="Any" />
<dmn:outputDecision href="#_eac3ef9e-37de-4dca-8802-ee08ded9e268" />
<dmn:encapsulatedDecision href="#_5b8d18fb-39d8-4f5c-84a0-b79913b7aded" />
<dmn:inputData href="#_89e85ee4-f052-4977-bee5-a3b81a600c6c" />
</dmn:decisionService>
<dmn:inputData id="_89e85ee4-f052-4977-bee5-a3b81a600c6c" name="employee">
<dmn:extensionElements/>
<dmn:variable id="_682874bf-b580-4a33-858d-7c1c4c8b9f3e" name="employee"/>
<dmn:extensionElements />
<dmn:variable id="_682874bf-b580-4a33-858d-7c1c4c8b9f3e" name="employee" />
</dmn:inputData>
<dmn:decision id="_eac3ef9e-37de-4dca-8802-ee08ded9e268" name="vacationDays">
<dmn:extensionElements/>
<dmn:variable id="_92a674f9-ebf5-4605-aa18-4731239cffe2" name="vacationDays" typeRef="number"/>
<dmn:extensionElements />
<dmn:variable id="_92a674f9-ebf5-4605-aa18-4731239cffe2" name="vacationDays" typeRef="number" />
<dmn:informationRequirement id="_5e303927-d1c9-403c-a1b2-2af72044737d">
<dmn:requiredInput href="#_89e85ee4-f052-4977-bee5-a3b81a600c6c"/>
<dmn:requiredInput href="#_89e85ee4-f052-4977-bee5-a3b81a600c6c" />
</dmn:informationRequirement>
<dmn:decisionTable id="_c7a83474-a6bc-49c6-8296-4428c9285f4d" typeRef="number" hitPolicy="UNIQUE" preferredOrientation="Rule-as-Row" outputLabel="vacationDays">
<dmn:input id="_22cc8d8b-037c-4d0b-a00d-9e0943b1278a">
Expand All @@ -85,131 +92,131 @@
<dmn:text>15</dmn:text>
</dmn:defaultOutputEntry>
</dmn:output>
<dmn:annotation name="" />
<dmn:rule id="_a346eaa2-d5f3-48b7-8623-348e53b26d4c">
<dmn:inputEntry id="_94a86171-b02d-493a-b3a7-f333402dfe71">
<dmn:text>"US"</dmn:text>
<dmn:text>&quot;US&quot;</dmn:text>
</dmn:inputEntry>
<dmn:outputEntry id="_f42f5ec5-0f78-4a82-b769-9027ef1545f8">
<dmn:text>10</dmn:text>
</dmn:outputEntry>
<dmn:annotationEntry>
<dmn:text></dmn:text>
</dmn:annotationEntry>
</dmn:rule>
<dmn:rule id="_f2778f91-68e7-4af8-bbd8-7ba73c0ad3d0">
<dmn:inputEntry id="_13ea8161-c6c9-4810-a50f-59b639c74729">
<dmn:text>"IT"</dmn:text>
<dmn:text>&quot;IT&quot;</dmn:text>
</dmn:inputEntry>
<dmn:outputEntry id="_311804d4-3ecb-4a9d-9674-5e96a600058f">
<dmn:text>20</dmn:text>
</dmn:outputEntry>
<dmn:annotationEntry>
<dmn:text></dmn:text>
</dmn:annotationEntry>
</dmn:rule>
</dmn:decisionTable>
</dmn:decision>
<dmn:decision id="_5b8d18fb-39d8-4f5c-84a0-b79913b7aded" name="compute Payroll">
<dmn:extensionElements/>
<dmn:variable id="_81066090-2dba-43d3-89ca-8144b20d73b8" name="compute Payroll" typeRef="tPayroll"/>
<dmn:extensionElements />
<dmn:variable id="_81066090-2dba-43d3-89ca-8144b20d73b8" name="compute Payroll" typeRef="tPayroll" />
<dmn:informationRequirement id="_de1a99cb-c0c9-4e58-be9c-dc619e856fa6">
<dmn:requiredDecision href="#_eac3ef9e-37de-4dca-8802-ee08ded9e268"/>
<dmn:requiredDecision href="#_eac3ef9e-37de-4dca-8802-ee08ded9e268" />
</dmn:informationRequirement>
<dmn:informationRequirement id="_621c38e6-638b-4907-bbc4-e7daf9d4272d">
<dmn:requiredInput href="#_89e85ee4-f052-4977-bee5-a3b81a600c6c"/>
<dmn:requiredInput href="#_89e85ee4-f052-4977-bee5-a3b81a600c6c" />
</dmn:informationRequirement>
<dmn:context id="_d1950d38-3f02-4339-af1b-aaeeed847baa" typeRef="tPayroll">
<dmn:contextEntry>
<dmn:variable id="_7a08f51d-28b5-4cd0-b508-8eaaedfcf48b" name="employee"/>
<dmn:contextEntry id="_626D0D10-2787-4B69-9B5F-7625C366D536">
<dmn:variable id="_7a08f51d-28b5-4cd0-b508-8eaaedfcf48b" name="employee" />
<dmn:literalExpression id="_590f5f1d-bc73-43e4-8b87-1b18ee5b5d8d">
<dmn:text>employee</dmn:text>
</dmn:literalExpression>
</dmn:contextEntry>
<dmn:contextEntry>
<dmn:variable id="_065dbf8c-b4a0-4e1c-8484-2e7933907796" name="paymentDate" typeRef="string"/>
<dmn:contextEntry id="_93249FBE-7BB3-455D-A3C7-D7D71C1F36FB">
<dmn:variable id="_065dbf8c-b4a0-4e1c-8484-2e7933907796" name="paymentDate" typeRef="string" />
<dmn:literalExpression id="_02d83b5e-33ff-4075-8edc-de24f4c5bd57">
<dmn:text>null</dmn:text>
</dmn:literalExpression>
</dmn:contextEntry>
<dmn:contextEntry>
<dmn:variable id="_fd31c524-408d-453a-9849-f7a5a35e469c" name="vacationDays" typeRef="number"/>
<dmn:contextEntry id="_2CD2DDDF-1F7E-4F5D-A265-795BE3FF6F63">
<dmn:variable id="_fd31c524-408d-453a-9849-f7a5a35e469c" name="vacationDays" typeRef="number" />
<dmn:literalExpression id="_5ec20766-f390-4a66-b146-8f6c2239ceb5">
<dmn:text>vacationDays</dmn:text>
</dmn:literalExpression>
</dmn:contextEntry>
<dmn:contextEntry>
<dmn:variable id="_d1845af2-3a42-44b6-9037-b76f71b71193" name="taxRate" typeRef="number"/>
<dmn:contextEntry id="_56A3EDB5-4E76-46B7-9BDE-BB67D192AC29">
<dmn:variable id="_d1845af2-3a42-44b6-9037-b76f71b71193" name="taxRate" typeRef="number" />
<dmn:literalExpression id="_3db60313-218f-4384-b34c-8188afb3d0a8">
<dmn:text>null</dmn:text>
</dmn:literalExpression>
</dmn:contextEntry>
</dmn:context>
</dmn:decision>
<dmn:decisionService id="_fcf22829-0fd8-4f41-919e-3e909f01fbff" name="days">
<dmn:extensionElements/>
<dmn:variable id="_8ea3497e-8969-4aa6-9a39-254e4e8edea5" name="days" typeRef="Any"/>
<dmn:outputDecision href="#_5b8d18fb-39d8-4f5c-84a0-b79913b7aded"/>
<dmn:encapsulatedDecision href="#_eac3ef9e-37de-4dca-8802-ee08ded9e268"/>
<dmn:inputData href="#_89e85ee4-f052-4977-bee5-a3b81a600c6c"/>
</dmn:decisionService>
<dmndi:DMNDI>
<dmndi:DMNDiagram>
<dmndi:DMNDiagram id="_AECB8363-7383-4A5B-8658-E9E975C387B1" name="DRG" useAlternativeInputDataShape="false">
<di:extension>
<kie:ComponentsWidthsExtension>
<kie:ComponentWidths dmnElementRef="_c7a83474-a6bc-49c6-8296-4428c9285f4d"/>
<kie:ComponentWidths dmnElementRef="_d1950d38-3f02-4339-af1b-aaeeed847baa"/>
<kie:ComponentWidths dmnElementRef="_590f5f1d-bc73-43e4-8b87-1b18ee5b5d8d"/>
<kie:ComponentWidths dmnElementRef="_02d83b5e-33ff-4075-8edc-de24f4c5bd57"/>
<kie:ComponentWidths dmnElementRef="_5ec20766-f390-4a66-b146-8f6c2239ceb5"/>
<kie:ComponentWidths dmnElementRef="_3db60313-218f-4384-b34c-8188afb3d0a8"/>
<kie:ComponentWidths dmnElementRef="_c7a83474-a6bc-49c6-8296-4428c9285f4d" />
<kie:ComponentWidths dmnElementRef="_d1950d38-3f02-4339-af1b-aaeeed847baa" />
<kie:ComponentWidths dmnElementRef="_590f5f1d-bc73-43e4-8b87-1b18ee5b5d8d" />
<kie:ComponentWidths dmnElementRef="_02d83b5e-33ff-4075-8edc-de24f4c5bd57" />
<kie:ComponentWidths dmnElementRef="_5ec20766-f390-4a66-b146-8f6c2239ceb5" />
<kie:ComponentWidths dmnElementRef="_3db60313-218f-4384-b34c-8188afb3d0a8" />
</kie:ComponentsWidthsExtension>
</di:extension>
<dmndi:DMNShape xmlns:p0="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnshape-_89e85ee4-f052-4977-bee5-a3b81a600c6c" dmnElementRef="p0:_89e85ee4-f052-4977-bee5-a3b81a600c6c" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
<dmndi:DMNShape id="dmnshape-drg-_fcf22829-0fd8-4f41-919e-3e909f01fbff" dmnElementRef="_fcf22829-0fd8-4f41-919e-3e909f01fbff" isCollapsed="false">
<dmndi:DMNStyle id="_1615772D-BF70-4FD2-8E00-ABDFB5520DF0">
<dmndi:FillColor red="255" green="255" blue="255" />
<dmndi:StrokeColor red="0" green="0" blue="0" />
<dmndi:FontColor red="0" green="0" blue="0" />
</dmndi:DMNStyle>
<dc:Bounds x="260" y="320.99999618530273" width="135.48234176635742" height="60.00000762939453"/>
<dmndi:DMNLabel/>
<dc:Bounds x="100.5" y="1" width="564.7411708831787" height="424" />
<dmndi:DMNLabel id="_0B4FAF7F-CBB9-47FC-8A9D-067ECD97D5F8" />
<dmndi:DMNDecisionServiceDividerLine id="_C4D74B54-387B-49E5-9310-AE8BF93BAE36">
<di:waypoint x="100.5" y="171" />
<di:waypoint x="665.2411708831787" y="171" />
</dmndi:DMNDecisionServiceDividerLine>
</dmndi:DMNShape>
<dmndi:DMNShape xmlns:p1="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnshape-_eac3ef9e-37de-4dca-8802-ee08ded9e268" dmnElementRef="p1:_eac3ef9e-37de-4dca-8802-ee08ded9e268" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
<dmndi:DMNShape id="dmnshape-drg-_89e85ee4-f052-4977-bee5-a3b81a600c6c" dmnElementRef="_89e85ee4-f052-4977-bee5-a3b81a600c6c" isCollapsed="false">
<dmndi:DMNStyle id="_455271AC-859E-4582-B134-657B6391A302">
<dmndi:FillColor red="255" green="255" blue="255" />
<dmndi:StrokeColor red="0" green="0" blue="0" />
<dmndi:FontColor red="0" green="0" blue="0" />
</dmndi:DMNStyle>
<dc:Bounds x="951.7411708831787" y="348" width="153" height="60"/>
<dmndi:DMNLabel/>
<dc:Bounds x="220" y="480" width="135.48234176635742" height="60.00000762939453" />
<dmndi:DMNLabel id="_B38C1A39-EC33-4F60-A25C-3B03F62D9B17" />
</dmndi:DMNShape>
<dmndi:DMNShape xmlns:p2="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnshape-_5b8d18fb-39d8-4f5c-84a0-b79913b7aded" dmnElementRef="p2:_5b8d18fb-39d8-4f5c-84a0-b79913b7aded" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
<dmndi:DMNShape id="dmnshape-drg-_eac3ef9e-37de-4dca-8802-ee08ded9e268" dmnElementRef="_eac3ef9e-37de-4dca-8802-ee08ded9e268" isCollapsed="false">
<dmndi:DMNStyle id="_6F86C913-14B3-4831-8678-31142148FA02">
<dmndi:FillColor red="255" green="255" blue="255" />
<dmndi:StrokeColor red="0" green="0" blue="0" />
<dmndi:FontColor red="0" green="0" blue="0" />
</dmndi:DMNStyle>
<dc:Bounds x="828.7411708831787" y="228" width="153" height="60"/>
<dmndi:DMNLabel/>
<dc:Bounds x="400" y="40" width="153" height="60" />
<dmndi:DMNLabel id="_6A0E8EFC-F1E6-4637-9EE8-CB28097030FD" />
</dmndi:DMNShape>
<dmndi:DMNShape xmlns:p3="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnshape-_fcf22829-0fd8-4f41-919e-3e909f01fbff" dmnElementRef="p3:_fcf22829-0fd8-4f41-919e-3e909f01fbff" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
<dmndi:DMNShape id="dmnshape-drg-_5b8d18fb-39d8-4f5c-84a0-b79913b7aded" dmnElementRef="_5b8d18fb-39d8-4f5c-84a0-b79913b7aded" isCollapsed="false">
<dmndi:DMNStyle id="_2F0EE76E-4BDC-44EE-8953-0528A37284BF">
<dmndi:FillColor red="255" green="255" blue="255" />
<dmndi:StrokeColor red="0" green="0" blue="0" />
<dmndi:FontColor red="0" green="0" blue="0" />
</dmndi:DMNStyle>
<dc:Bounds x="192.5" y="49" width="367.7411708831787" height="250"/>
<dmndi:DMNLabel/>
<dmndi:DMNDecisionServiceDividerLine>
<di:waypoint x="192.5" y="178"/>
<di:waypoint x="560.2411708831787" y="178"/>
</dmndi:DMNDecisionServiceDividerLine>
<dc:Bounds x="160" y="220" width="153" height="60" />
<dmndi:DMNLabel id="_FA24B2A3-C9B3-4B02-9AA2-C70F0848C62C" />
</dmndi:DMNShape>
<dmndi:DMNEdge xmlns:p4="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnedge-_5e303927-d1c9-403c-a1b2-2af72044737d" dmnElementRef="p4:_5e303927-d1c9-403c-a1b2-2af72044737d">
<di:waypoint x="396.2379722595215" y="350.99999618530273"/>
<di:waypoint x="1028.2411708831787" y="408"/>
<dmndi:DMNEdge id="dmnedge-drg-_5e303927-d1c9-403c-a1b2-2af72044737d" dmnElementRef="_5e303927-d1c9-403c-a1b2-2af72044737d">
<di:waypoint x="356.2379722595215" y="510" />
<di:waypoint x="476.5" y="100" />
</dmndi:DMNEdge>
<dmndi:DMNEdge xmlns:p5="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnedge-_de1a99cb-c0c9-4e58-be9c-dc619e856fa6" dmnElementRef="p5:_de1a99cb-c0c9-4e58-be9c-dc619e856fa6">
<di:waypoint x="1028.2411708831787" y="348"/>
<di:waypoint x="955.2411708831787" y="288"/>
<dmndi:DMNEdge id="dmnedge-drg-_de1a99cb-c0c9-4e58-be9c-dc619e856fa6" dmnElementRef="_de1a99cb-c0c9-4e58-be9c-dc619e856fa6">
<di:waypoint x="476.5" y="40" />
<di:waypoint x="286.5" y="280" />
</dmndi:DMNEdge>
<dmndi:DMNEdge xmlns:p6="http://www.trisotech.com/definitions/_9efe7fc6-f41b-422c-accd-95dcaaa67a39" id="dmnedge-_621c38e6-638b-4907-bbc4-e7daf9d4272d" dmnElementRef="p6:_621c38e6-638b-4907-bbc4-e7daf9d4272d">
<di:waypoint x="327.7379722595215" y="320.99999618530273"/>
<di:waypoint x="905.2411708831787" y="288"/>
<dmndi:DMNEdge id="dmnedge-drg-_621c38e6-638b-4907-bbc4-e7daf9d4272d" dmnElementRef="_621c38e6-638b-4907-bbc4-e7daf9d4272d">
<di:waypoint x="287.7379722595215" y="480" />
<di:waypoint x="236.5" y="280" />
</dmndi:DMNEdge>
</dmndi:DMNDiagram>
</dmndi:DMNDI>
</dmn:definitions>
</dmn:definitions>
Loading