Search in sources :

Example 1 with ValidationStatus

use of se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus in project webcert by sklintyg.

the class UtkastServiceImpl method convertToDraftValidation.

private DraftValidation convertToDraftValidation(ValidateDraftResponse dr) {
    DraftValidation draftValidation = new DraftValidation();
    ValidationStatus validationStatus = dr.getStatus();
    // Always return the warning messages
    for (ValidationMessage validationWarning : dr.getValidationWarnings()) {
        draftValidation.addWarning(new DraftValidationMessage(validationWarning.getCategory(), validationWarning.getField(), validationWarning.getType(), validationWarning.getMessage(), validationWarning.getDynamicKey()));
    }
    if (ValidationStatus.VALID.equals(validationStatus)) {
        LOG.debug("Validation is OK");
        return draftValidation;
    }
    draftValidation.setStatus(ValidationStatus.INVALID);
    // Only bother with returning validation (e.g. error) messages if the ArendeDraft is INVALID.
    for (ValidationMessage validationMsg : dr.getValidationErrors()) {
        draftValidation.addMessage(new DraftValidationMessage(validationMsg.getCategory(), validationMsg.getField(), validationMsg.getType(), validationMsg.getMessage(), validationMsg.getDynamicKey()));
    }
    LOG.debug("Validation failed with {} validation messages", draftValidation.getMessages().size());
    return draftValidation;
}
Also used : ValidationStatus(se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus) ValidationMessage(se.inera.intyg.common.support.modules.support.api.dto.ValidationMessage)

Example 2 with ValidationStatus

use of se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus in project webcert by sklintyg.

the class AbstractUtkastBuilder method validateDraft.

private UtkastStatus validateDraft(ModuleApi moduleApi, String draftCopyJson) throws ModuleException {
    ValidateDraftResponse validationResponse = moduleApi.validateDraft(draftCopyJson);
    ValidationStatus validationStatus = validationResponse.getStatus();
    return ValidationStatus.VALID.equals(validationStatus) ? UtkastStatus.DRAFT_COMPLETE : UtkastStatus.DRAFT_INCOMPLETE;
}
Also used : ValidationStatus(se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus) ValidateDraftResponse(se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)

Aggregations

ValidationStatus (se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus)2 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)1 ValidationMessage (se.inera.intyg.common.support.modules.support.api.dto.ValidationMessage)1