com.querydsl.core.types.Ops Java Examples

The following examples show how to use com.querydsl.core.types.Ops. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
private Expression<?> handleConversions(Expression<?> expression, FilterOperator operator) {
	// convert to String for LIKE operators
	if (expression.getType() != String.class && (operator == FilterOperator.LIKE)) {
		return Expressions.stringOperation(Ops.STRING_CAST, expression);
	}
	else {
		return expression;
	}
}
 
Example #2
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate and(List<Predicate> predicates) {
	if (predicates.size() == 1) {
		return predicates.get(0);
	}
	else {
		// only two elements for each operation supported, needs querydsl fix?
		Predicate result = predicates.get(0);
		for (int i = 1; i < predicates.size(); i++) {
			result = new BooleanPredicateOperation(Ops.AND, ImmutableList.of(result, predicates.get(i)));
		}
		return result;
	}
}
 
Example #3
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate or(List<Predicate> predicates) {
	if (predicates.size() == 1) {
		return predicates.get(0);
	}
	else {
		// only two elements for each operation supported, needs querydsl fix?
		Predicate result = predicates.get(0);
		for (int i = 1; i < predicates.size(); i++) {
			result = new BooleanPredicateOperation(Ops.OR, ImmutableList.of(result, predicates.get(i)));
		}
		return result;
	}
}
 
Example #4
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate not() {
	if (not == null) {
		not = ExpressionUtils.predicate(Ops.NOT, this);
	}
	return not;
}
 
Example #5
Source File: QuerydslQueryBackend.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate and(List<Predicate> predicates) {
	if (predicates.size() == 1) {
		return predicates.get(0);
	}
	else {
		// only two elements for each operation supported, needs querydsl fix?
		Predicate result = predicates.get(0);
		for (int i = 1; i < predicates.size(); i++) {
			result = new BooleanPredicateOperation(Ops.AND, (ImmutableList) ImmutableList.of(result, predicates.get(i)));
		}
		return result;
	}
}
 
Example #6
Source File: QuerydslQueryBackend.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate or(List<Predicate> predicates) {
	if (predicates.size() == 1) {
		return predicates.get(0);
	}
	else {
		// only two elements for each operation supported, needs querydsl fix?
		Predicate result = predicates.get(0);
		for (int i = 1; i < predicates.size(); i++) {
			result = new BooleanPredicateOperation(Ops.OR, (ImmutableList) ImmutableList.of(result, predicates.get(i)));
		}
		return result;
	}
}
 
Example #7
Source File: QuerydslQueryBackend.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate not() {
	if (not == null) {
		not = ExpressionUtils.predicate(Ops.NOT, this);
	}
	return not;
}
 
Example #8
Source File: ColumnFilter.java    From spring-data-jpa-datatables with Apache License 2.0 5 votes vote down vote up
@Override
public Predicate createPredicate(PathBuilder<?> pathBuilder, String attributeName) {
    StringOperation path = Expressions.stringOperation(Ops.STRING_CAST, pathBuilder.get(attributeName));
    BooleanPath booleanPath = pathBuilder.getBoolean(attributeName);

    if (values.isEmpty()) {
        return addNullCase ? path.isNull() : null;
    } else if (isBasicFilter()) {
        return super.createPredicate(pathBuilder, attributeName);
    }

    BooleanExpression predicate = isBooleanComparison ? booleanPath.in(booleanValues) : path.in(values);
    if (addNullCase) predicate = predicate.or(path.isNull());
    return predicate;
}
 
Example #9
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
protected BooleanPredicateOperation(Ops ops, ImmutableList<Expression<?>> list) {
	super(Boolean.class, ops, list);
	if (list.isEmpty()) {
		throw new IllegalArgumentException("list cannot be empty");
	}
}
 
Example #10
Source File: QuerydslQueryBackend.java    From katharsis-framework with Apache License 2.0 4 votes vote down vote up
protected BooleanPredicateOperation(Ops ops, ImmutableList<Expression<?>> list) {
	super(Boolean.class, ops, list);
	if (list.isEmpty()) {
		throw new IllegalArgumentException("list cannot be empty");
	}
}
 
Example #11
Source File: GlobalFilter.java    From spring-data-jpa-datatables with Apache License 2.0 4 votes vote down vote up
@Override
public com.querydsl.core.types.Predicate createPredicate(PathBuilder<?> pathBuilder, String attributeName) {
    StringOperation path = Expressions.stringOperation(Ops.STRING_CAST, pathBuilder.get(attributeName));
    return path.lower().like(escapedRawValue, '~');
}