Skip to content
Open
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
2 changes: 1 addition & 1 deletion hapi-deployable-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
Expand Down Expand Up @@ -192,6 +193,14 @@ default IBaseResource fetchCodeSystem(String theSystem) {
return null;
}

default <T extends IBaseResource> Stream<T> fetchResources(Class<T> theClazz, String theUrl) {
return Stream.empty();
}

default <T extends IBaseResource> Stream<T> fetchAllResourcesOfType(@Nonnull Class<T> theClazz) {
return Stream.empty();
}

/**
* Loads a resource needed by the validation (a StructureDefinition, or a
* ValueSet)
Expand Down
4 changes: 2 additions & 2 deletions hapi-fhir-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-bom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<packaging>pom</packaging>
<name>HAPI FHIR BOM</name>

<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-checkstyle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-cli/hapi-fhir-cli-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-cli/hapi-fhir-cli-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-client-apache-http5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-client-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jacoco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jaxrsserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpa-hibernate-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
import ca.uhn.fhir.jpa.api.model.ExpungeOptions;
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
import ca.uhn.fhir.jpa.api.svc.IPackageInstallerSvc;
import ca.uhn.fhir.jpa.api.svc.ISearchUrlJobMaintenanceSvc;
import ca.uhn.fhir.jpa.binary.interceptor.BinaryStorageInterceptor;
import ca.uhn.fhir.jpa.binary.provider.BinaryAccessProvider;
Expand Down Expand Up @@ -101,7 +102,6 @@
import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
import ca.uhn.fhir.jpa.packages.IHapiPackageCacheManager;
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
import ca.uhn.fhir.jpa.packages.JpaPackageCache;
import ca.uhn.fhir.jpa.packages.NpmJpaValidationSupport;
import ca.uhn.fhir.jpa.packages.PackageInstallerSvcImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import ca.uhn.fhir.jpa.model.util.JpaConstants;
import ca.uhn.fhir.jpa.packages.loader.NpmPackageData;
import ca.uhn.fhir.jpa.packages.loader.PackageLoaderSvc;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
Expand Down Expand Up @@ -345,6 +346,8 @@ private NpmPackage addPackageToCacheInternal(NpmPackageData thePackageData) {
} catch (IOException e) {
throw new InternalErrorException(Msg.code(2371) + e);
}
IParser jsonParser = packageContext.newJsonParser();
;
for (Map.Entry<String, List<String>> nextTypeToFiles : packageFolderTypes.entrySet()) {
String nextType = nextTypeToFiles.getKey();
for (String nextFile : nextTypeToFiles.getValue()) {
Expand All @@ -362,7 +365,7 @@ private NpmPackage addPackageToCacheInternal(NpmPackageData thePackageData) {
if (nextFile.toLowerCase().endsWith(".xml")) {
resource = packageContext.newXmlParser().parseResource(contentsString);
} else if (nextFile.toLowerCase().endsWith(".json")) {
resource = packageContext.newJsonParser().parseResource(contentsString);
resource = jsonParser.parseResource(contentsString);
} else {
getProcessingMessages(npmPackage).add("Not indexing file: " + nextFile);
continue;
Expand All @@ -375,10 +378,8 @@ private NpmPackage addPackageToCacheInternal(NpmPackageData thePackageData) {
*/
String contentType = Constants.CT_FHIR_JSON_NEW;
ResourceUtil.removeNarrative(packageContext, resource);
byte[] minimizedContents = packageContext
.newJsonParser()
.encodeResourceToString(resource)
.getBytes(StandardCharsets.UTF_8);
byte[] minimizedContents =
jsonParser.encodeResourceToString(resource).getBytes(StandardCharsets.UTF_8);

IBaseBinary resourceBinary = createPackageResourceBinary(minimizedContents, contentType);
ResourceTable persistedResource = createResourceBinary(resourceBinary);
Expand Down Expand Up @@ -428,7 +429,11 @@ private NpmPackage addPackageToCacheInternal(NpmPackageData thePackageData) {
}

getProcessingMessages(npmPackage)
.add("Successfully added package " + npmPackage.id() + "#" + npmPackage.version() + " to registry");
.add(String.format(
NpmPackageUtils.SUCCESSFULLY_INSTALLED_MSG_TEMPLATE,
npmPackage.id(),
npmPackage.version()));
// .add("Successfully added package " + npmPackage.id() + "#" + npmPackage.version() + " to registry");

return npmPackage;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.model.api.PagingIterator;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;

import java.util.List;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class NpmJpaValidationSupport implements IValidationSupport {

Expand Down Expand Up @@ -56,6 +63,55 @@ public IBaseResource fetchStructureDefinition(String theUri) {
return fetchResource("StructureDefinition", theUri);
}

@SuppressWarnings("unchecked")
@Override
public <T extends IBaseResource> T fetchResource(@Nullable Class<T> theClass, String theUri) {
if (theClass != null) {
String resourceType = myFhirContext.getResourceType(theClass);
// we can cast safely because the resource type must match what we're passing in.
// we aren't loading different versions of FHIR after all (since what we
// load is dependent on the fhir context too)
return (T) fetchResource(resourceType, theUri);
}

// no class
return null;
}

public static int batchSize() {
return 100;
}

@Override
public <T extends IBaseResource> Stream<T> fetchResources(Class<T> theClazz, String theUrl) {
FhirVersionEnum fhirVersion = myFhirContext.getVersion().getVersion();
PagingIterator<T> pagingIterator = new PagingIterator<>(
batchSize(),
(pageSize, batchSize, theConsumer) ->
myHapiPackageCacheManager
.loadPackageAssetsByUrl(fhirVersion, theUrl, PageRequest.of(pageSize, batchSize))
.stream()
.filter(r -> {
if (theClazz != null) {
return r.getClass().isAssignableFrom(theClazz);
}
return true;
})
.forEach(r -> theConsumer.accept((T) r)));

return StreamSupport.stream(
Spliterators.spliteratorUnknownSize(pagingIterator, Spliterator.ORDERED), false); // sequential
}

@Override
public <T extends IBaseResource> Stream<T> fetchAllResourcesOfType(@Nonnull Class<T> theClazz) {
FhirVersionEnum fhirVersion = myFhirContext.getVersion().getVersion();
return myHapiPackageCacheManager.loadPackageAssetsByType(fhirVersion, theClazz.getSimpleName()).stream()
.map(r -> (T) r)
.toList()
.stream();
}

@Nullable
public IBaseResource fetchResource(String theResourceType, String theUri) {
FhirVersionEnum fhirVersion = myFhirContext.getVersion().getVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
import ca.uhn.fhir.jpa.api.svc.IPackageInstallerSvc;
import ca.uhn.fhir.jpa.dao.data.INpmPackageVersionDao;
import ca.uhn.fhir.jpa.dao.tx.IHapiTransactionService;
import ca.uhn.fhir.jpa.dao.validation.SearchParameterDaoValidator;
Expand Down Expand Up @@ -199,6 +200,8 @@ public PackageInstallOutcomeJson install(PackageInstallationSpec theInstallation
"Package {}#{} is already installed",
theInstallationSpec.getName(),
theInstallationSpec.getVersion());
// add a property to specify whether we keep going or not.
// use quartz to schedule a batch job on one instance to install the packages
}

NpmPackage npmPackage = myPackageCacheManager.installPackage(theInstallationSpec);
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-elastic-test-utilities/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-hfql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-ips/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-mdm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>8.7.1-SNAPSHOT</version>
<version>8.7.2-SNAPSHOT-LS</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
Loading
Loading