From 3cb8209554c88c9ec952f6eaadf56115540215ae Mon Sep 17 00:00:00 2001 From: Daniel Hornung <d.hornung@indiscale.com> Date: Fri, 18 Jun 2021 14:46:29 +0200 Subject: [PATCH] FIX: Added an additional check for ID > 0 --- src/main/java/org/caosdb/server/jobs/Job.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/caosdb/server/jobs/Job.java b/src/main/java/org/caosdb/server/jobs/Job.java index f54cfa41..cc943fbd 100644 --- a/src/main/java/org/caosdb/server/jobs/Job.java +++ b/src/main/java/org/caosdb/server/jobs/Job.java @@ -561,25 +561,24 @@ public abstract class Job { */ protected EntityInterface resolve(final EntityInterface entity) throws EntityWasNotUniqueException { - EntityInterface resolvedParent = null; - // if the parent has an id>0, it is to be a valid entity. + EntityInterface resolvedEntity = null; if (!entity.hasId() && entity.hasName()) { - resolvedParent = getEntityByName(entity.getName()); - if (resolvedParent == null) { + resolvedEntity = getEntityByName(entity.getName()); + if (resolvedEntity == null) { final Integer eid = retrieveValidIDByName(entity.getName()); entity.setId(eid); } } if (entity.hasId()) { - // get parent from container - resolvedParent = getEntityById(entity.getId()); - if (resolvedParent == null) { - resolvedParent = retrieveValidEntity(entity.getId()); + // get entity from container + resolvedEntity = getEntityById(entity.getId()); + if (resolvedEntity == null && entity.getId() > 0) { + resolvedEntity = retrieveValidEntity(entity.getId()); } } - return resolvedParent; + return resolvedEntity; } /** -- GitLab