Search in sources :

Example 16 with IUiFilter

use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.

the class UiFilterToolsImpl method isPropertyFiltered.

@Override
public boolean isPropertyFiltered(final IUiFilter sourceFilter, final String propertyName) {
    Assert.paramNotNull(sourceFilter, "sourceFilter");
    Assert.paramNotNull(propertyName, "propertyName");
    if (sourceFilter instanceof IUiBooleanFilter) {
        final IUiBooleanFilter booleanSourceFilter = (IUiBooleanFilter) sourceFilter;
        for (final IUiFilter subSourceFilter : booleanSourceFilter.getFilters()) {
            if (isPropertyFiltered(subSourceFilter, propertyName)) {
                return true;
            }
        }
        return false;
    } else if (sourceFilter instanceof IUiArithmeticFilter<?>) {
        return propertyName.equals(((IUiArithmeticFilter<?>) sourceFilter).getPropertyName());
    } else if (sourceFilter instanceof IUiArithmeticPropertyFilter<?>) {
        return propertyName.equals(((IUiArithmeticPropertyFilter<?>) sourceFilter).getPropertyName());
    } else if (sourceFilter instanceof IUiCustomFilter<?>) {
        return propertyName.equals(((IUiCustomFilter<?>) sourceFilter).getPropertyName());
    } else {
        throw new IllegalArgumentException("The source filter type '" + sourceFilter.getClass().getName() + "' is not supported");
    }
}
Also used : IUiArithmeticPropertyFilter(org.jowidgets.cap.ui.api.filter.IUiArithmeticPropertyFilter) IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter) IUiCustomFilter(org.jowidgets.cap.ui.api.filter.IUiCustomFilter) IUiBooleanFilter(org.jowidgets.cap.ui.api.filter.IUiBooleanFilter) IUiArithmeticFilter(org.jowidgets.cap.ui.api.filter.IUiArithmeticFilter)

Example 17 with IUiFilter

use of org.jowidgets.cap.ui.api.filter.IUiFilter in project jo-client-platform by jo-source.

the class UiFilterToolsImpl method hasPropertyFilters.

@Override
public boolean hasPropertyFilters(final IUiFilter sourceFilter, final String... ignoredProperties) {
    Assert.paramNotNull(sourceFilter, "sourceFilter");
    final Set<String> ignored = new HashSet<String>();
    if (ignoredProperties != null) {
        ignored.addAll(Arrays.asList(ignoredProperties));
    }
    if (sourceFilter instanceof IUiBooleanFilter) {
        final IUiBooleanFilter booleanSourceFilter = (IUiBooleanFilter) sourceFilter;
        for (final IUiFilter subSourceFilter : booleanSourceFilter.getFilters()) {
            if (hasPropertyFilters(subSourceFilter, ignoredProperties)) {
                return true;
            }
        }
        return false;
    } else if (sourceFilter instanceof IUiArithmeticFilter<?>) {
        final String propertyName = ((IUiArithmeticFilter<?>) sourceFilter).getPropertyName();
        if (ignored.contains(propertyName)) {
            return false;
        } else {
            return true;
        }
    } else if (sourceFilter instanceof IUiArithmeticPropertyFilter<?>) {
        final String propertyName = ((IUiArithmeticPropertyFilter<?>) sourceFilter).getPropertyName();
        if (ignored.contains(propertyName)) {
            return false;
        } else {
            return true;
        }
    } else if (sourceFilter instanceof IUiCustomFilter<?>) {
        final String propertyName = ((IUiCustomFilter<?>) sourceFilter).getPropertyName();
        if (ignored.contains(propertyName)) {
            return false;
        } else {
            return true;
        }
    } else {
        throw new IllegalArgumentException("The source filter type '" + sourceFilter.getClass().getName() + "' is not supported");
    }
}
Also used : IUiArithmeticPropertyFilter(org.jowidgets.cap.ui.api.filter.IUiArithmeticPropertyFilter) IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter) IUiBooleanFilter(org.jowidgets.cap.ui.api.filter.IUiBooleanFilter) HashSet(java.util.HashSet)

Aggregations

IUiFilter (org.jowidgets.cap.ui.api.filter.IUiFilter)17 IUiFilterTools (org.jowidgets.cap.ui.api.filter.IUiFilterTools)7 IUiArithmeticPropertyFilter (org.jowidgets.cap.ui.api.filter.IUiArithmeticPropertyFilter)4 IUiBooleanFilter (org.jowidgets.cap.ui.api.filter.IUiBooleanFilter)4 IUiFilterFactory (org.jowidgets.cap.ui.api.filter.IUiFilterFactory)4 IBooleanFilterBuilder (org.jowidgets.cap.common.api.filter.IBooleanFilterBuilder)3 IFilter (org.jowidgets.cap.common.api.filter.IFilter)3 IUiArithmeticFilter (org.jowidgets.cap.ui.api.filter.IUiArithmeticFilter)3 IUiCustomFilter (org.jowidgets.cap.ui.api.filter.IUiCustomFilter)3 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 IArithmeticFilterBuilder (org.jowidgets.cap.common.api.filter.IArithmeticFilterBuilder)1 IArithmeticPropertyFilterBuilder (org.jowidgets.cap.common.api.filter.IArithmeticPropertyFilterBuilder)1 ICustomFilterBuilder (org.jowidgets.cap.common.api.filter.ICustomFilterBuilder)1 IAttributeConfig (org.jowidgets.cap.ui.api.attribute.IAttributeConfig)1 IUiBooleanFilterBuilder (org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder)1