From 5c1fac1a055aaa4a8dd5320de9ae7d1750842d32 Mon Sep 17 00:00:00 2001 From: sebg-mio42 Date: Fri, 6 Dec 2024 16:55:46 +0100 Subject: [PATCH] fix errors caused by using the same list for versioned and unversioned entries --- .../hl7/fhir/validation/BaseValidator.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java index ea64621dc..5e76f9a56 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java @@ -1049,25 +1049,40 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi if (resource != null) { String et = resource.getType(); String eid = resource.getNamedChildValue(ID, false); + String rl = null; if (eid != null) { - String rl = et+"/"+eid; + rl = et+"/"+eid; list = relMap.get(rl); if (list == null) { list = new ArrayList(); relMap.put(rl, list); - boolean versionIdPresent = resource.hasChild(META, false) - && resource.getNamedChild(META, false).hasChild(VERSION_ID, false) - && resource.getNamedChild(META, false).getNamedChild(VERSION_ID, false).hasValue(); - if (versionIdPresent){ - String versionId = resource.getNamedChild(META).getNamedChild(VERSION_ID).getValue(); - String fullUrlVersioned = fu + "/_history/" + versionId; - String relativePathVersioned = rl + "/_history/" + versionId; - relMap.put(relativePathVersioned, list); - map.put(fullUrlVersioned, list); - } } list.add(entry); } + boolean versionIdPresent = resource.hasChild(META, false) + && resource.getNamedChild(META, false).hasChild(VERSION_ID, false) + && resource.getNamedChild(META, false).getNamedChild(VERSION_ID, false).hasValue(); + if (versionIdPresent){ + String versionId = resource.getNamedChild(META).getNamedChild(VERSION_ID).getValue(); + String fullUrlVersioned = fu + "/_history/" + versionId; + List listMapVersioned = null; + listMapVersioned = map.get(fullUrlVersioned); + if (listMapVersioned == null) { + listMapVersioned = new ArrayList(); + map.put(fullUrlVersioned, listMapVersioned); + } + listMapVersioned.add(entry); + if (rl != null) { + String relativePathVersioned = rl + "/_history/" + versionId; + List listRelMapVersioned = null; + listRelMapVersioned = relMap.get(relativePathVersioned); + if (listRelMapVersioned == null) { + listRelMapVersioned = new ArrayList(); + relMap.put(relativePathVersioned, listRelMapVersioned); + } + listRelMapVersioned.add(entry); + } + } } } }