Search in sources :

Example 26 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class ParserBase method logError.

// FIXME: i18n should be done here
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
    if (errors != null) {
        if (policy == ValidationPolicy.EVERYTHING) {
            ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
            errors.add(msg);
        } else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
            throw new FHIRFormatError(message + String.format(" at line %d col %d", line, col));
    }
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 27 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class BaseValidator method warningOrError.

protected boolean warningOrError(boolean isError, List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
    if (!thePass) {
        String nmsg = context.formatMessage(msg, theMessageArguments);
        IssueSeverity lvl = isError ? IssueSeverity.ERROR : IssueSeverity.WARNING;
        if (doingLevel(lvl)) {
            addValidationMessage(errors, type, line, col, path, nmsg, lvl, msg);
        }
    }
    return thePass;
}
Also used : IssueSeverity(org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)

Example 28 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class BaseValidator method warning.

/**
 * Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
 *
 * @param thePass
 *          Set this parameter to <code>false</code> if the validation does not pass
 * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
 */
protected boolean warning(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
    if (!thePass && doingWarnings()) {
        String nmsg = context.formatMessage(msg, theMessageArguments);
        IssueSeverity severity = IssueSeverity.WARNING;
        addValidationMessage(errors, type, line, col, path, nmsg, severity, msg);
    }
    return thePass;
}
Also used : IssueSeverity(org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)

Example 29 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class BaseValidator method warningOrHint.

/**
 * Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
 *
 * @param thePass
 *          Set this parameter to <code>false</code> if the validation does not pass
 * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
 */
protected boolean warningOrHint(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, boolean warning, String msg, Object... theMessageArguments) {
    if (!thePass) {
        String message = context.formatMessage(msg, theMessageArguments);
        IssueSeverity lvl = warning ? IssueSeverity.WARNING : IssueSeverity.INFORMATION;
        if (doingLevel(lvl)) {
            addValidationMessage(errors, type, -1, -1, path, message, lvl, null);
        }
    }
    return thePass;
}
Also used : IssueSeverity(org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)

Example 30 with IssueSeverity

use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.

the class BaseValidator method suppressedwarning.

/**
 * Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
 *
 * @param thePass
 *          Set this parameter to <code>false</code> if the validation does not pass
 * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
 */
protected boolean suppressedwarning(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html) {
    if (!thePass && doingWarnings()) {
        IssueSeverity severity = IssueSeverity.INFORMATION;
        addValidationMessage(errors, type, path, msg, html, severity, null);
    }
    return thePass;
}
Also used : IssueSeverity(org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)

Aggregations

ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)12 ArrayList (java.util.ArrayList)9 IssueSeverity (org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)9 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 JsonObject (com.google.gson.JsonObject)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)2 ValidationResult (org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult)2 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)2 ValidationResult (org.hl7.fhir.r5.context.IWorkerContext.ValidationResult)2 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)2 TextFile (org.hl7.fhir.utilities.TextFile)2 JsonNull (com.google.gson.JsonNull)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Meta (org.hl7.fhir.dstu3.model.Meta)1 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)1 UriType (org.hl7.fhir.dstu3.model.UriType)1