-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOS-8994] Complex features nested attributes not correctly detected (…
- Loading branch information
Nuno Oliveira
committed
Nov 2, 2018
1 parent
fa19ec7
commit c3b1c03
Showing
12 changed files
with
387 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...-schema/app-schema-test/src/test/java/org/geoserver/test/NestedElementsFilteringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,66 @@ | |||
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved | |||
* This code is licensed under the GPL 2.0 license, available at the root | |||
* application directory. | |||
*/ | |||
package org.geoserver.test; | |||
|
|||
import static org.hamcrest.CoreMatchers.containsString; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.junit.Assert.assertThat; | |||
|
|||
import java.util.Collections; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.junit.Test; | |||
import org.springframework.mock.web.MockHttpServletResponse; | |||
|
|||
/** | |||
* Validates the encoding of filters on nested properties with some advanced mappings and xpaths. | |||
*/ | |||
public final class NestedElementsFilteringTest extends AbstractAppSchemaTestSupport { | |||
|
|||
private static final String STATIONS_PREFIX = "st"; | |||
private static final String STATIONS_URI = "http://www.stations.org/1.0"; | |||
|
|||
@Override | |||
protected StationsMockData createTestData() { | |||
// instantiate our custom complex types | |||
return new MockData(); | |||
} | |||
|
|||
/** Helper class that will setup custom complex feature types using the stations data set. */ | |||
private static final class MockData extends StationsMockData { | |||
|
|||
@Override | |||
public void addContent() { | |||
// add stations namespaces | |||
putNamespace(STATIONS_PREFIX, STATIONS_URI); | |||
// add stations feature types | |||
addAppSchemaFeatureType( | |||
STATIONS_PREFIX, | |||
null, | |||
"Station", | |||
"/test-data/stations/nestedElements/stations.xml", | |||
Collections.emptyMap(), | |||
"/test-data/stations/nestedElements/stations.xsd", | |||
"/test-data/stations/nestedElements/institutes.xml", | |||
"/test-data/stations/nestedElements/persons.xml", | |||
"/test-data/stations/nestedElements/stations.properties", | |||
"/test-data/stations/nestedElements/institutes.properties", | |||
"/test-data/stations/nestedElements/persons.properties"); | |||
} | |||
} | |||
|
|||
@Test | |||
public void testWfsGetFeatureWithAdvancedNestedFilter() throws Exception { | |||
// execute the WFS 2.0 request | |||
MockHttpServletResponse response = | |||
postAsServletResponse( | |||
"wfs", | |||
readResource( | |||
"/test-data/stations/nestedElements/requests/wfs_get_feature_1.xml")); | |||
// check that station 1 was returned | |||
String content = response.getContentAsString(); | |||
assertThat(content, containsString("gml:id=\"ins.1\"")); | |||
assertThat(StringUtils.countMatches(content, "<wfs:member>"), is(1)); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...pp-schema-test/src/test/resources/test-data/stations/nestedElements/institutes.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
_=ID:String,NAME:String,ADDRESS:String,STATION:String | |||
ins.1=ins.1|ins1|europe|st.1 |
72 changes: 72 additions & 0 deletions
72
...chema/app-schema-test/src/test/resources/test-data/stations/nestedElements/institutes.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,72 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://www.geotools.org/app-schema AppSchemaDataAccess.xsd"> | |||
<namespaces> | |||
<Namespace> | |||
<prefix>st</prefix> | |||
<uri>http://www.stations.org/1.0</uri> | |||
</Namespace> | |||
<Namespace> | |||
<prefix>xlink</prefix> | |||
<uri>http://www.w3.org/1999/xlink</uri> | |||
</Namespace> | |||
</namespaces> | |||
<sourceDataStores> | |||
<DataStore> | |||
<id>institutes</id> | |||
<parameters> | |||
<Parameter> | |||
<name>directory</name> | |||
<value>file:./</value> | |||
</Parameter> | |||
</parameters> | |||
</DataStore> | |||
</sourceDataStores> | |||
<targetTypes> | |||
<FeatureType> | |||
<schemaUri>stations.xsd</schemaUri> | |||
</FeatureType> | |||
</targetTypes> | |||
<typeMappings> | |||
<FeatureTypeMapping> | |||
<sourceDataStore>institutes</sourceDataStore> | |||
<sourceType>institutes</sourceType> | |||
<targetElement>st:Institute</targetElement> | |||
<attributeMappings> | |||
<AttributeMapping> | |||
<targetAttribute>st:Institute</targetAttribute> | |||
<idExpression> | |||
<OCQL>ID</OCQL> | |||
</idExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>st:Institute/st:name</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>NAME</OCQL> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>st:Institute/st:contact/st:identification/st:address</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>ADDRESS</OCQL> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>FEATURE_LINK[1]</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>STATION</OCQL> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>st:Institute/st:contact/st:persons</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>ID</OCQL> | |||
<linkElement>st:Person</linkElement> | |||
<linkField>FEATURE_LINK[2]</linkField> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
</attributeMappings> | |||
</FeatureTypeMapping> | |||
</typeMappings> | |||
</as:AppSchemaDataAccess> |
3 changes: 3 additions & 0 deletions
3
...a/app-schema-test/src/test/resources/test-data/stations/nestedElements/persons.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
_=ID:String,NAME:String,MAIL:String,INSTITUTE:String | |||
ps.1=ps.1|ps1|ps1@stations.org|ins.1 | |||
ps.2=ps.2|ps2|ps1@stations.org|ins.1 |
64 changes: 64 additions & 0 deletions
64
...p-schema/app-schema-test/src/test/resources/test-data/stations/nestedElements/persons.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,64 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://www.geotools.org/app-schema AppSchemaDataAccess.xsd"> | |||
<namespaces> | |||
<Namespace> | |||
<prefix>st</prefix> | |||
<uri>http://www.stations.org/1.0</uri> | |||
</Namespace> | |||
<Namespace> | |||
<prefix>xlink</prefix> | |||
<uri>http://www.w3.org/1999/xlink</uri> | |||
</Namespace> | |||
</namespaces> | |||
<sourceDataStores> | |||
<DataStore> | |||
<id>persons</id> | |||
<parameters> | |||
<Parameter> | |||
<name>directory</name> | |||
<value>file:./</value> | |||
</Parameter> | |||
</parameters> | |||
</DataStore> | |||
</sourceDataStores> | |||
<targetTypes> | |||
<FeatureType> | |||
<schemaUri>stations.xsd</schemaUri> | |||
</FeatureType> | |||
</targetTypes> | |||
<typeMappings> | |||
<FeatureTypeMapping> | |||
<sourceDataStore>persons</sourceDataStore> | |||
<sourceType>persons</sourceType> | |||
<targetElement>st:Person</targetElement> | |||
<attributeMappings> | |||
<AttributeMapping> | |||
<targetAttribute>st:Person</targetAttribute> | |||
<idExpression> | |||
<OCQL>ID</OCQL> | |||
</idExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>st:Person/st:name</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>NAME</OCQL> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>st:Person/st:mail</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>MAIL</OCQL> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
<AttributeMapping> | |||
<targetAttribute>FEATURE_LINK[2]</targetAttribute> | |||
<sourceExpression> | |||
<OCQL>INSTITUTE</OCQL> | |||
</sourceExpression> | |||
</AttributeMapping> | |||
</attributeMappings> | |||
</FeatureTypeMapping> | |||
</typeMappings> | |||
</as:AppSchemaDataAccess> |
17 changes: 17 additions & 0 deletions
17
...-test/src/test/resources/test-data/stations/nestedElements/requests/wfs_get_feature_1.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
<wfs:GetFeature | |||
service="WFS" version="2.0.0" | |||
xmlns:fes="http://www.opengis.net/fes/2.0" | |||
xmlns:wfs="http://www.opengis.net/wfs/2.0"> | |||
<wfs:Query typeNames="st:Station"> | |||
<fes:Filter> | |||
<fes:And> | |||
<fes:PropertyIsEqualTo> | |||
<fes:ValueReference> | |||
st:Station/st:meta/st:institutes/st:Institute/st:contact/st:identification/st:address | |||
</fes:ValueReference> | |||
<fes:Literal>europe</fes:Literal> | |||
</fes:PropertyIsEqualTo> | |||
</fes:And> | |||
</fes:Filter> | |||
</wfs:Query> | |||
</wfs:GetFeature> |
3 changes: 3 additions & 0 deletions
3
.../app-schema-test/src/test/resources/test-data/stations/nestedElements/stations.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
_=ID:String,NAME:String,LOCATION:Geometry:srid=4326 | |||
st.1=st.1|station1|POINT(-1 1) | |||
st.2=st.2|station2|POINT(-2 -3) |
Oops, something went wrong.