Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ruler to HAPI 6.1.1 and add Batch2 beans #634

Merged
merged 6 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .idea/runConfigurations/Launch_Server__Live_Reload_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"projectName": "cqf-ruler-core",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Dspring.main.lazy-initialization=true",
"-Ddebug=true",
"-Dloader.debug=true",
"-Dhapi.fhir.bulk_export_enabled=false",
Expand All @@ -38,7 +37,6 @@
"projectName": "cqf-ruler-server",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Dspring.main.lazy-initialization=true",
"-Ddebug=true",
"-Dloader.debug=true",
"-Dhapi.fhir.bulk_export_enabled=false",
Expand Down Expand Up @@ -99,7 +97,6 @@
"projectName": "cqf-ruler-server",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Dspring.main.lazy-initialization=true",
"-Ddebug=true",
"-Dloader.debug=true",
"-Dhapi.fhir.fhir_version=DSTU3",
Expand Down
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{
"name": "test-config",
"vmArgs": [
"-XX:TieredStopAtLevel=1",
"-Dspring.main.lazy-initialization=true"
"-XX:TieredStopAtLevel=1"
]
},
],
Expand Down Expand Up @@ -81,5 +80,5 @@
"files.eol": "\r\n",
"editor.formatOnSave": true,
"thunder-client.saveToWorkspace": true,
"java.jdt.ls.vmargs": "-noverify -Xmx2G -XX:+UseG1GC -XX:+UseStringDeduplication"
"java.jdt.ls.vmargs": "-Xmx2G -XX:+UseG1GC -XX:+UseStringDeduplication"
}
30 changes: 11 additions & 19 deletions core/src/main/java/org/opencds/cqf/ruler/Application.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.opencds.cqf.ruler;

import org.opencds.cqf.external.annotations.OnEitherVersion;
import org.opencds.cqf.external.mdm.MdmConfig;
import org.opencds.cqf.ruler.config.BeanFinderConfig;
import org.opencds.cqf.ruler.config.RulerConfig;
import org.opencds.cqf.ruler.config.ServerProperties;
import org.opencds.cqf.ruler.config.TesterUIConfig;
import org.opencds.cqf.ruler.external.FhirTesterConfig;
import org.opencds.cqf.ruler.external.annotations.OnEitherVersion;
import org.opencds.cqf.ruler.external.cql.StarterCqlDstu3Config;
import org.opencds.cqf.ruler.external.cql.StarterCqlR4Config;
import org.opencds.cqf.ruler.external.mdm.MdmConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.SpringApplication;
Expand All @@ -18,27 +17,20 @@
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.cql.config.BaseCqlConfig;
import ca.uhn.fhir.cql.config.CqlDstu3Config;
import ca.uhn.fhir.cql.config.CqlR4Config;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
import ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig;

