Skip to content

Commit

Permalink
[GEOS-9261] Update name to id in OGC API Collection
Browse files Browse the repository at this point in the history
This was changed in the WFS 3 spec in opengeospatial/ogcapi-features@a9be3db
  • Loading branch information
bradh committed Jun 23, 2019
1 parent f5fbc2c commit acf1638
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import org.springframework.http.MediaType; import org.springframework.http.MediaType;


/** Description of a single collection, that will be serialized to JSON/XML/HTML */ /** Description of a single collection, that will be serialized to JSON/XML/HTML */
@JsonPropertyOrder({"name", "title", "description", "extent", "links"}) @JsonPropertyOrder({"id", "title", "description", "extent", "links"})
@JacksonXmlRootElement(localName = "Collection", namespace = "http://www.opengis.net/wfs/3.0") @JacksonXmlRootElement(localName = "Collection", namespace = "http://www.opengis.net/wfs/3.0")
public class CollectionDocument extends AbstractDocument { public class CollectionDocument extends AbstractDocument {
static final Logger LOGGER = Logging.getLogger(CollectionDocument.class); static final Logger LOGGER = Logging.getLogger(CollectionDocument.class);


String name; String id;
String title; String title;
String description; String description;
WFSExtents extent; WFSExtents extent;
Expand All @@ -52,7 +52,7 @@ public class CollectionDocument extends AbstractDocument {
public CollectionDocument(GeoServer geoServer, FeatureTypeInfo featureType) { public CollectionDocument(GeoServer geoServer, FeatureTypeInfo featureType) {
// basic info // basic info
String collectionId = NCNameResourceCodec.encode(featureType); String collectionId = NCNameResourceCodec.encode(featureType);
setName(collectionId); setId(collectionId);
setTitle(featureType.getTitle()); setTitle(featureType.getTitle());
setDescription(featureType.getAbstract()); setDescription(featureType.getAbstract());
ReferencedEnvelope bbox = featureType.getLatLonBoundingBox(); ReferencedEnvelope bbox = featureType.getLatLonBoundingBox();
Expand Down Expand Up @@ -94,19 +94,19 @@ private boolean isWMSAvailable(GeoServer geoServer) {
geoServer geoServer
.getServices() .getServices()
.stream() .stream()
.filter(s -> "WMS".equals(s.getName())) .filter(s -> "WMS".equals(s.getId()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
return si != null; return si != null;
} }


@JacksonXmlProperty(localName = "Name") @JacksonXmlProperty(localName = "Id")
public String getName() { public String getId() {
return name; return id;
} }


public void setName(String name) { public void setId(String collectionId) {
this.name = name; id = collectionId;
} }


@JacksonXmlProperty(localName = "Title") @JacksonXmlProperty(localName = "Title")
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
<#else> <#else>
Attribute information is not available. Attribute information is not available.
</#if> </#if>
<#include "common-footer.ftl"> <#include "common-footer.ftl">
Original file line number Original file line Diff line number Diff line change
@@ -1,13 +1,13 @@
<ul> <ul>
<#if collection.title??> <#if collection.title??>
<li><b>Title</b>: <span id="${collection.name}_title">${collection.title}</span><br/></li> <li><b>Title</b>: <span id="${collection.id}_title">${collection.title}</span><br/></li>
</#if> </#if>
<#if collection.description??> <#if collection.description??>
<li><b>Description</b>: <span id="${collection.name}_description">${collection.description!}</span><br/></li> <li><b>Description</b>: <span id="${collection.id}_description">${collection.description!}</span><br/></li>
</#if> </#if>
<#assign se = collection.extent.spatial> <#assign se = collection.extent.spatial>
<li><b>Geographic extents</b>: ${se.getMinX()}, ${se.getMinY()}, ${se.getMaxX()}, ${se.getMaxY()}.</li> <li><b>Geographic extents</b>: ${se.getMinX()}, ${se.getMinY()}, ${se.getMaxX()}, ${se.getMaxY()}.</li>
<li>Data as <a id="html_${collection.name}_link" href="${collection.getLinkUrl('items', 'text/html')!}&limit=${service.maxNumberOfFeaturesForPreview}">HTML</a>. <li>Data as <a id="html_${collection.id}_link" href="${collection.getLinkUrl('items', 'text/html')!}&limit=${service.maxNumberOfFeaturesForPreview}">HTML</a>.
Collection items are also available in the following formats: Collection items are also available in the following formats:
<select onchange="window.open(this.options[this.selectedIndex].value + '&limit=${service.maxNumberOfFeaturesForPreview}');this.selectedIndex=0" > <select onchange="window.open(this.options[this.selectedIndex].value + '&limit=${service.maxNumberOfFeaturesForPreview}');this.selectedIndex=0" >
<option value="none" selected>--Please choose an option--</option> <option value="none" selected>--Please choose an option--</option>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This document is also available as <#list model.getLinksExcept(null, "text/html") as link><a href="${link.href}">${link.type}</a><#if link_has_next>, </#if></#list>.</p> This document is also available as <#list model.getLinksExcept(null, "text/html") as link><a href="${link.href}">${link.type}</a><#if link_has_next>, </#if></#list>.</p>


<#list model.collections as collection> <#list model.collections as collection>
<h2><a href="${serviceLink("ogc/features/collections/${collection.name}")}">${collection.name}</a></h2> <h2><a href="${serviceLink("ogc/features/collections/${collection.id}")}">${collection.id}</a></h2>
<#include "collection_include.ftl"> <#include "collection_include.ftl">
</#list> </#list>
<#include "common-footer.ftl"> <#include "common-footer.ftl">
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testCollectionJson() throws Exception {
String roadSegments = getEncodedName(MockData.ROAD_SEGMENTS); String roadSegments = getEncodedName(MockData.ROAD_SEGMENTS);
DocumentContext json = getAsJSONPath("ogc/features/collections/" + roadSegments, 200); DocumentContext json = getAsJSONPath("ogc/features/collections/" + roadSegments, 200);


assertEquals("cite__RoadSegments", json.read("$.name", String.class)); assertEquals("cite__RoadSegments", json.read("$.id", String.class));
assertEquals("RoadSegments", json.read("$.title", String.class)); assertEquals("RoadSegments", json.read("$.title", String.class));
assertEquals(-180, json.read("$.extent.spatial[0]", Double.class), 0d); assertEquals(-180, json.read("$.extent.spatial[0]", Double.class), 0d);
assertEquals(-90, json.read("$.extent.spatial[1]", Double.class), 0d); assertEquals(-90, json.read("$.extent.spatial[1]", Double.class), 0d);
Expand Down Expand Up @@ -63,7 +63,7 @@ public void testCollectionVirtualWorkspace() throws Exception {
String roadSegments = MockData.ROAD_SEGMENTS.getLocalPart(); String roadSegments = MockData.ROAD_SEGMENTS.getLocalPart();
DocumentContext json = getAsJSONPath("cite/ogc/features/collections/" + roadSegments, 200); DocumentContext json = getAsJSONPath("cite/ogc/features/collections/" + roadSegments, 200);


assertEquals("RoadSegments", json.read("$.name", String.class)); assertEquals("RoadSegments", json.read("$.id", String.class));
assertEquals("RoadSegments", json.read("$.title", String.class)); assertEquals("RoadSegments", json.read("$.title", String.class));


// check we have the expected number of links and they all use the right "rel" relation // check we have the expected number of links and they all use the right "rel" relation
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testCollectionXML() throws Exception {
"http://localhost:8080/geoserver/ogc/features/collections/cite__RoadSegments/items?f=application%2Fjson"; "http://localhost:8080/geoserver/ogc/features/collections/cite__RoadSegments/items?f=application%2Fjson";
XMLAssert.assertXpathEvaluatesTo( XMLAssert.assertXpathEvaluatesTo(
expected, expected,
"//wfs:Collection[wfs:Name='cite__RoadSegments']/atom:link[@atom:type='application/json']/@atom:href", "//wfs:Collection[wfs:id='cite__RoadSegments']/atom:link[@atom:type='application/json']/@atom:href",
dom); dom);
} }


Expand Down

0 comments on commit acf1638

Please sign in to comment.