From b49c1c1e2121790dc64aa738467685c041ae97fc Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 5 Oct 2022 14:43:16 +0200 Subject: [PATCH] #23834 Integrated with the create/view/delete Relationship facility --- CHANGELOG.md | 1 + .../geoportal/ProjectsCaller.java | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49915e7..0123df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#23909] Declared lombok required for JDK_11 - [#23913] Integrated with GUI presentation configurations read from IS - [#23927] Integrated with Relationship definition in UCD +- [#23834] Integrated with the create/view/delete Relationship facility ## [v1.4.0] - 2022-06-08 diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java index 3902c63..afe728d 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java @@ -19,6 +19,7 @@ import org.gcube.application.geoportal.common.model.configuration.Archive; import org.gcube.application.geoportal.common.model.configuration.Configuration; import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.rest.CreateRelationshipRequest; +import org.gcube.application.geoportal.common.model.rest.DeleteRelationshipRequest; import org.gcube.application.geoportal.common.model.rest.QueryRequest; import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest; import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest.Direction; @@ -324,30 +325,53 @@ public class ProjectsCaller { return client.updateDocument(projectID, updatedDocument); } - /** * Creates the relationship. * - * @param fromProfileID the from profile ID - * @param fromProjectID the from project ID + * @param fromProfileID the from profile ID + * @param fromProjectID the from project ID * @param relationshipName the relationship name - * @param toProfileID the to profile ID - * @param toProjectID the to project ID + * @param toProfileID the to profile ID + * @param toProjectID the to project ID * @throws RemoteException the remote exception */ - public void createRelationship(String fromProfileID, String fromProjectID, String relationshipName, + public void createRelationship(String fromProfileID, String fromProjectID, String relationshipId, String toProfileID, String toProjectID) throws RemoteException { LOG.info("createRelationship called for fromProfileID {} and fromProjectID {}", fromProfileID, fromProjectID); - LOG.info("create relationshipName {}", relationshipName); + LOG.info("create relationshipName {}", relationshipId); LOG.info("to toProfileID {} and toProjectID {}", toProfileID, toProjectID); Projects client = (Projects) getClient(fromProfileID); - - CreateRelationshipRequest request = new CreateRelationshipRequest(fromProjectID, relationshipName, toProjectID, toProfileID); + + CreateRelationshipRequest request = new CreateRelationshipRequest(fromProjectID, relationshipId, toProjectID, + toProfileID); client.setRelation(request); - + return; } + /** + * Delete relationship. + * + * @param fromProfileID the from profile ID + * @param fromProjectID the from project ID + * @param relationshipId the relationship id + * @param toProfileID the to profile ID + * @param toProjectID the to project ID + * @throws RemoteException the remote exception + */ + public void deleteRelationship(String fromProfileID, String fromProjectID, String relationshipId, + String toProfileID, String toProjectID) throws RemoteException { + LOG.info("deleteRelationship called for fromProfileID {} and fromProjectID {}", fromProfileID, fromProjectID); + LOG.info("deleteRelationship relationshipName {}", relationshipId); + LOG.info("to toProfileID {} and toProjectID {}", toProfileID, toProjectID); + + Projects client = (Projects) getClient(fromProfileID); + + DeleteRelationshipRequest request = new DeleteRelationshipRequest(fromProjectID, relationshipId, toProjectID, + toProfileID); + client.deleteRelation(request); + } + /** * Query on mongo. *