Search in sources :

Example 31 with FilesystemPackageCacheManager

use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.

the class UTGVersionSorter method loadPackageR2.

private Map<String, CanonicalResource> loadPackageR2(String id) throws IOException {
    Map<String, CanonicalResource> res = new HashMap<>();
    if (pcm == null) {
        pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
    }
    System.out.println("Load " + id);
    NpmPackage npm = pcm.loadPackage(id);
    for (PackageResourceInformation p : npm.listIndexedResources("CodeSystem", "ValueSet")) {
        CanonicalResource r = (CanonicalResource) VersionConvertorFactory_10_50.convertResource(new org.hl7.fhir.dstu2.formats.JsonParser().parse(npm.load(p)));
        res.put(r.getUrl(), r);
    }
    return res;
}
Also used : FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) PackageResourceInformation(org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation) NpmPackage(org.hl7.fhir.utilities.npm.NpmPackage)

Example 32 with FilesystemPackageCacheManager

use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.

the class OIDBasedValueSetImporter method init.

protected void init() throws FHIRException, IOException {
    FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
    NpmPackage npm = pcm.loadPackage("hl7.fhir.r5.core", "current");
    SimpleWorkerContext context = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).fromPackage(npm);
    context.loadFromPackage(pcm.loadPackage("hl7.terminology"), null);
    this.context = context;
}
Also used : FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) NpmPackage(org.hl7.fhir.utilities.npm.NpmPackage) SimpleWorkerContext(org.hl7.fhir.r5.context.SimpleWorkerContext)

Example 33 with FilesystemPackageCacheManager

use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.

the class TestingUtilities method context.

public static IWorkerContext context() {
    if (fcontext == null) {
        FilesystemPackageCacheManager pcm;
        try {
            pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
            fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
            fcontext.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml")));
            fcontext.setExpansionProfile(new Parameters());
        } catch (Exception e) {
            throw new Error(e);
        }
    }
    return fcontext;
}
Also used : UcumEssenceService(org.fhir.ucum.UcumEssenceService) FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) Parameters(org.hl7.fhir.r4.model.Parameters) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 34 with FilesystemPackageCacheManager

use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.

the class PackageCacheTests method testLastReleasedVersion.

@Test
public void testLastReleasedVersion() throws IOException {
    FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
    cache.clear();
    Assertions.assertEquals("0.0.8", cache.loadPackage(CommonPackages.ID_PUBPACK, "0.0.8").version());
    Assertions.assertEquals(CommonPackages.VER_PUBPACK, cache.loadPackage(CommonPackages.ID_PUBPACK).version());
}
Also used : FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) Test(org.junit.jupiter.api.Test)

Example 35 with FilesystemPackageCacheManager

use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.

the class PackageCacheTests method testNotCaseSensitive.

@Test
public void testNotCaseSensitive() throws IOException {
    FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
    cache.clear();
    Assertions.assertEquals(cache.loadPackage("KBV.Basis", "1.1.3").version(), "1.1.3");
    Assertions.assertEquals(cache.loadPackage("kbv.basis", "1.1.3").version(), "1.1.3");
}
Also used : FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) Test(org.junit.jupiter.api.Test)

Aggregations

FilesystemPackageCacheManager (org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager)34 NpmPackage (org.hl7.fhir.utilities.npm.NpmPackage)13 IOException (java.io.IOException)9 BeforeAll (org.junit.jupiter.api.BeforeAll)8 FileNotFoundException (java.io.FileNotFoundException)7 FHIRException (org.hl7.fhir.exceptions.FHIRException)6 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)6 File (java.io.File)5 FileOutputStream (java.io.FileOutputStream)5 Test (org.junit.jupiter.api.Test)5 JsonSyntaxException (com.google.gson.JsonSyntaxException)4 ArrayList (java.util.ArrayList)4 UcumEssenceService (org.fhir.ucum.UcumEssenceService)4 NotImplementedException (org.apache.commons.lang3.NotImplementedException)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)3 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)3 PackageResourceInformation (org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 R3ToR4Loader (org.hl7.fhir.convertors.loaders.loaderR4.R3ToR4Loader)2