Search in sources :

Example 6 with IUiFilter

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

the class UiFilterToolsImpl method removeProperty.

@SuppressWarnings("unchecked")
@Override
public IUiFilter removeProperty(final IUiFilter sourceFilter, final String propertyName) {
    Assert.paramNotNull(sourceFilter, "sourceFilter");
    Assert.paramNotNull(propertyName, "propertyName");
    final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
    if (sourceFilter instanceof IUiBooleanFilter) {
        boolean empty = true;
        final IUiBooleanFilter source = (IUiBooleanFilter) sourceFilter;
        final IUiBooleanFilterBuilder builder = filterFactory.booleanFilterBuilder();
        builder.setOperator(source.getOperator());
        builder.setInverted(source.isInverted());
        for (final IUiFilter childFilter : source.getFilters()) {
            final IUiFilter childResultFilter = removeProperty(childFilter, propertyName);
            if (childResultFilter != null) {
                builder.addFilter(childResultFilter);
                empty = false;
            }
        }
        if (empty) {
            return null;
        } else {
            return builder.build();
        }
    } else if (sourceFilter instanceof IUiArithmeticFilter<?>) {
        final IUiArithmeticFilter<Object> source = (IUiArithmeticFilter<Object>) sourceFilter;
        if (propertyName.equals(source.getPropertyName())) {
            return null;
        } else {
            return source;
        }
    } else if (sourceFilter instanceof IUiArithmeticPropertyFilter<?>) {
        final IUiArithmeticPropertyFilter<Object> source = (IUiArithmeticPropertyFilter<Object>) sourceFilter;
        if (propertyName.equals(source.getPropertyName())) {
            return null;
        } else {
            return source;
        }
    } else if (sourceFilter instanceof IUiCustomFilter<?>) {
        final IUiCustomFilter<Object> source = (IUiCustomFilter<Object>) sourceFilter;
        if (propertyName.equals(source.getPropertyName())) {
            return null;
        } else {
            return source;
        }
    } else {
        throw new IllegalArgumentException("The source filter type '" + sourceFilter.getClass().getName() + "' is not supported");
    }
}
Also used : IUiArithmeticPropertyFilter(org.jowidgets.cap.ui.api.filter.IUiArithmeticPropertyFilter) IUiBooleanFilterBuilder(org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder) IUiCustomFilter(org.jowidgets.cap.ui.api.filter.IUiCustomFilter) IUiBooleanFilter(org.jowidgets.cap.ui.api.filter.IUiBooleanFilter) IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter) IUiArithmeticFilter(org.jowidgets.cap.ui.api.filter.IUiArithmeticFilter)

Example 7 with IUiFilter

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

the class UiFilterToolsImpl method toHumanReadable.

private StringBuilder toHumanReadable(final IUiBooleanFilter filter, final Map<String, String> attributeMap) {
    final StringBuilder result = new StringBuilder();
    if (filter.getFilters().size() > 0) {
        int effectiveSize = 0;
        if (filter.isInverted()) {
            result.append("not (");
        }
        for (final IUiFilter subFilter : filter.getFilters()) {
            result.append('(');
            result.append(toHumanReadable(subFilter, attributeMap));
            result.append(')');
            effectiveSize = result.length();
            result.append(' ');
            result.append(filter.getOperator().getLabel());
            result.append(' ');
        }
        result.setLength(effectiveSize);
        if (filter.isInverted()) {
            result.append(')');
        }
    }
    return result;
}
Also used : IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter)

Example 8 with IUiFilter

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

the class BeanRelationNodeModelImpl method addFilter.

@Override
public void addFilter(final String id, final IUiFilter addedFilter) {
    Assert.paramNotNull(id, "id");
    Assert.paramNotNull(addedFilter, "addedFilter");
    final IUiFilterTools filterTools = CapUiToolkit.filterToolkit().filterTools();
    final IUiFilter currentFilter = getFilter(id);
    setFilter(id, filterTools.addFilter(currentFilter, addedFilter));
}
Also used : IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter) IUiFilterTools(org.jowidgets.cap.ui.api.filter.IUiFilterTools)

Example 9 with IUiFilter

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

the class BeanTabFolderModelImpl method addFilter.

@Override
public void addFilter(final String id, final IUiFilter addedFilter) {
    Assert.paramNotNull(id, "id");
    Assert.paramNotNull(addedFilter, "addedFilter");
    final IUiFilterTools filterTools = CapUiToolkit.filterToolkit().filterTools();
    final IUiFilter currentFilter = getFilter(id);
    setFilter(id, filterTools.addFilter(currentFilter, addedFilter));
}
Also used : IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter) IUiFilterTools(org.jowidgets.cap.ui.api.filter.IUiFilterTools)

Example 10 with IUiFilter

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

the class BeanTabFolderModelImpl method getFilter.

private IFilter getFilter() {
    if (filters.size() > 0) {
        final IBooleanFilterBuilder builder = CapCommonToolkit.filterFactory().booleanFilterBuilder();
        builder.setOperator(BooleanOperator.AND);
        final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
        for (final IUiFilter uiFilter : filters.values()) {
            builder.addFilter(filterFactory.convert(uiFilter));
        }
        return builder.build();
    } else {
        return null;
    }
}
Also used : IBooleanFilterBuilder(org.jowidgets.cap.common.api.filter.IBooleanFilterBuilder) IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter)

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