diff --git a/pom.xml b/pom.xml
index 0e272c5..c9c0fe2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 3.8.0
+ 4.0.0-SNAPSHOT
ca.uhn.hapi.fhir.demo
diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java
index d15c840..3cb3ebb 100644
--- a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java
+++ b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java
@@ -25,6 +25,7 @@ public class HapiProperties {
static final String DEFAULT_PRETTY_PRINT = "default_pretty_print";
static final String ETAG_SUPPORT = "etag_support";
static final String FHIR_VERSION = "fhir_version";
+ static final String ALLOW_CASCADING_DELETES = "allow_cascading_deletes";
static final String HAPI_PROPERTIES = "hapi.properties";
static final String LOGGER_ERROR_FORMAT = "logger.error_format";
static final String LOGGER_FORMAT = "logger.format";
@@ -239,6 +240,10 @@ public class HapiProperties {
return HapiProperties.getBooleanProperty(ALLOW_MULTIPLE_DELETE, false);
}
+ public static Boolean getAllowCascadingDeletes() {
+ return HapiProperties.getBooleanProperty(ALLOW_CASCADING_DELETES, false);
+ }
+
public static Boolean getAllowExternalReferences() {
return HapiProperties.getBooleanProperty(ALLOW_EXTERNAL_REFERENCES, false);
}
diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java
index 4a8a835..512b184 100644
--- a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java
+++ b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java
@@ -2,9 +2,12 @@ package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
+import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.dao.DaoRegistry;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
+import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
@@ -218,6 +221,14 @@ public class JpaRestfulServer extends RestfulServer {
interceptorService.registerInterceptor(new SubscriptionDebugLogInterceptor());
}
+ // Cascading deletes
+ DaoRegistry daoRegistry = appCtx.getBean(DaoRegistry.class);
+ IInterceptorBroadcaster interceptorBroadcaster = appCtx.getBean(IInterceptorBroadcaster.class);
+ if (HapiProperties.getAllowCascadingDeletes()) {
+ CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(daoRegistry, interceptorBroadcaster);
+ getInterceptorService().registerInterceptor(cascadingDeleteInterceptor);
+ }
+
}
}
diff --git a/src/main/resources/hapi.properties b/src/main/resources/hapi.properties
index 99e6a9a..f2e1888 100644
--- a/src/main/resources/hapi.properties
+++ b/src/main/resources/hapi.properties
@@ -23,6 +23,7 @@ allow_override_default_search_params=true
allow_contains_searches=true
allow_multiple_delete=true
allow_external_references=true
+allow_cascading_deletes=true
allow_placeholder_references=true
expunge_enabled=true
persistence_unit_name=HAPI_PU