Fix bug revalidating profiled abstract types

This commit is contained in:
Grahame Grieve 2022-10-20 16:17:03 +11:00
parent e47ffbd32e
commit aff52322ad
1 changed files with 7 additions and 6 deletions

View File

@ -5030,7 +5030,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
return; // there'll be an error elsewhere in this case, and we're going to stop.
List<ElementDefinition> typeChildDefinitions = getActualTypeChildren(hostContext, element, actualType);
// what were going to do is merge them - the type is not allowed to constrain things that the child definitions already do (well, if it does, it'll be ignored)
mergeChildLists(childDefinitions, typeChildDefinitions, definition.getPath(), actualType);
childDefinitions = mergeChildLists(childDefinitions, typeChildDefinitions, definition.getPath(), actualType);
}
List<ElementInfo> children = listChildren(element, stack);
@ -5045,21 +5045,22 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
}
private void mergeChildLists(List<ElementDefinition> master, List<ElementDefinition> additional, String masterPath, String typePath) {
private List<ElementDefinition> mergeChildLists(List<ElementDefinition> source, List<ElementDefinition> additional, String masterPath, String typePath) {
List<ElementDefinition> res = new ArrayList<>();
res.addAll(source);
for (ElementDefinition ed : additional) {
boolean inMaster = false;
for (ElementDefinition t : master) {
for (ElementDefinition t : source) {
String tp = masterPath + ed.getPath().substring(typePath.length());
if (t.getPath().equals(tp)) {
inMaster = true;
}
}
if (!inMaster) {
master.add(ed);
res.add(ed);
}
}
return res;
}
// todo: the element definition in context might assign a constrained profile for the type?