public class MongoDBQueryBuilder extends Object
Expression
.Modifier and Type | Class and Description |
---|---|
protected static class |
MongoDBQueryBuilder.FieldInfo |
Modifier and Type | Field and Description |
---|---|
protected MongoDBConverter |
converter |
protected AtomicInteger |
counter |
protected static String |
DATE_CAST |
protected List<String> |
documentTypes |
protected String |
elemMatchPrefix
Prefix to remove for $elemMatch (including final dot), or
null if there's no current prefix to remove. |
protected Expression |
expression |
boolean |
hasFulltext |
protected String |
idKey |
static Long |
LONG_ONE |
static Long |
LONG_ZERO |
static Double |
MINUS_ONE |
protected static Pattern |
NON_CANON_INDEX |
static Double |
ONE |
protected org.bson.Document |
orderBy |
protected OrderByClause |
orderByClause |
protected ExpressionEvaluator.PathResolver |
pathResolver |
protected org.bson.Document |
projection |
protected Map<String,String> |
propertyKeys |
protected org.bson.Document |
query |
protected SchemaManager |
schemaManager |
protected SelectClause |
selectClause |
protected static Pattern |
SLASH_WILDCARD_SLASH |
boolean |
sortOnFulltextScore |
Constructor and Description |
---|
MongoDBQueryBuilder(MongoDBRepository repository,
Expression expression,
SelectClause selectClause,
OrderByClause orderByClause,
ExpressionEvaluator.PathResolver pathResolver,
boolean fulltextSearchDisabled) |
Modifier and Type | Method and Description |
---|---|
static String |
canonicalXPath(String xpath)
Canonicalizes a Nuxeo-xpath.
|
protected Object |
checkBoolean(MongoDBQueryBuilder.FieldInfo fieldInfo,
Object right) |
protected void |
checkDateLiteralForCast(Operand value,
String name) |
protected void |
checkDateLiteralForCast(Operator op,
Operand value,
String name) |
protected List<String> |
getDocumentTypes() |
protected Set<String> |
getMixinDocumentTypes(String mixin) |
static String |
getMongoDBFulltextQuery(String query) |
org.bson.Document |
getOrderBy() |
org.bson.Document |
getProjection() |
org.bson.Document |
getQuery() |
boolean |
hasProjectionWildcard() |
protected boolean |
isMixinTypes(MongoDBQueryBuilder.FieldInfo fieldInfo) |
protected boolean |
isNeverPerInstanceMixin(String mixin) |
protected org.bson.Document |
newDocumentWithField(MongoDBQueryBuilder.FieldInfo fieldInfo,
Object value) |
protected MongoDBQueryBuilder.FieldInfo |
parseACP(String prop,
String[] parts) |
protected Object |
pushDownNot(Object object) |
protected String |
stripElemMatchPrefix(String field) |
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 org.bson.Document |
walkAncestorId(Operator op,
Operand rvalue) |
org.bson.Document |
walkAnd(Expression expr) |
protected org.bson.Document |
walkAnd(Expression expr,
List<Operand> values) |
org.bson.Document |
walkAndMultiExpression(MultiExpression expr) |
org.bson.Document |
walkBetween(Operand lvalue,
Operand rvalue,
boolean positive) |
Object |
walkBooleanLiteral(BooleanLiteral lit) |
Date |
walkDateLiteral(DateLiteral lit) |
Double |
walkDoubleLiteral(DoubleLiteral lit) |
protected org.bson.Document |
walkEcmFulltext(String name,
Operator op,
Operand rvalue) |
protected org.bson.Document |
walkEcmPath(Operator op,
Operand rvalue) |
org.bson.Document |
walkEq(Operand lvalue,
Operand rvalue) |
org.bson.Document |
walkExpression(Expression expr) |
Object |
walkFunction(Function func) |
org.bson.Document |
walkGt(Operand lvalue,
Operand rvalue) |
org.bson.Document |
walkGtEq(Operand lvalue,
Operand rvalue) |
org.bson.Document |
walkIn(Operand lvalue,
Operand rvalue,
boolean positive) |
Long |
walkIntegerLiteral(IntegerLiteral lit) |
org.bson.Document |
walkIsNotNull(Operand value) |
org.bson.Document |
walkIsNull(Operand value) |
org.bson.Document |
walkLike(Operand lvalue,
Operand rvalue,
boolean positive,
boolean caseInsensitive) |
Object |
walkLiteral(Literal lit) |
List<Object> |
walkLiteralList(LiteralList litList) |
org.bson.Document |
walkLt(Operand lvalue,
Operand rvalue) |
org.bson.Document |
walkLtEq(Operand lvalue,
Operand rvalue) |
org.bson.Document |
walkMixinTypes(List<String> mixins,
boolean include)
Matches the mixin types against a list of values.
|
org.bson.Document |
walkNot(Operand value) |
org.bson.Document |
walkNotEq(Operand lvalue,
Operand rvalue) |
Object |
walkOperand(Operand op) |
protected List<Object> |
walkOperandList(List<Operand> values) |
org.bson.Document |
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.
|
protected MongoDBQueryBuilder.FieldInfo |
walkReference(String name) |
org.bson.Document |
walkStartsWith(Operand lvalue,
Operand rvalue) |
protected org.bson.Document |
walkStartsWithNonPath(Operand lvalue,
String path) |
protected org.bson.Document |
walkStartsWithPath(String path) |
String |
walkStringLiteral(StringLiteral lit) |
protected static final String DATE_CAST
protected final AtomicInteger counter
protected final SchemaManager schemaManager
protected final MongoDBConverter converter
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 org.bson.Document query
protected org.bson.Document orderBy
protected org.bson.Document projection
protected Map<String,String> propertyKeys
protected String elemMatchPrefix
null
if there's no current prefix to remove.protected static final Pattern SLASH_WILDCARD_SLASH
protected static final Pattern NON_CANON_INDEX
public MongoDBQueryBuilder(MongoDBRepository repository, Expression expression, SelectClause selectClause, OrderByClause orderByClause, ExpressionEvaluator.PathResolver pathResolver, boolean fulltextSearchDisabled)
public void walk()
public org.bson.Document getQuery()
public org.bson.Document getOrderBy()
public org.bson.Document getProjection()
public boolean hasProjectionWildcard()
protected void walkOrderBy()
protected void walkProjection()
public org.bson.Document walkExpression(Expression expr)
protected void checkDateLiteralForCast(Operator op, Operand value, String name)
protected void checkDateLiteralForCast(Operand value, String name)
protected org.bson.Document walkEcmPath(Operator op, Operand rvalue)
protected org.bson.Document walkAncestorId(Operator op, Operand rvalue)
protected org.bson.Document 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)
protected org.bson.Document newDocumentWithField(MongoDBQueryBuilder.FieldInfo fieldInfo, Object value)
public org.bson.Document walkIsNull(Operand value)
public org.bson.Document walkIsNotNull(Operand value)
public org.bson.Document walkAndMultiExpression(MultiExpression expr)
public org.bson.Document walkAnd(Expression expr)
protected org.bson.Document walkAnd(Expression expr, List<Operand> values)
protected String stripElemMatchPrefix(String field)
protected Object checkBoolean(MongoDBQueryBuilder.FieldInfo fieldInfo, Object right)
public org.bson.Document walkBetween(Operand lvalue, Operand rvalue, boolean positive)
public org.bson.Document 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 org.bson.Document walkStartsWith(Operand lvalue, Operand rvalue)
protected org.bson.Document walkStartsWithPath(String path)
protected org.bson.Document 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 MongoDBQueryBuilder.FieldInfo walkReference(String name)
protected MongoDBQueryBuilder.FieldInfo parseACP(String prop, String[] parts)
protected boolean isMixinTypes(MongoDBQueryBuilder.FieldInfo fieldInfo)
protected Set<String> getMixinDocumentTypes(String mixin)
protected List<String> getDocumentTypes()
protected boolean isNeverPerInstanceMixin(String mixin)
public org.bson.Document 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 © 2018 Nuxeo. All rights reserved.