From d089f425dc66b954ee72f82b9cdb95727cf3eebc Mon Sep 17 00:00:00 2001 From: Rex Lai Date: Wed, 5 Feb 2025 14:29:08 +0000 Subject: [PATCH] add test for freemarker rdf templates. EMC-392 --- .../test/java/templates/RdfTemplateTest.java | 245 +++++++++++ .../templates/rdf/datastore/eidc-gemini.raw | 415 ++++++++++++++++++ .../rdf/datastore/monitoring-activity.raw | 113 +++++ .../rdf/datastore/monitoring-facility.raw | 96 ++++ .../rdf/datastore/monitoring-network.raw | 95 ++++ .../rdf/datastore/monitoring-programme.raw | 128 ++++++ .../templates/rdf/eidc/aggregation.ttl | 2 + .../resources/templates/rdf/eidc/gemini.ttl | 109 +++++ .../templates/rdf/monitoring/activity.ttl | 14 + .../templates/rdf/monitoring/facility.ttl | 18 + .../templates/rdf/monitoring/network.ttl | 15 + .../templates/rdf/monitoring/programme.ttl | 18 + 12 files changed, 1268 insertions(+) create mode 100644 java/src/test/java/templates/RdfTemplateTest.java create mode 100644 java/src/test/resources/templates/rdf/datastore/eidc-gemini.raw create mode 100644 java/src/test/resources/templates/rdf/datastore/monitoring-activity.raw create mode 100644 java/src/test/resources/templates/rdf/datastore/monitoring-facility.raw create mode 100644 java/src/test/resources/templates/rdf/datastore/monitoring-network.raw create mode 100644 java/src/test/resources/templates/rdf/datastore/monitoring-programme.raw create mode 100644 java/src/test/resources/templates/rdf/eidc/aggregation.ttl create mode 100644 java/src/test/resources/templates/rdf/eidc/gemini.ttl create mode 100644 java/src/test/resources/templates/rdf/monitoring/activity.ttl create mode 100644 java/src/test/resources/templates/rdf/monitoring/facility.ttl create mode 100644 java/src/test/resources/templates/rdf/monitoring/network.ttl create mode 100644 java/src/test/resources/templates/rdf/monitoring/programme.ttl diff --git a/java/src/test/java/templates/RdfTemplateTest.java b/java/src/test/java/templates/RdfTemplateTest.java new file mode 100644 index 000000000..3a7af8a61 --- /dev/null +++ b/java/src/test/java/templates/RdfTemplateTest.java @@ -0,0 +1,245 @@ +package templates; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import freemarker.template.Configuration; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import lombok.val; +import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; +import uk.ac.ceh.gateway.catalogue.gemini.GeminiDocument; +import uk.ac.ceh.gateway.catalogue.model.Link; +import uk.ac.ceh.gateway.catalogue.monitoring.MonitoringActivity; +import uk.ac.ceh.gateway.catalogue.monitoring.MonitoringFacility; +import uk.ac.ceh.gateway.catalogue.monitoring.MonitoringNetwork; +import uk.ac.ceh.gateway.catalogue.monitoring.MonitoringProgramme; +import uk.ac.ceh.gateway.catalogue.templateHelpers.JenaLookupService; + +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Objects; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + +@Slf4j +@DisplayName("Rdf template") +public class RdfTemplateTest { + Configuration configuration; + ObjectMapper objectMapper; + JenaLookupService jena; + + @SneakyThrows + private String expected(String filename) { + val expected = Objects.requireNonNull(getClass().getResourceAsStream(filename)); + return IOUtils.toString(expected, StandardCharsets.UTF_8); + } + + @SneakyThrows + private String template(String templateFilename, Object model) { + return FreeMarkerTemplateUtils.processTemplateIntoString( + configuration.getTemplate(templateFilename), + model + ); + } + + private void compare(String expected, String actual) { + assertThat(actual.trim(), equalTo(expected.trim())); + } + + @SneakyThrows + @BeforeEach + void init() { + configuration = new Configuration(Configuration.VERSION_2_3_23); + configuration.setDirectoryForTemplateLoading(new File("../templates")); + objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + jena = mock(JenaLookupService.class); + configuration.setSharedVariable("jena", jena); + } + + @Nested + @DisplayName("Eidc documents") + class Eidc { + + @Test + @SneakyThrows + @DisplayName("full dataset ttl") + void dataset() { + // given + val expected = expected("rdf/eidc/gemini.ttl"); + + val geminiDocument = objectMapper.readValue(expected("rdf/datastore/eidc-gemini.raw"), GeminiDocument.class); + + String predicateURI="https://vocabs.ceh.ac.uk/eidc#"; + given(jena.relationships(geminiDocument.getUri(), predicateURI + "memberOf")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000012345").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/000054321").build() + )); + given(jena.relationships(geminiDocument.getUri(), predicateURI + "supersedes")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/111112345").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/111154321").build() + )); + given(jena.relationships(geminiDocument.getUri(), predicateURI + "relatedTo")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/222212345").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/222254321").build() + )); + + // when + val actual = template("rdf/ttl.ftl", geminiDocument); + + //then + compare(expected, actual); + } + + @Test + @SneakyThrows + @DisplayName("aggregation part only") + void aggregation() { + // given + val expected = expected("rdf/eidc/aggregation.ttl"); + + val gemini = objectMapper.readValue(expected("rdf/datastore/eidc-gemini.raw"), GeminiDocument.class); + + given(jena.incomingEidcRelations(gemini.getUri())).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000012345").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/000054321").build() + )); + + // when + val actual = template("rdf/turtle/_aggregation.ftl", gemini); + + //then + compare(expected, actual); + } + } + + @Nested + @DisplayName("Monitoring documents") + class Monitoring { + + @Test + @SneakyThrows + @DisplayName("facility ttl") + void facility() { + //given + val expected = expected("rdf/monitoring/facility.ttl"); + + val facilityDocument = objectMapper.readValue(expected("rdf/datastore/monitoring-facility.raw"), MonitoringFacility.class); + + String predicateURI="http://onto.ceh.ac.uk/EF#"; + given(jena.relationships(facilityDocument.getUri(), predicateURI + "associatedWith")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000001").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000002").build() + )); + given(jena.relationships(facilityDocument.getUri(), predicateURI + "narrower")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000003").build() + )); + given(jena.relationships(facilityDocument.getUri(), predicateURI + "supersedes")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000004").build() + )); + given(jena.relationships(facilityDocument.getUri(), predicateURI + "belongsTo")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000005").build() + )); + + //when + val actual = template("rdf/monitoring/facility.ftl", facilityDocument); + + //then + compare(expected, actual); + } + + @Test + @SneakyThrows + @DisplayName("network ttl") + void network() { + //given + val expected = expected("rdf/monitoring/network.ttl"); + + val networkDocument = objectMapper.readValue(expected("rdf/datastore/monitoring-network.raw"), MonitoringNetwork.class); + + String predicateURI="http://onto.ceh.ac.uk/EF#"; + given(jena.relationships(networkDocument.getUri(), predicateURI + "associatedWith")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000001").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000002").build() + )); + given(jena.relationships(networkDocument.getUri(), predicateURI + "narrower")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000003").build() + )); + given(jena.relationships(networkDocument.getUri(), predicateURI + "supersedes")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000004").build() + )); + + //when + val actual = template("rdf/monitoring/network.ftl", networkDocument); + + //then + compare(expected, actual); + } + + @Test + @SneakyThrows + @DisplayName("programme ttl") + void programme() { + //given + val expected = expected("rdf/monitoring/programme.ttl"); + + val programmeDocument = objectMapper.readValue(expected("rdf/datastore/monitoring-programme.raw"), MonitoringProgramme.class); + + String predicateURI="http://onto.ceh.ac.uk/EF#"; + given(jena.relationships(programmeDocument.getUri(), predicateURI + "associatedWith")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000001").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000002").build() + )); + given(jena.relationships(programmeDocument.getUri(), predicateURI + "supersedes")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000003").build() + )); + given(jena.relationships(programmeDocument.getUri(), predicateURI + "utilises")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000004").build() + )); + given(jena.relationships(programmeDocument.getUri(), predicateURI + "hasChild")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000005").build() + )); + given(jena.relationships(programmeDocument.getUri(), predicateURI + "triggers")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000006").build() + )); + + //when + val actual = template("rdf/monitoring/programme.ftl", programmeDocument); + + //then + compare(expected, actual); + } + + @Test + @SneakyThrows + @DisplayName("activity ttl") + void activity() { + //given + val expected = expected("rdf/monitoring/activity.ttl"); + + val activityDocument = objectMapper.readValue(expected("rdf/datastore/monitoring-activity.raw"), MonitoringActivity.class); + + String predicateURI="http://onto.ceh.ac.uk/EF#"; + given(jena.relationships(activityDocument.getUri(), predicateURI + "uses")).willReturn(List.of( + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000001").build(), + Link.builder().href("https://catalogue.ceh.ac.uk/id/000000002").build() + )); + + //when + val actual = template("rdf/monitoring/activity.ftl", activityDocument); + + //then + compare(expected, actual); + } + } +} + diff --git a/java/src/test/resources/templates/rdf/datastore/eidc-gemini.raw b/java/src/test/resources/templates/rdf/datastore/eidc-gemini.raw new file mode 100644 index 000000000..a5a5a12c4 --- /dev/null +++ b/java/src/test/resources/templates/rdf/datastore/eidc-gemini.raw @@ -0,0 +1,415 @@ +{ + "id": "f8eb7ef3-cd5d-4931-8a4b-ef9ea2b13a16", + "uri": "http://localhost:8080/id/f8eb7ef3-cd5d-4931-8a4b-ef9ea2b13a16", + "type": "dataset", + "title": "Test title", + "description": "Test description zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", + "metadataDate": "2025-02-04T11:48:28.271823554", + "resourceIdentifiers": [ + { + "code": "http://localhost:8080/id/f8eb7ef3-cd5d-4931-8a4b-ef9ea2b13a16" + } + ], + "relationships": [ + { + "relation": "https://vocabs.ceh.ac.uk/eidc#relatedTo", + "target": "c88921ba-f871-44c3-9339-51c5bee4024a" + }, + { + "relation": "https://vocabs.ceh.ac.uk/eidc#supersedes", + "target": "c88921ba-f871-44c3-9339-51c5bee4024a" + }, + { + "relation": "https://vocabs.ceh.ac.uk/eidc#memberOf", + "target": "c88921ba-f871-44c3-9339-51c5bee4024a" + }, + { + "relation": "https://vocabs.ceh.ac.uk/eidc#generates", + "target": "c88921ba-f871-44c3-9339-51c5bee4024a" + }, + { + "relation": "https://vocabs.ceh.ac.uk/eidc#uses", + "target": "c88921ba-f871-44c3-9339-51c5bee4024a" + } + ], + "lineage": "Test quality lineage", + "reasonChanged": "Test quality reason for change", + "version": 1, + "alternateTitles": [ + "Test alternative titles" + ], + "spatialRepresentationTypes": [ + "grid" + ], + "temporalResolution": [ + "Test temporal resolution" + ], + "topicCategories": [ + { + "value": "biota", + "uri": "http://inspire.ec.europa.eu/metadata-codelist/TopicCategory/biota" + } + ], + "keywordsInstrument": [ + { + "value": "water pH of stagnant surface water", + "uri": "http://vocabs.lter-europe.net/EnvThes/30347" + } + ], + "keywordsPlace": [ + { + "value": "water level", + "uri": "http://onto.nerc.ac.uk/CAST/276" + }, + { + "value": "water depth measurement", + "uri": "http://onto.nerc.ac.uk/CAST/187" + } + ], + "keywordsProject": [ + { + "value": "water flux", + "uri": "http://onto.nerc.ac.uk/CAST/287" + } + ], + "keywordsTheme": [ + { + "value": "Agriculture", + "uri": "http://onto.nerc.ac.uk/CEHMD/topic/1" + } + ], + "keywordsOther": [ + { + "value": "water turbidity of stagnant surface water", + "uri": "http://vocabs.lter-europe.net/EnvThes/30349" + } + ], + "observedProperty": [ + { + "value": "Test observed properties name", + "uri": "https://test-observed-properties .ac.uk", + "title": "Test observed properties title", + "description": "Test observed properties description", + "type": "string", + "units": "kg", + "unitsUri": "https://test-unit.ac.uk", + "format": "YYYY-MM-DD", + "constraints": { + "minimum": "5", + "maximum": "60", + "minLength": "3", + "maxLength": "300", + "unique": true + } + } + ], + "distributionFormats": [ + { + "name": "Comma-separated values (CSV)", + "type": "text/csv", + "version": "1.1" + } + ], + "inspireThemes": [ + { + "theme": "Addresses", + "uri": "http://inspire.ec.europa.eu/theme/ad", + "conformity": "Conformant" + } + ], + "spatialResolutions": [ + { + "distance": "5000" + } + ], + "funding": [ + { + "funderName": "Biotechnology and Biological Sciences Research Council", + "funderIdentifier": "https://ror.org/00cwqg982", + "awardTitle": "Test supplemental award name", + "awardNumber": "Test supplemental award reference", + "awardURI": "https://testaward.ac.uk", + "ror": true, + "orcid": false + } + ], + "boundingBoxes": [ + { + "westBoundLongitude": -6.452, + "eastBoundLongitude": 1.768, + "southBoundLatitude": 49.864, + "northBoundLatitude": 55.812, + "bounds": "{\"type\": \"Feature\", \"properties\": {}, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [[[-6.452, 49.864], [-6.452, 55.812], [1.768, 55.812], [1.768, 49.864], [-6.452, 49.864]]] }}", + "coordinates": "[[[-6.452, 49.864], [-6.452, 55.812], [1.768, 55.812], [1.768, 49.864], [-6.452, 49.864]]]" + } + ], + "distributorContacts": [ + { + "individualName": "Test distribution person", + "organisationName": "NERC EDS Environmental Information Data Centre", + "organisationIdentifier": "https://ror.org/04xw4m193", + "role": "distributor", + "email": "info@eidc.ac.uk", + "nameIdentifier": "https://orcid.org/0000-1111-2345-6789", + "address": { + "deliveryPoint": "Test distribution address", + "city": "Test distribution City", + "administrativeArea": "Test distribution County", + "postalCode": "4321", + "country": "US" + } + } + ], + "responsibleParties": [ + { + "individualName": "Test contact author", + "organisationName": "UK Centre for Ecology & Hydrology", + "organisationIdentifier": "https://ror.org/00pggkr55", + "role": "author", + "email": "enquiries@ceh.ac.uk", + "nameIdentifier": "https://orcid.org/0000-0001-2345-6789", + "address": { + "deliveryPoint": "Test author address", + "city": "Test author City", + "administrativeArea": "Test author County", + "postalCode": "1234", + "country": "UK" + } + }, + { + "individualName": "Test contact point of contact", + "organisationName": "UK Centre for Ecology & Hydrology", + "organisationIdentifier": "https://ror.org/00pggkr55", + "role": "pointOfContact", + "email": "enquiries@ceh.ac.uk", + "nameIdentifier": "https://orcid.org/0000-2222-2345-6789", + "address": { + "deliveryPoint": "Lancaster Environment Centre, Library Avenue, Bailrigg", + "city": "Lancaster", + "administrativeArea": "Lancashire", + "postalCode": "LA1 4AP", + "country": "United Kingdom" + }, + "pointOfContact": "UK Centre for Ecology & Hydrology" + }, + { + "individualName": "Test contact custodian", + "organisationName": "NERC EDS Environmental Information Data Centre", + "organisationIdentifier": "https://ror.org/04xw4m193", + "role": "custodian", + "email": "info@eidc.ac.uk", + "nameIdentifier": "https://orcid.org/0000-3333-2345-6789", + "address": { + "deliveryPoint": "Test custodian address", + "city": "Test custodian city", + "administrativeArea": "Test custodian county", + "postalCode": "3456", + "country": "Germany" + } + }, + { + "individualName": "Test contact publisher", + "organisationName": "NERC EDS Environmental Information Data Centre", + "organisationIdentifier": "https://ror.org/04xw4m193", + "role": "publisher", + "email": "info@eidc.ac.uk", + "nameIdentifier": "https://orcid.org/0000-4444-2345-6789", + "address": { + "deliveryPoint": "Test publisher address", + "city": "Test publisher city", + "administrativeArea": "Test publisher county", + "postalCode": "6789", + "country": "Finland" + } + } + ], + "temporalExtents": [ + { + "begin": "2025-02-04", + "end": "2025-02-28" + } + ], + "onlineResources": [ + { + "url": "https://data-package.ceh.ac.uk/data/{fileIdentifier}", + "name": "Download the data", + "description": "Download a copy of this data", + "function": "download", + "size": "1000000", + "type": "OTHER" + } + ], + "spatialReferenceSystems": [ + { + "code": "http://www.opengis.net/def/crs/EPSG/0/27700", + "title": "OSGB 1936 / British National Grid" + } + ], + "incomingCitations": [ + { + "description": "Test Admin details", + "url": "https://test-admin-url.ac.uk", + "type": "academic" + } + ], + "supplemental": [ + { + "name": "Test supplemental name", + "description": "Test supplemental description", + "url": "https://testurl.ac.uk", + "function": "relatedArticle" + } + ], + "datasetReferenceDate": { + "creationDate": "2025-02-04", + "publicationDate": "2025-02-05", + "unavailableDate": "2025-02-07", + "supersededDate": "2025-02-08", + "releasedDate": "2025-02-06" + }, + "resourceMaintenance": [ + { + "frequencyOfUpdate": "biannually", + "note": "Test qualitymaintenace notes" + } + ], + "service": { + "type": "discovery", + "versions": [ + "1.2" + ], + "coupledResources": [ + { + "operationName": "Corba", + "identifier": "test-web-service-identifier", + "layerName": "Test web-service-layer-name" + } + ], + "containsOperations": [ + { + "operationName": "Confirm", + "platform": "COM", + "url": "https://test-web-service.ac.uk" + } + ] + }, + "useConstraints": [ + { + "value": "This resource is available under the terms of the Open Government Licence", + "code": "license", + "uri": "https://eidc.ceh.ac.uk/licences/OGL/plain" + } + ], + "mapDataDefinition": { + "data": [ + { + "path": "Test web service path", + "epsgCode": "4326", + "type": "POLYGON", + "features": { + "name": "Test web service layer", + "label": "Test web service legend", + "style": { + "colour": "#000000" + } + }, + "bytetype": false + } + ] + }, + "resourceType": { + "value": "dataset" + }, + "accessLimitation": { + "value": "no limitations to public access", + "code": "Available", + "uri": "http://purl.org/coar/access_right/c_abf2" + }, + "notGEMINI": true, + "hasOnlineServiceAgreement": true, + "publicationDate": "2025-02-05T00:00:00.000+00:00", + "authors": [ + { + "individualName": "Test contact author", + "organisationName": "UK Centre for Ecology & Hydrology", + "organisationIdentifier": "https://ror.org/00pggkr55", + "role": "author", + "email": "enquiries@ceh.ac.uk", + "nameIdentifier": "https://orcid.org/0000-0001-2345-6789", + "address": { + "deliveryPoint": "Test author address", + "city": "Test author City", + "administrativeArea": "Test author County", + "postalCode": "1234", + "country": "UK" + } + } + ], + "resourceStatus": "Available", + "topics": [ + "http://onto.nerc.ac.uk/CEHMD/topic/1" + ], + "custodians": [ + { + "individualName": "Test contact custodian", + "organisationName": "NERC EDS Environmental Information Data Centre", + "organisationIdentifier": "https://ror.org/04xw4m193", + "role": "custodian", + "email": "info@eidc.ac.uk", + "nameIdentifier": "https://orcid.org/0000-3333-2345-6789", + "address": { + "deliveryPoint": "Test custodian address", + "city": "Test custodian city", + "administrativeArea": "Test custodian county", + "postalCode": "3456", + "country": "Germany" + } + } + ], + "pointsOfContact": [ + { + "individualName": "Test contact point of contact", + "organisationName": "UK Centre for Ecology & Hydrology", + "organisationIdentifier": "https://ror.org/00pggkr55", + "role": "pointOfContact", + "email": "enquiries@ceh.ac.uk", + "nameIdentifier": "https://orcid.org/0000-2222-2345-6789", + "address": { + "deliveryPoint": "Lancaster Environment Centre, Library Avenue, Bailrigg", + "city": "Lancaster", + "administrativeArea": "Lancashire", + "postalCode": "LA1 4AP", + "country": "United Kingdom" + }, + "pointOfContact": "UK Centre for Ecology & Hydrology" + } + ], + "publishers": [ + { + "individualName": "Test contact publisher", + "organisationName": "NERC EDS Environmental Information Data Centre", + "organisationIdentifier": "https://ror.org/04xw4m193", + "role": "publisher", + "email": "info@eidc.ac.uk", + "nameIdentifier": "https://orcid.org/0000-4444-2345-6789", + "address": { + "deliveryPoint": "Test publisher address", + "city": "Test publisher city", + "administrativeArea": "Test publisher county", + "postalCode": "6789", + "country": "Finland" + } + } + ], + "licences": [ + { + "value": "This resource is available under the terms of the Open Government Licence", + "code": "license", + "uri": "https://eidc.ceh.ac.uk/licences/OGL/plain" + } + ], + "coupledResources": [ + "test-web-service-identifier" + ], + "incomingCitationCount": 1 +} diff --git a/java/src/test/resources/templates/rdf/datastore/monitoring-activity.raw b/java/src/test/resources/templates/rdf/datastore/monitoring-activity.raw new file mode 100644 index 000000000..f691092b0 --- /dev/null +++ b/java/src/test/resources/templates/rdf/datastore/monitoring-activity.raw @@ -0,0 +1,113 @@ +{ + "id": "6b9a9875-5077-4641-b4b4-1a4c6e48988d", + "uri": "http://localhost:8080/id/6b9a9875-5077-4641-b4b4-1a4c6e48988d", + "type": "monitoringActivity", + "title": "Test activity name", + "description": "Test activity description", + "metadataDate": "2025-02-05T12:00:11.579103632", + "resourceIdentifiers": [ + { + "code": "http://localhost:8080/id/6b9a9875-5077-4641-b4b4-1a4c6e48988d", + "codeSpace": "1234", + "version": "1.2" + }, + { + "code": "http://localhost:8080/id/6b9a9875-5077-4641-b4b4-1a4c6e48988d" + } + ], + "relationships": [ + { + "relation": "http://onto.ceh.ac.uk/EF#uses", + "target": "09b6b7f5-1bc3-4d21-864a-adf249e86618" + } + ], + "keywords": [ + { + "value": "point", + "uri": "http://www.eionet.europa.eu/gemet/concept/14919" + }, + { + "value": "poison", + "uri": "http://www.eionet.europa.eu/gemet/concept/6358" + } + ], + "alternateTitles": [ + "Test activity alternative name" + ], + "objectives": "Test activity objectives", + "operationalStatus": "Inactive", + "boundingBox": { + "westBoundLongitude": -6.452, + "eastBoundLongitude": 1.768, + "southBoundLatitude": 49.864, + "northBoundLatitude": 55.812, + "bounds": "{\"type\": \"Feature\", \"properties\": {}, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [[[-6.452, 49.864], [-6.452, 55.812], [1.768, 55.812], [1.768, 49.864], [-6.452, 49.864]]] }}", + "coordinates": "[[[-6.452, 49.864], [-6.452, 55.812], [1.768, 55.812], [1.768, 49.864], [-6.452, 49.864]]]" + }, + "responsibleParties": [ + { + "individualName": "Test contact person", + "organisationName": "Natural Resources Wales", + "organisationIdentifier": "https://ror.org/04x65hs26", + "role": "pointOfContact", + "email": "enquiries@naturalresourceswales.gov.uk", + "nameIdentifier": "https://orcid.org/0000-0001-2345-6789", + "address": { + "deliveryPoint": "Test contact address", + "city": "Test contact City", + "administrativeArea": "Test contact County", + "postalCode": "1234", + "country": "UK" + }, + "pointOfContact": "Natural Resources Wales" + } + ], + "operatingPeriod": [ + { + "begin": "2025-02-08", + "end": "2025-03-04" + } + ], + "environmentalDomain": [ + { + "value": "Groundwater", + "uri": "http://ex.org/domain/groundwater" + }, + { + "value": "Marine", + "uri": "http://ex.org/domain/marine" + } + ], + "purposeOfCollection": [ + { + "value": "legislative", + "uri": "http://ex.org/domain/legislative" + }, + { + "value": "modelling", + "uri": "http://ex.org/domain/modelling" + } + ], + "keywordsParameters": [ + { + "value": "polder", + "uri": "http://www.eionet.europa.eu/gemet/concept/6365" + }, + { + "value": "political power", + "uri": "http://www.eionet.europa.eu/gemet/concept/6388" + } + ], + "linksData": [ + { + "description": "Test activity links to data description", + "url": "https://testurl.ac.uk" + } + ], + "linksOther": [ + { + "description": "Test activity other links description", + "url": "https://test.ac.uk" + } + ] +} diff --git a/java/src/test/resources/templates/rdf/datastore/monitoring-facility.raw b/java/src/test/resources/templates/rdf/datastore/monitoring-facility.raw new file mode 100644 index 000000000..af076673a --- /dev/null +++ b/java/src/test/resources/templates/rdf/datastore/monitoring-facility.raw @@ -0,0 +1,96 @@ +{ + "id": "de64ac2e-4fd4-4dcb-9e83-1464219bb1c2", + "uri": "http://localhost:8080/id/de64ac2e-4fd4-4dcb-9e83-1464219bb1c2", + "type": "monitoringFacility", + "title": "Test facility name", + "description": "Test facitlity description", + "metadataDate": "2025-02-05T09:02:01.466032293", + "resourceIdentifiers": [ + { + "code": "123456", + "codeSpace": "1234", + "version": "1.2" + }, + { + "code": "http://localhost:8080/id/de64ac2e-4fd4-4dcb-9e83-1464219bb1c2" + } + ], + "relationships": [ + { + "relation": "http://onto.ceh.ac.uk/EF#associatedWith", + "target": "0246d1a0-3077-4578-8746-34c08c48bdf6" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#supersedes", + "target": "0246d1a0-3077-4578-8746-34c08c48bdf6" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#narrower", + "target": "b1a617c6-5f20-4384-af3c-069b2ff79e61" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#belongsTo", + "target": "0246d1a0-3077-4578-8746-34c08c48bdf6" + } + ], + "keywords": [ + { + "value": "landform", + "uri": "http://www.eionet.europa.eu/gemet/concept/4629" + } + ], + "operationalStatus": "Active", + "alternateTitles": [ + "Test alternative name" + ], + "facilityType": { + "value": "platform", + "uri": "http://ex.com/facilityType/platform" + }, + "geometry": { + "geometryString": "{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-3.27393,56.84071],[0.68115,54.61423],[-0.37354,52.47358],[-5.03174,52.25891],[-5.64697,54.76663],[-3.27393,56.84071]]]}}", + "wkt": "POLYGON((-3.27393 56.84071, 0.68115 54.61423, -0.37354 52.47358, -5.03174 52.25891, -5.64697 54.76663, -3.27393 56.84071))" + }, + "geometryRepresentative": true, + "mobile": true, + "responsibleParties": [ + { + "individualName": "Test contact person", + "organisationName": "Environment Agency", + "organisationIdentifier": "https://ror.org/01zewfb16", + "role": "pointOfContact", + "email": "enquiries@environment-agency.gov.uk", + "nameIdentifier": "https://orcid.org/0000-0001-2345-6789", + "address": { + "deliveryPoint": "Test contact address", + "city": "Test contact City", + "administrativeArea": "Test contact County", + "postalCode": "1234", + "country": "UK" + }, + "pointOfContact": "Environment Agency" + } + ], + "operatingPeriod": [ + { + "begin": "2025-02-05", + "end": "2025-02-28" + } + ], + "environmentalDomain": [ + { + "value": "Atmosphere", + "uri": "http://ex.org/domain/atmosphere" + } + ], + "keywordsParameters": [ + { + "value": "land", + "uri": "http://www.eionet.europa.eu/gemet/concept/4599" + }, + { + "value": "landfill", + "uri": "http://www.eionet.europa.eu/gemet/concept/4621" + } + ] +} diff --git a/java/src/test/resources/templates/rdf/datastore/monitoring-network.raw b/java/src/test/resources/templates/rdf/datastore/monitoring-network.raw new file mode 100644 index 000000000..77abdd8b5 --- /dev/null +++ b/java/src/test/resources/templates/rdf/datastore/monitoring-network.raw @@ -0,0 +1,95 @@ +{ + "id": "09b6b7f5-1bc3-4d21-864a-adf249e86618", + "uri": "http://localhost:8080/id/09b6b7f5-1bc3-4d21-864a-adf249e86618", + "type": "monitoringNetwork", + "title": "Test network name", + "description": "Test network description", + "metadataDate": "2025-02-05T10:06:13.190218907", + "resourceIdentifiers": [ + { + "code": "http://localhost:8080/id/09b6b7f5-1bc3-4d21-864a-adf249e86618", + "codeSpace": "1234", + "version": "1.7" + }, + { + "code": "http://localhost:8080/id/09b6b7f5-1bc3-4d21-864a-adf249e86618" + } + ], + "relationships": [ + { + "relation": "http://onto.ceh.ac.uk/EF#narrower", + "target": "0246d1a0-3077-4578-8746-34c08c48bdf6" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#associatedWith", + "target": "09b6b7f5-1bc3-4d21-864a-adf249e86618" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#supersedes", + "target": "09b6b7f5-1bc3-4d21-864a-adf249e86618" + } + ], + "keywords": [ + { + "value": "landform", + "uri": "http://www.eionet.europa.eu/gemet/concept/4629" + }, + { + "value": "landscape", + "uri": "http://www.eionet.europa.eu/gemet/concept/4648" + } + ], + "alternateTitles": [ + "Test network alternative name" + ], + "objectives": "Test network objectives", + "operationalStatus": "Active", + "responsibleParties": [ + { + "individualName": "Test contact person", + "organisationName": "Defra", + "organisationIdentifier": "https://ror.org/00tnppw48", + "role": "funder", + "email": "defra.helpline@defra.gsi.gov.uk", + "address": { + "deliveryPoint": "Test contact address", + "city": "Test contact City", + "administrativeArea": "Test contact County", + "postalCode": "1234", + "country": "UK" + } + } + ], + "environmentalDomain": [ + { + "value": "Atmosphere", + "uri": "http://ex.org/domain/atmosphere" + }, + { + "value": "Biosphere", + "uri": "http://ex.org/domain/biosphere" + } + ], + "keywordsParameters": [ + { + "value": "land", + "uri": "http://www.eionet.europa.eu/gemet/concept/4599" + }, + { + "value": "landfill", + "uri": "http://www.eionet.europa.eu/gemet/concept/4621" + } + ], + "linksData": [ + { + "description": "Test link data description", + "url": "https://testurl.ac.uk" + } + ], + "linksOther": [ + { + "description": "Test other links description", + "url": "https://test.ac.uk" + } + ] +} diff --git a/java/src/test/resources/templates/rdf/datastore/monitoring-programme.raw b/java/src/test/resources/templates/rdf/datastore/monitoring-programme.raw new file mode 100644 index 000000000..3ecce2dd6 --- /dev/null +++ b/java/src/test/resources/templates/rdf/datastore/monitoring-programme.raw @@ -0,0 +1,128 @@ +{ + "id": "43414cbf-03ab-4f5a-a581-b01ce145d312", + "uri": "http://localhost:8080/id/43414cbf-03ab-4f5a-a581-b01ce145d312", + "type": "monitoringProgramme", + "title": "Test programme name", + "description": "Test programme description", + "metadataDate": "2025-02-05T10:21:49.361880949", + "resourceIdentifiers": [ + { + "code": "http://localhost:8080/id/43414cbf-03ab-4f5a-a581-b01ce145d312", + "codeSpace": "1234", + "version": "1.9" + }, + { + "code": "http://localhost:8080/id/43414cbf-03ab-4f5a-a581-b01ce145d312" + } + ], + "relationships": [ + { + "relation": "http://onto.ceh.ac.uk/EF#hasChild", + "target": "de64ac2e-4fd4-4dcb-9e83-1464219bb1c2" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#triggers", + "target": "09b6b7f5-1bc3-4d21-864a-adf249e86618" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#associatedWith", + "target": "cfa36a6b-1aa5-48c8-86f4-862558c41f43" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#supersedes", + "target": "09b6b7f5-1bc3-4d21-864a-adf249e86618" + }, + { + "relation": "http://onto.ceh.ac.uk/EF#utilises", + "target": "09b6b7f5-1bc3-4d21-864a-adf249e86618" + } + ], + "keywords": [ + { + "value": "airborne noise", + "uri": "http://www.eionet.europa.eu/gemet/concept/11918" + }, + { + "value": "air movement", + "uri": "http://www.eionet.europa.eu/gemet/concept/262" + } + ], + "alternateTitles": [ + "Test alternative programme name" + ], + "objectives": "Test programme objectives", + "operationalStatus": "Inactive", + "boundingBox": { + "westBoundLongitude": -8.648, + "eastBoundLongitude": -0.728, + "southBoundLatitude": 54.634, + "northBoundLatitude": 60.861, + "bounds": "{\"type\": \"Feature\", \"properties\": {}, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [[[-8.648, 54.634], [-8.648, 60.861], [-0.728, 60.861], [-0.728, 54.634], [-8.648, 54.634]]] }}", + "coordinates": "[[[-8.648, 54.634], [-8.648, 60.861], [-0.728, 60.861], [-0.728, 54.634], [-8.648, 54.634]]]" + }, + "responsibleParties": [ + { + "individualName": "Test contact person", + "organisationName": "Scottish Government", + "organisationIdentifier": "https://ror.org/04v2xmd71", + "role": "funder", + "email": "info@eidc.ac.uk", + "nameIdentifier": "https://orcid.org/0000-0001-2345-6789", + "address": { + "deliveryPoint": "Test contact address", + "city": "Test contact City", + "administrativeArea": "Test contact County", + "postalCode": "1234", + "country": "UK" + } + } + ], + "operatingPeriod": [ + { + "begin": "2025-02-08", + "end": "2025-03-22" + } + ], + "environmentalDomain": [ + { + "value": "Cryosphere", + "uri": "http://ex.org/domain/cryosphere" + }, + { + "value": "Marine", + "uri": "http://ex.org/domain/marine" + } + ], + "purposeOfCollection": [ + { + "value": "dataSeries", + "uri": "http://ex.org/domain/dataSeries" + }, + { + "value": "dataCollection", + "uri": "http://ex.org/domain/dataCollection" + } + ], + "keywordsParameters": [ + { + "value": "air", + "uri": "http://www.eionet.europa.eu/gemet/concept/245" + }, + { + "value": "aircraft", + "uri": "http://www.eionet.europa.eu/gemet/concept/253" + } + ], + "linksData": [ + { + "description": "Test programme links to data description", + "url": "https://testurl.ac.uk" + } + ], + "linksOther": [ + { + "description": "Test programme other links", + "url": "https://test.ac.uk" + } + ] +} diff --git a/java/src/test/resources/templates/rdf/eidc/aggregation.ttl b/java/src/test/resources/templates/rdf/eidc/aggregation.ttl new file mode 100644 index 000000000..c9a1da246 --- /dev/null +++ b/java/src/test/resources/templates/rdf/eidc/aggregation.ttl @@ -0,0 +1,2 @@ +a dcmitype:Collection ; + dct:hasPart , ; diff --git a/java/src/test/resources/templates/rdf/eidc/gemini.ttl b/java/src/test/resources/templates/rdf/eidc/gemini.ttl new file mode 100644 index 000000000..b6b491704 --- /dev/null +++ b/java/src/test/resources/templates/rdf/eidc/gemini.ttl @@ -0,0 +1,109 @@ +PREFIX rdf: +PREFIX rdfs: +PREFIX skos: +PREFIX owl: +PREFIX xsd: +PREFIX dct: +PREFIX dcat: +PREFIX dcmitype: +PREFIX foaf: +PREFIX geo: +PREFIX vcard: +PREFIX prov: +PREFIX odrs: +PREFIX sosa: +PREFIX sdo: +PREFIX ef: +PREFIX : +:f8eb7ef3-cd5d-4931-8a4b-ef9ea2b13a16 +dct:title "Test title" ; +dct:identifier "http://localhost:8080/id/f8eb7ef3-cd5d-4931-8a4b-ef9ea2b13a16" ; +dct:description "Test description zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" ; +dct:provenance [ +a dct:ProvenanceStatement ; +rdfs:label "Test quality lineage" +] ; +dct:spatial "POLYGON((-6.452 49.864, -6.452 55.812, 1.768 55.812, 1.768 49.864, -6.452 49.864))"^^geo:wktLiteral ; +dct:temporal "2025-02-04/2025-02-28"^^dct:PeriodOfTime ; +dcat:contactPoint + ; +dct:publisher + ; +dct:isPartOf , ; +dct:replaces , ; +dct:relation , ; +dct:isReferencedBy + ; +dct:subject +, +, +, +, +, + ; +sdo:variableMeasured ; +prov:wasGeneratedBy + ; +a dcat:Dataset, dcmitype:Dataset ; +dct:type dcmitype:Dataset ; +dct:available "2025-02-05"^^xsd:date ; +dcat:landingPage ; +dct:license +; +dct:accessRights [ a dct:RightsStatement ; +odrs:attributionText "no limitations to public access" ; +odrs:attributionUrl +] ; +dct:theme + ; +dcat:distribution [ +dcat:accessURL + ; +dct:license +; +dct:accessRights [ a dct:RightsStatement ; +odrs:attributionText "no limitations to public access" ; +odrs:attributionUrl +] ; +dct:format +[ +a dct:IMT ; +rdf:value "Comma-separated values (CSV)" ; rdfs:label "Comma-separated values (CSV)" +] ; +]; +dct:contributor + ; +dct:language "eng" . + a vcard:Individual ; +vcard:fn "Test contact point of contact" ; +vcard:organization-name "UK Centre for Ecology & Hydrology" ; +vcard:hasEmail "enquiries@ceh.ac.uk" ; +. + a vcard:Individual ; +vcard:fn "Test contact publisher" ; +vcard:organization-name "NERC EDS Environmental Information Data Centre" ; +vcard:hasEmail "info@eidc.ac.uk" ; +. + a vcard:Individual ; +vcard:fn "Test contact author" ; +vcard:organization-name "UK Centre for Ecology & Hydrology" ; +vcard:hasEmail "enquiries@ceh.ac.uk" ; +. + a ; +rdfs:label "Test Admin details"; +. + a skos:Concept; +skos:prefLabel "water pH of stagnant surface water"; rdfs:label "water pH of stagnant surface water" +. a skos:Concept; +skos:prefLabel "water level"; rdfs:label "water level" +. a skos:Concept; +skos:prefLabel "water depth measurement"; rdfs:label "water depth measurement" +. a skos:Concept; +skos:prefLabel "water flux"; rdfs:label "water flux" +. a skos:Concept; +skos:prefLabel "Agriculture"; rdfs:label "Agriculture" +. a skos:Concept; +skos:prefLabel "water turbidity of stagnant surface water"; rdfs:label "water turbidity of stagnant surface water" +. + a skos:Concept;skos:prefLabel "Test observed properties title"; rdfs:label "Test observed properties title". + a prov:Activity ; rdfs:label "Test supplemental award name" . diff --git a/java/src/test/resources/templates/rdf/monitoring/activity.ttl b/java/src/test/resources/templates/rdf/monitoring/activity.ttl new file mode 100644 index 000000000..f2a6eabae --- /dev/null +++ b/java/src/test/resources/templates/rdf/monitoring/activity.ttl @@ -0,0 +1,14 @@ +PREFIX : +PREFIX dct: +PREFIX skos: +PREFIX ef: +PREFIX sosa: +PREFIX geo: +:6b9a9875-5077-4641-b4b4-1a4c6e48988d +a ef:Activity ; +dct:title "Test activity name" ; +dct:description "Test activity description" ; +ef:boundingBox "POLYGON((-6.45 49.864, -6.45 55.812, 1.76 55.812, 1.76 49.864, -6.45 49.864))"^^geo:wktLiteral ; +dct:language "eng"; +ef:uses , ; +. diff --git a/java/src/test/resources/templates/rdf/monitoring/facility.ttl b/java/src/test/resources/templates/rdf/monitoring/facility.ttl new file mode 100644 index 000000000..2a87eee4b --- /dev/null +++ b/java/src/test/resources/templates/rdf/monitoring/facility.ttl @@ -0,0 +1,18 @@ +PREFIX : +PREFIX dct: +PREFIX skos: +PREFIX ef: +PREFIX sosa: +PREFIX geo: +:de64ac2e-4fd4-4dcb-9e83-1464219bb1c2 +a sosa:Platform, ef:Facility ; +dct:title "Test facility name" ; +dct:description "Test facitlity description" ; +dct:geometry "POLYGON((-3.27393 56.84071, 0.68115 54.61423, -0.37354 52.47358, -5.03174 52.25891, -5.64697 54.76663, -3.27393 56.84071))"^^geo:wktLiteral ; +ef:mediaMonitored ; +dct:language "eng"; +ef:associatedWith , ; +ef:narrower ; +ef:supersedes ; +ef:belongsTo ; +. diff --git a/java/src/test/resources/templates/rdf/monitoring/network.ttl b/java/src/test/resources/templates/rdf/monitoring/network.ttl new file mode 100644 index 000000000..572c7337b --- /dev/null +++ b/java/src/test/resources/templates/rdf/monitoring/network.ttl @@ -0,0 +1,15 @@ +PREFIX : +PREFIX dct: +PREFIX skos: +PREFIX ef: +PREFIX sosa: +PREFIX geo: +:09b6b7f5-1bc3-4d21-864a-adf249e86618 +a ef:Network ; +dct:title "Test network name" ; +dct:description "Test network description" ; +dct:language "eng"; +ef:associatedWith , ; +ef:narrower ; +ef:supersedes ; +. diff --git a/java/src/test/resources/templates/rdf/monitoring/programme.ttl b/java/src/test/resources/templates/rdf/monitoring/programme.ttl new file mode 100644 index 000000000..bfe9a3020 --- /dev/null +++ b/java/src/test/resources/templates/rdf/monitoring/programme.ttl @@ -0,0 +1,18 @@ +PREFIX : +PREFIX dct: +PREFIX skos: +PREFIX ef: +PREFIX sosa: +PREFIX geo: +:43414cbf-03ab-4f5a-a581-b01ce145d312 +a ef:Programme ; +dct:title "Test programme name" ; +dct:description "Test programme description" ; +ef:boundingBox "POLYGON((-8.64 54.634, -8.64 60.861, -0.72 60.861, -0.72 54.634, -8.64 54.634))"^^geo:wktLiteral ; +dct:language "eng"; +ef:associatedWith , ; +ef:supersedes ; +ef:utilises ; +ef:hasChild ; +ef:triggers ; +.