* ignore canonical resources found in the examples package

This commit is contained in:
Grahame Grieve 2021-12-22 22:33:50 +11:00
parent 66ab13dba7
commit 939b377fe2
3 changed files with 70 additions and 59 deletions

View File

@ -312,64 +312,66 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
map = new HashMap<String, ResourceProxy>();
allResourcesById.put(r.getType(), map);
}
map.put(r.getId(), new ResourceProxy(r));
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r));
}
String url = r.getUrl();
if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
// spcial 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));
String url = r.getUrl();
if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
// spcial workaround for known problems with existing packages
if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
return;
}
switch(r.getType()) {
case "StructureDefinition":
if ("1.4.0".equals(version)) {
StructureDefinition sd = (StructureDefinition) r.getResource();
fixOldSD(sd);
}
structures.register(r, packageInfo);
break;
case "ValueSet":
valueSets.register(r, packageInfo);
break;
case "CodeSystem":
codeSystems.register(r, packageInfo);
break;
case "ImplementationGuide":
guides.register(r, packageInfo);
break;
case "CapabilityStatement":
capstmts.register(r, packageInfo);
break;
case "Measure":
measures.register(r, packageInfo);
break;
case "Library":
libraries.register(r, packageInfo);
break;
case "SearchParameter":
searchParameters.register(r, packageInfo);
break;
case "PlanDefinition":
plans.register(r, packageInfo);
break;
case "OperationDefinition":
operations.register(r, packageInfo);
break;
case "Questionnaire":
questionnaires.register(r, packageInfo);
break;
case "ConceptMap":
maps.register(r, packageInfo);
break;
case "StructureMap":
transforms.register(r, packageInfo);
break;
case "NamingSystem":
systems.register(r, packageInfo);
break;
throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
}
switch(r.getType()) {
case "StructureDefinition":
if ("1.4.0".equals(version)) {
StructureDefinition sd = (StructureDefinition) r.getResource();
fixOldSD(sd);
}
structures.register(r, packageInfo);
break;
case "ValueSet":
valueSets.register(r, packageInfo);
break;
case "CodeSystem":
codeSystems.register(r, packageInfo);
break;
case "ImplementationGuide":
guides.register(r, packageInfo);
break;
case "CapabilityStatement":
capstmts.register(r, packageInfo);
break;
case "Measure":
measures.register(r, packageInfo);
break;
case "Library":
libraries.register(r, packageInfo);
break;
case "SearchParameter":
searchParameters.register(r, packageInfo);
break;
case "PlanDefinition":
plans.register(r, packageInfo);
break;
case "OperationDefinition":
operations.register(r, packageInfo);
break;
case "Questionnaire":
questionnaires.register(r, packageInfo);
break;
case "ConceptMap":
maps.register(r, packageInfo);
break;
case "StructureMap":
transforms.register(r, packageInfo);
break;
case "NamingSystem":
systems.register(r, packageInfo);
break;
}
}
}
@ -382,12 +384,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r));
} else {
System.out.println("Ingore "+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();

View File

@ -218,7 +218,7 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
if (cr.getPackageInfo() != null && cr.getPackageInfo().getId() != null && cr.getPackageInfo().getId().startsWith("hl7.terminology") && "http://nucc.org/provider-taxonomy".equals(cr.getUrl())) {
return;
}
if (enforceUniqueId && map.containsKey(cr.getId())) {
drop(cr.getId());
}
@ -236,7 +236,7 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
}
}
CachedCanonicalResource<T> existing = cr.hasVersion() ? map.get(cr.getUrl()+"|"+cr.getVersion()) : map.get(cr.getUrl()+"|#0");
if (existing != null && (cr.getPackageInfo() != null && cr.getPackageInfo().isExamplesPackage())) {
if (map.get(cr.getUrl()) != null && (cr.getPackageInfo() != null && cr.getPackageInfo().isExamplesPackage())) {
return;
}
if (existing != null) {
@ -245,6 +245,7 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
list.add(cr);
map.put(cr.getId(), cr); // we do this so we can drop by id
map.put(cr.getUrl(), cr);
if (cr.getUrl() != null) {
// first, this is the correct reosurce for this version (if it has a version)

View File

@ -171,8 +171,14 @@ public interface IWorkerContext {
return version;
}
public boolean isExamplesPackage() {
return !(id.startsWith("hl7.fhir.") && id.endsWith(".example"));
boolean b = id.startsWith("hl7.fhir.") && id.endsWith(".examples");
return b;
}
@Override
public String toString() {
return id+"#"+version;
}
}
public class PackageDetails extends PackageVersion {