Fix pathing issues in the validator
This commit is contained in:
parent
a2c6dd6af1
commit
3a319a5d57
|
@ -790,8 +790,9 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
|
||||||
return signpost;
|
return signpost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSignpost(boolean signpost) {
|
public ValidationMessage setSignpost(boolean signpost) {
|
||||||
this.signpost = signpost;
|
this.signpost = signpost;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ TYPE_CHECKS_FIXED_CC_US = The pattern [system {0}, code {1}, display ''{2}'' and
|
||||||
VALIDATION_VAL_GLOBAL_PROFILE_UNKNOWN = Global Profile reference ''{0}'' from IG {1} could not be resolved, so has not been checked
|
VALIDATION_VAL_GLOBAL_PROFILE_UNKNOWN = Global Profile reference ''{0}'' from IG {1} could not be resolved, so has not been checked
|
||||||
VALIDATION_VAL_PROFILE_SIGNPOST_BASE = Validate resource against profile
|
VALIDATION_VAL_PROFILE_SIGNPOST_BASE = Validate resource against profile
|
||||||
VALIDATION_VAL_PROFILE_SIGNPOST = Validate resource against profile {0}
|
VALIDATION_VAL_PROFILE_SIGNPOST = Validate resource against profile {0}
|
||||||
VALIDATION_VAL_PROFILE_SIGNPOST_META = Validate resource against profile {0} - listed in meta
|
VALIDATION_VAL_PROFILE_SIGNPOST_META = Validate resource against profile {0} (per meta)
|
||||||
VALIDATION_VAL_PROFILE_SIGNPOST_BUNDLE_PARAM = Validate resource against profile {0} - provided as bundle param
|
VALIDATION_VAL_PROFILE_SIGNPOST_BUNDLE_PARAM = Validate resource against profile {0} - provided as bundle param
|
||||||
VALIDATION_VAL_PROFILE_SIGNPOST_GLOBAL = Validate resource against profile {0} - a global profile in {1}
|
VALIDATION_VAL_PROFILE_SIGNPOST_GLOBAL = Validate resource against profile {0} - a global profile in {1}
|
||||||
ERROR_GENERATING_SNAPSHOT = Error generating Snapshot: {0} (this usually arises from a problem in the differential)
|
ERROR_GENERATING_SNAPSHOT = Error generating Snapshot: {0} (this usually arises from a problem in the differential)
|
||||||
|
|
|
@ -284,12 +284,9 @@ public class BaseValidator {
|
||||||
return thePass;
|
return thePass;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean signpost(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
|
protected ValidationMessage signpost(List<ValidationMessage> errors, IssueType type, int line, int col, String path, String theMessage, Object... theMessageArguments) {
|
||||||
if (!thePass) {
|
|
||||||
String message = context.formatMessage(theMessage, theMessageArguments);
|
String message = context.formatMessage(theMessage, theMessageArguments);
|
||||||
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage).setSignpost(true);
|
return addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage).setSignpost(true);
|
||||||
}
|
|
||||||
return thePass;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean txHint(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
|
protected boolean txHint(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
|
||||||
|
|
|
@ -3270,8 +3270,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
rr.setResource(nstack.getElement());
|
rr.setResource(nstack.getElement());
|
||||||
rr.setFocus(nstack.getElement());
|
rr.setFocus(nstack.getElement());
|
||||||
rr.setExternal(false);
|
rr.setExternal(false);
|
||||||
rr.setStack(nstack.push(nstack.getElement(), -1, nstack.getElement().getProperty().getDefinition(), nstack.getElement().getProperty().getDefinition()));
|
rr.setStack(nstack);
|
||||||
rr.getStack().qualifyPath(".ofType("+nstack.getElement().fhirType()+")");
|
// rr.getStack().qualifyPath(".ofType("+nstack.getElement().fhirType()+")");
|
||||||
|
System.out.println("-->"+nstack.getLiteralPath());
|
||||||
return rr;
|
return rr;
|
||||||
}
|
}
|
||||||
if (nstack.getElement().getSpecial() == SpecialElement.CONTAINED) {
|
if (nstack.getElement().getSpecial() == SpecialElement.CONTAINED) {
|
||||||
|
@ -3951,7 +3952,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
// checkSpecials = we're only going to run these tests if we are actually validating this content (as opposed to we looked it up)
|
// checkSpecials = we're only going to run these tests if we are actually validating this content (as opposed to we looked it up)
|
||||||
private void start(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element resource, Element element, StructureDefinition defn, NodeStack stack) throws FHIRException {
|
private void start(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element resource, Element element, StructureDefinition defn, NodeStack stack) throws FHIRException {
|
||||||
checkLang(resource, stack);
|
checkLang(resource, stack);
|
||||||
signpost(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), !crumbTrails, I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST, defn.getUrl());
|
if (crumbTrails) {
|
||||||
|
element.addMessage(signpost(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST, defn.getUrl()));
|
||||||
|
}
|
||||||
|
|
||||||
if (BUNDLE.equals(element.fhirType())) {
|
if (BUNDLE.equals(element.fhirType())) {
|
||||||
resolveBundleReferences(element, new ArrayList<Element>());
|
resolveBundleReferences(element, new ArrayList<Element>());
|
||||||
|
@ -3996,7 +3999,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sd != null) {
|
if (sd != null) {
|
||||||
signpost(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), !crumbTrails, I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_META, sd.getUrl());
|
if (crumbTrails) {
|
||||||
|
element.addMessage(signpost(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_META, sd.getUrl()));
|
||||||
|
}
|
||||||
stack.resetIds();
|
stack.resetIds();
|
||||||
startInner(hostContext, errors, resource, element, sd, stack, false);
|
startInner(hostContext, errors, resource, element, sd, stack, false);
|
||||||
}
|
}
|
||||||
|
@ -4011,7 +4016,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
if (rt.equals(gl.getType())) {
|
if (rt.equals(gl.getType())) {
|
||||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class, gl.getProfile());
|
StructureDefinition sd = context.fetchResource(StructureDefinition.class, gl.getProfile());
|
||||||
if (warning(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), sd != null, I18nConstants.VALIDATION_VAL_GLOBAL_PROFILE_UNKNOWN, gl.getProfile())) {
|
if (warning(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), sd != null, I18nConstants.VALIDATION_VAL_GLOBAL_PROFILE_UNKNOWN, gl.getProfile())) {
|
||||||
signpost(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), !crumbTrails, I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_GLOBAL, sd.getUrl(), ig.getUrl());
|
if (crumbTrails) {
|
||||||
|
element.addMessage(signpost(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_GLOBAL, sd.getUrl(), ig.getUrl()));
|
||||||
|
}
|
||||||
stack.resetIds();
|
stack.resetIds();
|
||||||
startInner(hostContext, errors, resource, element, sd, stack, false);
|
startInner(hostContext, errors, resource, element, sd, stack, false);
|
||||||
}
|
}
|
||||||
|
@ -4517,13 +4524,15 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
type = null;
|
type = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NodeStack localStack = stack.push(ei.getElement(), ei.count, checkDefn, type == null ? typeDefn : resolveType(type, checkDefn.getType()));
|
NodeStack localStack = stack.push(ei.getElement(), "*".equals(ei.getDefinition().getBase().getMax()) && ei.count == -1 ? 0 : ei.count, checkDefn, type == null ? typeDefn : resolveType(type, checkDefn.getType()));
|
||||||
// if (debug) {
|
// if (debug) {
|
||||||
// System.out.println(" check " + localStack.getLiteralPath()+" against "+ei.getDefinition().getId()+" in profile "+profile.getUrl());
|
// System.out.println(" check " + localStack.getLiteralPath()+" against "+ei.getDefinition().getId()+" in profile "+profile.getUrl());
|
||||||
// }
|
// }
|
||||||
String localStackLiterapPath = localStack.getLiteralPath();
|
String localStackLiteralPath = localStack.getLiteralPath();
|
||||||
String eiPath = ei.getPath();
|
String eiPath = ei.getPath();
|
||||||
assert (eiPath.equals(localStackLiterapPath)) : "ei.path: " + ei.getPath() + " - localStack.getLiteralPath: " + localStackLiterapPath;
|
if (!eiPath.equals(localStackLiteralPath)) {
|
||||||
|
assert (eiPath.equals(localStackLiteralPath)) : "ei.path: " + ei.getPath() + " - localStack.getLiteralPath: " + localStackLiteralPath;
|
||||||
|
}
|
||||||
boolean thisIsCodeableConcept = false;
|
boolean thisIsCodeableConcept = false;
|
||||||
String thisExtension = null;
|
String thisExtension = null;
|
||||||
boolean checkDisplay = true;
|
boolean checkDisplay = true;
|
||||||
|
|
|
@ -112,7 +112,9 @@ public class BundleValidator extends BaseValidator{
|
||||||
} else {
|
} else {
|
||||||
Element res = entry.getNamedChild(RESOURCE);
|
Element res = entry.getNamedChild(RESOURCE);
|
||||||
NodeStack rstack = estack.push(res, -1, null, null);
|
NodeStack rstack = estack.push(res, -1, null, null);
|
||||||
signpost(errors, IssueType.INFORMATIONAL, res.line(), res.col(), stack.getLiteralPath(), !validator.isCrumbTrails(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_BUNDLE_PARAM, defn.getUrl());
|
if (validator.isCrumbTrails()) {
|
||||||
|
res.addMessage(signpost(errors, IssueType.INFORMATIONAL, res.line(), res.col(), stack.getLiteralPath(), I18nConstants.VALIDATION_VAL_PROFILE_SIGNPOST_BUNDLE_PARAM, defn.getUrl()));
|
||||||
|
}
|
||||||
stack.resetIds();
|
stack.resetIds();
|
||||||
validator.startInner(hostContext, errors, res, res, defn, rstack, false);
|
validator.startInner(hostContext, errors, res, res, defn, rstack, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,12 @@ public class ChildIterator {
|
||||||
String na = cursor >= parent.getChildren().size() - 1 ? "--" : parent.getChildren().get(cursor + 1).getName();
|
String na = cursor >= parent.getChildren().size() - 1 ? "--" : parent.getChildren().get(cursor + 1).getName();
|
||||||
if (name().equals(nb) || name().equals(na)) {
|
if (name().equals(nb) || name().equals(na)) {
|
||||||
return lastCount;
|
return lastCount;
|
||||||
} else
|
} else if (element().isBaseList()) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean next() {
|
public boolean next() {
|
||||||
if (cursor == -1) {
|
if (cursor == -1) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class NodeStack {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
ids = new HashMap<>();
|
ids = new HashMap<>();
|
||||||
this.element = element;
|
this.element = element;
|
||||||
literalPath = element.getName();
|
literalPath = element.getPath();
|
||||||
workingLang = validationLanguage;
|
workingLang = validationLanguage;
|
||||||
if (!element.getName().equals(element.fhirType())) {
|
if (!element.getName().equals(element.fhirType())) {
|
||||||
logicalPaths = new ArrayList<>();
|
logicalPaths = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue