public class MongoDBQueryBuilder extends Object
Expression
.Modifier and Type | Class and Description |
---|---|
protected static class |
MongoDBQueryBuilder.FieldInfo |
protected static class |
MongoDBQueryBuilder.FieldInfoDBObject |
Modifier and Type | Field and Description |
---|---|
protected AtomicInteger |
counter |
protected List<String> |
documentTypes |
protected Expression |
expression |
boolean |
hasFulltext |
protected static Pattern |
NON_CANON_INDEX |
protected com.mongodb.DBObject |
orderBy |
protected OrderByClause |
orderByClause |
protected ExpressionEvaluator.PathResolver |
pathResolver |
protected com.mongodb.DBObject |
projection |
protected com.mongodb.DBObject |
query |
protected SchemaManager |
schemaManager |
protected SelectClause |
selectClause |
boolean |
sortOnFulltextScore |
protected static Pattern |
WILDCARD_SPLIT
Splits foo.*.bar into foo, *, bar and foo.*1.bar into foo, *1, bar
|
Constructor and Description |
---|
MongoDBQueryBuilder(Expression expression,
SelectClause selectClause,
OrderByClause orderByClause,
ExpressionEvaluator.PathResolver pathResolver) |
Modifier and Type | Method and Description |
---|---|
static String |
canonicalXPath(String xpath)
Canonicalizes a Nuxeo-xpath.
|
protected Object |
checkBoolean(MongoDBQueryBuilder.FieldInfo fieldInfo,
Object right) |
protected List<String> |
getDocumentTypes() |
protected Set<String> |
getMixinDocumentTypes(String mixin) |
static String |
getMongoDBFulltextQuery(String query) |
com.mongodb.DBObject |
getOrderBy() |
com.mongodb.DBObject |
getProjection() |
com.mongodb.DBObject |
getQuery() |
protected boolean |
isMixinTypes(MongoDBQueryBuilder.FieldInfo fieldInfo) |
protected boolean |
isNeverPerInstanceMixin(String mixin) |
protected Object |
pushDownNot(Object object) |
protected static String |
translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft,
boolean and)
Transforms the NXQL fulltext syntax into MongoDB syntax.
|
protected static void |
translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft,
List<String> buf,
boolean and) |
void |
walk() |
protected com.mongodb.DBObject |
walkAncestorId(Operator op,
Operand rvalue) |
protected com.mongodb.DBObject |
walkAnd(List<Operand> values) |
com.mongodb.DBObject |
walkAnd(Operand lvalue,
Operand rvalue) |
com.mongodb.DBObject |
walkBetween(Operand lvalue,
Operand rvalue,
boolean positive) |
Object |
walkBooleanLiteral(BooleanLiteral lit) |
Date |
walkDateLiteral(DateLiteral lit) |
Double |
walkDoubleLiteral(DoubleLiteral lit) |
protected com.mongodb.DBObject |
walkEcmFulltext(String name,
Operator op,
Operand rvalue) |
protected com.mongodb.DBObject |
walkEcmPath(Operator op,
Operand rvalue) |
com.mongodb.DBObject |
walkEq(Operand lvalue,
Operand rvalue) |
com.mongodb.DBObject |
walkExpression(Expression expr) |
Object |
walkFunction(Function func) |
com.mongodb.DBObject |
walkGt(Operand lvalue,
Operand rvalue) |
com.mongodb.DBObject |
walkGtEq(Operand lvalue,
Operand rvalue) |
com.mongodb.DBObject |
walkIn(Operand lvalue,
Operand rvalue,
boolean positive) |
Long |
walkIntegerLiteral(IntegerLiteral lit) |
com.mongodb.DBObject |
walkIsNotNull(Operand value) |
com.mongodb.DBObject |
walkIsNull(Operand value) |
com.mongodb.DBObject |
walkLike(Operand lvalue,
Operand rvalue,
boolean positive,
boolean caseInsensitive) |
Object |
walkLiteral(Literal lit) |
List<Object> |
walkLiteralList(LiteralList litList) |
com.mongodb.DBObject |
walkLt(Operand lvalue,
Operand rvalue) |
com.mongodb.DBObject |
walkLtEq(Operand lvalue,
Operand rvalue) |
com.mongodb.DBObject |
walkMixinTypes(List<String> mixins,
boolean include)
Matches the mixin types against a list of values.
|
com.mongodb.DBObject |
walkMultiExpression(MultiExpression expr) |
com.mongodb.DBObject |
walkNot(Operand value) |
com.mongodb.DBObject |
walkNotEq(Operand lvalue,
Operand rvalue) |
Object |
walkOperand(Operand op) |
protected List<Object> |
walkOperandList(List<Operand> values) |
com.mongodb.DBObject |
walkOr(Operand lvalue,
Operand rvalue) |
protected void |
walkOrderBy() |
protected void |
walkProjection() |
protected MongoDBQueryBuilder.FieldInfo |
walkReference(Operand value) |
MongoDBQueryBuilder.FieldInfo |
walkReference(Reference ref)
Returns the MongoDB field for this reference.
|
com.mongodb.DBObject |
walkStartsWith(Operand lvalue,
Operand rvalue) |
protected com.mongodb.DBObject |
walkStartsWithNonPath(Operand lvalue,
String path) |
protected com.mongodb.DBObject |
walkStartsWithPath(String path) |
String |
walkStringLiteral(StringLiteral lit) |
protected final AtomicInteger counter
protected final SchemaManager schemaManager
protected List<String> documentTypes
protected final Expression expression
protected final SelectClause selectClause
protected final OrderByClause orderByClause
protected final ExpressionEvaluator.PathResolver pathResolver
public boolean hasFulltext
public boolean sortOnFulltextScore
protected com.mongodb.DBObject query
protected com.mongodb.DBObject orderBy
protected com.mongodb.DBObject projection
protected static final Pattern NON_CANON_INDEX
protected static final Pattern WILDCARD_SPLIT
public MongoDBQueryBuilder(Expression expression, SelectClause selectClause, OrderByClause orderByClause, ExpressionEvaluator.PathResolver pathResolver)
public void walk()
public com.mongodb.DBObject getQuery()
public com.mongodb.DBObject getOrderBy()
public com.mongodb.DBObject getProjection()
protected void walkOrderBy()
protected void walkProjection()
public com.mongodb.DBObject walkExpression(Expression expr)
protected com.mongodb.DBObject walkEcmPath(Operator op, Operand rvalue)
protected com.mongodb.DBObject walkAncestorId(Operator op, Operand rvalue)
protected com.mongodb.DBObject walkEcmFulltext(String name, Operator op, Operand rvalue)
public static String getMongoDBFulltextQuery(String query)
protected static String translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft, boolean and)
The MongoDB fulltext query syntax is badly documented, but is actually the following:
The matching algorithm is (excluding stemming and stop words):
protected static void translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft, List<String> buf, boolean and)
protected Object pushDownNot(Object object)
public com.mongodb.DBObject walkIsNull(Operand value)
public com.mongodb.DBObject walkIsNotNull(Operand value)
public com.mongodb.DBObject walkMultiExpression(MultiExpression expr)
protected Object checkBoolean(MongoDBQueryBuilder.FieldInfo fieldInfo, Object right)
public com.mongodb.DBObject walkBetween(Operand lvalue, Operand rvalue, boolean positive)
public com.mongodb.DBObject walkLike(Operand lvalue, Operand rvalue, boolean positive, boolean caseInsensitive)
public Object walkOperand(Operand op)
public Object walkLiteral(Literal lit)
public Object walkBooleanLiteral(BooleanLiteral lit)
public Date walkDateLiteral(DateLiteral lit)
public Double walkDoubleLiteral(DoubleLiteral lit)
public Long walkIntegerLiteral(IntegerLiteral lit)
public String walkStringLiteral(StringLiteral lit)
public List<Object> walkLiteralList(LiteralList litList)
protected List<Object> walkOperandList(List<Operand> values)
public Object walkFunction(Function func)
public com.mongodb.DBObject walkStartsWith(Operand lvalue, Operand rvalue)
protected com.mongodb.DBObject walkStartsWithPath(String path)
protected com.mongodb.DBObject walkStartsWithNonPath(Operand lvalue, String path)
protected MongoDBQueryBuilder.FieldInfo walkReference(Operand value)
public static String canonicalXPath(String xpath)
Replaces a/foo[123]/b
with a/123/b
A star or a star followed by digits can be used instead of just the digits as well.
xpath
- the xpathpublic MongoDBQueryBuilder.FieldInfo walkReference(Reference ref)
protected boolean isMixinTypes(MongoDBQueryBuilder.FieldInfo fieldInfo)
protected Set<String> getMixinDocumentTypes(String mixin)
protected List<String> getDocumentTypes()
protected boolean isNeverPerInstanceMixin(String mixin)
public com.mongodb.DBObject walkMixinTypes(List<String> mixins, boolean include)
Used for:
ecm:mixinTypes IN ('Foo', 'Bar')
{ "$or" : [ { "ecm:primaryType" : { "$in" : [ ... types with Foo or Bar ...]}} , { "ecm:mixinTypes" : { "$in" : [ "Foo" , "Bar]}}]}ecm:mixinTypes NOT IN ('Foo', 'Bar')
{ "$and" : [ { "ecm:primaryType" : { "$in" : [ ... types without Foo nor Bar ...]}} , { "ecm:mixinTypes" : { "$nin" : [ "Foo" , "Bar]}}]}
Copyright © 2015 Nuxeo SA. All rights reserved.