List of usage examples for com.mongodb QueryBuilder not
public QueryBuilder not()
From source file:org.pentaho.di.trans.dataservice.optimization.mongod.MongoFunc.java
License:Apache License
public void negate(QueryBuilder queryBuilder, String attribute, Object value) { affirm(queryBuilder.not(), attribute, value); }
From source file:org.teiid.translator.mongodb.MongoDBSelectVisitor.java
License:Open Source License
protected QueryBuilder buildLikeQuery(Like obj, QueryBuilder query) { if (obj.isNegated()) { query.not(); }//w ww.ja v a2s . co m append(obj.getRightExpression()); StringBuilder value = new StringBuilder((String) this.onGoingExpression.pop()); int idx = -1; while (true) { idx = value.indexOf("%", idx + 1);//$NON-NLS-1$ if (idx != -1 && idx == 0) { continue; } if (idx != -1 && idx == value.length() - 1) { continue; } if (idx == -1) { break; } value.replace(idx, idx + 1, ".*"); //$NON-NLS-1$ } if (value.charAt(0) != '%') { value.insert(0, '^'); } idx = value.length(); if (value.charAt(idx - 1) != '%') { value.insert(idx, '$'); } String regex = value.toString().replaceAll("%", ""); //$NON-NLS-1$ //$NON-NLS-2$ query.is(Pattern.compile(regex)); return query; }