Search in sources :

Example 1 with ViewFilterMapping

use of com.blazebit.persistence.view.metamodel.ViewFilterMapping in project blaze-persistence by Blazebit.

the class EntityViewSettingHelper method applyViewFilters.

private static <T, Q extends FullQueryBuilder<T, Q>> void applyViewFilters(EntityViewSetting<?, ?> setting, EntityViewManagerImpl evm, Q cb, ManagedViewTypeImplementor<?> viewType) {
    // Add named view filter
    for (String filterName : setting.getViewFilters()) {
        ViewFilterMapping filterMapping = ((ViewType<?>) viewType).getViewFilter(filterName);
        if (filterMapping == null) {
            throw new IllegalArgumentException("Could not find view filter mapping with the name '" + filterName + "' in the entity view type '" + viewType.getJavaType().getName() + "'");
        }
        // TODO: allow parameter injection
        ViewFilterProvider provider = evm.createViewFilter(filterMapping.getFilterClass());
        provider.apply(cb);
    }
}
Also used : ViewFilterProvider(com.blazebit.persistence.view.ViewFilterProvider) ViewFilterMapping(com.blazebit.persistence.view.metamodel.ViewFilterMapping) FlatViewType(com.blazebit.persistence.view.metamodel.FlatViewType) ViewType(com.blazebit.persistence.view.metamodel.ViewType)

Aggregations

ViewFilterProvider (com.blazebit.persistence.view.ViewFilterProvider)1 FlatViewType (com.blazebit.persistence.view.metamodel.FlatViewType)1 ViewFilterMapping (com.blazebit.persistence.view.metamodel.ViewFilterMapping)1 ViewType (com.blazebit.persistence.view.metamodel.ViewType)1