Search in sources :

Example 1 with ResourceValidationTracker

use of org.hl7.fhir.validation.instance.utils.ResourceValidationTracker in project org.hl7.fhir.core by hapifhir.

the class InstanceValidator method getResourceTracker.

private ResourceValidationTracker getResourceTracker(Element element) {
    ResourceValidationTracker res = resourceTracker.get(element);
    if (res == null) {
        res = new ResourceValidationTracker();
        resourceTracker.put(element, res);
    }
    return res;
}
Also used : ResourceValidationTracker(org.hl7.fhir.validation.instance.utils.ResourceValidationTracker)

Example 2 with ResourceValidationTracker

use of org.hl7.fhir.validation.instance.utils.ResourceValidationTracker in project org.hl7.fhir.core by hapifhir.

the class InstanceValidator method startInner.

public void startInner(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element resource, Element element, StructureDefinition defn, NodeStack stack, boolean checkSpecials) {
    // the first piece of business is to see if we've validated this resource against this profile before.
    // if we have (*or if we still are*), then we'll just return our existing errors
    ResourceValidationTracker resTracker = getResourceTracker(element);
    List<ValidationMessage> cachedErrors = resTracker.getOutcomes(defn);
    if (cachedErrors != null) {
        for (ValidationMessage vm : cachedErrors) {
            if (!errors.contains(vm)) {
                errors.add(vm);
            }
        }
        return;
    }
    if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), defn.hasSnapshot(), I18nConstants.VALIDATION_VAL_PROFILE_NOSNAPSHOT, defn.getUrl())) {
        List<ValidationMessage> localErrors = new ArrayList<ValidationMessage>();
        resTracker.startValidating(defn);
        trackUsage(defn, hostContext, element);
        validateElement(hostContext, localErrors, defn, defn.getSnapshot().getElement().get(0), null, null, resource, element, element.getName(), stack, false, true, null);
        resTracker.storeOutcomes(defn, localErrors);
        for (ValidationMessage vm : localErrors) {
            if (!errors.contains(vm)) {
                errors.add(vm);
            }
        }
    }
    if (checkSpecials) {
        checkSpecials(hostContext, errors, element, stack, checkSpecials);
        validateResourceRules(errors, element, stack);
    }
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ResourceValidationTracker(org.hl7.fhir.validation.instance.utils.ResourceValidationTracker) ArrayList(java.util.ArrayList)

Aggregations

ResourceValidationTracker (org.hl7.fhir.validation.instance.utils.ResourceValidationTracker)2 ArrayList (java.util.ArrayList)1 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)1