Search in sources :

Example 21 with BooleanExpression

use of com.querydsl.core.types.dsl.BooleanExpression in project Settler by EmhyrVarEmreis.

the class PermissionManagerImplementation method isAuthorized.

@Override
public boolean isAuthorized(Long sourceId, Long targetId, OperationType operationType) {
    BooleanExpression expression = jTBObjectHierarchy.objectFrom.id.eq(jTBObjectPrivilege.objectTo.id).and(jTBObjectHierarchy.objectTo.id.eq(targetId));
    expression = expression.or(jTBObjectPrivilege.objectTo.id.eq(targetId));
    expression = expression.or(jTBObjectPrivilege.objectTo.isNull());
    return new JPAQuery<Void>(entityManager).select(Expressions.ONE).from(jTBObjectPrivilege, jTBObjectHierarchy).where(jTBObjectPrivilege.objectFrom.id.eq(sourceId), (jTBObjectPrivilege.operationType.eq(operationType)), expression).fetchFirst() != null;
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression)

Example 22 with BooleanExpression

use of com.querydsl.core.types.dsl.BooleanExpression in project jeeshop by remibantos.

the class CatalogItemFinder method buildSearchPredicate.

private BooleanExpression buildSearchPredicate(String search, QCatalogItem qCatalogItem) {
    BooleanExpression searchPredicate = qCatalogItem.name.containsIgnoreCase(search).or(qCatalogItem.description.containsIgnoreCase(search));
    if (NumberUtils.isNumber(search)) {
        Long searchId = Long.parseLong(search);
        searchPredicate = qCatalogItem.id.eq(searchId);
    }
    return searchPredicate;
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression)

Example 23 with BooleanExpression

use of com.querydsl.core.types.dsl.BooleanExpression in project tutorials by eugenp.

the class MyUserPredicatesBuilder method build.

public BooleanExpression build() {
    if (params.size() == 0) {
        return null;
    }
    final List<BooleanExpression> predicates = new ArrayList<>();
    MyUserPredicate predicate;
    for (final SearchCriteria param : params) {
        predicate = new MyUserPredicate(param);
        final BooleanExpression exp = predicate.getPredicate();
        if (exp != null) {
            predicates.add(exp);
        }
    }
    BooleanExpression result = predicates.get(0);
    for (int i = 1; i < predicates.size(); i++) {
        result = result.and(predicates.get(i));
    }
    return result;
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression) ArrayList(java.util.ArrayList) SearchCriteria(org.baeldung.web.util.SearchCriteria)

Example 24 with BooleanExpression

use of com.querydsl.core.types.dsl.BooleanExpression in project modesti by jlsalmon.

the class PredicateBuilder method build.

public BooleanExpression build() {
    if (params.size() == 0) {
        return null;
    }
    List<BooleanExpression> predicates = new ArrayList<>();
    Predicate<T> predicate;
    for (SearchCriteria param : params) {
        predicate = new Predicate<>(param, klass);
        BooleanExpression exp = predicate.getPredicate();
        if (exp != null) {
            predicates.add(exp);
        }
    }
    BooleanExpression result = predicates.get(0);
    for (int i = 1; i < predicates.size(); i++) {
        result = result.and(predicates.get(i));
    }
    return result;
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression) ArrayList(java.util.ArrayList)

Example 25 with BooleanExpression

use of com.querydsl.core.types.dsl.BooleanExpression in project modesti by jlsalmon.

the class RsqlExpressionBuilder method createExpression.

private BooleanExpression createExpression(final LogicalNode logicalNode) {
    List<BooleanExpression> expressions = new ArrayList<>();
    BooleanExpression temp;
    for (final Node node : logicalNode.getChildren()) {
        temp = createExpression(node);
        if (temp != null) {
            expressions.add(temp);
        }
    }
    BooleanExpression result = expressions.get(0);
    if (logicalNode.getOperator() == LogicalOperator.AND) {
        for (int i = 1; i < expressions.size(); i++) {
            result = result.and(expressions.get(i));
        }
    } else if (logicalNode.getOperator() == LogicalOperator.OR) {
        for (int i = 1; i < expressions.size(); i++) {
            result = result.or(expressions.get(i));
        }
    }
    return result;
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression) ArrayList(java.util.ArrayList)

Aggregations

BooleanExpression (com.querydsl.core.types.dsl.BooleanExpression)30 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)4 StringPath (com.querydsl.core.types.dsl.StringPath)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 Predicate (com.querydsl.core.types.Predicate)2 Field (java.lang.reflect.Field)2 LinkedList (java.util.LinkedList)2 QueryException (com.evolveum.midpoint.repo.sqlbase.QueryException)1 RelationalValueSearchQuery (com.evolveum.midpoint.schema.RelationalValueSearchQuery)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 LookupTableRowType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Tuple (com.querydsl.core.Tuple)1 Expression (com.querydsl.core.types.Expression)1 OrderSpecifier (com.querydsl.core.types.OrderSpecifier)1 ComparableExpressionBase (com.querydsl.core.types.dsl.ComparableExpressionBase)1 EntityPathBase (com.querydsl.core.types.dsl.EntityPathBase)1 StringExpression (com.querydsl.core.types.dsl.StringExpression)1 QAdDescription (de.spring.example.persistence.domain.QAdDescription)1