From d6521900b52ff0c5c6e3cee071c6a82d58a4ef3a Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Mon, 11 Apr 2022 17:23:27 +0200 Subject: [PATCH] Identification References --- .../SimpleLifeCycleManager.java | 2 +- .../reports/DocumentHandlingReport.java | 18 +++++-- .../plugins/reports/IndexDocumentReport.java | 23 +++++---- .../plugins/reports/StepExecutionReport.java | 2 - .../common/model/document/Project.java | 31 +++++++----- .../common/model/document/Relationship.java | 3 ++ .../CentroidRecordReference.java | 7 +++ .../IdentificationReference.java | 22 +++++++++ .../identification/SpatialReference.java | 24 +++++++++ .../identification/TemporalReference.java | 10 ++++ .../document/temporal/TemporalReference.java | 14 ------ .../ProfiledConcessioniTests.java | 5 +- .../cms/sdi/plugins/SDIIndexerPlugin.java | 49 +++++++++++-------- .../cms/sdi/plugins/IndexerTest.java | 3 +- .../profiledDocuments/profiles/mosi.json | 41 ++++++++++++++++ 15 files changed, 187 insertions(+), 67 deletions(-) create mode 100644 geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/CentroidRecordReference.java create mode 100644 geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/IdentificationReference.java create mode 100644 geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/SpatialReference.java create mode 100644 geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/TemporalReference.java delete mode 100644 geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/temporal/TemporalReference.java create mode 100644 test-data/profiledDocuments/profiles/mosi.json diff --git a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java index 66993c6..d356940 100644 --- a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java +++ b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java @@ -228,7 +228,7 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements case OK : { info.setLastOperationStatus(LifecycleInformation.Status.OK); if(toHandle instanceof IndexDocumentReport) - toUpdate.setToSetSpatialReference(((IndexDocumentReport)toHandle).getToSetSpatialReference()); + toUpdate.setToSetIdentificationReferences(((IndexDocumentReport)toHandle).getToSetIdentificationReferences()); // Propagate changes for further processings toUpdate.getTheRequest().getDocument().setTheDocument(toHandle.getResultingDocument()); toUpdate.setToSetLifecycleInformation(toHandle.getToSetLifecycleInformation()); diff --git a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/DocumentHandlingReport.java b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/DocumentHandlingReport.java index e9e175a..45e0499 100644 --- a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/DocumentHandlingReport.java +++ b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/DocumentHandlingReport.java @@ -9,8 +9,12 @@ import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException; import org.gcube.application.cms.plugins.faults.PluginExecutionException; import org.gcube.application.cms.plugins.requests.BaseExecutionRequest; import org.gcube.application.geoportal.common.model.document.Project; +import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference; import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; -import org.gcube.application.geoportal.common.model.document.temporal.TemporalReference; +import org.gcube.application.geoportal.common.model.document.identification.TemporalReference; + +import java.util.ArrayList; +import java.util.List; @Data @@ -23,9 +27,13 @@ public class DocumentHandlingReport extends Repo Document resultingDocument; LifecycleInformation toSetLifecycleInformation; + protected List toSetIdentificationReferences=null; - TemporalReference toSetTemporalReference; - Document toSetSpatialReference; + public DocumentHandlingReport addIdentificationReference(IdentificationReference toAdd){ + if(toSetIdentificationReferences == null) toSetIdentificationReferences = new ArrayList<>(); + toSetIdentificationReferences.add(toAdd); + return this; + } public DocumentHandlingReport(@NonNull T theRequest) throws InvalidPluginRequestException { @@ -77,8 +85,8 @@ public class DocumentHandlingReport extends Repo break; } } - if(toSetSpatialReference != null) toReturn.setSpatialReference(toSetSpatialReference); - if(toSetTemporalReference != null) toReturn.setTemporalReference(toSetTemporalReference); + if(toSetIdentificationReferences!=null) + toReturn.setIdentificationReferences(toSetIdentificationReferences); return toReturn; } } diff --git a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/IndexDocumentReport.java b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/IndexDocumentReport.java index 9366231..04019f7 100644 --- a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/IndexDocumentReport.java +++ b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/IndexDocumentReport.java @@ -9,25 +9,28 @@ import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException; import org.gcube.application.cms.plugins.faults.PluginExecutionException; import org.gcube.application.cms.plugins.requests.IndexDocumentRequest; import org.gcube.application.geoportal.common.model.document.Project; -import org.gcube.application.geoportal.common.model.document.temporal.TemporalReference; +import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference; +import org.gcube.application.geoportal.common.model.document.identification.TemporalReference; + +import java.util.ArrayList; +import java.util.List; @Getter @Setter public class IndexDocumentReport extends DocumentHandlingReport { - public TemporalReference toSetTemporalReference; - public Document toSetSpatialReference; +// protected List toSetIndexReferences=new ArrayList<>(); public IndexDocumentReport(@NonNull IndexDocumentRequest theRequest) throws InvalidPluginRequestException { super(theRequest); } - @Override - public Project prepareResult() throws JsonProcessingException, PluginExecutionException { - Project toReturn= super.prepareResult(); - if(toSetSpatialReference != null) toReturn.setSpatialReference(toSetSpatialReference); - if(toSetTemporalReference != null) toReturn.setTemporalReference(toSetTemporalReference); - return toReturn; - } +// @Override +// public Project prepareResult() throws JsonProcessingException, PluginExecutionException { +// Project toReturn= super.prepareResult(); +// if(toSetSpatialReference != null) toReturn.setSpatialReference(toSetSpatialReference); +// if(toSetTemporalReference != null) toReturn.setTemporalReference(toSetTemporalReference); +// return toReturn; +// } } diff --git a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/StepExecutionReport.java b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/StepExecutionReport.java index 3cd1931..3c84bb9 100644 --- a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/StepExecutionReport.java +++ b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/StepExecutionReport.java @@ -2,13 +2,11 @@ package org.gcube.application.cms.plugins.reports; import com.fasterxml.jackson.core.JsonProcessingException; import lombok.*; -import org.bson.Document; import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException; import org.gcube.application.cms.plugins.faults.PluginExecutionException; import org.gcube.application.cms.plugins.requests.EventExecutionRequest; import org.gcube.application.cms.plugins.requests.StepExecutionRequest; import org.gcube.application.geoportal.common.model.document.Project; -import org.gcube.application.geoportal.common.model.document.temporal.TemporalReference; import java.util.ArrayList; import java.util.List; diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Project.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Project.java index bad242c..b9e5092 100644 --- a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Project.java +++ b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Project.java @@ -1,15 +1,18 @@ package org.gcube.application.geoportal.common.model.document; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.vdurmont.semver4j.Semver; import lombok.*; import org.bson.Document; import org.gcube.application.geoportal.common.model.document.accounting.PublicationInfo; +import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference; import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; -import org.gcube.application.geoportal.common.model.document.temporal.TemporalReference; -import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; @NoArgsConstructor @@ -26,8 +29,7 @@ public class Project { public static final String PROFILE_VERSION="_profileVersion"; public static final String LIFECYCLE_INFORMATION="_lifecycleInformation"; public static final String RELATIONSHIPS="_relationships"; - public static final String SPATIAL_REFERENCE="_spatialReference"; - public static final String TEMPORAL_REFERENCE="_temporalReference"; + public static final String IDENTIFICATION_REFERENCES="_identificationReferences"; public static final String THE_DOCUMENT="_theDocument"; public static final String LOCK="_lock"; @@ -52,14 +54,10 @@ public class Project { private LifecycleInformation lifecycleInformation; @JsonProperty(RELATIONSHIPS) - private Relationship[] relationships; + private List relationships; - // Expected GEOJSON - @JsonProperty(SPATIAL_REFERENCE) - private Document spatialReference; - - @JsonProperty(TEMPORAL_REFERENCE) - private TemporalReference temporalReference; + @JsonProperty(IDENTIFICATION_REFERENCES) + private List identificationReferences; @JsonProperty(THE_DOCUMENT) private Document theDocument; @@ -79,6 +77,15 @@ public class Project { if (this == o) return true; if (!(o instanceof Project)) return false; Project project = (Project) o; - return Objects.equals(getId(), project.getId()) && Objects.equals(getVersion(), project.getVersion()) && Objects.equals(getInfo(), project.getInfo()) && Objects.equals(getProfileID(), project.getProfileID()) && Objects.equals(getProfileVersion(), project.getProfileVersion()) && Objects.equals(getLifecycleInformation(), project.getLifecycleInformation()) && Arrays.equals(getRelationships(), project.getRelationships()) && Objects.equals(getSpatialReference(), project.getSpatialReference()) && Objects.equals(getTemporalReference(), project.getTemporalReference()) && Objects.equals(getTheDocument(), project.getTheDocument()); + return Objects.equals(getId(), project.getId()) && Objects.equals(getVersion(), project.getVersion()) && Objects.equals(getInfo(), project.getInfo()) && Objects.equals(getProfileID(), project.getProfileID()) && Objects.equals(getProfileVersion(), project.getProfileVersion()) && Objects.equals(getLifecycleInformation(), project.getLifecycleInformation()) && Objects.equals(getIdentificationReferences(), project.getIdentificationReferences()) && Objects.equals(getRelationships(), project.getRelationships()) && Objects.equals(getTheDocument(), project.getTheDocument()); } + + + @JsonIgnore + public List getIdentificationReferenceByType(String type){ + if(identificationReferences==null) return Collections.emptyList(); + else return identificationReferences.stream() + .filter(item -> item.getType().equals(type)).collect(Collectors.toList()); + }; + } diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Relationship.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Relationship.java index 688e30d..1e4f0cb 100644 --- a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Relationship.java +++ b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/Relationship.java @@ -12,10 +12,13 @@ public class Relationship { public static final String RELATIONSHIP_NAME="_relationshipName"; public static final String TARGET_ID="_targetID"; + public static final String TARGET_UCD="_targetUCD"; @JsonProperty(RELATIONSHIP_NAME) private String relationshipName; @JsonProperty(TARGET_ID) private String targetID; + @JsonProperty(TARGET_ID) + private String targetUCD; } diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/CentroidRecordReference.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/CentroidRecordReference.java new file mode 100644 index 0000000..88a0e9b --- /dev/null +++ b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/CentroidRecordReference.java @@ -0,0 +1,7 @@ +package org.gcube.application.geoportal.common.model.document.identification; + +public class CentroidRecordReference extends IdentificationReference{ + + public static final String CENTROID_RECORD_REFERENCE="CENTROID_RECORD_TYPE"; + +} diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/IdentificationReference.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/IdentificationReference.java new file mode 100644 index 0000000..29f91bf --- /dev/null +++ b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/IdentificationReference.java @@ -0,0 +1,22 @@ +package org.gcube.application.geoportal.common.model.document.identification; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.bson.Document; + +@ToString(callSuper = true) +@NoArgsConstructor +public class IdentificationReference extends Document { + + public static final String TYPE="_type"; + + public IdentificationReference(String type) { + setType(type); + } + + @JsonIgnore + public String getType(){return super.getString(TYPE);} + @JsonIgnore + public void setType(String type){super.put(TYPE,type);} +} diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/SpatialReference.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/SpatialReference.java new file mode 100644 index 0000000..9ec1d99 --- /dev/null +++ b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/SpatialReference.java @@ -0,0 +1,24 @@ +package org.gcube.application.geoportal.common.model.document.identification; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@NoArgsConstructor +@ToString(callSuper = true) +public class SpatialReference extends IdentificationReference{ + + public static final String SPATIAL_REFERENCE_TYPE="SPATIAL REFERENCE"; + public static final String GEO_JSON="geoJSON"; + + + public SpatialReference(Object geoJSON) { + setGeoJson(geoJSON); + setType(SPATIAL_REFERENCE_TYPE); + } + + @JsonIgnore + public Object getGeoJson(){return super.get(GEO_JSON);} + @JsonIgnore + public Object setGeoJson(Object geoJSON){return super.put(GEO_JSON,geoJSON);} +} diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/TemporalReference.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/TemporalReference.java new file mode 100644 index 0000000..34e0580 --- /dev/null +++ b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/identification/TemporalReference.java @@ -0,0 +1,10 @@ +package org.gcube.application.geoportal.common.model.document.identification; + +import lombok.*; +import org.bson.Document; + +@ToString (callSuper = true) +public class TemporalReference extends IdentificationReference { + + public static final String TEMPORAL_REFERENCE_TYPE="TEMPORAL_REFERENCE_TYPE"; +} diff --git a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/temporal/TemporalReference.java b/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/temporal/TemporalReference.java deleted file mode 100644 index 4e0c763..0000000 --- a/geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/temporal/TemporalReference.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.gcube.application.geoportal.common.model.document.temporal; - -import lombok.*; -import org.bson.Document; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@ToString -public class TemporalReference extends Document { - - private String field; -} diff --git a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/profiledDocuments/ProfiledConcessioniTests.java b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/profiledDocuments/ProfiledConcessioniTests.java index f5f6529..11b4857 100644 --- a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/profiledDocuments/ProfiledConcessioniTests.java +++ b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/profiledDocuments/ProfiledConcessioniTests.java @@ -3,6 +3,7 @@ package org.gcube.application.geoportal.service.profiledDocuments; import org.bson.Document; import org.gcube.application.cms.serialization.Serialization; import org.gcube.application.geoportal.common.model.document.Project; +import org.gcube.application.geoportal.common.model.document.identification.SpatialReference; import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field; import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest; @@ -67,7 +68,7 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{ doc=step(doc.getId(),approveDraftReq); System.out.println(doc); assertTrue(doc.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)); - assertTrue(doc.getSpatialReference()!=null); - System.out.println("Project "+doc.getId()+" published with spatial reference "+doc.getSpatialReference().toJson()); + assertTrue(doc.getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE).size()==1); + System.out.println("Project "+doc.getId()+" published with spatial reference "+doc.getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE).get(0)); } } diff --git a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java index 39528f2..a29c2b5 100644 --- a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java +++ b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java @@ -10,6 +10,8 @@ import org.gcube.application.cms.plugins.faults.InitializationException; import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException; import org.gcube.application.cms.plugins.faults.InvalidProfileException; import org.gcube.application.cms.plugins.model.ComparableVersion; +import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference; +import org.gcube.application.geoportal.common.model.document.identification.SpatialReference; import org.gcube.application.geoportal.common.model.plugins.IndexerPluginDescriptor; import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor; import org.gcube.application.cms.plugins.reports.IndexDocumentReport; @@ -121,31 +123,38 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin // ********************** EVALAUTE POSITION log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId()); - if(project.getSpatialReference()!=null){ - log.debug("Using user defined spatial reference "+ project.getSpatialReference()); + SpatialReference reference =null; + List refs=project.getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE); + if(!refs.isEmpty()){ - GeoJsonObject object = Serialization.convert(project.getSpatialReference(), GeoJsonObject.class); + // Use existing Reference - GCubeSDILayer.BBOX bbox= GCubeSDILayer.BBOX.fromGeoJSON( object.getBbox()); + reference = Serialization.convert(refs.get(0), SpatialReference.class); - log.info("Found declared BBOX {} ",bbox); - Double pointX=(bbox.getMaxX()-bbox.getMinX()); - Double pointY = bbox.getMaxY()-bbox.getMinY(); - String wkt = String .format("POINT (%1$f %2$f) ", + log.debug("Using user defined spatial reference " + reference); + + GeoJsonObject object = Serialization.convert(reference.getGeoJson(), GeoJsonObject.class); + + GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.fromGeoJSON(object.getBbox()); + + log.info("Found declared BBOX {} ", bbox); + Double pointX = (bbox.getMaxX() - bbox.getMinX()); + Double pointY = bbox.getMaxY() - bbox.getMinY(); + String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY); - centroidDoc.put("geom",wkt); - + centroidDoc.put("geom", wkt); throw new Exception("Not yet implemented"); - }else { + } else{ + // unable to use current Spatial reference, try evaluating it log.debug("UseCaseDescriptor {} : Getting evaluation paths from useCaseDescriptor.. ", useCaseDescriptor.getId()); List bboxEvaluationPaths = profileConfiguration.get("bboxEvaluation",List.class); if(bboxEvaluationPaths==null || bboxEvaluationPaths.isEmpty()) throw new Exception("Missing configuration bboxEvaluation"); - - GCubeSDILayer.BBOX toSet = null; + + GCubeSDILayer.BBOX toSet = null; for(Object pathObj : bboxEvaluationPaths){ log.debug("UseCaseDescriptor {} : Evaluating path {} ", useCaseDescriptor.getId(),pathObj); List bboxObjects = documentNavigator.getByPath(pathObj.toString()); @@ -153,7 +162,7 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin for(Object bboxObject : bboxObjects) { log.info("Matched path {}, value is {} ",pathObj.toString(),bboxObject); GCubeSDILayer.BBOX box = Serialization.convert(bboxObject, GCubeSDILayer.BBOX.class); - + if(toSet == null) toSet = box; if(box.getMaxX()>toSet.getMaxX()) toSet.setMaxX(box.getMaxX()); if(box.getMaxY()>toSet.getMaxY()) toSet.setMaxY(box.getMaxY()); @@ -166,7 +175,6 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin if(toSet == null) throw new IndexingException("No BBOX has been found on paths : "+bboxEvaluationPaths); - Double pointX=(toSet.getMaxX()-toSet.getMinX()); Double pointY = toSet.getMaxY()-toSet.getMinY(); log.info("Evaluated BBOX {} ",toSet); @@ -176,14 +184,15 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin centroidDoc.put("geom",wkt); - Point toSetSpatialReference = new Point(); + Point toSetgeoJSON = new Point(); LngLatAlt pointCoordinates = new LngLatAlt(); pointCoordinates.setLongitude(pointX); pointCoordinates.setLatitude(pointY); - toSetSpatialReference.setCoordinates(pointCoordinates); + toSetgeoJSON.setCoordinates(pointCoordinates); + toSetgeoJSON.setBbox(toSet.asGeoJSONArray()); + reference = new SpatialReference(toSetgeoJSON); - toSetSpatialReference.setBbox(toSet.asGeoJSONArray()); - report.setToSetSpatialReference(Serialization.asDocument(toSetSpatialReference)); + report.addIdentificationReference(reference); } @@ -288,7 +297,7 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin fields.add(new PostgisTable.Field(m.getName(), PostgisTable.FieldType.valueOf(m.getType()))); }); - return fields; + return fields; } diff --git a/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/IndexerTest.java b/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/IndexerTest.java index ee01cd2..b011c40 100644 --- a/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/IndexerTest.java +++ b/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/IndexerTest.java @@ -18,6 +18,7 @@ import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer; import org.gcube.application.geoportal.common.model.document.filesets.Materialization; import org.gcube.application.geoportal.common.model.document.filesets.sdi.GeoServerPlatform; +import org.gcube.application.geoportal.common.model.document.identification.SpatialReference; import org.gcube.application.geoportal.common.model.rest.ConfigurationException; import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; import org.gcube.application.geoportal.common.utils.Files; @@ -50,7 +51,7 @@ public class IndexerTest extends BasicPluginTest { System.out.println("Response is "+Serialization.write(response)); assertTrue(response.getStatus().equals(Report.Status.OK)); - assertTrue(response.prepareResult().getSpatialReference()!=null); + assertTrue(response.prepareResult().getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE).size()==1); } diff --git a/test-data/profiledDocuments/profiles/mosi.json b/test-data/profiledDocuments/profiles/mosi.json new file mode 100644 index 0000000..2bcdb77 --- /dev/null +++ b/test-data/profiledDocuments/profiles/mosi.json @@ -0,0 +1,41 @@ +{ + "_id" : "MOSI", + "_version" : "1.0.0", + "_name" : "GNA : MOSI", + + "_description" : "Modulistica siti", + "_creationInfo": { + "_user" : { + "_username": "fabio.sinibaldi" + } + }, + + "_schema" :{ "title" : {"_min" : 1}, + "section" : { "_max" : 1, "_min" : 1, + "_children" : [ + {"fileset" :{"_type" : "RegisteredFileSet", "_min": 1}}, + {"title" : {"_min" : 1}} + ] + } + }, + "_dataAccessPolicies" : [ + {"_policy" : {"_read" : "own", "_write" : "own"}, "_roles":[]}, + {"_policy" : {"_read" : "any", "_write" : "none"}, "_roles":["Guest"], + "_enforcer": {"_filter" : "{\"_lifecycleInformation._phase\" : {\"$eq\" : \"PUBLISHED\"}}"}}, + {"_policy" : {"_read" : "any", "_write" : "none"}, "_roles":["Editor"]}, + {"_policy" : {"_read" : "any", "_write" : "any"}, "_roles":["Admin"]} + ], + + + "_handlers" : [ + { + "_id" : "DEFAULT-SINGLE-STEP", + "_type" : "LifecycleManagement", + "_configuration" : { + "step_access" : [ + {"STEP" : "PUBLISH", "roles" :[]} + ] + } + } + ] +} \ No newline at end of file