use of org.molgenis.validation.ConstraintViolation in project molgenis by molgenis.
the class EntityAttributesValidator method checkValidationExpressions.
private Set<ConstraintViolation> checkValidationExpressions(Entity entity, EntityType meta) {
List<String> validationExpressions = new ArrayList<>();
List<Attribute> expressionAttributes = new ArrayList<>();
for (Attribute attribute : meta.getAtomicAttributes()) {
if (StringUtils.isNotBlank(attribute.getValidationExpression())) {
expressionAttributes.add(attribute);
validationExpressions.add(attribute.getValidationExpression());
}
}
Set<ConstraintViolation> violations = new LinkedHashSet<>();
if (!validationExpressions.isEmpty()) {
List<Boolean> results = expressionValidator.resolveBooleanExpressions(validationExpressions, entity);
for (int i = 0; i < results.size(); i++) {
if (!TRUE.equals(results.get(i))) {
violations.add(createConstraintViolation(entity, expressionAttributes.get(i), meta, format("Offended validation expression: %s", validationExpressions.get(i))));
}
}
}
return violations;
}
Aggregations