From df4e62cfccd4b9f73dc452fb2da2b6290f868685 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Fri, 30 Sep 2022 16:21:55 +0200 Subject: [PATCH] Bugfix relation management --- .../geoportal/service/engine/mongo/ProfiledMongoManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java index a2d9fff..9ed6dd1 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java @@ -339,13 +339,16 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI< Project toUpdate=lock(id,"Delete Relation"); try{ + // SET target UCD to present UCD as default + final String toUseTargetUCD = (targetUCD == null || targetUCD.equals(""))? getUseCaseDescriptor().getId():targetUCD; + // check if relation existing List relations = toUpdate.getRelationships(); if(relations!=null && !relations.isEmpty()){ int beforeSize = relations.size(); toUpdate.getRelationships().removeIf(r -> r.getRelationshipName().equals(relation)&& - r.getTargetUCD().equals(targetUCD)&& + r.getTargetUCD().equals(toUseTargetUCD)&& r.getTargetID().equals(targetId)); // update only if something changed if(toUpdate.getRelationships().size()!=beforeSize) {