use of org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder in project jo-client-platform by jo-source.
the class AttributesBeanPropertyValidator method validateProperty.
@Override
public Collection<IBeanValidationResult> validateProperty(final IBeanProxy<BEAN_TYPE> bean, final String propertyName) {
final IBeanValidationResultListBuilder builder = CapCommonToolkit.beanValidationResultListBuilder();
builder.addResult(validatePropertyImpl(bean, propertyName), propertyName);
return builder.build();
}
use of org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder in project jo-client-platform by jo-source.
the class BeanProxyImpl method validateProperty.
private List<IBeanValidationResult> validateProperty(final String propertyName) {
Assert.paramNotNull(propertyName, "propertyName");
final IBeanValidationResultListBuilder builder = CapCommonToolkit.beanValidationResultListBuilder();
builder.addResult(ValidationResult.ok(), propertyName);
if (validateUnmodified || hasModifications() || isTransient) {
final IAttribute<Object> attribute = getAttribute(propertyName);
if (attribute != null) {
final String currentLabel = attribute.getCurrentLabel();
addValidationResults(beanPropertyValidators, builder, propertyName, currentLabel);
} else {
LOGGER.warn("Try to validate property with name '" + propertyName + "' but property is not known to this IBeanProxy: " + this);
}
}
return builder.build();
}
use of org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder in project jo-client-platform by jo-source.
the class BeanProxyImpl method validateProperties.
private void validateProperties(Collection<String> propertyNames) {
if (!isValidationNecessary()) {
clearValidationResults();
return;
}
propertyNames = getDependendProperties(propertyNames);
final IBeanValidationResultListBuilder builder = CapCommonToolkit.beanValidationResultListBuilder();
final ValueHolder<IBeanValidationResult> firstWorstIndependendResultHolder = new ValueHolder<IBeanValidationResult>();
for (final String propertyName : propertyNames) {
builder.addResult(validateProperty(propertyName));
}
Map<String, IBeanValidationResult> consolidatedResult;
consolidatedResult = consolidateBeanValidationResult(firstWorstIndependendResultHolder, builder.build());
// validate all results external
if (!consolidatedResult.isEmpty()) {
final List<IBeanValidationResult> externalResults = new LinkedList<IBeanValidationResult>();
for (final Entry<String, IBeanValidationResult> parentResultEntry : consolidatedResult.entrySet()) {
final String propertyName = parentResultEntry.getKey();
final IBeanValidationResult parentResult = parentResultEntry.getValue();
for (final IExternalBeanValidator externalValidator : getRegisteredExternalValidators(propertyName)) {
externalResults.addAll(externalValidator.validate(Collections.singletonList(parentResult)));
}
}
if (!externalResults.isEmpty()) {
consolidatedResult = consolidateBeanValidationResult(consolidatedResult, firstWorstIndependendResultHolder, externalResults);
}
}
setValidationResults(firstWorstIndependendResultHolder, consolidatedResult.values());
}
Aggregations