Search in sources :

Example 11 with PackageInfo

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

the class BaseWorkerContext method cacheResourceFromPackage.

public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        if (r.getId() != null) {
            Map<String, ResourceProxy> map = allResourcesById.get(r.fhirType());
            if (map == null) {
                map = new HashMap<String, ResourceProxy>();
                allResourcesById.put(r.fhirType(), map);
            }
            if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
                map.put(r.getId(), new ResourceProxy(r));
            } else {
                logger.logDebugMessage(LogCategory.PROGRESS, "Ignore " + r.fhirType() + "/" + r.getId() + " from package " + packageInfo.toString());
            }
        }
        if (r instanceof CodeSystem || r instanceof NamingSystem) {
            oidCache.clear();
        }
        if (r instanceof CanonicalResource) {
            CanonicalResource m = (CanonicalResource) r;
            String url = m.getUrl();
            if (!allowLoadingDuplicates && hasResource(r.getClass(), url)) {
                // special workaround for known problems with existing packages
                if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
                    return;
                }
                throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
            }
            if (r instanceof StructureDefinition) {
                StructureDefinition sd = (StructureDefinition) m;
                if ("1.4.0".equals(version)) {
                    fixOldSD(sd);
                }
                structures.see(sd, packageInfo);
            } else if (r instanceof ValueSet) {
                valueSets.see((ValueSet) m, packageInfo);
            } else if (r instanceof CodeSystem) {
                CodeSystemUtilities.crossLinkCodeSystem((CodeSystem) r);
                codeSystems.see((CodeSystem) m, packageInfo);
            } else if (r instanceof ImplementationGuide) {
                guides.see((ImplementationGuide) m, packageInfo);
            } else if (r instanceof CapabilityStatement) {
                capstmts.see((CapabilityStatement) m, packageInfo);
            } else if (r instanceof Measure) {
                measures.see((Measure) m, packageInfo);
            } else if (r instanceof Library) {
                libraries.see((Library) m, packageInfo);
            } else if (r instanceof SearchParameter) {
                searchParameters.see((SearchParameter) m, packageInfo);
            } else if (r instanceof PlanDefinition) {
                plans.see((PlanDefinition) m, packageInfo);
            } else if (r instanceof OperationDefinition) {
                operations.see((OperationDefinition) m, packageInfo);
            } else if (r instanceof Questionnaire) {
                questionnaires.see((Questionnaire) m, packageInfo);
            } else if (r instanceof ConceptMap) {
                maps.see((ConceptMap) m, packageInfo);
            } else if (r instanceof StructureMap) {
                transforms.see((StructureMap) m, packageInfo);
            } else if (r instanceof NamingSystem) {
                systems.see((NamingSystem) m, packageInfo);
            }
        }
    }
}
Also used : Questionnaire(org.hl7.fhir.r5.model.Questionnaire) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) CanonicalResourceProxy(org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy) StructureMap(org.hl7.fhir.r5.model.StructureMap) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) CapabilityStatement(org.hl7.fhir.r5.model.CapabilityStatement) Measure(org.hl7.fhir.r5.model.Measure) PlanDefinition(org.hl7.fhir.r5.model.PlanDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) Library(org.hl7.fhir.r5.model.Library) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) ValueSet(org.hl7.fhir.r5.model.ValueSet) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition)

Example 12 with PackageInfo

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

the class CachingPackageClientTests method testRegistry.

@Test
public void testRegistry() throws IOException {
    CachingPackageClient client = new CachingPackageClient("http://packages.fhir.org/packages");
    List<PackageInfo> matches1 = client.listFromRegistry(null, null, null);
    List<PackageInfo> matches2 = client.listFromRegistry(null, null, "4.0.1");
    Assertions.assertTrue(matches1.size() > matches2.size());
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 13 with PackageInfo

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

the class CachingPackageClientTests method testVersions.

@Test
public void testVersions() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1);
    List<PackageInfo> matches = client.getVersions("Simplifier.Core.STU3");
    for (PackageInfo pi : matches) {
        System.out.println(pi.toString());
    }
    Assertions.assertTrue(matches.size() > 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 14 with PackageInfo

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

the class CachingPackageClientTests method testSearchNoMatches2.

@Test
public void testSearchNoMatches2() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2);
    List<PackageInfo> matches = client.search("corezxxx", null, null, false);
    Assertions.assertTrue(matches.size() == 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 15 with PackageInfo

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

the class CachingPackageClientTests method testSearchNoMatches.

@Test
public void testSearchNoMatches() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1);
    List<PackageInfo> matches = client.search("corezxxx", null, null, false);
    Assertions.assertTrue(matches.size() == 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Aggregations

PackageInfo (org.hl7.fhir.utilities.npm.PackageInfo)12 CachingPackageClient (org.hl7.fhir.utilities.npm.CachingPackageClient)11 CodeType (org.hl7.fhir.r5.model.CodeType)10 Test (org.junit.jupiter.api.Test)10 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)8 ArrayList (java.util.ArrayList)6 ValueSetComposeComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent)5 File (java.io.File)4 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)4 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)4 FileInputStream (java.io.FileInputStream)3 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 XmlParser (org.hl7.fhir.r5.formats.XmlParser)3 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)3 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2