Bugfix relation management

This commit is contained in:
Fabio Sinibaldi 2022-09-30 16:21:55 +02:00
parent 1aa4a43b95
commit df4e62cfcc
1 changed files with 4 additions and 1 deletions

View File

@ -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<Relationship> 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) {