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;
}
}
Aggregations