From a77896ff2d5a9e7aba5cbb97ed35c09cbcf6a218 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 26 Jun 2018 07:54:21 -0400 Subject: [PATCH] Add callback for resource deletion --- .../java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index 7b7bd441049..e5eca6dee30 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -1482,6 +1482,15 @@ public abstract class BaseHapiFhirDao implements IDao, // nothing } + /** + * Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database + * + * @param theEntity The resource + */ + protected void postDelete(ResourceTable theEntity) { + // nothing + } + /** * Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database * @@ -2027,6 +2036,10 @@ public abstract class BaseHapiFhirDao implements IDao, postPersist(theEntity, (T) theResource); + } else if (theEntity.getDeleted() != null) { + + postDelete(theEntity); + } else { theEntity = myEntityManager.merge(theEntity);