From fa2e46af791e833c8ffc434330fb2a6d44329f93 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 3 Oct 2022 17:51:29 +0200 Subject: [PATCH] Fixing relationships --- .../ConvertToDataValueObjectModel.java | 5 ++++- .../shared/SearchingFilter.java | 1 + .../geoportal/project/RelationshipDV.java | 18 +++++++++++++++++- .../org/gcube/application/Project_Tests.java | 18 ++++++++++++++++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index cf0d184..0b932e3 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -989,7 +989,10 @@ public class ConvertToDataValueObjectModel { if (relationship == null) return null; - RelationshipDV rDV = new RelationshipDV(relationship.getRelationshipName(), relationship.getTargetID()); + RelationshipDV rDV = new RelationshipDV(); + rDV.setRelationshipName(relationship.getRelationshipName()); + rDV.setTargetID(relationship.getTargetID()); + rDV.setTargetUCD(relationship.getTargetUCD()); String jsonDocument = null; try { diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java b/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java index bf66e33..c01df09 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java @@ -105,6 +105,7 @@ public class SearchingFilter implements Serializable { projection.put("_version", 1); projection.put("_lifecycleInformation", 1); projection.put("_info", 1); + projection.put("_relationships", 1); } } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/project/RelationshipDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/project/RelationshipDV.java index ff2a535..46f99a4 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/project/RelationshipDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/project/RelationshipDV.java @@ -11,14 +11,26 @@ public class RelationshipDV implements Serializable { private String relationshipName; private String targetID; private String asJSON; + private String targetUCD; public RelationshipDV() { } - public RelationshipDV(String relationshipName, String targetID) { + public RelationshipDV(String relationshipName, String targetID, String targetUCD, String asJSON) { + super(); this.relationshipName = relationshipName; this.targetID = targetID; + this.targetUCD = targetUCD; + this.asJSON = asJSON; + } + + public String getTargetUCD() { + return targetUCD; + } + + public void setTargetUCD(String targetUCD) { + this.targetUCD = targetUCD; } public String getTargetID() { @@ -52,6 +64,10 @@ public class RelationshipDV implements Serializable { builder.append(relationshipName); builder.append(", targetID="); builder.append(targetID); + builder.append(", asJSON="); + builder.append(asJSON); + builder.append(", targetUCD="); + builder.append(targetUCD); builder.append("]"); return builder.toString(); } diff --git a/src/test/java/org/gcube/application/Project_Tests.java b/src/test/java/org/gcube/application/Project_Tests.java index 21bd840..f654b40 100644 --- a/src/test/java/org/gcube/application/Project_Tests.java +++ b/src/test/java/org/gcube/application/Project_Tests.java @@ -27,6 +27,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.scope.api.ScopeProvider; import org.junit.Before; +import org.junit.Test; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; @@ -42,9 +43,9 @@ public class Project_Tests { // private static String TOKEN = ""; //preVRE private static String CONTEXT = "/gcube/devsec/devVRE"; - private static String TOKEN = ""; // devVRE + private static String TOKEN = "c41a00c0-7897-48d2-a67a-05190d6ce5e6-98187548"; // devVRE private static String PROFILE_ID = "profiledConcessioni"; - private static String PROJECT_ID = "630f905855e2947b0278c1a8"; + private static String PROJECT_ID = "632c633155e2947b0278c999"; @Before public void getClient() { @@ -89,6 +90,19 @@ public class Project_Tests { } } + + @Test + public void getResultDocumentForID() { + try { + ProjectsCaller projects = GeoportalClientCaller.projects(); + Project project = projects.getProjectByID(PROFILE_ID, PROJECT_ID); + ResultDocumentDV documentDV = ConvertToDataValueObjectModel.toResultDocumentDV(project); + System.out.println("returning: " + documentDV); + + } catch (Exception e) { + e.printStackTrace(); + } + } // @Test public void getListProjectsDVFiltered() throws Exception {