@ServletComponentScan(basePackageClasses = Application.class)
@ComponentScan(basePackageClasses = { org.opencds.cqf.ruler.external.Application.class,
Application.class }, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {
FhirTesterConfig.class, org.opencds.cqf.ruler.external.Application.class, StarterCqlR4Config.class,
StarterCqlDstu3Config.class, CqlR4Config.class, CqlDstu3Config.class, BaseCqlConfig.class }))
@SpringBootApplication(exclude = { ElasticsearchRestClientAutoConfiguration.class, QuartzAutoConfiguration.class })
@Import({ SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class,
WebsocketDispatcherConfig.class, MdmConfig.class, TesterUIConfig.class, BeanFinderConfig.class })
@Import({
RulerConfig.class,
ServerProperties.class,
WebsocketDispatcherConfig.class,
MdmConfig.class,
TesterUIConfig.class,
BeanFinderConfig.class, })
public class Application extends SpringBootServletInitializer {

public static void main(String[] args) {
Expand Down
35 changes: 24 additions & 11 deletions core/src/main/java/org/opencds/cqf/ruler/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,48 @@

import org.hl7.fhir.dstu3.model.CapabilityStatement;
import org.hl7.fhir.instance.model.api.IBaseConformance;
import org.opencds.cqf.external.AppProperties;
import org.opencds.cqf.external.BaseJpaRestfulServer;
import org.opencds.cqf.external.mdm.MdmConfig;
import org.opencds.cqf.ruler.api.Interceptor;
import org.opencds.cqf.ruler.api.MetadataExtender;
import org.opencds.cqf.ruler.api.OperationProvider;
import org.opencds.cqf.ruler.capability.ExtensibleJpaCapabilityStatementProvider;
import org.opencds.cqf.ruler.capability.ExtensibleJpaConformanceProviderDstu2;
import org.opencds.cqf.ruler.capability.ExtensibleJpaConformanceProviderDstu3;
import org.opencds.cqf.ruler.config.BeanFinderConfig;
import org.opencds.cqf.ruler.config.ServerProperties;
import org.opencds.cqf.ruler.external.AppProperties;
import org.opencds.cqf.ruler.external.BaseJpaRestfulServer;
import org.opencds.cqf.ruler.config.TesterUIConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.batch2.jobs.config.Batch2JobsConfig;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider;
import ca.uhn.fhir.jpa.batch2.JpaBatch2Config;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
import ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig;
import ca.uhn.fhir.model.dstu2.resource.Conformance;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;

@Import({
ServerProperties.class,
SubscriptionSubmitterConfig.class,
SubscriptionProcessorConfig.class,
SubscriptionChannelConfig.class,
WebsocketDispatcherConfig.class,
MdmConfig.class,
JpaBatch2Config.class,
Batch2JobsConfig.class,
TesterUIConfig.class,
BeanFinderConfig.class })
public class Server extends BaseJpaRestfulServer {
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -59,9 +79,6 @@ public class Server extends BaseJpaRestfulServer {
@Autowired
ServerProperties myServerProperties;

@Autowired
ValueSetOperationProvider valueSetOperationProvider;

public Server() {
super();
}
Expand All @@ -71,10 +88,6 @@ public Server() {
protected void initialize() throws ServletException {
super.initialize();

// TODO: This is needed due to a version mismatch with HAPI. Once we upgrade to
// >=5.7.0 we need to remove this
this.registerProvider(valueSetOperationProvider);

log.info("Loading operation providers from plugins");
Map<String, OperationProvider> providers = applicationContext.getBeansOfType(OperationProvider.class);
for (OperationProvider o : providers.values()) {
Expand All @@ -88,7 +101,7 @@ protected void initialize() throws ServletException {
log.info("Registering {} interceptor", o.getClass().getName());
this.registerInterceptor(o);
}

log.info("Loading metadata extenders from plugins");
Map<String, MetadataExtender> extenders = applicationContext.getBeansOfType(MetadataExtender.class);
for (MetadataExtender o : extenders.values()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.opencds.cqf.ruler.config;

import org.opencds.cqf.external.annotations.OnDSTU2Condition;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.jpa.config.JpaDstu2Config;

@Configuration
@Conditional(OnDSTU2Condition.class)
@Import({
JpaDstu2Config.class
})
public class FhirServerConfigDstu2 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.opencds.cqf.ruler.config;

import org.opencds.cqf.external.ElasticsearchConfig;
import org.opencds.cqf.external.annotations.OnDSTU3Condition;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.jpa.config.dstu3.JpaDstu3Config;

@Configuration
@Conditional(OnDSTU3Condition.class)
@Import({
JpaDstu3Config.class,
ElasticsearchConfig.class })
public class FhirServerConfigDstu3 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.opencds.cqf.ruler.config;

import org.opencds.cqf.external.ElasticsearchConfig;
import org.opencds.cqf.external.annotations.OnR4Condition;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.jpa.config.r4.JpaR4Config;

@Configuration
@Conditional(OnR4Condition.class)
@Import({
JpaR4Config.class,
ElasticsearchConfig.class
})
public class FhirServerConfigR4 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.opencds.cqf.ruler.config;

import org.opencds.cqf.external.ElasticsearchConfig;
import org.opencds.cqf.external.annotations.OnR5Condition;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import ca.uhn.fhir.jpa.config.r5.JpaR5Config;

@Configuration
@Conditional(OnR5Condition.class)
@Import({
JpaR5Config.class,
ElasticsearchConfig.class
})
public class FhirServerConfigR5 {
}
125 changes: 125 additions & 0 deletions core/src/main/java/org/opencds/cqf/ruler/config/JpaConfigCommon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package org.opencds.cqf.ruler.config;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport;
import org.opencds.cqf.external.AppProperties;
import org.opencds.cqf.external.EnvironmentHelper;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;

import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.api.IDaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.batch.config.NonPersistedBatchConfigurer;
import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil;
import ca.uhn.fhir.jpa.config.util.ResourceCountCacheUtil;
import ca.uhn.fhir.jpa.config.util.ValidationSupportConfigUtil;
import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl;
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl;
import ca.uhn.fhir.jpa.dao.search.HSearchSortHelperImpl;
import ca.uhn.fhir.jpa.dao.search.IHSearchSortHelper;
import ca.uhn.fhir.jpa.entity.MdmLink;
import ca.uhn.fhir.jpa.provider.DaoRegistryResourceSupportedSvc;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc;
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvcImpl;
import ca.uhn.fhir.jpa.util.ResourceCountCache;
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain;
import ca.uhn.fhir.mdm.dao.IMdmLinkDao;
import ca.uhn.fhir.rest.api.IResourceSupportedSvc;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;

@Configuration
public class JpaConfigCommon {
@Bean
public IFulltextSearchSvc fullTextSearchSvc() {
return new FulltextSearchSvcImpl();
}

@Bean
public IStaleSearchDeletingSvc staleSearchDeletingSvc() {
return new StaleSearchDeletingSvcImpl();
}

@Primary
@Bean
public CachingValidationSupport validationSupportChain(JpaValidationSupportChain theJpaValidationSupportChain) {
return ValidationSupportConfigUtil.newCachingValidationSupport(theJpaValidationSupportChain);
}

@Bean
public BatchConfigurer batchConfigurer() {
return new NonPersistedBatchConfigurer();
}

/**
* Customize the default/max page sizes for search results. You can set these
* however
* you want, although very large page sizes will require a lot of RAM.
*/
@Bean
public DatabaseBackedPagingProvider databaseBackedPagingProvider(AppProperties appProperties) {
DatabaseBackedPagingProvider pagingProvider = new DatabaseBackedPagingProvider();
pagingProvider.setDefaultPageSize(appProperties.getDefault_page_size());
pagingProvider.setMaximumPageSize(appProperties.getMax_page_size());
return pagingProvider;
}

@Bean
public IResourceSupportedSvc resourceSupportedSvc(IDaoRegistry theDaoRegistry) {
return new DaoRegistryResourceSupportedSvc(theDaoRegistry);
}

@Bean(name = "myResourceCountsCache")
public ResourceCountCache resourceCountsCache(IFhirSystemDao<?, ?> theSystemDao) {
return ResourceCountCacheUtil.newResourceCountCache(theSystemDao);
}

@Primary
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
ConfigurableListableBeanFactory myConfigurableListableBeanFactory, FhirContext theFhirContext,
DataSource myDataSource,
ConfigurableEnvironment configurableEnvironment) {
LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil
.newEntityManagerFactory(myConfigurableListableBeanFactory, theFhirContext);
retVal.setPersistenceUnitName("HAPI_PU");

try {
retVal.setDataSource(myDataSource);
} catch (Exception e) {
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
}
retVal.setJpaProperties(
EnvironmentHelper.getHibernateProperties(configurableEnvironment, myConfigurableListableBeanFactory));
return retVal;
}

@Bean
@Primary
public JpaTransactionManager hapiTransactionManager(EntityManagerFactory entityManagerFactory) {
JpaTransactionManager retVal = new JpaTransactionManager();
retVal.setEntityManagerFactory(entityManagerFactory);
return retVal;
}

@Bean
public IHSearchSortHelper hSearchSortHelper(ISearchParamRegistry mySearchParamRegistry) {
return new HSearchSortHelperImpl(mySearchParamRegistry);
}

@Bean
public IMdmLinkDao<MdmLink> mdmLinkDao() {
return new MdmLinkDaoJpaImpl();
}
}
Loading