Search in sources :

Example 1 with IFilter

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

the class CriteriaQueryCreator method createBooleanFilterPredicate.

private Predicate createBooleanFilterPredicate(final CriteriaBuilder criteriaBuilder, final Root<?> bean, final CriteriaQuery<?> query, final IBooleanFilter filter, final PARAM_TYPE parameter) {
    final List<Predicate> predicates = new LinkedList<Predicate>();
    for (final IFilter subFilter : filter.getFilters()) {
        final Predicate predicate = createFilterPredicate(criteriaBuilder, bean, query, subFilter, parameter);
        predicates.add(predicate);
    }
    if (filter.getOperator() == BooleanOperator.AND) {
        return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
    }
    return criteriaBuilder.or(predicates.toArray(new Predicate[0]));
}
Also used : IFilter(org.jowidgets.cap.common.api.filter.IFilter) LinkedList(java.util.LinkedList) Predicate(javax.persistence.criteria.Predicate)

Example 2 with IFilter

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

the class BeanRelationNodeModelImpl method getFilter.

private IFilter getFilter() {
    final IFilter addedDataFilter = getAddedDataFilter();
    if (filters.size() > 0 || addedDataFilter != null) {
        final IBooleanFilterBuilder builder = CapCommonToolkit.filterFactory().booleanFilterBuilder();
        builder.setOperator(BooleanOperator.AND);
        final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
        for (final IUiFilter uiFilter : filters.values()) {
            builder.addFilter(filterFactory.convert(uiFilter));
        }
        if (addedDataFilter != null) {
            builder.addFilter(addedDataFilter);
        }
        return builder.build();
    } else {
        return addedDataFilter;
    }
}
Also used : IBooleanFilterBuilder(org.jowidgets.cap.common.api.filter.IBooleanFilterBuilder) IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IFilter(org.jowidgets.cap.common.api.filter.IFilter) IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter)

Example 3 with IFilter

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

the class BeanTableModelImpl method getFilter.

private IFilter getFilter() {
    final IFilter addedDataFilter = getAddedDataFilter();
    if (filters.size() > 0 || addedDataFilter != null) {
        final IBooleanFilterBuilder builder = CapCommonToolkit.filterFactory().booleanFilterBuilder();
        builder.setOperator(BooleanOperator.AND);
        final IUiFilterFactory filterFactory = CapUiToolkit.filterToolkit().filterFactory();
        for (final IUiFilter uiFilter : filters.values()) {
            builder.addFilter(filterFactory.convert(uiFilter));
        }
        if (addedDataFilter != null) {
            builder.addFilter(addedDataFilter);
        }
        return builder.build();
    } else {
        return addedDataFilter;
    }
}
Also used : IBooleanFilterBuilder(org.jowidgets.cap.common.api.filter.IBooleanFilterBuilder) IUiFilterFactory(org.jowidgets.cap.ui.api.filter.IUiFilterFactory) IFilter(org.jowidgets.cap.common.api.filter.IFilter) IUiFilter(org.jowidgets.cap.ui.api.filter.IUiFilter)

Example 4 with IFilter

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

the class OrderedBeansCrudInterceptorImpl method createReadFilter.

private IFilter createReadFilter(final Object group) {
    final IFilter groupFilter = groupMapper.createGroupFilter(group);
    final IFilter orderNumberNotNullFilter = createOrderNumberNotNullFilter();
    if (groupFilter == null) {
        return orderNumberNotNullFilter;
    } else {
        return BooleanFilter.create(groupFilter, orderNumberNotNullFilter);
    }
}
Also used : IFilter(org.jowidgets.cap.common.api.filter.IFilter)

Example 5 with IFilter

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

the class UniqueConstraintCheckerImpl method checkCreation.

@Override
public void checkCreation(final Collection<? extends IBeanData> beansData, final IExecutionCallback executionCallback) {
    final IFilter filter = createFilter(beansData);
    final SyncResultCallback<Integer> resultCallback = new SyncResultCallback<Integer>();
    final List<IBeanKey> parentBeanKeys = Collections.emptyList();
    this.readerService.count(resultCallback, parentBeanKeys, filter, null, executionCallback);
    final Integer result = resultCallback.getResultSynchronious();
    if (result != null && result.intValue() > 0) {
        throw new UniqueConstraintViolationException(propertyNames);
    }
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IFilter(org.jowidgets.cap.common.api.filter.IFilter) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) UniqueConstraintViolationException(org.jowidgets.cap.common.api.exception.UniqueConstraintViolationException)

Aggregations

IFilter (org.jowidgets.cap.common.api.filter.IFilter)10 LinkedList (java.util.LinkedList)3 IUiFilter (org.jowidgets.cap.ui.api.filter.IUiFilter)3 Predicate (javax.persistence.criteria.Predicate)2 IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)2 IBooleanFilterBuilder (org.jowidgets.cap.common.api.filter.IBooleanFilterBuilder)2 IUiFilterFactory (org.jowidgets.cap.ui.api.filter.IUiFilterFactory)2 HashSet (java.util.HashSet)1 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)1 UniqueConstraintViolationException (org.jowidgets.cap.common.api.exception.UniqueConstraintViolationException)1 IArithmeticFilterBuilder (org.jowidgets.cap.common.api.filter.IArithmeticFilterBuilder)1 IArithmeticPropertyFilterBuilder (org.jowidgets.cap.common.api.filter.IArithmeticPropertyFilterBuilder)1 ICustomFilterBuilder (org.jowidgets.cap.common.api.filter.ICustomFilterBuilder)1 SyncResultCallback (org.jowidgets.cap.common.tools.execution.SyncResultCallback)1 IUiArithmeticFilter (org.jowidgets.cap.ui.api.filter.IUiArithmeticFilter)1 IUiArithmeticPropertyFilter (org.jowidgets.cap.ui.api.filter.IUiArithmeticPropertyFilter)1 IUiBooleanFilter (org.jowidgets.cap.ui.api.filter.IUiBooleanFilter)1 IUiCustomFilter (org.jowidgets.cap.ui.api.filter.IUiCustomFilter)1 Some (org.jowidgets.util.maybe.Some)1