Search in sources :

Example 1 with IUiBooleanFilterBuilder

use of org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder 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 2 with IUiBooleanFilterBuilder

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

the class UiFilterToolsImpl method invert.

@SuppressWarnings("unchecked")
@Override
public IUiFilter invert(final IUiFilter sourceFilter) {
    Assert.paramNotNull(sourceFilter, "sourceFilter");
    final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
    if (sourceFilter instanceof IUiBooleanFilter) {
        final IUiBooleanFilter source = (IUiBooleanFilter) sourceFilter;
        final IUiBooleanFilterBuilder builder = filterFactory.booleanFilterBuilder();
        builder.setOperator(source.getOperator());
        builder.setInverted(!source.isInverted());
        builder.setFilters(source.getFilters());
        return builder.build();
    } else if (sourceFilter instanceof IUiArithmeticFilter<?>) {
        final IUiArithmeticFilter<Object> source = (IUiArithmeticFilter<Object>) sourceFilter;
        final IUiArithmeticFilterBuilder<Object> builder = filterFactory.arithmeticFilterBuilder();
        builder.setOperator(source.getOperator());
        builder.setPropertyName(source.getPropertyName());
        builder.setParameters(source.getParameters());
        builder.setConfig(source.getConfig());
        builder.setInverted(!source.isInverted());
        return builder.build();
    } else if (sourceFilter instanceof IUiArithmeticPropertyFilter<?>) {
        final IUiArithmeticPropertyFilter<Object> source = (IUiArithmeticPropertyFilter<Object>) sourceFilter;
        final IUiArithmeticPropertyFilterBuilder<Object> builder = filterFactory.arithmeticPropertyFilterBuilder();
        builder.setOperator(source.getOperator());
        builder.setPropertyName(source.getPropertyName());
        builder.setRightHandPropertyNames(source.getRightHandPropertyNames());
        builder.setConfig(source.getConfig());
        builder.setInverted(!source.isInverted());
        return builder.build();
    } else if (sourceFilter instanceof IUiCustomFilter<?>) {
        final IUiCustomFilter<Object> source = (IUiCustomFilter<Object>) sourceFilter;
        final IUiCustomFilterBuilder<Object> builder = filterFactory.customFilterBuilder();
        builder.setOperator(source.getOperator());
        builder.setPropertyName(source.getPropertyName());
        builder.setValue(source.getValue());
        builder.setFilterType(source.getFilterType());
        builder.setConfig(source.getConfig());
        builder.setInverted(!source.isInverted());
        return builder.build();
    } 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) IUiCustomFilterBuilder(org.jowidgets.cap.ui.api.filter.IUiCustomFilterBuilder) IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IUiArithmeticFilterBuilder(org.jowidgets.cap.ui.api.filter.IUiArithmeticFilterBuilder) IUiArithmeticFilter(org.jowidgets.cap.ui.api.filter.IUiArithmeticFilter)

Example 3 with IUiBooleanFilterBuilder

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

the class UiFilterToolsImpl method addFilter.

@Override
public IUiFilter addFilter(final IUiFilter sourceFilter, final IUiFilter addedFilter) {
    Assert.paramNotNull(addedFilter, "addedFilter");
    final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
    if (sourceFilter == null) {
        return addedFilter;
    } else if (sourceFilter instanceof IUiBooleanFilter) {
        final IUiBooleanFilter booleanSourceFilter = (IUiBooleanFilter) sourceFilter;
        final IUiBooleanFilterBuilder builder = filterFactory.booleanFilterBuilder();
        builder.setOperator(booleanSourceFilter.getOperator());
        builder.setInverted(booleanSourceFilter.isInverted());
        builder.setFilters(booleanSourceFilter.getFilters());
        builder.addFilter(addedFilter);
        return builder.build();
    } else {
        final IUiBooleanFilterBuilder builder = filterFactory.booleanFilterBuilder();
        builder.setOperator(BooleanOperator.AND);
        builder.addFilter(sourceFilter);
        builder.addFilter(addedFilter);
        return builder.build();
    }
}
Also used : IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IUiBooleanFilterBuilder(org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder) IUiBooleanFilter(org.jowidgets.cap.ui.api.filter.IUiBooleanFilter)

Example 4 with IUiBooleanFilterBuilder

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

the class BeanLinkPanelImpl method doFilter.

private void doFilter(final IBeanProxy<LINKABLE_BEAN_TYPE> bean) {
    final IBeanTableModel<LINKABLE_BEAN_TYPE> tableModel = linkableTable.getModel();
    final IFilterToolkit filterToolkit = CapUiToolkit.filterToolkit();
    final IUiFilterFactory filterFactory = filterToolkit.filterFactory();
    final IUiBooleanFilterBuilder filterBuilder;
    filterBuilder = filterFactory.booleanFilterBuilder().setOperator(BooleanOperator.AND);
    if (bean != null) {
        for (final IBeanModification modification : bean.getModifications()) {
            final String propertyName = modification.getPropertyName();
            final IAttribute<Object> attribute = tableModel.getAttribute(propertyName);
            final IIncludingFilterFactory<Object> includingFilterFactory = getIncludingFilterFactory(attribute);
            if (includingFilterFactory != null) {
                final Object operand = getModifiedFilterOperand(modification.getNewValue());
                filterBuilder.addFilter(includingFilterFactory.getIncludingFilter(operand));
            }
        }
    }
    if (filterBuilder.hasEntries()) {
        tableModel.setFilter(BEAN_LINK_SEARCH_FILTER_ID, filterBuilder.build());
    } else {
        tableModel.setFilter(BEAN_LINK_SEARCH_FILTER_ID, null);
    }
    tableModel.loadScheduled(LOAD_DELAY);
}
Also used : IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IFilterToolkit(org.jowidgets.cap.ui.api.filter.IFilterToolkit) IUiBooleanFilterBuilder(org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder) IBeanModification(org.jowidgets.cap.common.api.bean.IBeanModification)

Aggregations

IUiBooleanFilterBuilder (org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder)4 IUiFilterFactory (org.jowidgets.cap.ui.api.filter.IUiFilterFactory)4 IUiBooleanFilter (org.jowidgets.cap.ui.api.filter.IUiBooleanFilter)3 IUiArithmeticFilter (org.jowidgets.cap.ui.api.filter.IUiArithmeticFilter)2 IUiArithmeticPropertyFilter (org.jowidgets.cap.ui.api.filter.IUiArithmeticPropertyFilter)2 IUiCustomFilter (org.jowidgets.cap.ui.api.filter.IUiCustomFilter)2 IBeanModification (org.jowidgets.cap.common.api.bean.IBeanModification)1 IFilterToolkit (org.jowidgets.cap.ui.api.filter.IFilterToolkit)1 IUiArithmeticFilterBuilder (org.jowidgets.cap.ui.api.filter.IUiArithmeticFilterBuilder)1 IUiCustomFilterBuilder (org.jowidgets.cap.ui.api.filter.IUiCustomFilterBuilder)1 IUiFilter (org.jowidgets.cap.ui.api.filter.IUiFilter)1