use of org.jowidgets.cap.common.api.filter.IBooleanFilter in project jo-client-platform by jo-source.
the class CriteriaQueryCreator method createFilterPredicate.
private Predicate createFilterPredicate(final CriteriaBuilder criteriaBuilder, final Root<?> bean, final CriteriaQuery<?> query, final IFilter filter, final PARAM_TYPE parameter) {
if (filter instanceof IPropertyFilter) {
final IPropertyFilter propertyFilter = (IPropertyFilter) filter;
final String propertyName = propertyFilter.getPropertyName();
final IPropertyFilterPredicateCreator<PARAM_TYPE> predicateCreator = propertyFilterPredicateCreators.get(propertyName);
if (predicateCreator != null) {
return predicateCreator.createPredicate(criteriaBuilder, bean, query, propertyFilter, parameter);
}
}
if (filter instanceof IArithmeticFilter) {
return createArithmeticFilterPredicate(criteriaBuilder, bean, query, (IArithmeticFilter) filter);
} else if (filter instanceof IArithmeticPropertyFilter) {
// TODO MG support IArithmeticPropertyFilter
throw new IllegalArgumentException("unsupported filter type: " + filter.getClass().getName());
} else if (filter instanceof IBooleanFilter) {
final Predicate predicate;
predicate = createBooleanFilterPredicate(criteriaBuilder, bean, query, (IBooleanFilter) filter, parameter);
return invertPredicateIfNeeded(criteriaBuilder, predicate, filter, true);
} else if (filter instanceof ICustomFilter) {
final ICustomFilter customFilter = (ICustomFilter) filter;
final ICustomFilterPredicateCreator<PARAM_TYPE> customFilterPredicateCreator = getCustomFilterPredicateCreator(customFilter);
if (customFilterPredicateCreator != null) {
final Predicate predicate;
predicate = customFilterPredicateCreator.createPredicate(criteriaBuilder, getPath(bean, customFilter.getPropertyName()), query, customFilter, parameter);
return invertPredicateIfNeeded(criteriaBuilder, predicate, filter, true);
} else {
throw new IllegalArgumentException("unsupported custom filter type: " + customFilter.getFilterType());
}
} else {
throw new IllegalArgumentException("unsupported filter type: " + filter.getClass().getName());
}
}
Aggregations