Search in sources :

Example 1 with ExternalCodeListProvider

use of org.openforis.idm.metamodel.ExternalCodeListProvider in project collect by openforis.

the class ExternalCodeValidator method evaluate.

@Override
public ValidationResultFlag evaluate(CodeAttribute codeAttribute) {
    if (codeAttribute.getSurvey().getId() == null) {
        return ValidationResultFlag.OK;
    }
    ExternalCodeListProvider externalCodeListProvider = getExternalCodeListProvider(codeAttribute);
    ExternalCodeListItem item = externalCodeListProvider.getItem(codeAttribute);
    if (item == null || item.getCode() == null || !item.getCode().equals(codeAttribute.getValue().getCode())) {
        if (isUnlistedAllowed(codeAttribute)) {
            return ValidationResultFlag.WARNING;
        } else {
            return ValidationResultFlag.ERROR;
        }
    } else {
        return ValidationResultFlag.OK;
    }
}
Also used : ExternalCodeListItem(org.openforis.idm.metamodel.ExternalCodeListItem) ExternalCodeListProvider(org.openforis.idm.metamodel.ExternalCodeListProvider)

Aggregations

ExternalCodeListItem (org.openforis.idm.metamodel.ExternalCodeListItem)1 ExternalCodeListProvider (org.openforis.idm.metamodel.ExternalCodeListProvider)1