Example usage for com.mongodb QueryBuilder in

List of usage examples for com.mongodb QueryBuilder in

Introduction

In this page you can find the example usage for com.mongodb QueryBuilder in.

Prototype

public QueryBuilder in(final Object object) 

Source Link

Document

Equivalent of the $in operand

Usage

From source file:org.apache.gora.mongodb.filters.DefaultFactory.java

License:Apache License

protected QueryBuilder appendToBuilder(final QueryBuilder builder, final FilterOp filterOp,
        final List<Object> rawOperands) {
    List<String> operands = convertOperandsToString(rawOperands);
    switch (filterOp) {
    case EQUALS:/*from w ww .ja  v a2 s .c om*/
        if (operands.size() == 1) {
            builder.is(operands.iterator().next());
        } else {
            builder.in(operands);
        }
        break;
    case NOT_EQUALS:
        if (operands.size() == 1) {
            builder.notEquals(operands.iterator().next());
        } else {
            builder.notIn(operands);
        }
        break;
    case LESS:
        builder.lessThan(operands);
        break;
    case LESS_OR_EQUAL:
        builder.lessThanEquals(operands);
        break;
    case GREATER:
        builder.greaterThan(operands);
        break;
    case GREATER_OR_EQUAL:
        builder.greaterThanEquals(operands);
        break;
    default:
        throw new IllegalArgumentException(filterOp + " no MongoDB equivalent yet");
    }
    return builder;
}

From source file:org.teiid.translator.mongodb.MongoDBSelectVisitor.java

License:Open Source License

protected QueryBuilder buildInQuery(In obj, QueryBuilder query) {
    append(obj.getRightExpressions());/*from  w  w  w  . j a v a2s .co m*/
    BasicDBList values = new BasicDBList();
    for (int i = 0; i < obj.getRightExpressions().size(); i++) {
        values.add(0, this.onGoingExpression.pop());
    }
    if (obj.isNegated()) {
        query.notIn(values);
    } else {
        query.in(values);
    }
    return query;
}

From source file:org.wrml.contrib.runtime.service.mongo.MongoService.java

License:Apache License

private void addQueryCriterion(final SearchCriterion searchCriterion, final QueryBuilder queryBuilder) {

    final ComparisonOperator comparisonOperator = searchCriterion.getComparisonOperator();
    final Object comparisonValue = searchCriterion.getComparisonValue();
    switch (comparisonOperator) {

    case containsAll: {
        queryBuilder.all(comparisonValue);
        break;/*from   w  ww. j  a  v  a 2 s. c om*/
    }

    case equalTo: {
        queryBuilder.equals(comparisonValue);
        break;
    }

    case equalToAny: {
        queryBuilder.in(comparisonValue);
        break;
    }

    case exists: {
        queryBuilder.exists(true);
        break;
    }

    case greaterThan: {
        queryBuilder.greaterThan(comparisonValue);
        break;
    }

    case greaterThanOrEqualTo: {
        queryBuilder.greaterThanEquals(comparisonValue);
        break;
    }

    case lessThan: {
        queryBuilder.lessThan(comparisonValue);
        break;
    }

    case lessThanOrEqualTo: {
        queryBuilder.lessThanEquals(comparisonValue);
        break;
    }

    case notEqualTo: {
        queryBuilder.notEquals(comparisonValue);
        break;
    }

    case notEqualToAny: {
        queryBuilder.notIn(comparisonValue);
        break;
    }

    case notExists: {
        queryBuilder.exists(false);
        break;
    }

    case regex: {
        final Pattern regexPattern = searchCriterion.getRegexPattern();
        if (regexPattern != null) {
            queryBuilder.regex(regexPattern);
        }

        break;
    }

    }
}