From 73e50b990d987a298681a9bf7553fb709e1b908c Mon Sep 17 00:00:00 2001 From: jampukka Date: Thu, 22 Oct 2026 09:14:07 +0300 Subject: [PATCH 1/2] HTML collection page links to schema and shows spatial and temporal extent (#185) --- .../fi/nls/hakunapi/html/collectionInfo.ftl | 19 +++++++ .../features/CollectionPageHtmlTest.java | 54 +++++++++++++++++++ .../hakuna_html_map/hakuna.properties | 10 +++- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/java/fi/nls/hakunapi/simple/webapp/jakarta/features/CollectionPageHtmlTest.java diff --git a/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/collectionInfo.ftl b/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/collectionInfo.ftl index 5618d890..bec2f230 100644 --- a/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/collectionInfo.ftl +++ b/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/collectionInfo.ftl @@ -61,6 +61,25 @@

${model.storageCrs}

+ <#if model.extent??> + <#if model.extent.spatialExtent??> +

Spatial extent

+ + + <#if model.extent.temporalExtent??> +

Temporal extent

+ + + +

Queryable properties

Find out properties usable in filters

diff --git a/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/java/fi/nls/hakunapi/simple/webapp/jakarta/features/CollectionPageHtmlTest.java b/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/java/fi/nls/hakunapi/simple/webapp/jakarta/features/CollectionPageHtmlTest.java new file mode 100644 index 00000000..9b6fbfc3 --- /dev/null +++ b/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/java/fi/nls/hakunapi/simple/webapp/jakarta/features/CollectionPageHtmlTest.java @@ -0,0 +1,54 @@ +package fi.nls.hakunapi.simple.webapp.jakarta.features; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; + +import java.io.File; + +import jakarta.servlet.ServletContextEvent; +import jakarta.ws.rs.core.Application; +import jakarta.ws.rs.core.MediaType; + +import org.glassfish.jersey.test.JerseyTest; +import org.junit.Test; + +import fi.nls.hakunapi.simple.webapp.jakarta.HakunaContextListener; +import fi.nls.hakunapi.simple.webapp.jakarta.HakunaTestServletContext; +import fi.nls.hakunapi.simple.webapp.jakarta.SimpleFeaturesApplication; + +public class CollectionPageHtmlTest extends JerseyTest { + + @Override + protected Application configure() { + File file = new File(getClass().getClassLoader().getResource("hakuna_html_map/hakuna.properties").getFile()); + System.setProperty("hakuna.config.path", file.getParentFile().getAbsolutePath() + "/"); + + HakunaTestServletContext sc = new HakunaTestServletContext(); + new HakunaContextListener().contextInitialized(new ServletContextEvent(sc)); + return new SimpleFeaturesApplication(sc); + } + + private String html(String collectionId) { + return target("/collections/" + collectionId).request(MediaType.TEXT_HTML).get(String.class); + } + + @Test + public void testSchemaLinkAndSpatialExtent() { + String page = html("fence"); + + assertThat(page, containsString("href=\"collections/fence/schema\"")); + assertThat(page, containsString("Spatial extent")); + assertThat(page, containsString("-110, -60, 140, 30")); + assertThat(page, not(containsString("Temporal extent"))); + } + + @Test + public void testTemporalExtent() { + String page = html("survey"); + + assertThat(page, containsString("Temporal extent")); + assertThat(page, containsString("2020-01-01T00:00:00Z / 2021-01-01T00:00:00Z")); + } + +} diff --git a/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/resources/hakuna_html_map/hakuna.properties b/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/resources/hakuna_html_map/hakuna.properties index 819c0306..c0e65971 100644 --- a/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/resources/hakuna_html_map/hakuna.properties +++ b/webapp-jakarta/hakunapi-simple-webapp-test-jakarta/src/test/resources/hakuna_html_map/hakuna.properties @@ -23,8 +23,16 @@ srid=3067,3857 srid.3067.proj4=+proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs default.collections.srid=3067,3857 -collections=fence +collections=fence,survey collections.fence.geometry.type=POINT collections.fence.properties=name +collections.fence.extent.spatial.crs84=-110,-60,140,30 collections.fence.testdata.1=1;POINT(1 1);Fence A + +collections.survey.geometry.type=POINT +collections.survey.properties=name,surveyed +collections.survey.properties.surveyed.type=DATE +collections.survey.time=surveyed +collections.survey.extent.temporal=2020-01-01T00:00:00Z,2021-01-01T00:00:00Z +collections.survey.testdata.1=1;POINT(2 2);Survey A;2020-06-01 From d7e5c907d4f949481cf425ae97a1a28a1e8a03fe Mon Sep 17 00:00:00 2001 From: jampukka Date: Thu, 22 Oct 2026 09:15:31 +0300 Subject: [PATCH 2/2] Changelog for #185 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 571b1a60..f150cce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ - `collectionInfo.ftl` shows the collection id alongside its title and description, and links to the collection's schema. `collections.ftl` lists entries as `collection_id (Title)`. +- The HTML collection page links to the collection schema and shows the spatial and temporal extent when available (#185). ## 2.0.0