use of org.jowidgets.cap.ui.api.bean.IExternalBeanValidator 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());
}
use of org.jowidgets.cap.ui.api.bean.IExternalBeanValidator in project jo-client-platform by jo-source.
the class BeanProxyImpl method clearValidationResults.
private void clearValidationResults() {
final boolean hasResults = independentWorstResult.get() != null || validationResults.size() > 0;
if (hasResults) {
if (independentWorstResult.get() != null) {
for (final Entry<String, IObserverSet<IExternalBeanValidator>> entry : externalValidators.entrySet()) {
final IBeanValidationResult okResult = BeanValidationResult.create(entry.getKey(), ValidationResult.ok());
for (final IExternalBeanValidator externalValidator : entry.getValue()) {
externalValidator.validate(Collections.singletonList(okResult));
}
}
} else {
for (final String propertyName : validationResults.keySet()) {
final IBeanValidationResult okResult = BeanValidationResult.create(propertyName, ValidationResult.ok());
for (final IExternalBeanValidator externalValidator : getRegisteredExternalValidators(propertyName)) {
externalValidator.validate(Collections.singletonList(okResult));
}
}
}
independentWorstResult.set(null);
validationResults.clear();
fireValidationConditionsChanged();
}
}
Aggregations