From 89f309feaa6d785340b5aceed62811fb19b0551c Mon Sep 17 00:00:00 2001 From: Enrico Ottonello Date: Tue, 22 Jun 2021 11:06:56 +0200 Subject: [PATCH] added mapping for polygon data when aocat:has_polygonal_representation is in wkt format (snd::zip) --- .../ariadneplus/elasticsearch/BulkUpload.java | 14 ++++++++++++ .../elasticsearch/model/Spatial.java | 9 ++++++++ .../src/main/resources/application.properties | 10 +++++++++ .../read_collection_data_template.sparql | 14 +++++++----- .../sparql/read_record_data_template.sparql | 14 +++++++----- .../GraphDbReaderAndESIndexTest.java | 22 +++++++++++++++++++ 6 files changed, 73 insertions(+), 10 deletions(-) diff --git a/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/BulkUpload.java b/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/BulkUpload.java index 4c2bb1d..eed24d7 100644 --- a/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/BulkUpload.java +++ b/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/BulkUpload.java @@ -66,6 +66,14 @@ public class BulkUpload { AriadnePlusEntry ace = ((AriadnePlusEntry) next); if (isCollection) { ace.setResourceType("collection"); + if (ace.getSpatial()!=null) { + ace.getSpatial() + .stream() + .filter(s -> Objects.nonNull(s.getWkt())) + .forEach(s -> { + s.setPolygon(s.getWkt()); + }); + } // if (ace.getSpatial()==null) { // ace.setSpatial(Arrays.asList(new Spatial())); // } @@ -123,6 +131,12 @@ public class BulkUpload { log.debug("POLYGON "+wkt); s.setPolygon(wkt); }); + ace.getSpatial() + .stream() + .filter(s -> Objects.nonNull(s.getWkt())) + .forEach(s -> { + s.setPolygon(s.getWkt()); + }); if (ace.getSpatial().size()==2) { Spatial uniqueSpatial = new Spatial(); boolean uniquePlaceNameFound = ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).count()==1; diff --git a/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/model/Spatial.java b/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/model/Spatial.java index 0be7909..efd7220 100644 --- a/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/model/Spatial.java +++ b/dnet-ariadneplus-graphdb-publisher/src/main/java/eu/dnetlib/ariadneplus/elasticsearch/model/Spatial.java @@ -23,6 +23,7 @@ public class Spatial { private transient String lat; private transient String lon; private transient List polygonGeoPoints; + private transient String wkt; public String getAddress() { return address; @@ -136,6 +137,14 @@ public class Spatial { this.polygonGeoPoints = polygonGeoPoints; } + public String getWkt() { + return wkt; + } + + public void setWkt(String wkt) { + this.wkt = wkt; + } + public Spatial() { } diff --git a/dnet-ariadneplus-graphdb-publisher/src/main/resources/application.properties b/dnet-ariadneplus-graphdb-publisher/src/main/resources/application.properties index febb6f7..6e87911 100644 --- a/dnet-ariadneplus-graphdb-publisher/src/main/resources/application.properties +++ b/dnet-ariadneplus-graphdb-publisher/src/main/resources/application.properties @@ -125,6 +125,11 @@ class.map.specifications={\ "substring": "no",\ "element_type": "java.lang.String",\ "external_reference": "AriadneGeoPoint"\ +},\ +"https://www.ariadne-infrastructure.eu/property/wkt": {\ +"class_field": "Wkt",\ +"substring": "no",\ +"element_type": "java.lang.String"\ }\ }\ },\ @@ -281,6 +286,11 @@ class.map.specifications={\ "substring": "no",\ "external_reference": "Spatial"\ },\ +"https://www.ariadne-infrastructure.eu/property/spatialRegionWKTPolygon": {\ +"class_field": "Spatial",\ +"substring": "no",\ +"external_reference": "Spatial"\ +},\ "https://www.ariadne-infrastructure.eu/property/landingPage": {\ "class_field": "LandingPage",\ "substring": "no",\ diff --git a/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_collection_data_template.sparql b/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_collection_data_template.sparql index 0597db8..d40b53d 100644 --- a/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_collection_data_template.sparql +++ b/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_collection_data_template.sparql @@ -33,7 +33,6 @@ CONSTRUCT { %record aoprop:landingPage ?landingPage . %record aoprop:spatialRegion ?spatialRegion . ?spatialRegion aoprop:placeName ?spatialPlaceName . -?spatialRegion aoprop:spatialCoordinateSystem ?spatialCoordinateSystem . %record aoprop:spatialRegionPoint ?spatialRegionPoint . ?spatialRegionPoint aoprop:lat ?spatialLocationLat . ?spatialRegionPoint aoprop:lon ?spatialLocationLon . @@ -42,6 +41,8 @@ CONSTRUCT { ?spatialRegionBox aoprop:boxMaxLon ?spatialLocationBBMaxLon . ?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat . ?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon . +%record aoprop:spatialRegionWKTPolygon ?spatialRegionWKTPolygon . +?spatialRegionWKTPolygon aoprop:wkt ?wkt . %record aoprop:temporal ?temporal . ?temporal aoprop:periodOName ?temporalPeriodName . ?temporal aoprop:from ?temporalFrom . @@ -179,10 +180,6 @@ where { %record aocat:has_spatial_coverage ?spatialRegion . ?spatialRegion aocat:has_place_name ?spatialPlaceName . } - optional { - %record aocat:has_spatial_coverage ?spatialRegion . - ?spatialRegion aocat:has_coordinate_system ?spatialCoordinateSystem . - } optional { %record aocat:has_spatial_coverage ?spatialRegionPoint . ?spatialRegionPoint aocat:has_latitude ?spatialLocationLat ; @@ -195,6 +192,13 @@ where { aocat:has_bounding_box_min_lat ?spatialLocationBBMinLat ; aocat:has_bounding_box_min_lon ?spatialLocationBBMinLon ; } + optional { + %record aocat:has_spatial_coverage ?spatialRegionWKTPolygon . + ?spatialRegionWKTPolygon rdf:type aocat:AO_Spatial_Region_Polygon . + ?spatialRegionWKTPolygon aocat:has_polygonal_representation ?wkt . + filter (datatype(?wkt) = rdf:XMLLiteral) + filter (!isIRI(?wkt)) + } } } } diff --git a/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql b/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql index e2de085..86dc7ae 100644 --- a/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql +++ b/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql @@ -33,7 +33,6 @@ CONSTRUCT { %record aoprop:landingPage ?landingPage . %record aoprop:spatialRegion ?spatialRegion . ?spatialRegion aoprop:placeName ?spatialPlaceName . -?spatialRegion aoprop:spatialCoordinateSystem ?spatialCoordinateSystem . %record aoprop:spatialRegionPoint ?spatialRegionPoint . ?spatialRegionPoint aoprop:lat ?spatialLocationLat . ?spatialRegionPoint aoprop:lon ?spatialLocationLon . @@ -46,6 +45,8 @@ CONSTRUCT { ?spatialRegionPolygon aoprop:geoPoint ?geoPoint . ?geoPoint aoprop:lat ?lat . ?geoPoint aoprop:lon ?lon . +%record aoprop:spatialRegionWKTPolygon ?spatialRegionWKTPolygon . +?spatialRegionWKTPolygon aoprop:wkt ?wkt . %record aoprop:temporal ?temporal . ?temporal aoprop:periodOName ?temporalPeriodName . ?temporal aoprop:from ?temporalFrom . @@ -163,10 +164,6 @@ where { where { %record aocat:has_spatial_coverage ?spatialRegion . ?spatialRegion aocat:has_place_name ?spatialPlaceName . - optional { - %record aocat:has_spatial_coverage ?spatialRegion . - ?spatialRegion aocat:has_coordinate_system ?spatialCoordinateSystem . - } optional { %record aocat:has_spatial_coverage ?spatialRegionPoint . ?spatialRegionPoint aocat:has_latitude ?spatialLocationLat ; @@ -185,6 +182,13 @@ where { ?geoPoint aocat:has_latitude ?lat . ?geoPoint aocat:has_longitude ?lon . } + optional { + %record aocat:has_spatial_coverage ?spatialRegionWKTPolygon . + ?spatialRegionWKTPolygon rdf:type aocat:AO_Spatial_Region_Polygon . + ?spatialRegionWKTPolygon aocat:has_polygonal_representation ?wkt . + filter (datatype(?wkt) = rdf:XMLLiteral) + filter (!isIRI(?wkt)) + } } } } diff --git a/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/GraphDbReaderAndESIndexTest.java b/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/GraphDbReaderAndESIndexTest.java index 1fdc621..d721238 100644 --- a/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/GraphDbReaderAndESIndexTest.java +++ b/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/GraphDbReaderAndESIndexTest.java @@ -72,6 +72,7 @@ public class GraphDbReaderAndESIndexTest { } @Test +// @Ignore public void uploadADSRecordTest() throws Exception { boolean isRecord = true; String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/34E3811A-0BAD-3832-B3A0-3139E8A0285C"; @@ -161,6 +162,7 @@ public class GraphDbReaderAndESIndexTest { } @Test +// @Ignore public void uploadDansTemporalPolygonTest() throws Exception { boolean isRecord = true; String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/D4E12349-E214-3F3F-BEE4-D39D9138916B"; @@ -219,6 +221,26 @@ public class GraphDbReaderAndESIndexTest { readAndIndexTest(isRecord, recordId, datasource, collectionId); } + @Test +// @Ignore + public void uploadFastiMultipleAriadneSubjectTest() throws Exception { + boolean isRecord = true; + String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/FASTIONLINE/FE740BC7-2D9E-3644-A88E-3E8E5A5EA95F"; + String datasource = "fasti"; + String collectionId = "fieldwork"; + readAndIndexTest(isRecord, recordId, datasource, collectionId); + } + + @Test +// @Ignore + public void uploadSNDArchivePolygonTest() throws Exception { + boolean isRecord = false; + String recordId = "https://ariadne-infrastructure.eu/aocat/Collection/A7A2588A-1FE7-3FDD-AD66-C84EACE1860E"; + String datasource = "snd"; + String collectionId = "zip"; + readAndIndexTest(isRecord, recordId, datasource, collectionId); + } + private void readAndIndexTest(boolean isRecord, String recordId, String datasource, String collectionId) throws Exception { final ClassPathResource resource = new ClassPathResource("application.properties"); Properties appProps = new Properties();