Search in sources :

Example 1 with IBeanValidationResultListBuilder

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();
}
Also used : IBeanValidationResultListBuilder(org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder)

Example 2 with IBeanValidationResultListBuilder

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();
}
Also used : IBeanValidationResultListBuilder(org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder)

Example 3 with IBeanValidationResultListBuilder

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());
}
Also used : IBeanValidationResult(org.jowidgets.cap.common.api.validation.IBeanValidationResult) ValueHolder(org.jowidgets.util.ValueHolder) IExternalBeanValidator(org.jowidgets.cap.ui.api.bean.IExternalBeanValidator) IBeanValidationResultListBuilder(org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder) LinkedList(java.util.LinkedList)

Aggregations

IBeanValidationResultListBuilder (org.jowidgets.cap.common.api.validation.IBeanValidationResultListBuilder)3 LinkedList (java.util.LinkedList)1 IBeanValidationResult (org.jowidgets.cap.common.api.validation.IBeanValidationResult)1 IExternalBeanValidator (org.jowidgets.cap.ui.api.bean.IExternalBeanValidator)1 ValueHolder (org.jowidgets.util.ValueHolder)1