use of eu.esdihumboldt.hale.common.codelist.CodeList.CodeEntry in project hale by halestudio.
the class CodeListValidator method validateCodeListValue.
private void validateCodeListValue(@Nullable Object value, @Nullable EntityDefinition entity) throws ValidationException {
CodeListAssociations associations = null;
if (projectService != null) {
associations = projectService.getProperty(CodeListAssociations.KEY_ASSOCIATIONS).as(CodeListAssociations.class);
}
if (value != null && entity != null && associations != null && codeLists != null) {
CodeListReference clRef = associations.getCodeList(entity);
if (clRef != null) {
CodeList cl = codeLists.findCodeList(clRef);
if (cl != null) {
String strValue = value.toString();
CodeEntry entry = cl.getEntryByIdentifier(strValue);
if (entry == null) {
throw new ValidationException(MessageFormat.format("Value ''{0}'' not found in associated code list", strValue));
}
} else {
log.warn("Code list " + clRef + " not found for validation");
}
}
}
}
Aggregations