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

Metadata: Fix the namespace for FEEL types #687

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
15 changes: 15 additions & 0 deletions dmn-core/src/main/java/com/gs/dmn/QualifiedName.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import com.gs.dmn.ast.TDefinitions;
import com.gs.dmn.ast.TImport;
import com.gs.dmn.ast.TItemDefinition;
import com.gs.dmn.feel.analysis.semantics.type.FEELTypes;
import com.gs.dmn.serialization.DMNVersion;

import javax.xml.namespace.QName;
Expand All @@ -34,6 +36,7 @@ public static QualifiedName toQualifiedName(TDefinitions model, String qName) {
if (qName == null || qName.isEmpty()) {
return null;
}
// Check the FEEL prefix
if (qName.startsWith(DMNVersion.LATEST.getFeelPrefix() + ".")) {
String prefix = DMNVersion.LATEST.getFeelPrefix();
String localPart = qName.substring(qName.indexOf('.') + 1);
Expand All @@ -42,13 +45,25 @@ public static QualifiedName toQualifiedName(TDefinitions model, String qName) {
if (model == null) {
return new QualifiedName(null, qName);
} else {
// Check the imports
for (TImport import_: model.getImport()) {
String importName = import_.getName();
if (qName.startsWith(importName + '.')) {
String localPart = qName.substring(qName.indexOf('.') + 1);
return new QualifiedName(importName, localPart);
}
}
// Check the types defined in the model
for (TItemDefinition itemDefinition: model.getItemDefinition()) {
if (itemDefinition.getName().equals(qName)) {
return new QualifiedName(null, qName);
}
}
// Check the FEEL types
if (FEELTypes.FEEL_TYPE_NAMES.contains(qName)) {
return new QualifiedName(DMNVersion.LATEST.getFeelPrefix(), qName);
}

return new QualifiedName(null, qName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b1"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand All @@ -62,12 +62,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b1"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand All @@ -94,12 +94,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b2"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand Down Expand Up @@ -128,12 +128,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "Any",
"namespace" : "http://www.provider.com/definitions/model-c"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "inputData",
Expand All @@ -145,7 +145,7 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b1"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand All @@ -62,12 +62,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b1"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand All @@ -94,12 +94,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b2"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand Down Expand Up @@ -128,12 +128,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "Any",
"namespace" : "http://www.provider.com/definitions/model-c"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "inputData",
Expand All @@ -145,7 +145,7 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b1"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand All @@ -62,12 +62,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b1"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand All @@ -94,12 +94,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-b2"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "decision",
Expand Down Expand Up @@ -128,12 +128,12 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ],
"typeRef" : {
"localName" : "Any",
"namespace" : "http://www.provider.com/definitions/model-c"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
}, {
"@kind" : "inputData",
Expand All @@ -145,7 +145,7 @@
"namespace" : "http://www.provider.com/definitions/model-a",
"typeRef" : {
"localName" : "string",
"namespace" : "http://www.provider.com/definitions/model-a"
"namespace" : "http://www.omg.org/spec/FEEL/20140401"
}
} ]
}
Loading
Loading