Class NXQLQueryMaker.WhereBuilder
- java.lang.Object
-
- org.nuxeo.ecm.core.query.sql.model.DefaultQueryVisitor
-
- org.nuxeo.ecm.core.storage.sql.jdbc.NXQLQueryMaker.WhereBuilder
-
- All Implemented Interfaces:
IVisitor
- Enclosing class:
- NXQLQueryMaker
protected class NXQLQueryMaker.WhereBuilder extends DefaultQueryVisitor
Builds the database-level WHERE query from the AST.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
aliasOrderByColumns
protected boolean
allowSubSelect
protected int
arraySubQueryJoinCount
protected int
ftJoinNumber
protected Dialect.FulltextMatchInfo
ftMatchInfo
protected int
hierJoinCount
protected boolean
inOrderBy
protected boolean
inSelect
protected boolean
isProxies
static String
PATH_SEP
protected Map<String,Column>
posColumns
protected List<Column>
posColumnsInOrderBy
protected Map<String,Dialect.ArraySubQuery>
propertyArraySubQueries
protected Map<String,Table>
propertyHierTables
StringBuilder
sb
protected int
uniqueJoinIndex
protected boolean
visitingId
LinkedList<Column>
whatColumns
LinkedList<String>
whatKeys
-
Constructor Summary
Constructors Constructor Description WhereBuilder(boolean isProxies)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addLikeEscaping()
protected void
checkDateLiteralForCast(Operand value, Expression node)
This operand is going to be used with a lvalue that has a DATE cast, so if it's a date literal make sure it's not a TIMESTAMP.protected void
generateExistsEnd(StringBuilder sb)
protected void
generateExistsStart(StringBuilder sb, Table table)
protected ColumnType
getAggregateType(String func, ColumnType arg)
protected Dialect.ArraySubQuery
getArraySubQuery(Table contextHier, String contextKey, Column arrayColumn, boolean skipJoin)
Gets the arraySubquery for the given arrayColumn in the given contextKey, and maybe adds a JOIN if one is not already done.protected Operand
getBooleanLiteral(Operand rvalue)
NXQLQueryMaker.ColumnInfo
getColumnInfo(String name)
Finds info about column (special or not).protected NXQLQueryMaker.ColumnInfo
getRegularColumnInfo(String xpath)
Gets column information for a regular property.protected NXQLQueryMaker.ColumnInfo
getSpecialColumnInfo(String name)
protected int
getUniqueJoinIndex()
void
visitBooleanLiteral(BooleanLiteral node)
protected void
visitColumnExpression(Column column, Operator op, Operand rvalue, String cast, String lvalueName, int arrayElementIndex)
void
visitDateLiteral(DateLiteral node)
void
visitDoubleLiteral(DoubleLiteral node)
void
visitExpression(Expression node)
protected void
visitExpressionAncestorId(Expression node)
protected void
visitExpressionEcmPath(Expression node)
protected void
visitExpressionEqOrIn(Column column, Operator op, Operand rvalue, String cast, int arrayElementIndex)
protected void
visitExpressionFulltext(Expression node, String name)
protected void
visitExpressionIlike(Column column, Operator op, Operand rvalue, String lvalueName, int arrayElementIndex)
protected void
visitExpressionIsProxy(Expression node)
protected void
visitExpressionIsTrashed(Expression node)
protected void
visitExpressionIsTrashedOnLifeCycle(Expression node)
protected void
visitExpressionLike(Column column, Operator op, Operand rvalue, String lvalueName, int arrayElementIndex)
protected void
visitExpressionMixinType(Expression expr)
Include or exclude mixins.protected void
visitExpressionStartsWith(Expression node)
protected void
visitExpressionStartsWithNonPath(Expression node, String path)
protected void
visitExpressionStartsWithPath(String path)
protected void
visitExpressionWhereFalseIsNull(Expression node)
protected void
visitExpressionWhereFalseMayBeNull(Expression node)
void
visitFunction(Function node)
protected void
visitId(String string)
void
visitIntegerLiteral(IntegerLiteral node)
void
visitLiteralList(LiteralList node)
void
visitMultiExpression(MultiExpression node)
void
visitOperator(Operator node)
void
visitOrderByExpr(OrderByExpr node)
void
visitOrderByList(OrderByList node)
void
visitOrderByPosColumns()
void
visitQuery(SQLQuery node)
void
visitReference(Reference node)
protected void
visitReference(Column column)
protected void
visitReference(Column column, int arrayElementIndex)
protected void
visitReference(Column column, String cast)
protected void
visitReference(Column column, String cast, int arrayElementIndex)
protected void
visitScore()
void
visitSelectClause(SelectClause node)
protected void
visitSimpleExpression(Column column, Operator op, Operand rvalue, String cast, int arrayElementIndex)
void
visitStringLiteral(String string)
void
visitStringLiteral(StringLiteral node)
-
Methods inherited from class org.nuxeo.ecm.core.query.sql.model.DefaultQueryVisitor
visitFromClause, visitGroupByClause, visitHavingClause, visitLiteral, visitOperandList, visitOrderByClause, visitReferenceList, visitWhereClause
-
-
-
-
Field Detail
-
PATH_SEP
public static final String PATH_SEP
- See Also:
- Constant Field Values
-
whatColumns
public final LinkedList<Column> whatColumns
-
whatKeys
public final LinkedList<String> whatKeys
-
sb
public final StringBuilder sb
-
uniqueJoinIndex
protected int uniqueJoinIndex
-
hierJoinCount
protected int hierJoinCount
-
isProxies
protected final boolean isProxies
-
aliasOrderByColumns
protected boolean aliasOrderByColumns
-
allowSubSelect
protected boolean allowSubSelect
-
inSelect
protected boolean inSelect
-
inOrderBy
protected boolean inOrderBy
-
ftJoinNumber
protected int ftJoinNumber
-
ftMatchInfo
protected Dialect.FulltextMatchInfo ftMatchInfo
-
visitingId
protected boolean visitingId
-
propertyArraySubQueries
protected Map<String,Dialect.ArraySubQuery> propertyArraySubQueries
-
arraySubQueryJoinCount
protected int arraySubQueryJoinCount
-
-
Method Detail
-
getUniqueJoinIndex
protected int getUniqueJoinIndex()
-
getArraySubQuery
protected Dialect.ArraySubQuery getArraySubQuery(Table contextHier, String contextKey, Column arrayColumn, boolean skipJoin)
Gets the arraySubquery for the given arrayColumn in the given contextKey, and maybe adds a JOIN if one is not already done.LEFT JOIN (SELECT id, UNNEST(somecol) AS item, generate_subscripts(somecol, 1) AS pos FROM someschema) _A1 ON _A1.id = hierarchy.id
-
getSpecialColumnInfo
protected NXQLQueryMaker.ColumnInfo getSpecialColumnInfo(String name)
-
getColumnInfo
public NXQLQueryMaker.ColumnInfo getColumnInfo(String name)
Finds info about column (special or not).
-
getRegularColumnInfo
protected NXQLQueryMaker.ColumnInfo getRegularColumnInfo(String xpath)
Gets column information for a regular property.Accumulates info about joins needed to get to this property.
IMPORTANT: THIS MUST NOT BE CALLED TWICE ON THE SAME PROPERTY as some structures are updated (joins, counters).
- Throws:
QueryParseException
- if the property doesn't exist
-
visitQuery
public void visitQuery(SQLQuery node)
- Specified by:
visitQuery
in interfaceIVisitor
- Overrides:
visitQuery
in classDefaultQueryVisitor
-
visitSelectClause
public void visitSelectClause(SelectClause node)
- Specified by:
visitSelectClause
in interfaceIVisitor
- Overrides:
visitSelectClause
in classDefaultQueryVisitor
-
visitMultiExpression
public void visitMultiExpression(MultiExpression node)
- Specified by:
visitMultiExpression
in interfaceIVisitor
- Overrides:
visitMultiExpression
in classDefaultQueryVisitor
-
visitExpression
public void visitExpression(Expression node)
- Specified by:
visitExpression
in interfaceIVisitor
- Overrides:
visitExpression
in classDefaultQueryVisitor
-
visitColumnExpression
protected void visitColumnExpression(Column column, Operator op, Operand rvalue, String cast, String lvalueName, int arrayElementIndex)
-
visitSimpleExpression
protected void visitSimpleExpression(Column column, Operator op, Operand rvalue, String cast, int arrayElementIndex)
-
checkDateLiteralForCast
protected void checkDateLiteralForCast(Operand value, Expression node)
This operand is going to be used with a lvalue that has a DATE cast, so if it's a date literal make sure it's not a TIMESTAMP.
-
generateExistsStart
protected void generateExistsStart(StringBuilder sb, Table table)
-
generateExistsEnd
protected void generateExistsEnd(StringBuilder sb)
-
visitExpressionStartsWith
protected void visitExpressionStartsWith(Expression node)
-
visitExpressionStartsWithPath
protected void visitExpressionStartsWithPath(String path)
-
visitExpressionStartsWithNonPath
protected void visitExpressionStartsWithNonPath(Expression node, String path)
-
visitExpressionEcmPath
protected void visitExpressionEcmPath(Expression node)
-
visitExpressionAncestorId
protected void visitExpressionAncestorId(Expression node)
-
visitExpressionIsProxy
protected void visitExpressionIsProxy(Expression node)
-
visitExpressionWhereFalseIsNull
protected void visitExpressionWhereFalseIsNull(Expression node)
-
visitExpressionWhereFalseMayBeNull
protected void visitExpressionWhereFalseMayBeNull(Expression node)
-
visitExpressionIsTrashed
protected void visitExpressionIsTrashed(Expression node)
-
visitExpressionIsTrashedOnLifeCycle
protected void visitExpressionIsTrashedOnLifeCycle(Expression node)
-
visitExpressionMixinType
protected void visitExpressionMixinType(Expression expr)
Include or exclude mixins.include: primarytype IN (... types with Foo or Bar ...) OR mixintypes LIKE '%Foo%' OR mixintypes LIKE '%Bar%'
exclude: primarytype IN (... types without Foo or Bar ...) AND (mixintypes NOT LIKE '%Foo%' AND mixintypes NOT LIKE '%Bar%' OR mixintypes IS NULL)
-
visitExpressionFulltext
protected void visitExpressionFulltext(Expression node, String name)
-
visitExpressionEqOrIn
protected void visitExpressionEqOrIn(Column column, Operator op, Operand rvalue, String cast, int arrayElementIndex)
-
visitExpressionLike
protected void visitExpressionLike(Column column, Operator op, Operand rvalue, String lvalueName, int arrayElementIndex)
-
visitExpressionIlike
protected void visitExpressionIlike(Column column, Operator op, Operand rvalue, String lvalueName, int arrayElementIndex)
-
addLikeEscaping
protected void addLikeEscaping()
-
visitOperator
public void visitOperator(Operator node)
- Specified by:
visitOperator
in interfaceIVisitor
- Overrides:
visitOperator
in classDefaultQueryVisitor
-
visitReference
public void visitReference(Reference node)
- Specified by:
visitReference
in interfaceIVisitor
- Overrides:
visitReference
in classDefaultQueryVisitor
-
visitReference
protected void visitReference(Column column)
-
visitReference
protected void visitReference(Column column, int arrayElementIndex)
-
visitLiteralList
public void visitLiteralList(LiteralList node)
- Specified by:
visitLiteralList
in interfaceIVisitor
- Overrides:
visitLiteralList
in classDefaultQueryVisitor
-
visitDateLiteral
public void visitDateLiteral(DateLiteral node)
- Specified by:
visitDateLiteral
in interfaceIVisitor
- Overrides:
visitDateLiteral
in classDefaultQueryVisitor
-
visitStringLiteral
public void visitStringLiteral(StringLiteral node)
- Specified by:
visitStringLiteral
in interfaceIVisitor
- Overrides:
visitStringLiteral
in classDefaultQueryVisitor
-
visitId
protected void visitId(String string)
-
visitStringLiteral
public void visitStringLiteral(String string)
-
visitDoubleLiteral
public void visitDoubleLiteral(DoubleLiteral node)
- Specified by:
visitDoubleLiteral
in interfaceIVisitor
- Overrides:
visitDoubleLiteral
in classDefaultQueryVisitor
-
visitIntegerLiteral
public void visitIntegerLiteral(IntegerLiteral node)
- Specified by:
visitIntegerLiteral
in interfaceIVisitor
- Overrides:
visitIntegerLiteral
in classDefaultQueryVisitor
-
visitBooleanLiteral
public void visitBooleanLiteral(BooleanLiteral node)
- Specified by:
visitBooleanLiteral
in interfaceIVisitor
- Overrides:
visitBooleanLiteral
in classDefaultQueryVisitor
-
visitFunction
public void visitFunction(Function node)
- Specified by:
visitFunction
in interfaceIVisitor
- Overrides:
visitFunction
in classDefaultQueryVisitor
-
visitScore
protected void visitScore()
-
getAggregateType
protected ColumnType getAggregateType(String func, ColumnType arg)
-
visitOrderByList
public void visitOrderByList(OrderByList node)
- Specified by:
visitOrderByList
in interfaceIVisitor
- Overrides:
visitOrderByList
in classDefaultQueryVisitor
-
visitOrderByPosColumns
public void visitOrderByPosColumns()
-
visitOrderByExpr
public void visitOrderByExpr(OrderByExpr node)
- Specified by:
visitOrderByExpr
in interfaceIVisitor
- Overrides:
visitOrderByExpr
in classDefaultQueryVisitor
-
-