diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java index fa2dfdb18..32f1c52c2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseEntityCrudService.java @@ -5,6 +5,7 @@ import java.util.Map; import org.alliancegenome.curation_api.auth.AuthenticatedUser; +import org.alliancegenome.curation_api.dao.PersonDAO; import org.alliancegenome.curation_api.dao.base.BaseEntityDAO; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.exceptions.ApiErrorException; @@ -31,7 +32,8 @@ protected void setSQLDao(BaseSQLDAO dao) { @Inject @AuthenticatedUser protected Person authenticatedPerson; @Inject PersonService personService; - + @Inject PersonDAO personDAO; + protected abstract void init(); @Transactional @@ -156,11 +158,11 @@ public E deprecateOrDelete(Long id, Boolean throwApiError, String requestSource, if (deprecate) { if (!object.getObsolete()) { object.setObsolete(true); - if (authenticatedPerson.getId() != null) { - object.setUpdatedBy(authenticatedPerson); - } else { - object.setUpdatedBy(personService.fetchByUniqueIdOrCreate(requestSource)); + if (authenticatedPerson.getUniqueId() != null) { + requestSource = authenticatedPerson.getUniqueId(); } + Person updatedBy = personService.fetchByUniqueIdOrCreate(requestSource); + object.setUpdatedBy(updatedBy); object.setDateUpdated(OffsetDateTime.now()); return dao.persist(object); } else {