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 Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import org.springframework.http.MediaType;

/** 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")
public class CollectionDocument extends AbstractDocument {
static final Logger LOGGER = Logging.getLogger(CollectionDocument.class);

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

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

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

@JacksonXmlProperty(localName = "Title")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
<#else>
Attribute information is not available.
</#if>
<#include "common-footer.ftl">
<#include "common-footer.ftl">
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<ul>
<#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 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>
<#assign se = collection.extent.spatial>
<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:
<select onchange="window.open(this.options[this.selectedIndex].value + '&limit=${service.maxNumberOfFeaturesForPreview}');this.selectedIndex=0" >
<option value="none" selected>--Please choose an option--</option>
Expand Down
Original file line number 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>

<#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">
</#list>
<#include "common-footer.ftl">
<#include "common-footer.ftl">
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testCollectionJson() throws Exception {
String roadSegments = getEncodedName(MockData.ROAD_SEGMENTS);
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(-180, json.read("$.extent.spatial[0]", 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();
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));

// 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";
XMLAssert.assertXpathEvaluatesTo(
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);
}

Expand Down

0 comments on commit acf1638

Please sign in to comment.