Expose hapi-fhir-storage-cr config to downstream modules for testing (#6272)
* Ensure IRepositoryFactory returns a Repository, and not a HapiFhirRepository. * Rename test so that it will run from Maven and the pipeline since it didn't before. Fix small bug that made the test error out. * Move TestCrConfig and TestCrR4Config to main source folder. Extract TestHapiFhirCrPartitionConfig as separate test config to be used only in the test source folder. Add Maven compile dependency to hapi-fhir-jpaserver-base in order to ensure that moved Config classes will compile. * Add possible code change to RequestDetailsClone to clone partition info. * Introduce separate factory interface for Repository to preserve backward compatibility. * Remove IRepositoryFactoryForInterface. * Spotless * Add javadoc. * Get rid of TODO. * Restore RepositoryConfig to master. * Move test config to different packages. * Leverage use of new RepositoryFactoryForRepositoryInterface for CrR4Config and RepositoryFactoryForRepositoryInterface. * Ensure CrR4Config and RepositoryConfig make use of new RepositoryFactoryForRepositoryInterface. * Add copyright header * Add @FunctionalInterface to factory.
This commit is contained in:
parent
1fad912193
commit
fb93c3d601
|
@ -145,6 +145,20 @@
|
|||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- For test CR config that's exported to downstream modules -->
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-jpaserver-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<!-- prevent conflict with other version of this dependency sourced from elsewhere -->
|
||||
<exclusion>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.json</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
|
|
|
@ -21,8 +21,10 @@ package ca.uhn.fhir.cr.common;
|
|||
|
||||
import ca.uhn.fhir.cr.repo.HapiFhirRepository;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import com.google.common.annotations.Beta;
|
||||
|
||||
@FunctionalInterface
|
||||
@Beta
|
||||
public interface IRepositoryFactory {
|
||||
HapiFhirRepository create(RequestDetails theRequestDetails);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Clinical Reasoning
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.fhir.cr.common;
|
||||
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import org.opencds.cqf.fhir.api.Repository;
|
||||
|
||||
/**
|
||||
* Factory interface to return a {@link Repository} from a {@link RequestDetails}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RepositoryFactoryForRepositoryInterface {
|
||||
Repository create(RequestDetails theRequestDetails);
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
package ca.uhn.fhir.cr.config;
|
||||
|
||||
import ca.uhn.fhir.cr.common.IRepositoryFactory;
|
||||
import ca.uhn.fhir.cr.common.RepositoryFactoryForRepositoryInterface;
|
||||
import ca.uhn.fhir.cr.repo.HapiFhirRepository;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
@ -28,8 +29,15 @@ import org.springframework.context.annotation.Configuration;
|
|||
|
||||
@Configuration
|
||||
public class RepositoryConfig {
|
||||
|
||||
@Bean
|
||||
IRepositoryFactory repositoryFactory(DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) {
|
||||
return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer);
|
||||
}
|
||||
|
||||
@Bean
|
||||
RepositoryFactoryForRepositoryInterface repositoryFactoryForInterface(
|
||||
DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) {
|
||||
return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.cr.config.r4;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.cr.common.IRepositoryFactory;
|
||||
import ca.uhn.fhir.cr.common.RepositoryFactoryForRepositoryInterface;
|
||||
import ca.uhn.fhir.cr.config.ProviderLoader;
|
||||
import ca.uhn.fhir.cr.config.ProviderSelector;
|
||||
import ca.uhn.fhir.cr.config.RepositoryConfig;
|
||||
|
@ -66,7 +67,8 @@ public class CrR4Config {
|
|||
|
||||
@Bean
|
||||
IMeasureServiceFactory r4MeasureServiceFactory(
|
||||
IRepositoryFactory theRepositoryFactory, MeasureEvaluationOptions theEvaluationOptions) {
|
||||
RepositoryFactoryForRepositoryInterface theRepositoryFactory,
|
||||
MeasureEvaluationOptions theEvaluationOptions) {
|
||||
return rd -> new R4MeasureService(theRepositoryFactory.create(rd), theEvaluationOptions);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,23 @@
|
|||
package ca.uhn.fhir.cr;
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Clinical Reasoning
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.fhir.cr.config.test;
|
||||
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerException;
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
|
||||
|
@ -7,7 +26,9 @@ import org.cqframework.cql.cql2elm.LibraryBuilder;
|
|||
import org.opencds.cqf.fhir.cql.CqlEngineOptions;
|
||||
import org.opencds.cqf.fhir.cql.CqlOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Common CQL properties shared with downstream modules.
|
||||
*/
|
||||
public class TestCqlProperties {
|
||||
|
||||
//cql settings
|
|
@ -1,4 +1,23 @@
|
|||
package ca.uhn.fhir.cr;
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Clinical Reasoning
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.fhir.cr.config.test;
|
||||
|
||||
import ca.uhn.fhir.batch2.jobs.reindex.ReindexProvider;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -47,6 +66,9 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Common hapi-fhir clinical reasoning config shared with downstream modules.
|
||||
*/
|
||||
@Configuration
|
||||
@Import({SubscriptionSubmitterConfig.class, SubscriptionChannelConfig.class})
|
||||
public class TestCrConfig {
|
||||
|
@ -77,7 +99,9 @@ public class TestCrConfig {
|
|||
}
|
||||
@Bean
|
||||
public TestCqlProperties testCqlProperties(){
|
||||
return new TestCqlProperties();}
|
||||
return new TestCqlProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JpaStorageSettings storageSettings() {
|
||||
JpaStorageSettings storageSettings = new JpaStorageSettings();
|
||||
|
@ -87,12 +111,6 @@ public class TestCrConfig {
|
|||
storageSettings.setResourceClientIdStrategy(JpaStorageSettings.ClientIdStrategyEnum.ANY);
|
||||
return storageSettings;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PartitionHelper partitionHelper() {
|
||||
return new PartitionHelper();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ModelManager modelManager(Map<ModelIdentifier, Model> theGlobalModelCache) {
|
||||
return new ModelManager(theGlobalModelCache);
|
|
@ -1,9 +1,28 @@
|
|||
package ca.uhn.fhir.cr.r4;
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Clinical Reasoning
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.fhir.cr.config.test.r4;
|
||||
|
||||
import ca.uhn.fhir.cr.TestCqlProperties;
|
||||
import ca.uhn.fhir.cr.TestCrConfig;
|
||||
import ca.uhn.fhir.cr.common.CqlThreadFactory;
|
||||
import ca.uhn.fhir.cr.config.r4.CrR4Config;
|
||||
import ca.uhn.fhir.cr.config.test.TestCqlProperties;
|
||||
import ca.uhn.fhir.cr.config.test.TestCrConfig;
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
|
||||
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
|
||||
import org.cqframework.cql.cql2elm.model.Model;
|
||||
|
@ -30,6 +49,9 @@ import java.util.Set;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Common hapi-fhir clinical reasoning config specifically for R4 shared with downstream modules.
|
||||
*/
|
||||
@Configuration
|
||||
@Import({TestCrConfig.class, CrR4Config.class})
|
||||
public class TestCrR4Config {
|
|
@ -0,0 +1,10 @@
|
|||
package ca.uhn.fhir.cr;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
public class TestHapiFhirCrPartitionConfig {
|
||||
@Bean
|
||||
public PartitionHelper partitionHelper() {
|
||||
return new PartitionHelper();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package ca.uhn.fhir.cr.dstu3;
|
||||
|
||||
import ca.uhn.fhir.cr.TestCqlProperties;
|
||||
import ca.uhn.fhir.cr.TestCrConfig;
|
||||
import ca.uhn.fhir.cr.TestHapiFhirCrPartitionConfig;
|
||||
import ca.uhn.fhir.cr.config.test.TestCqlProperties;
|
||||
import ca.uhn.fhir.cr.config.dstu3.CrDstu3Config;
|
||||
import ca.uhn.fhir.cr.config.test.TestCrConfig;
|
||||
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
|
||||
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
|
||||
import org.cqframework.cql.cql2elm.model.Model;
|
||||
|
@ -26,6 +27,7 @@ import java.util.Set;
|
|||
|
||||
@Configuration
|
||||
@Import({
|
||||
TestHapiFhirCrPartitionConfig.class,
|
||||
TestCrConfig.class,
|
||||
CrDstu3Config.class
|
||||
})
|
||||
|
|
|
@ -2,10 +2,12 @@ package ca.uhn.fhir.cr.r4;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.cr.IResourceLoader;
|
||||
import ca.uhn.fhir.cr.TestHapiFhirCrPartitionConfig;
|
||||
import ca.uhn.fhir.cr.config.r4.ApplyOperationConfig;
|
||||
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.cr.config.test.r4.TestCrR4Config;
|
||||
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
|
@ -38,6 +40,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
|
||||
@ContextConfiguration(classes = {
|
||||
TestHapiFhirCrPartitionConfig.class,
|
||||
TestCrR4Config.class,
|
||||
ApplyOperationConfig.class,
|
||||
ExtractOperationConfig.class,
|
||||
|
|
Loading…
Reference in New Issue