Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,9 @@ private Optional<FeatureSchema> lookupChild(
String wireUri = wireNamespaceUri == null ? "" : wireNamespaceUri;
for (FeatureSchema p : parent.getProperties()) {
String key = propertyKey(p, useAlias);
if (!wireLocalName.equals(stripPrefix(key))) {
String base = stripPrefix(key);
boolean suffixed = inputProfile.getObjectTypeSuffixedProperties().contains(base);
if (!(wireLocalName.equals(base) || (suffixed && wireLocalName.startsWith(base + "_")))) {
continue;
}
String expectedUri = expectedNamespaceUri(p, parent, key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import de.ii.xtraplatform.crs.domain.EpsgCrs;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.immutables.value.Value;

/**
Expand Down Expand Up @@ -162,6 +163,18 @@ default String getFeatureMemberElementName() {

Map<String, List<String>> getValueWrap();

/**
* Reverse of {@code GmlConfiguration#objectTypeSuffixedProperties}: the name (or alias, when
* {@link #getUseAlias()}) of each FEATURE_REF property whose GML element on the wire is the base
* property name plus a {@code _<ObjectType>} suffix naming the referenced feature type (e.g. base
* {@code gehoertZuBauwerk} → {@code gehoertZuBauwerk_AX_Turm}). For these properties the decoder
* accepts an element whose local name is the base name optionally followed by a {@code
* _<segment>} suffix and maps it to the base property. The suffix is ignored: the referenced
* object type is carried independently through the FEATURE_REF join, so it need not be captured
* from the wire.
*/
Set<String> getObjectTypeSuffixedProperties();

static FeatureTokenDecoderGmlInputProfile empty() {
return ImmutableFeatureTokenDecoderGmlInputProfile.builder().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,69 @@ class FeatureTokenDecoderGmlSpec extends Specification {
!tokens.contains("urn:adv:oid:DENW36AL00000AAA")
}

static final FeatureTokenDecoderGmlInputProfile NAS_TEMPLATES_SUFFIXED =
ImmutableFeatureTokenDecoderGmlInputProfile.builder()
.useAlias(true)
.featureRefTemplate("urn:adv:oid:{{value}}")
.addObjectTypeSuffixedProperties("istGebucht")
.build()

def 'objectTypeSuffixedProperties: a _<ObjectType>-suffixed element maps to the base feature-ref property'() {
given:
// ALKIS NAS names this element adv:gehoertZuBauwerk_AX_Turm; istGebucht stands in here as a
// declared suffixed property. The _AX_Turm suffix is ignored and the href is reduced as for
// the plain element.
def decoder = newDecoder(axFlurstueckWithRefsSchema(), NAS_TEMPLATES_SUFFIXED)
def xml = """<adv:AX_Flurstueck xmlns:adv="${ADV_NS}"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xlink="http://www.w3.org/1999/xlink"
gml:id="DENW36AL10000XYZ">
<adv:istGebucht_AX_Turm xlink:href="urn:adv:oid:DENW36ALl800005x"/>
</adv:AX_Flurstueck>"""

when:
def tokens = runDecoder(decoder, xml)

then:
valueAtPath(tokens, ["11001-21008"]) == "DENW36ALl800005x"
}

def 'objectTypeSuffixedProperties: the unsuffixed element still matches a declared property'() {
given:
def decoder = newDecoder(axFlurstueckWithRefsSchema(), NAS_TEMPLATES_SUFFIXED)
def xml = """<adv:AX_Flurstueck xmlns:adv="${ADV_NS}"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xlink="http://www.w3.org/1999/xlink"
gml:id="DENW36AL10000XYZ">
<adv:istGebucht xlink:href="urn:adv:oid:DENW36ALl800005x"/>
</adv:AX_Flurstueck>"""

when:
def tokens = runDecoder(decoder, xml)

then:
valueAtPath(tokens, ["11001-21008"]) == "DENW36ALl800005x"
}

def 'a suffixed element is not matched when the property is not declared in objectTypeSuffixedProperties'() {
given:
// Same element, but the default profile declares no suffixed properties: the suffix is not
// stripped, the element matches no property and is skipped (the FK is not emitted).
def decoder = newDecoder(axFlurstueckWithRefsSchema(), NAS_TEMPLATES)
def xml = """<adv:AX_Flurstueck xmlns:adv="${ADV_NS}"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xlink="http://www.w3.org/1999/xlink"
gml:id="DENW36AL10000XYZ">
<adv:istGebucht_AX_Turm xlink:href="urn:adv:oid:DENW36ALl800005x"/>
</adv:AX_Flurstueck>"""

when:
def tokens = runDecoder(decoder, xml)

then:
valueAtPath(tokens, ["11001-21008"]) == null
}

def 'xlink:href is emitted unchanged when no template is configured'() {
given:
def profile = ImmutableFeatureTokenDecoderGmlInputProfile.builder()
Expand Down
Loading