Search in sources :

Example 1 with TimeValidator

use of org.openforis.idm.metamodel.validation.TimeValidator in project collect by openforis.

the class ValidationMessageBuilder method getMessageKey.

protected String getMessageKey(Attribute<?, ?> attribute, ValidationResult validationResult) {
    String key = null;
    ValidationRule<?> validator = validationResult.getValidator();
    if (validator instanceof CodeValidator) {
        key = "validation.codeError";
    } else if (validator instanceof CodeParentValidator) {
        key = "validation.codeParentError";
    } else if (validator instanceof ComparisonCheck) {
        key = "validation.comparisonError";
    } else if (validator instanceof CoordinateValidator) {
        if (attribute.isFilled()) {
            key = "validation.coordinateError";
        } else {
            key = "validation.incompleteCoordinateError";
        }
    } else if (validator instanceof DateValidator) {
        if (attribute.isFilled()) {
            key = "validation.dateError";
        } else {
            key = "validation.incompleteDateError";
        }
    } else if (validator instanceof DistanceCheck) {
        key = "validation.distanceError";
    } else if (validator instanceof EntityKeyValidator) {
        key = "validation.entityKeyUniquenessError";
    } else if (validator instanceof ExternalCodeValidator) {
        key = "validation.externalCodeError";
    } else if (validator instanceof IntegerRangeValidator) {
        key = "validation.integerRangeError";
    } else if (validator instanceof PatternCheck) {
        key = "validation.patternError";
    } else if (validator instanceof RealRangeValidator) {
        key = "validation.realRangeError";
    } else if (validator instanceof RecordKeyUniquenessValidator) {
        key = "validation.recordKeyUniquenessError";
    } else if (validator instanceof SpecifiedValidator) {
        if (validationResult.getFlag() == ValidationResultFlag.ERROR) {
            key = "validation.specifiedError";
        } else {
            key = "validation.requiredField";
        }
    } else if (validator instanceof TimeValidator) {
        if (attribute.isFilled()) {
            key = "validation.timeError";
        } else {
            key = "validation.incompleteTimeError";
        }
    } else if (validator instanceof TaxonVernacularLanguageValidator) {
        TaxonAttribute taxonAttr = (TaxonAttribute) attribute;
        if (StringUtils.isNotBlank(taxonAttr.getVernacularName()) && StringUtils.isBlank(taxonAttr.getLanguageCode())) {
            key = "validator.taxon.missingVernacularLanguage";
        } else {
            key = "validator.taxon.vernacularLanguageNotRequired";
        }
    } else if (validator instanceof UniquenessCheck) {
        key = "validation.uniquenessError";
    } else if (validator instanceof NumberValueUnitValidator || validator instanceof NumericRangeUnitValidator) {
        key = "validation.unitNotSpecifiedError";
    }
    return key;
}
Also used : DateValidator(org.openforis.idm.metamodel.validation.DateValidator) IntegerRangeValidator(org.openforis.idm.metamodel.validation.IntegerRangeValidator) TimeValidator(org.openforis.idm.metamodel.validation.TimeValidator) TaxonVernacularLanguageValidator(org.openforis.idm.metamodel.validation.TaxonVernacularLanguageValidator) NumberValueUnitValidator(org.openforis.idm.metamodel.validation.NumberValueUnitValidator) ExternalCodeValidator(org.openforis.idm.metamodel.validation.ExternalCodeValidator) CodeValidator(org.openforis.idm.metamodel.validation.CodeValidator) ComparisonCheck(org.openforis.idm.metamodel.validation.ComparisonCheck) EntityKeyValidator(org.openforis.idm.metamodel.validation.EntityKeyValidator) NumericRangeUnitValidator(org.openforis.idm.metamodel.validation.NumericRangeUnitValidator) PatternCheck(org.openforis.idm.metamodel.validation.PatternCheck) RealRangeValidator(org.openforis.idm.metamodel.validation.RealRangeValidator) TaxonAttribute(org.openforis.idm.model.TaxonAttribute) DistanceCheck(org.openforis.idm.metamodel.validation.DistanceCheck) ExternalCodeValidator(org.openforis.idm.metamodel.validation.ExternalCodeValidator) UniquenessCheck(org.openforis.idm.metamodel.validation.UniquenessCheck) CodeParentValidator(org.openforis.idm.metamodel.validation.CodeParentValidator) CoordinateValidator(org.openforis.idm.metamodel.validation.CoordinateValidator)

Aggregations

CodeParentValidator (org.openforis.idm.metamodel.validation.CodeParentValidator)1 CodeValidator (org.openforis.idm.metamodel.validation.CodeValidator)1 ComparisonCheck (org.openforis.idm.metamodel.validation.ComparisonCheck)1 CoordinateValidator (org.openforis.idm.metamodel.validation.CoordinateValidator)1 DateValidator (org.openforis.idm.metamodel.validation.DateValidator)1 DistanceCheck (org.openforis.idm.metamodel.validation.DistanceCheck)1 EntityKeyValidator (org.openforis.idm.metamodel.validation.EntityKeyValidator)1 ExternalCodeValidator (org.openforis.idm.metamodel.validation.ExternalCodeValidator)1 IntegerRangeValidator (org.openforis.idm.metamodel.validation.IntegerRangeValidator)1 NumberValueUnitValidator (org.openforis.idm.metamodel.validation.NumberValueUnitValidator)1 NumericRangeUnitValidator (org.openforis.idm.metamodel.validation.NumericRangeUnitValidator)1 PatternCheck (org.openforis.idm.metamodel.validation.PatternCheck)1 RealRangeValidator (org.openforis.idm.metamodel.validation.RealRangeValidator)1 TaxonVernacularLanguageValidator (org.openforis.idm.metamodel.validation.TaxonVernacularLanguageValidator)1 TimeValidator (org.openforis.idm.metamodel.validation.TimeValidator)1 UniquenessCheck (org.openforis.idm.metamodel.validation.UniquenessCheck)1 TaxonAttribute (org.openforis.idm.model.TaxonAttribute)1