Properly process invariants that have a source in the validator
This commit is contained in:
parent
323d933f76
commit
071a3dd927
|
@ -4706,7 +4706,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
NodeStack localStack = stack.push(ei.getElement(), ei.count, ei.definition, type == null ? typeDefn : resolveType(type, ei.definition.getType()));
|
NodeStack localStack = stack.push(ei.getElement(), ei.count, ei.definition, type == null ? typeDefn : resolveType(type, ei.definition.getType()));
|
||||||
if (debug) {
|
if (debug) {
|
||||||
System.out.println(" " + localStack.getLiteralPath());
|
System.out.println(" check " + localStack.getLiteralPath()+" against "+ei.getDefinition().getId()+" in profile "+profile.getUrl());
|
||||||
}
|
}
|
||||||
String localStackLiterapPath = localStack.getLiteralPath();
|
String localStackLiterapPath = localStack.getLiteralPath();
|
||||||
String eiPath = ei.getPath();
|
String eiPath = ei.getPath();
|
||||||
|
@ -5154,7 +5154,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) {
|
for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) {
|
||||||
if (inv.hasExpression() && (!onlyNonInherited || !inv.hasSource() || profile.getUrl().equals(inv.getSource()))) {
|
if (inv.hasExpression() && (!onlyNonInherited || !inv.hasSource() || !isInheritedProfile(profile, inv.getSource()))) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Set<String> invList = executionId.equals(element.getUserString(EXECUTION_ID)) ? (Set<String>) element.getUserData(EXECUTED_CONSTRAINT_LIST) : null;
|
Set<String> invList = executionId.equals(element.getUserString(EXECUTION_ID)) ? (Set<String>) element.getUserData(EXECUTED_CONSTRAINT_LIST) : null;
|
||||||
if (invList == null) {
|
if (invList == null) {
|
||||||
|
@ -5172,6 +5172,21 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isInheritedProfile(StructureDefinition profile, String source) {
|
||||||
|
if (source.equals(profile.getUrl())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
while (profile != null) {
|
||||||
|
profile = context.fetchResource(StructureDefinition.class, profile.getBaseDefinition());
|
||||||
|
if (profile != null) {
|
||||||
|
if (source.equals(profile.getUrl())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void checkInvariant(ValidatorHostContext hostContext, List<ValidationMessage> errors, String path, StructureDefinition profile, Element resource, Element element, ElementDefinitionConstraintComponent inv) throws FHIRException {
|
public void checkInvariant(ValidatorHostContext hostContext, List<ValidationMessage> errors, String path, StructureDefinition profile, Element resource, Element element, ElementDefinitionConstraintComponent inv) throws FHIRException {
|
||||||
ExpressionNode n = (ExpressionNode) inv.getUserData("validator.expression.cache");
|
ExpressionNode n = (ExpressionNode) inv.getUserData("validator.expression.cache");
|
||||||
if (n == null) {
|
if (n == null) {
|
||||||
|
|
|
@ -191,6 +191,9 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
||||||
if (content.has("profile")) {
|
if (content.has("profile")) {
|
||||||
System.out.print("** Profile: ");
|
System.out.print("** Profile: ");
|
||||||
JsonObject profile = content.getAsJsonObject("profile");
|
JsonObject profile = content.getAsJsonObject("profile");
|
||||||
|
if (profile.getAsJsonObject("java").has("debug")) {
|
||||||
|
val.setDebug(profile.getAsJsonObject("java").get("debug").getAsBoolean());
|
||||||
|
}
|
||||||
if (profile.has("supporting")) {
|
if (profile.has("supporting")) {
|
||||||
for (JsonElement e : profile.getAsJsonArray("supporting")) {
|
for (JsonElement e : profile.getAsJsonArray("supporting")) {
|
||||||
String filename = e.getAsString();
|
String filename = e.getAsString();
|
||||||
|
|
Loading…
Reference in New Issue