Example usage for com.mongodb QueryBuilder notEquals

List of usage examples for com.mongodb QueryBuilder notEquals

Introduction

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

Prototype

public QueryBuilder notEquals(final Object object) 

Source Link

Document

Equivalent of the $ne 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:/* ww w  . j  av  a 2  s  .  co  m*/
        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 void buildComparisionQuery(Comparison obj, Object rightExpr, QueryBuilder query) {
    switch (obj.getOperator()) {
    case EQ://  w ww . ja  v a2  s .  c o  m
        query.is(rightExpr);
        break;
    case NE:
        query.notEquals(rightExpr);
        break;
    case LT:
        query.lessThan(rightExpr);
        break;
    case LE:
        query.lessThanEquals(rightExpr);
        break;
    case GT:
        query.greaterThan(rightExpr);
        break;
    case GE:
        query.greaterThanEquals(rightExpr);
        break;
    }
}

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

License:Open Source License

protected QueryBuilder buildIsNullQuery(IsNull obj, QueryBuilder query) {
    if (obj.isNegated()) {
        query.notEquals(null);
    } else {//  w w w  . j  a  va 2s . c  o  m
        query.is(null);
    }
    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  w w .  j  a va2s  .co m*/
    }

    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;
    }

    }
}