Search in sources :

Example 1 with ValidationResultFlag

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

the class CollectMinCountValidator method evaluate.

@Override
public ValidationResultFlag evaluate(Entity entity) {
    CollectRecord record = (CollectRecord) entity.getRecord();
    ValidationResultFlag resultFlag = super.evaluate(entity);
    // you can approve missing values in entry phase as well
    if (resultFlag == ValidationResultFlag.ERROR) {
        if (record.getStep() == Step.CLEANSING && record.isMissingApproved(entity, getNodeDefinition())) {
            resultFlag = ValidationResultFlag.WARNING;
        }
    }
    return resultFlag;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) ValidationResultFlag(org.openforis.idm.metamodel.validation.ValidationResultFlag)

Example 2 with ValidationResultFlag

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

the class CollectNumberValueUnitValidator method evaluate.

@Override
public ValidationResultFlag evaluate(NumberAttribute<?, ?> attribute) {
    CollectRecord record = (CollectRecord) attribute.getRecord();
    Step step = record.getStep();
    ValidationResultFlag resultFlag = super.evaluate(attribute);
    if (resultFlag == ValidationResultFlag.ERROR && step == Step.ENTRY) {
        Character unitSymbolChar = attribute.getUnitField().getSymbol();
        FieldSymbol unitSymbol = FieldSymbol.valueOf(unitSymbolChar);
        if (unitSymbol != null && unitSymbol.isReasonBlank()) {
            return ValidationResultFlag.WARNING;
        }
    }
    return resultFlag;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) ValidationResultFlag(org.openforis.idm.metamodel.validation.ValidationResultFlag) FieldSymbol(org.openforis.collect.model.FieldSymbol) Step(org.openforis.collect.model.CollectRecord.Step)

Example 3 with ValidationResultFlag

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

the class CollectValidator method validateNumericRangeUnit.

@Override
protected void validateNumericRangeUnit(NumericRangeAttribute<?, ?> attribute, ValidationResults results) {
    NumericRangeUnitValidator unitValidator = new CollectNumericRangeUnitValidator();
    ValidationResultFlag unitValidationResult = unitValidator.evaluate(attribute);
    results.addResult(unitValidator, unitValidationResult);
}
Also used : ValidationResultFlag(org.openforis.idm.metamodel.validation.ValidationResultFlag) NumericRangeUnitValidator(org.openforis.idm.metamodel.validation.NumericRangeUnitValidator)

Example 4 with ValidationResultFlag

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

the class CollectValidator method validateMaxCount.

@Override
public ValidationResultFlag validateMaxCount(Entity entity, NodeDefinition childDef) {
    ValidationResultFlag flag = super.validateMaxCount(entity, childDef);
    CollectRecord record = (CollectRecord) entity.getRecord();
    record.updateMaxCountsValidationCache(entity, childDef, flag);
    return flag;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) ValidationResultFlag(org.openforis.idm.metamodel.validation.ValidationResultFlag)

Example 5 with ValidationResultFlag

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

the class CollectValidator method validateNumericAttributeUnit.

@Override
protected void validateNumericAttributeUnit(NumberAttribute<?, ?> attribute, ValidationResults results) {
    NumberValueUnitValidator validator = new CollectNumberValueUnitValidator();
    ValidationResultFlag result = validator.evaluate(attribute);
    results.addResult(validator, result);
}
Also used : ValidationResultFlag(org.openforis.idm.metamodel.validation.ValidationResultFlag) NumberValueUnitValidator(org.openforis.idm.metamodel.validation.NumberValueUnitValidator)

Aggregations

ValidationResultFlag (org.openforis.idm.metamodel.validation.ValidationResultFlag)20 Entity (org.openforis.idm.model.Entity)7 Test (org.junit.Test)6 CollectRecord (org.openforis.collect.model.CollectRecord)5 ArrayList (java.util.ArrayList)3 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)2 Step (org.openforis.collect.model.CollectRecord.Step)2 FieldSymbol (org.openforis.collect.model.FieldSymbol)2 ValidationResult (org.openforis.idm.metamodel.validation.ValidationResult)2 ValidationResults (org.openforis.idm.metamodel.validation.ValidationResults)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 NumberValueUnitValidator (org.openforis.idm.metamodel.validation.NumberValueUnitValidator)1 NumericRangeUnitValidator (org.openforis.idm.metamodel.validation.NumericRangeUnitValidator)1 Validator (org.openforis.idm.metamodel.validation.Validator)1 Attribute (org.openforis.idm.model.Attribute)1