Get Filter Value

Hi Guys, probably an easy question, but:

How do I programmatically get the values set by a user in a filter in a GenericFilter.ConfigurationRefreshEvent?

Example: User adds a filter “Name” contains “Chris”.

The filter (“name”) I can get by
String filterName = event.getUpdatedConfiguration().getName();

But …how do I get the “Chris” Value?

Hi!

You can do the following:

    @Subscribe("genericFilter")
    public void onGenericFilterConfigurationRefresh(final GenericFilter.ConfigurationRefreshEvent event) {
        LogicalFilterComponent<?> rootFilterComponent = event.getUpdatedConfiguration().getRootLogicalFilterComponent();

        //or other logic to find the component
        PropertyFilter<?> namePropertyFilter = rootFilterComponent.getOwnFilterComponents().stream()
                .filter(filterComponent -> filterComponent instanceof PropertyFilter<?>)
                .map(filterComponent -> ((PropertyFilter<?>) filterComponent))
                .filter(filterComponent -> "name".equals(filterComponent.getProperty()))
                .findAny()
                .orElse(null);
        
        // your value
        namePropertyFilter.getValue();
    }

Best regards,
Dmitriy