Search in sources :

Example 1 with IBeanDtoCustomFilterPlugin

use of org.jowidgets.cap.common.api.plugin.IBeanDtoCustomFilterPlugin in project jo-client-platform by jo-source.

the class BeanDtoFilterImpl method acceptCustom.

private boolean acceptCustom(final IBeanDto beanDto, final ICustomFilter filter) {
    Assert.paramNotEmpty(filter.getFilterType(), "filter.getFilterType()");
    final IPluginPropertiesBuilder propertiesBuilder = PluginToolkit.pluginPropertiesBuilder();
    propertiesBuilder.add(IBeanDtoCustomFilterPlugin.FILTER_TYPE_PROPERTY_KEY, filter.getFilterType());
    final List<IBeanDtoCustomFilterPlugin> plugins;
    plugins = PluginProvider.getPlugins(IBeanDtoCustomFilterPlugin.ID, propertiesBuilder.build());
    if (plugins.size() == 0) {
        throw new IllegalStateException("No '" + IBeanDtoCustomFilterPlugin.class.getName() + "' implementation found for the filter type '" + filter.getFilterType() + "'");
    }
    for (final IBeanDtoCustomFilterPlugin plugin : plugins) {
        // plug in has to negate result itself if filter is inverted
        if (!plugin.accept(beanDto, filter)) {
            return false;
        }
    }
    return true;
}
Also used : IBeanDtoCustomFilterPlugin(org.jowidgets.cap.common.api.plugin.IBeanDtoCustomFilterPlugin) IPluginPropertiesBuilder(org.jowidgets.plugin.api.IPluginPropertiesBuilder)

Aggregations

IBeanDtoCustomFilterPlugin (org.jowidgets.cap.common.api.plugin.IBeanDtoCustomFilterPlugin)1 IPluginPropertiesBuilder (org.jowidgets.plugin.api.IPluginPropertiesBuilder)1