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);
}
}
}
}
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());
}
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);
}
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);
}
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);
}
Aggregations