* 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>(); map = new HashMap<String, ResourceProxy>();
allResourcesById.put(r.getType(), map); 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(); String url = r.getUrl();
if (!allowLoadingDuplicates && hasResource(r.getType(), url)) { if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
// spcial workaround for known problems with existing packages // spcial workaround for known problems with existing packages
if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) { if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
return; return;
}
throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
} }
switch(r.getType()) { throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
case "StructureDefinition": }
if ("1.4.0".equals(version)) { switch(r.getType()) {
StructureDefinition sd = (StructureDefinition) r.getResource(); case "StructureDefinition":
fixOldSD(sd); if ("1.4.0".equals(version)) {
} StructureDefinition sd = (StructureDefinition) r.getResource();
structures.register(r, packageInfo); fixOldSD(sd);
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;
} }
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,6 +384,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
} }
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) { if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r)); 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) { if (r instanceof CodeSystem || r instanceof NamingSystem) {

View File

@ -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"); 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; return;
} }
if (existing != null) { if (existing != null) {
@ -245,6 +245,7 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
list.add(cr); list.add(cr);
map.put(cr.getId(), cr); // we do this so we can drop by id map.put(cr.getId(), cr); // we do this so we can drop by id
map.put(cr.getUrl(), cr);
if (cr.getUrl() != null) { if (cr.getUrl() != null) {
// first, this is the correct reosurce for this version (if it has a version) // 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; return version;
} }
public boolean isExamplesPackage() { 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 { public class PackageDetails extends PackageVersion {