From 0cf1ec8a7e4b4062848d1b6ae99945c72edeb6fa Mon Sep 17 00:00:00 2001 From: Justin McKelvy <60718638+Capt-Mac@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:30:44 -0700 Subject: [PATCH] removed basecr config due to spring errors --- pom.xml | 6 +- .../uhn/fhir/jpa/starter/cr/BaseCrConfig.java | 85 ------------------- .../jpa/starter/cr/StarterCrDstu3Config.java | 59 ++++++++++++- .../jpa/starter/cr/StarterCrR4Config.java | 59 ++++++++++++- .../jpa/starter/ExampleServerDstu3IT.java | 2 +- 5 files changed, 122 insertions(+), 89 deletions(-) delete mode 100644 src/main/java/ca/uhn/fhir/jpa/starter/cr/BaseCrConfig.java diff --git a/pom.xml b/pom.xml index b477e48787b..9549b8cfeaf 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ <parent> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-fhir</artifactId> - <version>6.9.10-SNAPSHOT</version> + <version>6.10.0</version> </parent> <artifactId>hapi-fhir-jpaserver-starter</artifactId> @@ -132,6 +132,10 @@ <artifactId>hapi-fhir-jpaserver-mdm</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + </dependency> <!-- This dependency includes the CDS Hooks Server --> <dependency> <groupId>ca.uhn.hapi.fhir</groupId> diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/cr/BaseCrConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/cr/BaseCrConfig.java deleted file mode 100644 index 04101af9a60..00000000000 --- a/src/main/java/ca/uhn/fhir/jpa/starter/cr/BaseCrConfig.java +++ /dev/null @@ -1,85 +0,0 @@ -package ca.uhn.fhir.jpa.starter.cr; - -import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener; -import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener; -import ca.uhn.fhir.jpa.api.dao.DaoRegistry; -import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry; -import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import org.cqframework.cql.cql2elm.model.CompiledLibrary; -import org.cqframework.cql.cql2elm.model.Model; -import org.hl7.cql.model.ModelIdentifier; -import org.hl7.elm.r1.VersionedIdentifier; -import org.opencds.cqf.cql.engine.runtime.Code; -import org.opencds.cqf.fhir.cql.EvaluationSettings; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@Configuration -public class BaseCrConfig { - @Bean - public CrProperties crProperties() { - return new CrProperties(); - } - - @Bean - public Map<VersionedIdentifier, CompiledLibrary> globalLibraryCache() { - return new ConcurrentHashMap<>(); - } - - @Bean - public Map<ModelIdentifier, Model> globalModelCache() { - return new ConcurrentHashMap<>(); - } - - @Bean - public Map<String, List<Code>> globalValueSetCache() { - return new ConcurrentHashMap<>(); - } - - @Bean - public ElmCacheResourceChangeListener elmCacheResourceChangeListener( - IResourceChangeListenerRegistry theResourceChangeListenerRegistry, - DaoRegistry theDaoRegistry, - EvaluationSettings theEvaluationSettings) { - ElmCacheResourceChangeListener listener = - new ElmCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getLibraryCache()); - theResourceChangeListenerRegistry.registerResourceResourceChangeListener( - "Library", SearchParameterMap.newSynchronous(), listener, 1000); - return listener; - } - - @Bean - public CodeCacheResourceChangeListener codeCacheResourceChangeListener( - IResourceChangeListenerRegistry theResourceChangeListenerRegistry, - EvaluationSettings theEvaluationSettings, - DaoRegistry theDaoRegistry) { - - CodeCacheResourceChangeListener listener = new CodeCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getValueSetCache()); - //registry - theResourceChangeListenerRegistry.registerResourceResourceChangeListener( - "ValueSet", SearchParameterMap.newSynchronous(), listener,1000); - - return listener; - } - - // These beans were being duplicated - // @Bean - // public IResourceChangeListenerRegistry resourceChangeListenerRegistry(InMemoryResourceMatcher theInMemoryResourceMatcher, FhirContext theFhirContext, ResourceChangeListenerCacheFactory theResourceChangeListenerCacheFactory) { - // return new ResourceChangeListenerRegistryImpl(theFhirContext, theResourceChangeListenerCacheFactory, theInMemoryResourceMatcher); - // } - - // @Bean - // IResourceChangeListenerCacheRefresher resourceChangeListenerCacheRefresher() { - // return new ResourceChangeListenerCacheRefresherImpl(); - // } - - @Bean - public ResourceChangeListenerRegistryInterceptor resourceChangeListenerRegistryInterceptor() { - return new ResourceChangeListenerRegistryInterceptor(); - } -} diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrDstu3Config.java b/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrDstu3Config.java index 78bd7fd679b..2ad1e155217 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrDstu3Config.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrDstu3Config.java @@ -1,10 +1,16 @@ package ca.uhn.fhir.jpa.starter.cr; +import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener; +import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener; import ca.uhn.fhir.cr.config.dstu3.ApplyOperationConfig; import ca.uhn.fhir.cr.config.dstu3.CrDstu3Config; import ca.uhn.fhir.cr.config.dstu3.ExtractOperationConfig; import ca.uhn.fhir.cr.config.dstu3.PackageOperationConfig; import ca.uhn.fhir.cr.config.dstu3.PopulateOperationConfig; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; +import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry; +import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.starter.annotations.OnDSTU3Condition; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; @@ -26,11 +32,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; @Configuration @Conditional({ OnDSTU3Condition.class, CrConfigCondition.class }) @Import({ - BaseCrConfig.class, + //BaseCrConfig.class, CrDstu3Config.class, ApplyOperationConfig.class, ExtractOperationConfig.class, @@ -132,4 +139,54 @@ public PostInitProviderRegisterer postInitProviderRegisterer(RestfulServer theRe ResourceProviderFactory theResourceProviderFactory) { return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory);} + @Bean + public CrProperties crProperties() { + return new CrProperties(); + } + + @Bean + public Map<VersionedIdentifier, CompiledLibrary> globalLibraryCache() { + return new ConcurrentHashMap<>(); + } + + @Bean + public Map<ModelIdentifier, Model> globalModelCache() { + return new ConcurrentHashMap<>(); + } + + @Bean + public Map<String, List<Code>> globalValueSetCache() { + return new ConcurrentHashMap<>(); + } + + @Bean + public ElmCacheResourceChangeListener elmCacheResourceChangeListener( + IResourceChangeListenerRegistry theResourceChangeListenerRegistry, + DaoRegistry theDaoRegistry, + EvaluationSettings theEvaluationSettings) { + ElmCacheResourceChangeListener listener = + new ElmCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getLibraryCache()); + theResourceChangeListenerRegistry.registerResourceResourceChangeListener( + "Library", SearchParameterMap.newSynchronous(), listener, 1000); + return listener; + } + + @Bean + public CodeCacheResourceChangeListener codeCacheResourceChangeListener( + IResourceChangeListenerRegistry theResourceChangeListenerRegistry, + EvaluationSettings theEvaluationSettings, + DaoRegistry theDaoRegistry) { + + CodeCacheResourceChangeListener listener = new CodeCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getValueSetCache()); + //registry + theResourceChangeListenerRegistry.registerResourceResourceChangeListener( + "ValueSet", SearchParameterMap.newSynchronous(), listener,1000); + + return listener; + } + + @Bean + public ResourceChangeListenerRegistryInterceptor resourceChangeListenerRegistryInterceptor() { + return new ResourceChangeListenerRegistryInterceptor(); + } } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrR4Config.java b/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrR4Config.java index a562e584ab8..c42f44a9bd9 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrR4Config.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/cr/StarterCrR4Config.java @@ -1,10 +1,16 @@ package ca.uhn.fhir.jpa.starter.cr; +import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener; +import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener; import ca.uhn.fhir.cr.config.r4.ApplyOperationConfig; import ca.uhn.fhir.cr.config.r4.CrR4Config; import ca.uhn.fhir.cr.config.r4.ExtractOperationConfig; import ca.uhn.fhir.cr.config.r4.PackageOperationConfig; import ca.uhn.fhir.cr.config.r4.PopulateOperationConfig; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; +import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry; +import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; @@ -34,13 +40,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @Configuration @Conditional({ OnR4Condition.class, CrConfigCondition.class }) @Import({ - BaseCrConfig.class, CrR4Config.class, ApplyOperationConfig.class, ExtractOperationConfig.class, @@ -163,4 +169,55 @@ public PostInitProviderRegisterer postInitProviderRegisterer(RestfulServer theRe return new PostInitProviderRegisterer(theRestfulServer, theResourceProviderFactory); } + @Bean + public CrProperties crProperties() { + return new CrProperties(); + } + + @Bean + public Map<VersionedIdentifier, CompiledLibrary> globalLibraryCache() { + return new ConcurrentHashMap<>(); + } + + @Bean + public Map<ModelIdentifier, Model> globalModelCache() { + return new ConcurrentHashMap<>(); + } + + @Bean + public Map<String, List<Code>> globalValueSetCache() { + return new ConcurrentHashMap<>(); + } + + @Bean + public ElmCacheResourceChangeListener elmCacheResourceChangeListener( + IResourceChangeListenerRegistry theResourceChangeListenerRegistry, + DaoRegistry theDaoRegistry, + EvaluationSettings theEvaluationSettings) { + ElmCacheResourceChangeListener listener = + new ElmCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getLibraryCache()); + theResourceChangeListenerRegistry.registerResourceResourceChangeListener( + "Library", SearchParameterMap.newSynchronous(), listener, 1000); + return listener; + } + + @Bean + public CodeCacheResourceChangeListener codeCacheResourceChangeListener( + IResourceChangeListenerRegistry theResourceChangeListenerRegistry, + EvaluationSettings theEvaluationSettings, + DaoRegistry theDaoRegistry) { + + CodeCacheResourceChangeListener listener = new CodeCacheResourceChangeListener(theDaoRegistry, theEvaluationSettings.getValueSetCache()); + //registry + theResourceChangeListenerRegistry.registerResourceResourceChangeListener( + "ValueSet", SearchParameterMap.newSynchronous(), listener,1000); + + return listener; + } + + @Bean + public ResourceChangeListenerRegistryInterceptor resourceChangeListenerRegistryInterceptor() { + return new ResourceChangeListenerRegistryInterceptor(); + } + } diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java index a9d7e1d8aa4..636a6ad55ec 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java @@ -42,8 +42,8 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr3", - "hapi.fhir.cr_enabled=true", "hapi.fhir.fhir_version=dstu3", + "hapi.fhir.cr_enabled=true", "hapi.fhir.subscription.websocket_enabled=true", "hapi.fhir.allow_external_references=true", "hapi.fhir.allow_placeholder_references=true",