Skip to content

Commit

Permalink
Feature/using package installer spec (hapifhir#577)
Browse files Browse the repository at this point in the history
* Adjusting to HAPI core classes

* Added example as default

* Commented the example IG out again
  • Loading branch information
jkiddo authored Aug 22, 2023
1 parent d6e9aba commit 37a9317
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 46 deletions.
37 changes: 4 additions & 33 deletions src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.ClientIdStrategyEnum;
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
import ca.uhn.fhir.rest.api.EncodingEnum;
import org.hl7.fhir.r4.model.Bundle;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand Down Expand Up @@ -74,7 +75,7 @@ public class AppProperties {
private Partitioning partitioning = null;
private Boolean install_transitive_ig_dependencies = true;
private Boolean reload_existing_implementationguides = false;
private Map<String, ImplementationGuide> implementationGuides = null;
private Map<String, PackageInstallationSpec> implementationGuides = null;

private String staticLocation = null;

Expand Down Expand Up @@ -148,11 +149,11 @@ public void setDefer_indexing_for_codesystems_of_size(Integer defer_indexing_for
this.defer_indexing_for_codesystems_of_size = defer_indexing_for_codesystems_of_size;
}

public Map<String, ImplementationGuide> getImplementationGuides() {
public Map<String, PackageInstallationSpec> getImplementationGuides() {
return implementationGuides;
}

public void setImplementationGuides(Map<String, ImplementationGuide> implementationGuides) {
public void setImplementationGuides(Map<String, PackageInstallationSpec> implementationGuides) {
this.implementationGuides = implementationGuides;
}

Expand Down Expand Up @@ -696,36 +697,6 @@ public void setRefuse_to_fetch_third_party_urls(Boolean refuse_to_fetch_third_pa
}
}

public static class ImplementationGuide
{
private String url;
private String name;
private String version;

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}
}

public static class Validation {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@

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

import java.util.*;

import static ca.uhn.fhir.jpa.starter.common.validation.IRepositoryValidationInterceptorFactory.ENABLE_REPOSITORY_VALIDATING_INTERCEPTOR;
Expand Down Expand Up @@ -194,13 +193,15 @@ public IPackageInstallerSvc packageInstaller(AppProperties appProperties, JobDef
jobDefinitionRegistry.addJobDefinitionIfNotRegistered(reindexJobParametersJobDefinition);

if (appProperties.getImplementationGuides() != null) {
Map<String, AppProperties.ImplementationGuide> guides = appProperties.getImplementationGuides();
for (Map.Entry<String, AppProperties.ImplementationGuide> guide : guides.entrySet()) {
PackageInstallationSpec packageInstallationSpec = new PackageInstallationSpec().setPackageUrl(guide.getValue().getUrl()).setName(guide.getValue().getName()).setVersion(guide.getValue().getVersion()).setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL);
packageInstallationSpec.setReloadExisting(appProperties.getReload_existing_implementationguides());
Map<String, PackageInstallationSpec> guides = appProperties.getImplementationGuides();
for (Map.Entry<String, PackageInstallationSpec> guidesEntry : guides.entrySet()) {
PackageInstallationSpec packageInstallationSpec = guidesEntry.getValue();
if (appProperties.getInstall_transitive_ig_dependencies()) {
packageInstallationSpec.setFetchDependencies(true);
packageInstallationSpec.setDependencyExcludes(List.of("hl7.fhir.r2.core", "hl7.fhir.r3.core", "hl7.fhir.r4.core", "hl7.fhir.r5.core"));

packageInstallationSpec.addDependencyExclude("hl7.fhir.r2.core")
.addDependencyExclude("hl7.fhir.r3.core")
.addDependencyExclude("hl7.fhir.r4.core")
.addDependencyExclude("hl7.fhir.r5.core");
}
packageInstallerSvc.install(packageInstallationSpec);
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ hapi:
# install_transitive_ig_dependencies: true
### tells the server whether to attempt to load IG resources that are already present
# reload_existing_implementationGuides : false
# implementationguides:
#implementationguides:
### example from registry (packages.fhir.org)
# swiss:
# name: swiss.mednet.fhir
# version: 0.8.0
# swiss:
# name: swiss.mednet.fhir
# version: 0.8.0
# reloadExisting : false
# example not from registry
# ips_1_0_0:
# url: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz
# packageUrl: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz
# name: hl7.fhir.uv.ips
# version: 1.0.0
# supported_resource_types:
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ hapi:
# swiss:
# name: swiss.mednet.fhir
# version: 0.8.0
# reloadExisting : false
# example not from registry
# ips_1_0_0:
# url: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz
# packageUrl: https://build.fhir.org/ig/HL7/fhir-ips/package.tgz
# name: hl7.fhir.uv.ips
# version: 1.0.0
# supported_resource_types:
Expand Down

0 comments on commit 37a9317

Please sign in to comment.