Accidentally reverted a fix in InstanceValidator

This commit is contained in:
James Agnew 2017-10-11 13:38:05 -04:00
parent 9b31741147
commit 0ac53e55d4
1 changed files with 28 additions and 13 deletions

View File

@ -105,7 +105,6 @@ import org.w3c.dom.Node;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import ca.uhn.fhir.util.ObjectUtil; import ca.uhn.fhir.util.ObjectUtil;
@ -293,6 +292,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
source = Source.InstanceValidator; source = Source.InstanceValidator;
} }
@Override @Override
public boolean isNoInvariantChecks() { public boolean isNoInvariantChecks() {
return noInvariantChecks; return noInvariantChecks;
@ -1357,17 +1358,31 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
checkFixedValue(errors, path + ".denominator", focus.getNamedChild("denominator"), fixed.getDenominator(), "denominator", focus); checkFixedValue(errors, path + ".denominator", focus.getNamedChild("denominator"), fixed.getDenominator(), "denominator", focus);
} }
private void checkReference(Object appContext, List<ValidationMessage> errors, String path, Element element, StructureDefinition profile, ElementDefinition container, String parentType, NodeStack stack) throws FHIRException, IOException { private Reference readAsReference(Element item) {
String ref = null; Reference r = new Reference();
try { r.setDisplay(item.getNamedChildValue("display"));
// Do this inside a try because invalid instances might provide more than one reference. r.setReference(item.getNamedChildValue("reference"));
ref = element.getNamedChildValue("reference"); List<Element> identifier = item.getChildrenByName("identifier");
} catch (Error e) { if (identifier.isEmpty() == false) {
r.setIdentifier(readAsIdentifier(identifier.get(0)));
} }
return r;
}
private Identifier readAsIdentifier(Element item) {
Identifier r = new Identifier();
r.setSystem(item.getNamedChildValue("system"));
r.setValue(item.getNamedChildValue("value"));
return r;
}
private void checkReference(Object appContext, List<ValidationMessage> errors, String path, Element element, StructureDefinition profile, ElementDefinition container, String parentType, NodeStack stack) throws FHIRException, IOException {
Reference reference = readAsReference(element);
String ref = reference.getReference();
if (Utilities.noString(ref)) { if (Utilities.noString(ref)) {
// todo - what should we do in this case? if (Utilities.noString(reference.getIdentifier().getSystem()) && Utilities.noString(reference.getIdentifier().getValue())) {
warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), "A Reference without an actual reference should have a display"); warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), "A Reference without an actual reference or identifier should have a display");
}
return; return;
} }