From 7d60e03a0217663a9d30873b3c0fac1fb3070efd Mon Sep 17 00:00:00 2001 From: Lyn Elisa Goltz Date: Mon, 11 Mar 2024 10:41:14 +0100 Subject: [PATCH] #9590 (#181) - handle types in xpath to find properties; added support of GenericFeature --- .../sql/mapper/AppSchemaMapper.java | 6 +- .../persistence/sql/mapper/CycleAnalyser.java | 30 ++-- .../sql/mapper/GmlReferenceData.java | 111 +++++++++------ .../persistence/sql/mapper/PathStep.java | 77 +++++++++++ .../persistence/sql/mapper/ReferenceData.java | 6 +- .../sql/mapper/AppSchemaMapperTest.java | 91 +++++++------ .../sql/mapper/GmlReferenceDataTest.java | 128 ++++++++++-------- .../mapper/data/Inspire-MineralResources.xml | 92 +++++++++++++ 8 files changed, 385 insertions(+), 156 deletions(-) create mode 100644 deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/PathStep.java create mode 100644 deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/resources/org/deegree/feature/persistence/sql/mapper/data/Inspire-MineralResources.xml diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java index d3adef1de3..5de90d6a0f 100644 --- a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java @@ -967,7 +967,7 @@ private List generateMapping(XSWildcard wildCard, int occurrence, Mappi private boolean referenceDataHasProperty(CycleAnalyser cycleAnalyser) { if (referenceData == null || !useRefDataProps) return true; - List xpath = cycleAnalyser.getPath(); + List xpath = cycleAnalyser.getPath(); QName featureTypeName = cycleAnalyser.getFeatureTypeName(); return referenceData.hasProperty(featureTypeName, xpath); } @@ -975,7 +975,7 @@ private boolean referenceDataHasProperty(CycleAnalyser cycleAnalyser) { private boolean referenceDataPropertyIsNil(CycleAnalyser cycleAnalyser) { if (referenceData == null || !useRefDataProps) return false; - List xpath = cycleAnalyser.getPath(); + List xpath = cycleAnalyser.getPath(); QName featureTypeName = cycleAnalyser.getFeatureTypeName(); return referenceData.isPropertyNilled(featureTypeName, xpath); } @@ -983,7 +983,7 @@ private boolean referenceDataPropertyIsNil(CycleAnalyser cycleAnalyser) { private boolean referenceDataHasOnlyOne(CycleAnalyser cycleAnalyser) { if (referenceData == null) return false; - List xpath = cycleAnalyser.getPath(); + List xpath = cycleAnalyser.getPath(); QName featureTypeName = cycleAnalyser.getFeatureTypeName(); return referenceData.hasZeroOrOneProperty(featureTypeName, xpath); } diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/CycleAnalyser.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/CycleAnalyser.java index a78aa45d3a..b640cead81 100644 --- a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/CycleAnalyser.java +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/CycleAnalyser.java @@ -20,7 +20,7 @@ public class CycleAnalyser { private static final Logger LOG = LoggerFactory.getLogger(CycleAnalyser.class); - private final List path = new ArrayList<>(); + private final List path = new ArrayList<>(); private final List parentEls = new ArrayList<>(); @@ -67,7 +67,7 @@ public boolean checkStopAtCycle(XSComplexTypeDefinition typeDef) { * @param pt never null */ public void start(PropertyType pt) { - path.add(pt.getName()); + path.add(new PathStep(pt.getName())); } /** @@ -87,7 +87,7 @@ public void add(XSComplexTypeDefinition typeDef) { if (typeDef.getAnonymous()) return; parentCTs.add(typeDef); - path.add(getQName(typeDef)); + path.add(new PathStep(getQName(typeDef), true)); } /** @@ -96,7 +96,7 @@ public void add(XSComplexTypeDefinition typeDef) { */ public void add(XSElementDeclaration elDecl) { parentEls.add(elDecl); - path.add(getQName(elDecl)); + path.add(new PathStep(getQName(elDecl))); } /** @@ -143,21 +143,22 @@ public QName getFeatureTypeName() { /** * @return the current path. May be empty but never null */ - public List getPath() { + public List getPath() { return path; } private void log() { StringBuffer sb = new StringBuffer(); Map nameToCycleDepth = new HashMap<>(); - for (QName step : path) { + for (PathStep pathStep : path) { + QName stepName = pathStep.getName(); sb.append("\n -> "); - if (nameToCycleDepth.containsKey(step)) - nameToCycleDepth.put(step, (nameToCycleDepth.get(step) + 1)); + if (nameToCycleDepth.containsKey(stepName)) + nameToCycleDepth.put(stepName, (nameToCycleDepth.get(stepName) + 1)); else - nameToCycleDepth.put(step, 0); - sb.append(step); - sb.append(" (cycle depth: ").append(nameToCycleDepth.get(step)).append(")"); + nameToCycleDepth.put(stepName, 0); + sb.append(stepName); + sb.append(" (cycle depth: ").append(nameToCycleDepth.get(stepName)).append(")"); } LOG.info("Current path:" + sb.toString()); } @@ -191,11 +192,16 @@ private boolean stop(QName qname) { } private long currentCycleDepth(QName qname) { - return this.path.stream().filter(e -> qname.equals(e)).count(); + return this.path.stream().filter(e -> qname.equals(e.getName())).count(); } private boolean isLast(List list, T entry) { return list.lastIndexOf(entry) == list.size() - 1; } + private boolean isLast(List list, QName entry) { + PathStep last = list.get(list.size() - 1); + return entry.equals(last.getName()); + } + } \ No newline at end of file diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceData.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceData.java index f929d75ed2..e2c4a009f1 100644 --- a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceData.java +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceData.java @@ -7,6 +7,7 @@ import org.deegree.cs.exceptions.UnknownCRSException; import org.deegree.feature.Feature; import org.deegree.feature.FeatureCollection; +import org.deegree.feature.GenericFeature; import org.deegree.gml.GMLInputFactory; import org.deegree.gml.GMLStreamReader; import org.deegree.gml.GMLVersion; @@ -16,6 +17,7 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -38,7 +40,7 @@ public GmlReferenceData(URL referenceData) throws IOException, XMLStreamExceptio } @Override - public boolean hasProperty(QName featureTypeName, List xpath) { + public boolean hasProperty(QName featureTypeName, List xpath) { List featuresOfType = this.features.get(featureTypeName); if (featuresOfType != null && !featuresOfType.isEmpty()) { for (Feature feature : featuresOfType) { @@ -50,7 +52,7 @@ public boolean hasProperty(QName featureTypeName, List xpath) { } @Override - public boolean isPropertyNilled(QName featureTypeName, List xpath) { + public boolean isPropertyNilled(QName featureTypeName, List xpath) { List featuresOfType = this.features.get(featureTypeName); if (featuresOfType != null && !featuresOfType.isEmpty()) { for (Feature feature : featuresOfType) { @@ -62,7 +64,7 @@ public boolean isPropertyNilled(QName featureTypeName, List xpath) { } @Override - public boolean hasZeroOrOneProperty(QName featureTypeName, List xpath) { + public boolean hasZeroOrOneProperty(QName featureTypeName, List xpath) { List featuresOfType = this.features.get(featureTypeName); if (featuresOfType != null && !featuresOfType.isEmpty()) { for (Feature feature : featuresOfType) { @@ -79,26 +81,26 @@ public boolean shouldFeatureTypeMapped(QName featureTypeName) { return features.containsKey(featureTypeName); } - private boolean hasProperty(Feature feature, List xpath) { + private boolean hasProperty(Feature feature, List xpath) { if (xpath.isEmpty()) return true; - Iterator iterator = xpath.iterator(); - QName firstProperty = iterator.next(); - List properties = feature.getProperties(firstProperty); + Iterator iterator = xpath.iterator(); + PathStep firstProperty = getNext(iterator); + List properties = feature.getProperties(firstProperty.getName()); return hasProperty(iterator, properties); } - private boolean hasProperty(Iterator iterator, List properties) { - if (!iterator.hasNext()) { + private boolean hasProperty(Iterator iterator, List properties) { + PathStep next = getNext(iterator); + if (next == null) { if (properties.size() >= 1) return true; else return false; } else { - QName next = iterator.next(); - for (ElementNode property : properties) { - List subProperties = getChildsByName(property, next); + for (TypedObjectNode property : properties) { + List subProperties = getChildsByName(property, next); if (hasProperty(iterator, subProperties)) return true; } @@ -106,27 +108,28 @@ private boolean hasProperty(Iterator iterator, Li } } - private boolean hasNilledPropertyOrIsMissing(Feature feature, List xpath) { + private boolean hasNilledPropertyOrIsMissing(Feature feature, List xpath) { if (xpath.isEmpty()) { return true; } - Iterator iterator = xpath.iterator(); - QName firstProperty = iterator.next(); - List properties = feature.getProperties(firstProperty); + Iterator iterator = xpath.iterator(); + PathStep firstProperty = getNext(iterator); + List properties = feature.getProperties(firstProperty.getName()); return hasNilledPropertyOrIsMissing(iterator, properties); } - private boolean hasNilledPropertyOrIsMissing(Iterator iterator, List properties) { - if (iterator.hasNext()) { - QName next = iterator.next(); - for (ElementNode property : properties) { - List subProperties = getChildsByName(property, next); + private boolean hasNilledPropertyOrIsMissing(Iterator iterator, + List properties) { + PathStep next = getNext(iterator); + if (next != null) { + for (TypedObjectNode property : properties) { + List subProperties = getChildsByName(property, next); if (hasNilledPropertyOrIsMissing(iterator, subProperties)) return true; } } else if (!properties.isEmpty()) { - for (ElementNode property : properties) { + for (TypedObjectNode property : properties) { if (!isNilTrue(property)) return false; } @@ -135,34 +138,36 @@ else if (!properties.isEmpty()) { return false; } - private boolean isNilTrue(ElementNode property) { - Map attributes = property.getAttributes(); + private boolean isNilTrue(TypedObjectNode property) { + if (!(property instanceof ElementNode)) + return false; + Map attributes = ((ElementNode) property).getAttributes(); PrimitiveValue nil = attributes.get(new QName(XSINS, "nil", XSI_PREFIX)); if (nil == null) return false; return Boolean.parseBoolean(nil.getAsText()); } - private boolean hasMoreThanOne(Feature feature, List xpath) { + private boolean hasMoreThanOne(Feature feature, List xpath) { if (xpath.isEmpty()) return true; - Iterator iterator = xpath.iterator(); - QName firstProperty = iterator.next(); - List properties = feature.getProperties(firstProperty); + Iterator iterator = xpath.iterator(); + PathStep firstProperty = getNext(iterator); + List properties = feature.getProperties(firstProperty.getName()); return hasMoreThanOne(iterator, properties); } - private boolean hasMoreThanOne(Iterator iterator, List properties) { - if (!iterator.hasNext()) { + private boolean hasMoreThanOne(Iterator iterator, List properties) { + PathStep next = getNext(iterator); + if (next == null) { if (properties.size() > 1) return true; else return false; } else { - QName next = iterator.next(); - for (ElementNode property : properties) { - List subProperties = getChildsByName(property, next); + for (TypedObjectNode property : properties) { + List subProperties = getChildsByName(property, next); if (hasMoreThanOne(iterator, subProperties)) return true; } @@ -170,17 +175,45 @@ private boolean hasMoreThanOne(Iterator iterator, } } - private List getChildsByName(ElementNode property, QName propertyName) { - List properties = new ArrayList<>(); - List children = property.getChildren(); - for (TypedObjectNode child : children) { + private List getChildsByName(TypedObjectNode property, PathStep pathStep) { + if (property instanceof ElementNode) + return getChildsByName((ElementNode) property, pathStep); + if (property instanceof GenericFeature) + return getChildsByName((GenericFeature) property, pathStep); + return Collections.emptyList(); + } + + private List getChildsByName(ElementNode property, PathStep pathStep) { + List properties = new ArrayList<>(); + for (TypedObjectNode child : property.getChildren()) { if (child instanceof ElementNode) { QName name = ((ElementNode) child).getName(); - if (name.equals(propertyName)) - properties.add((ElementNode) child); + if (name.equals(pathStep.getName())) + properties.add(child); + } + else if (child instanceof GenericFeature) { + QName name = ((GenericFeature) child).getName(); + if (name.equals(pathStep.getName())) + properties.add(child); } } return properties; } + private List getChildsByName(GenericFeature property, PathStep pathStep) { + return property.getProperties(pathStep.getName()) + .stream() + .map(prop -> (TypedObjectNode) prop) + .collect(Collectors.toList()); + } + + private PathStep getNext(Iterator iterator) { + while (iterator.hasNext()) { + PathStep next = iterator.next(); + if (!next.isTypeDefinition()) + return next; + } + return null; + } + } diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/PathStep.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/PathStep.java new file mode 100644 index 0000000000..7bbbc4e709 --- /dev/null +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/PathStep.java @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------- + This file is part of deegree + Copyright (C) 2001-2024 by: + - Department of Geography, University of Bonn - + and + - lat/lon GmbH - + and others + + This library is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free + Software Foundation; either version 2.1 of the License, or (at your option) + any later version. + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact information: + + e-mail: info@deegree.org + website: http://www.deegree.org/ +----------------------------------------------------------------------------*/ +package org.deegree.feature.persistence.sql.mapper; + +import javax.xml.namespace.QName; +import java.util.Objects; + +/** + * @author Lyn Goltz + */ +class PathStep { + + private final QName name; + + private boolean isTypeDefinition = false; + + public PathStep(QName name) { + this.name = name; + } + + public PathStep(QName name, boolean isTypeDefinition) { + this.name = name; + this.isTypeDefinition = isTypeDefinition; + } + + public boolean isTypeDefinition() { + return isTypeDefinition; + } + + public QName getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + PathStep pathStep = (PathStep) o; + return Objects.equals(name, pathStep.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return name.toString(); + } + +} \ No newline at end of file diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/ReferenceData.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/ReferenceData.java index 61a085eb12..8d4ad0a723 100644 --- a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/ReferenceData.java +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/ReferenceData.java @@ -15,7 +15,7 @@ public interface ReferenceData { * @return true if the property identified by the path occurs at least * one time, false otherwise */ - boolean hasProperty(QName featureTypeName, List xpath); + boolean hasProperty(QName featureTypeName, List xpath); /** * @param featureTypeName the name of the feature type, never null @@ -24,7 +24,7 @@ public interface ReferenceData { * @return true if the property identified by the path occurs at least * one time has AND is nilled and contains no value, false otherwise */ - boolean isPropertyNilled(QName featureTypeName, List xpath); + boolean isPropertyNilled(QName featureTypeName, List xpath); /** * @param featureTypeName the name of the feature type, never null @@ -33,7 +33,7 @@ public interface ReferenceData { * @return true if the property identified by the path occurs one or zero * times, false otherwise */ - boolean hasZeroOrOneProperty(QName featureTypeName, List xpath); + boolean hasZeroOrOneProperty(QName featureTypeName, List xpath); /** * @param featureTypeName the name of the feature type, never null diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapperTest.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapperTest.java index 97e0f48636..1a998c0d13 100644 --- a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapperTest.java +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/AppSchemaMapperTest.java @@ -22,9 +22,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static org.deegree.feature.types.property.GeometryPropertyType.CoordinateDimension.DIM_2; import static org.hamcrest.CoreMatchers.is; @@ -490,9 +491,9 @@ public void testWithReferenceData() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeName)).thenReturn(true); QName propA1 = new QName("http://test.de/schema", "prop_A1", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propA1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propA1))).thenReturn(false); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propA3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propA3))).thenReturn(true); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); GeometryStorageParams geometryParams = new GeometryStorageParams(storageCrs, "0", DIM_2); @@ -521,19 +522,18 @@ public void testWithReferenceData_ComplexData_ComplexN() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeName)).thenReturn(true); QName propA1 = new QName("http://test.de/schema", "prop_A1", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propA1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propA1))).thenReturn(false); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propA3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propA3))).thenReturn(true); QName propComplexA4 = new QName("http://test.de/schema", "complex_A4", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propComplexA4))) - .thenReturn(false); - List complexA4_1 = new ArrayList<>(); - complexA4_1.add(new QName("http://test.de/schema", "complex_A4", "te")); - complexA4_1.add(new QName("http://test.de/schema", "prop_A4_1", "te")); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propComplexA4))).thenReturn(false); + List complexA4_1 = new ArrayList<>(); + complexA4_1.add(asPathStep("http://test.de/schema", "complex_A4", "te")); + complexA4_1.add(asPathStep("http://test.de/schema", "prop_A4_1", "te")); when(referenceData.hasZeroOrOneProperty(featureTypeName, complexA4_1)).thenReturn(false); - List complexA4_2 = new ArrayList<>(); - complexA4_2.add(new QName("http://test.de/schema", "complex_A4", "te")); - complexA4_2.add(new QName("http://test.de/schema", "prop_A4_3", "te")); + List complexA4_2 = new ArrayList<>(); + complexA4_2.add(asPathStep("http://test.de/schema", "complex_A4", "te")); + complexA4_2.add(asPathStep("http://test.de/schema", "prop_A4_3", "te")); when(referenceData.hasZeroOrOneProperty(featureTypeName, complexA4_2)).thenReturn(true); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); @@ -569,19 +569,18 @@ public void testWithReferenceData_ComplexData_Complex1() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeName)).thenReturn(true); QName propA1 = new QName("http://test.de/schema", "prop_A1", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propA1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propA1))).thenReturn(false); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propA3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propA3))).thenReturn(true); QName propComplexA4 = new QName("http://test.de/schema", "complex_A4", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeName, Collections.singletonList(propComplexA4))) - .thenReturn(true); - List complexA4_1 = new ArrayList<>(); - complexA4_1.add(new QName("http://test.de/schema", "complex_A4", "te")); - complexA4_1.add(new QName("http://test.de/schema", "prop_A4_1", "te")); + when(referenceData.hasZeroOrOneProperty(featureTypeName, asPathStep(propComplexA4))).thenReturn(true); + List complexA4_1 = new ArrayList<>(); + complexA4_1.add(asPathStep("http://test.de/schema", "complex_A4", "te")); + complexA4_1.add(asPathStep("http://test.de/schema", "prop_A4_1", "te")); when(referenceData.hasZeroOrOneProperty(featureTypeName, complexA4_1)).thenReturn(false); - List complexA4_2 = new ArrayList<>(); - complexA4_2.add(new QName("http://test.de/schema", "complex_A4", "te")); - complexA4_2.add(new QName("http://test.de/schema", "prop_A4_3", "te")); + List complexA4_2 = new ArrayList<>(); + complexA4_2.add(asPathStep("http://test.de/schema", "complex_A4", "te")); + complexA4_2.add(asPathStep("http://test.de/schema", "prop_A4_3", "te")); when(referenceData.hasZeroOrOneProperty(featureTypeName, complexA4_2)).thenReturn(true); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); @@ -617,19 +616,18 @@ public void testWithReferenceData_ReferencedFeature_RefN() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeNameB)).thenReturn(true); QName propB1 = new QName("http://test.de/schema", "prop_B1", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameB, Collections.singletonList(propB1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeNameB, asPathStep(propB1))).thenReturn(false); QName propB3 = new QName("http://test.de/schema", "prop_B3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameB, Collections.singletonList(propB3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeNameB, asPathStep(propB3))).thenReturn(true); QName propFfeatureA = new QName("http://test.de/schema", "featureA", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameB, Collections.singletonList(propFfeatureA))) - .thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeNameB, asPathStep(propFfeatureA))).thenReturn(false); QName featureTypeNameA = new QName("http://test.de/schema", "FeatureA", "te"); QName propA1 = new QName("http://test.de/schema", "prop_A1", "te"); when(referenceData.shouldFeatureTypeMapped(featureTypeNameA)).thenReturn(true); - when(referenceData.hasZeroOrOneProperty(featureTypeNameA, Collections.singletonList(propA1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeNameA, asPathStep(propA1))).thenReturn(false); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameA, Collections.singletonList(propA3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeNameA, asPathStep(propA3))).thenReturn(true); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); GeometryStorageParams geometryParams = new GeometryStorageParams(storageCrs, "0", DIM_2); @@ -666,19 +664,18 @@ public void testWithReferenceData_ReferencedFeature_Ref1() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeNameB)).thenReturn(true); QName propB1 = new QName("http://test.de/schema", "prop_B1", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameB, Collections.singletonList(propB1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeNameB, asPathStep(propB1))).thenReturn(false); QName propB3 = new QName("http://test.de/schema", "prop_B3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameB, Collections.singletonList(propB3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeNameB, asPathStep(propB3))).thenReturn(true); QName propFfeatureA = new QName("http://test.de/schema", "featureA", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameB, Collections.singletonList(propFfeatureA))) - .thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeNameB, asPathStep(propFfeatureA))).thenReturn(true); QName featureTypeNameA = new QName("http://test.de/schema", "FeatureA", "te"); when(referenceData.shouldFeatureTypeMapped(featureTypeNameA)).thenReturn(true); QName propA1 = new QName("http://test.de/schema", "prop_A1", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameA, Collections.singletonList(propA1))).thenReturn(false); + when(referenceData.hasZeroOrOneProperty(featureTypeNameA, asPathStep(propA1))).thenReturn(false); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasZeroOrOneProperty(featureTypeNameA, Collections.singletonList(propA3))).thenReturn(true); + when(referenceData.hasZeroOrOneProperty(featureTypeNameA, asPathStep(propA3))).thenReturn(true); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); GeometryStorageParams geometryParams = new GeometryStorageParams(storageCrs, "0", DIM_2); @@ -715,9 +712,9 @@ public void testWithReferenceDataAndConsiderProperties() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeName)).thenReturn(true); QName propA1 = new QName("http://test.de/schema", "prop_A1", "te"); - when(referenceData.hasProperty(featureTypeName, Collections.singletonList(propA1))).thenReturn(false); + when(referenceData.hasProperty(featureTypeName, asPathStep(propA1))).thenReturn(false); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasProperty(featureTypeName, Collections.singletonList(propA3))).thenReturn(false); + when(referenceData.hasProperty(featureTypeName, asPathStep(propA3))).thenReturn(false); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); GeometryStorageParams geometryParams = new GeometryStorageParams(storageCrs, "0", DIM_2); @@ -746,11 +743,11 @@ public void testWithReferenceDataAndNilProperties() throws Exception { ReferenceData referenceData = mock(ReferenceData.class); when(referenceData.shouldFeatureTypeMapped(featureTypeName)).thenReturn(true); QName propA3 = new QName("http://test.de/schema", "prop_A3", "te"); - when(referenceData.hasProperty(featureTypeName, Collections.singletonList(propA3))).thenReturn(true); - when(referenceData.isPropertyNilled(featureTypeName, Collections.singletonList(propA3))).thenReturn(true); + when(referenceData.hasProperty(featureTypeName, asPathStep(propA3))).thenReturn(true); + when(referenceData.isPropertyNilled(featureTypeName, asPathStep(propA3))).thenReturn(true); QName propA4 = new QName("http://test.de/schema", "complex_A4", "te"); - when(referenceData.hasProperty(featureTypeName, Collections.singletonList(propA4))).thenReturn(true); - when(referenceData.isPropertyNilled(featureTypeName, Collections.singletonList(propA4))).thenReturn(true); + when(referenceData.hasProperty(featureTypeName, asPathStep(propA4))).thenReturn(true); + when(referenceData.isPropertyNilled(featureTypeName, asPathStep(propA4))).thenReturn(true); CRSRef storageCrs = CRSManager.getCRSRef("EPSG:4326"); GeometryStorageParams geometryParams = new GeometryStorageParams(storageCrs, "0", DIM_2); @@ -857,9 +854,19 @@ private PrimitiveMapping getPrimitive(List mappings, String name) { private File copyToTmpFolder(String resourceName) throws IOException { InputStream resource = AppSchemaMapperTest.class.getResourceAsStream(resourceName); - File schema = folder.newFile(resourceName); + String fileName = resourceName.contains("/") ? resourceName.substring(resourceName.indexOf("/") + 1) + : resourceName; + File schema = folder.newFile(fileName); IOUtils.copy(resource, new FileOutputStream(schema)); return schema; } + private PathStep asPathStep(String namespaceUrl, String localPart, String prefix) { + return new PathStep(new QName(namespaceUrl, localPart, prefix)); + } + + private List asPathStep(QName... name) { + return Arrays.stream(name).map(qName -> new PathStep(qName)).collect(Collectors.toList()); + } + } diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceDataTest.java b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceDataTest.java index 75036c73c0..0a94d05d21 100644 --- a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceDataTest.java +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceDataTest.java @@ -5,10 +5,10 @@ import javax.xml.namespace.QName; import java.net.URL; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; -import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -40,8 +40,7 @@ public void test_NoSample() throws Exception { URL resource = getClass().getResource("data/sampleValues_simple_1.xml"); GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); - boolean hasMaxOne1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, - Collections.singletonList(PROP_B1_NAME)); + boolean hasMaxOne1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, asPathStep(PROP_B1_NAME)); assertThat(hasMaxOne1, is(false)); } @@ -50,8 +49,7 @@ public void test_NoProperty() throws Exception { URL resource = getClass().getResource("data/sampleValues_simple_1.xml"); GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); - boolean hasMaxOne2 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A3_NAME)); + boolean hasMaxOne2 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A3_NAME)); assertThat(hasMaxOne2, is(true)); } @@ -60,12 +58,10 @@ public void test_Simple_1() throws Exception { URL resource = getClass().getResource("data/sampleValues_simple_1.xml"); GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); - boolean hasMaxOne1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A1_NAME)); + boolean hasMaxOne1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A1_NAME)); assertThat(hasMaxOne1, is(true)); - boolean hasMaxOne3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A3_NAME)); + boolean hasMaxOne3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A3_NAME)); assertThat(hasMaxOne3, is(true)); } @@ -74,12 +70,10 @@ public void test_Simple_N() throws Exception { URL resource = getClass().getResource("data/sampleValues_simple_N.xml"); GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); - boolean hasMaxOne1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A1_NAME)); + boolean hasMaxOne1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A1_NAME)); assertThat(hasMaxOne1, is(false)); - boolean hasMaxOne3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A3_NAME)); + boolean hasMaxOne3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A3_NAME)); assertThat(hasMaxOne3, is(false)); } @@ -89,15 +83,15 @@ public void test_Complex_1() throws Exception { GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); boolean hasMaxOneB1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_COMPLEX_A4_NAME)); + asPathStep(PROP_COMPLEX_A4_NAME)); assertThat(hasMaxOneB1, is(true)); boolean hasMaxOneA4_1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - asList(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_1_NAME)); + asPathStep(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_1_NAME)); assertThat(hasMaxOneA4_1, is(true)); boolean hasMaxOneA4_3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - asList(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_3_NAME)); + asPathStep(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_3_NAME)); assertThat(hasMaxOneA4_3, is(true)); } @@ -107,15 +101,15 @@ public void test_Complex_N() throws Exception { GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); boolean hasMaxOneB1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_COMPLEX_A4_NAME)); + asPathStep(PROP_COMPLEX_A4_NAME)); assertThat(hasMaxOneB1, is(false)); boolean hasMaxOneA4_1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - asList(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_1_NAME)); + asPathStep(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_1_NAME)); assertThat(hasMaxOneA4_1, is(false)); boolean hasMaxOneA4_3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - asList(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_3_NAME)); + asPathStep(PROP_COMPLEX_A4_NAME, PROP_COMPLEX_A4_3_NAME)); assertThat(hasMaxOneA4_3, is(true)); } @@ -124,20 +118,16 @@ public void test_Reference_1() throws Exception { URL resource = getClass().getResource("data/sampleValues_reference_1.xml"); GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); - boolean hasMaxOneB1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, - Collections.singletonList(PROP_B1_NAME)); + boolean hasMaxOneB1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, asPathStep(PROP_B1_NAME)); assertThat(hasMaxOneB1, is(false)); - boolean hasMaxOneB3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, - Collections.singletonList(PROP_B3_NAME)); + boolean hasMaxOneB3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, asPathStep(PROP_B3_NAME)); assertThat(hasMaxOneB3, is(false)); - boolean hasMaxOneA1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A1_NAME)); + boolean hasMaxOneA1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A1_NAME)); assertThat(hasMaxOneA1, is(false)); - boolean hasMaxOneA3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A3_NAME)); + boolean hasMaxOneA3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A3_NAME)); assertThat(hasMaxOneA3, is(false)); } @@ -146,20 +136,16 @@ public void test_Reference_N() throws Exception { URL resource = getClass().getResource("data/sampleValues_reference_N.xml"); GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); - boolean hasMaxOneB1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, - Collections.singletonList(PROP_B1_NAME)); + boolean hasMaxOneB1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, asPathStep(PROP_B1_NAME)); assertThat(hasMaxOneB1, is(false)); - boolean hasMaxOneB3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, - Collections.singletonList(PROP_B3_NAME)); + boolean hasMaxOneB3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_B_NAME, asPathStep(PROP_B3_NAME)); assertThat(hasMaxOneB3, is(false)); - boolean hasMaxOneA1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A1_NAME)); + boolean hasMaxOneA1 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A1_NAME)); assertThat(hasMaxOneA1, is(false)); - boolean hasMaxOneA3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, - Collections.singletonList(PROP_A3_NAME)); + boolean hasMaxOneA3 = gmlReferenceData.hasZeroOrOneProperty(FEATURETYPE_A_NAME, asPathStep(PROP_A3_NAME)); assertThat(hasMaxOneA3, is(false)); } @@ -171,13 +157,12 @@ public void test_Inspire() throws Exception { QName AdressFeatureTypeName = new QName("http://inspire.ec.europa.eu/schemas/ad/4.0", "Address", "ad"); QName position = new QName("http://test.de/schema", "position", "te"); - List posSpec = new ArrayList<>(); - posSpec.add(position); - posSpec.add(new QName("http://test.de/schema", "GeographicPosition", "te")); - posSpec.add(new QName("http://test.de/schema", "specification", "te")); + List posSpec = new ArrayList<>(); + posSpec.add(new PathStep(position)); + posSpec.add(new PathStep(new QName("http://test.de/schema", "GeographicPosition", "te"))); + posSpec.add(new PathStep(new QName("http://test.de/schema", "specification", "te"))); - boolean hasMaxOnePosition = gmlReferenceData.hasZeroOrOneProperty(AdressFeatureTypeName, - Collections.singletonList(position)); + boolean hasMaxOnePosition = gmlReferenceData.hasZeroOrOneProperty(AdressFeatureTypeName, asPathStep(position)); assertThat(hasMaxOnePosition, is(true)); boolean hasMaxOnePosSpec = gmlReferenceData.hasZeroOrOneProperty(AdressFeatureTypeName, posSpec); @@ -192,20 +177,19 @@ public void test_Inspire_hasProperty() throws Exception { QName AdressFeatureTypeName = new QName("http://inspire.ec.europa.eu/schemas/ad/4.0", "Address", "ad"); QName inspireId = new QName("http://inspire.ec.europa.eu/schemas/ad/4.0", "inspireId", "ad"); - List posSpec = new ArrayList<>(); - posSpec.add(inspireId); - posSpec.add(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "Identifier", "ad")); - posSpec.add(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "localId", "ad")); + List posSpec = new ArrayList<>(); + posSpec.add(new PathStep(inspireId)); + posSpec.add(new PathStep(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "Identifier", "ad"))); + posSpec.add(new PathStep(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "localId", "ad"))); - boolean hasProperty = gmlReferenceData.hasProperty(AdressFeatureTypeName, Collections.singletonList(inspireId)); + boolean hasProperty = gmlReferenceData.hasProperty(AdressFeatureTypeName, asPathStep(inspireId)); assertThat(hasProperty, is(true)); boolean hasPropertyPosSpec = gmlReferenceData.hasZeroOrOneProperty(AdressFeatureTypeName, posSpec); assertThat(hasPropertyPosSpec, is(true)); QName unknown = new QName("http://test.de/schema", "unknown", "te"); - boolean hasPropertyUnknown = gmlReferenceData.hasProperty(AdressFeatureTypeName, - Collections.singletonList(unknown)); + boolean hasPropertyUnknown = gmlReferenceData.hasProperty(AdressFeatureTypeName, asPathStep(unknown)); assertThat(hasPropertyUnknown, is(false)); } @@ -217,22 +201,52 @@ public void test_Inspire_isPropertyNilled() throws Exception { QName adressFeatureTypeName = new QName("http://inspire.ec.europa.eu/schemas/ad/4.0", "Address", "ad"); QName inspireId = new QName("http://inspire.ec.europa.eu/schemas/ad/4.0", "inspireId", "ad"); - List versionId = new ArrayList<>(); - versionId.add(inspireId); - versionId.add(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "Identifier", "ad")); - versionId.add(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "versionId", "ad")); + List versionId = new ArrayList<>(); + versionId.add(new PathStep(inspireId)); + versionId.add(new PathStep(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "Identifier", "ad"))); + versionId.add(new PathStep(new QName("http://inspire.ec.europa.eu/schemas/base/3.3", "versionId", "ad"))); - boolean propertyIsNilled = gmlReferenceData.isPropertyNilled(adressFeatureTypeName, - Collections.singletonList(inspireId)); + boolean propertyIsNilled = gmlReferenceData.isPropertyNilled(adressFeatureTypeName, asPathStep(inspireId)); assertThat(propertyIsNilled, is(false)); boolean propertyIsNilledVersionId = gmlReferenceData.isPropertyNilled(adressFeatureTypeName, versionId); assertThat(propertyIsNilledVersionId, is(true)); QName status = new QName("http://inspire.ec.europa.eu/schemas/ad/4.0", "status", "ad"); - boolean propertyIsNilledStatus = gmlReferenceData.isPropertyNilled(adressFeatureTypeName, - Collections.singletonList(status)); + boolean propertyIsNilledStatus = gmlReferenceData.isPropertyNilled(adressFeatureTypeName, asPathStep(status)); assertThat(propertyIsNilledStatus, is(true)); } + @Test + public void test_InspireMineralResources_hasProperty() throws Exception { + URL resource = getClass().getResource("data/Inspire-MineralResources.xml"); + GmlReferenceData gmlReferenceData = new GmlReferenceData(resource); + + String mrCoreNs = "http://inspire.ec.europa.eu/schemas/mr-core/4.0"; + String sweNs = "http://www.opengis.net/swe/2.0"; + + QName mineralOccurrenceFeatureTypeName = new QName(mrCoreNs, "MineralOccurrence", "mr-core"); + + List xPath = new ArrayList<>(); + xPath.add(asPathStep(mrCoreNs, "expression", "mr-core", false)); + xPath.add(asPathStep(sweNs, "Category", "swe", false)); + xPath.add(asPathStep(sweNs, "CategoryType", "swe", true)); + xPath.add(asPathStep(sweNs, "constraint", "swe", false)); + xPath.add(asPathStep(sweNs, "AllowedTokensPropertyType", "swe", true)); + xPath.add(asPathStep(sweNs, "AllowedTokens", "swe", false)); + xPath.add(asPathStep(sweNs, "AllowedTokensType", "swe", true)); + xPath.add(asPathStep(sweNs, "value", "swe", false)); + + boolean hasZeroOrOneProperty = gmlReferenceData.hasZeroOrOneProperty(mineralOccurrenceFeatureTypeName, xPath); + assertThat(hasZeroOrOneProperty, is(false)); + } + + private List asPathStep(QName... name) { + return Arrays.stream(name).map(qName -> new PathStep(qName)).collect(Collectors.toList()); + } + + private PathStep asPathStep(String nsUrl, String localPart, String prefix, boolean isTypeDefinition) { + return new PathStep(new QName(nsUrl, localPart, prefix), isTypeDefinition); + } + } \ No newline at end of file diff --git a/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/resources/org/deegree/feature/persistence/sql/mapper/data/Inspire-MineralResources.xml b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/resources/org/deegree/feature/persistence/sql/mapper/data/Inspire-MineralResources.xml new file mode 100644 index 0000000000..1b5abaf289 --- /dev/null +++ b/deegree-datastores/deegree-featurestores/deegree-featurestore-sql/src/test/resources/org/deegree/feature/persistence/sql/mapper/data/Inspire-MineralResources.xml @@ -0,0 +1,92 @@ + + + + + Number: 1 + + https://registry.gdi-de.org/id/test1/MineralOccurrence_1 + + + + MineralOccurrence_1 + https://registry.gdi-de.org/id/test1 + + + Test + + + + + + + + + + 2016-06-19T22:00:00Z + + + + + + https://registry.gdi-de.org/id/test1/DocumentCitation_1 + + Map of the ... + MAP + + + + 2023-01-01 + + + publication + + + + + https://example.org/test.pdf + Karte... + + + + + + + + value1 + value2 + + + value + + + + + + + + + + + + + \ No newline at end of file