Skip to content

Commit

Permalink
WIP bump HAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
dotasek committed Jun 17, 2024
1 parent 422d200 commit 8f731a2
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 44 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>7.3.2-SNAPSHOT</version>
<version>7.3.7-SNAPSHOT</version>
</parent>

<artifactId>hapi-fhir-jpaserver-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider;
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
import ca.uhn.fhir.jpa.model.config.PartitionSettings.CrossPartitionReferenceMode;
import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
import ca.uhn.fhir.jpa.model.entity.StorageSettings;
import ca.uhn.fhir.jpa.starter.AppProperties;
import ca.uhn.fhir.jpa.starter.util.JpaHibernatePropertiesProvider;
Expand Down Expand Up @@ -87,6 +88,40 @@ public FhirServerConfigCommon(AppProperties appProperties) {
}
}

@Bean
public SubscriptionSettings subscriptionSettings(AppProperties appProperties) {
SubscriptionSettings subscriptionSettings = new SubscriptionSettings();
if (appProperties.getSubscription() != null) {
if (appProperties.getSubscription().getEmail() != null)
subscriptionSettings.setEmailFromAddress(
appProperties.getSubscription().getEmail().getFrom());

// Subscriptions are enabled by channel type
if (appProperties.getSubscription().getResthook_enabled()) {
ourLog.info("Enabling REST-hook subscriptions");
subscriptionSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
}
if (appProperties.getSubscription().getEmail() != null) {
ourLog.info("Enabling email subscriptions");
subscriptionSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
}
if (appProperties.getSubscription().getWebsocket_enabled()) {
ourLog.info("Enabling websocket subscriptions");
subscriptionSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
}

}
if (appProperties.getMdm_enabled()) {
// MDM requires the subscription of type message
ourLog.info("Enabling message subscriptions");
subscriptionSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE);
}
return subscriptionSettings;
}
/**
* Configure FHIR properties around the JPA server via this bean
*/
Expand All @@ -112,10 +147,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled());
jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled());
jpaStorageSettings.setLanguageSearchParameterEnabled(appProperties.getLanguage_search_parameter_enabled());
if (appProperties.getSubscription() != null
&& appProperties.getSubscription().getEmail() != null)
jpaStorageSettings.setEmailFromAddress(
appProperties.getSubscription().getEmail().getFrom());


Integer maxFetchSize = appProperties.getMax_page_size();
jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize);
Expand All @@ -129,24 +161,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins();
jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000);

if (appProperties.getSubscription() != null) {
// Subscriptions are enabled by channel type
if (appProperties.getSubscription().getResthook_enabled()) {
ourLog.info("Enabling REST-hook subscriptions");
jpaStorageSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
}
if (appProperties.getSubscription().getEmail() != null) {
ourLog.info("Enabling email subscriptions");
jpaStorageSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
}
if (appProperties.getSubscription().getWebsocket_enabled()) {
ourLog.info("Enabling websocket subscriptions");
jpaStorageSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
}
}


jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled());
jpaStorageSettings.setAdvancedHSearchIndexing(appProperties.getAdvanced_lucene_indexing());
Expand Down Expand Up @@ -202,13 +217,6 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());

if (appProperties.getMdm_enabled()) {
// MDM requires the subscription of type message
ourLog.info("Enabling message subscriptions");
jpaStorageSettings.addSupportedSubscriptionType(
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE);
}

storageSettings(appProperties, jpaStorageSettings);
return jpaStorageSettings;
}
Expand Down Expand Up @@ -249,10 +257,6 @@ protected StorageSettings storageSettings(AppProperties appProperties, JpaStorag
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
jpaStorageSettings.setDefaultSearchParamsCanBeOverridden(
appProperties.getAllow_override_default_search_params());
if (appProperties.getSubscription() != null
&& appProperties.getSubscription().getEmail() != null)
jpaStorageSettings.setEmailFromAddress(
appProperties.getSubscription().getEmail().getFrom());

jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingInterceptor;
import ca.uhn.fhir.jpa.ips.provider.IpsOperationProvider;
import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
import ca.uhn.fhir.jpa.partition.PartitionManagementProvider;
Expand Down Expand Up @@ -252,6 +253,7 @@ public RestfulServer restfulServer(
IJpaSystemProvider jpaSystemProvider,
ResourceProviderFactory resourceProviderFactory,
JpaStorageSettings jpaStorageSettings,
SubscriptionSettings subscriptionSettings,
ISearchParamRegistry searchParamRegistry,
IValidationSupport theValidationSupport,
DatabaseBackedPagingProvider databaseBackedPagingProvider,
Expand Down Expand Up @@ -378,7 +380,7 @@ public RestfulServer restfulServer(

corsInterceptor.ifPresent(fhirServer::registerInterceptor);

if (jpaStorageSettings.getSupportedSubscriptionTypes().size() > 0) {
if (!subscriptionSettings.getSupportedSubscriptionTypes().isEmpty()) {
// Subscription debug logging
fhirServer.registerInterceptor(new SubscriptionDebugLogInterceptor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
RepositoryConfig.class
}, properties =
{
"spring.profiles.include=storageSettingsTest",
"spring.profiles.include=subscriptionSettingsTest",
"spring.datasource.url=jdbc:h2:mem:dbr3",
"hapi.fhir.fhir_version=dstu3",
"hapi.fhir.cr_enabled=true",
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
NicknameServiceConfig.class,
RepositoryConfig.class
}, properties = {
"spring.profiles.include=storageSettingsTest",
"spring.profiles.include=subscriptionSettingsTest",
"spring.datasource.url=jdbc:h2:mem:dbr4",
"hapi.fhir.enable_repository_validating_interceptor=true",
"hapi.fhir.fhir_version=r4",
Expand Down Expand Up @@ -237,7 +237,7 @@ void testWebsocketSubscription() throws Exception {
IIdType mySubscriptionId = methodOutcome.getId();

// Wait for the subscription to be activated
await().atMost(1, TimeUnit.MINUTES).until(()->activeSubscriptionCount(), equalTo(initialActiveSubscriptionCount + 1));
await().atMost(1, TimeUnit.MINUTES).until(this::activeSubscriptionCount, equalTo(initialActiveSubscriptionCount + 1));

/*
* Attach websocket
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
import org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -21,9 +22,12 @@ class MdmTest {
@Autowired
JpaStorageSettings jpaStorageSettings;

@Autowired
SubscriptionSettings subscriptionSettings;

@Test
void testApplicationStartedSuccessfully() {
assertThat(nicknameService).isNotNull();
assertThat(jpaStorageSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE);
assertThat(subscriptionSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package ca.uhn.fhir.jpa.starter;

import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
import org.hl7.fhir.dstu2.model.Subscription;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;

@Profile("storageSettingsTest")
@Profile("subscriptionSettingsTest")
@Configuration
public class JpaStorageSettingsConfig {
public class SubscriptionSettingsConfig {
@Primary
@Bean
public JpaStorageSettings storageSettings() {
JpaStorageSettings retVal = new JpaStorageSettings();
public SubscriptionSettings subscriptionSettings() {
SubscriptionSettings retVal = new SubscriptionSettings();

retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.WEBSOCKET);
retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.MESSAGE);
Expand Down

0 comments on commit 8f731a2

Please sign in to comment.