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 booleanaliasOrderByColumnsprotected booleanallowSubSelectprotected intarraySubQueryJoinCountprotected intftJoinNumberprotected Dialect.FulltextMatchInfoftMatchInfoprotected inthierJoinCountprotected booleaninOrderByprotected booleaninSelectprotected booleanisProxiesstatic StringPATH_SEPprotected Map<String,Column>posColumnsprotected List<Column>posColumnsInOrderByprotected Map<String,Dialect.ArraySubQuery>propertyArraySubQueriesprotected Map<String,Table>propertyHierTablesStringBuildersbprotected intuniqueJoinIndexprotected booleanvisitingIdLinkedList<Column>whatColumnsLinkedList<String>whatKeys
-
Constructor Summary
Constructors Constructor Description WhereBuilder(boolean isProxies)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddLikeEscaping()protected voidcheckDateLiteralForCast(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 voidgenerateExistsEnd(StringBuilder sb)protected voidgenerateExistsStart(StringBuilder sb, Table table)protected ColumnTypegetAggregateType(String func, ColumnType arg)protected Dialect.ArraySubQuerygetArraySubQuery(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 OperandgetBooleanLiteral(Operand rvalue)NXQLQueryMaker.ColumnInfogetColumnInfo(String name)Finds info about column (special or not).protected NXQLQueryMaker.ColumnInfogetRegularColumnInfo(String xpath)Gets column information for a regular property.protected NXQLQueryMaker.ColumnInfogetSpecialColumnInfo(String name)protected intgetUniqueJoinIndex()voidvisitBooleanLiteral(BooleanLiteral node)protected voidvisitColumnExpression(Column column, Operator op, Operand rvalue, String cast, String lvalueName, int arrayElementIndex)voidvisitDateLiteral(DateLiteral node)voidvisitDoubleLiteral(DoubleLiteral node)voidvisitExpression(Expression node)protected voidvisitExpressionAncestorId(Expression node)protected voidvisitExpressionEcmPath(Expression node)protected voidvisitExpressionEqOrIn(Column column, Operator op, Operand rvalue, String cast, int arrayElementIndex)protected voidvisitExpressionFulltext(Expression node, String name)protected voidvisitExpressionIlike(Column column, Operator op, Operand rvalue, String lvalueName, int arrayElementIndex)protected voidvisitExpressionIsProxy(Expression node)protected voidvisitExpressionIsTrashed(Expression node)protected voidvisitExpressionIsTrashedOnLifeCycle(Expression node)protected voidvisitExpressionLike(Column column, Operator op, Operand rvalue, String lvalueName, int arrayElementIndex)protected voidvisitExpressionMixinType(Expression expr)Include or exclude mixins.protected voidvisitExpressionStartsWith(Expression node)protected voidvisitExpressionStartsWithNonPath(Expression node, String path)protected voidvisitExpressionStartsWithPath(String path)protected voidvisitExpressionWhereFalseIsNull(Expression node)protected voidvisitExpressionWhereFalseMayBeNull(Expression node)voidvisitFunction(Function node)protected voidvisitId(String string)voidvisitIntegerLiteral(IntegerLiteral node)voidvisitLiteralList(LiteralList node)voidvisitMultiExpression(MultiExpression node)voidvisitOperator(Operator node)voidvisitOrderByExpr(OrderByExpr node)voidvisitOrderByList(OrderByList node)voidvisitOrderByPosColumns()voidvisitQuery(SQLQuery node)voidvisitReference(Reference node)protected voidvisitReference(Column column)protected voidvisitReference(Column column, int arrayElementIndex)protected voidvisitReference(Column column, String cast)protected voidvisitReference(Column column, String cast, int arrayElementIndex)protected voidvisitScore()voidvisitSelectClause(SelectClause node)protected voidvisitSimpleExpression(Column column, Operator op, Operand rvalue, String cast, int arrayElementIndex)voidvisitStringLiteral(String string)voidvisitStringLiteral(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
-
propertyHierTables
protected Map<String,Table> propertyHierTables
-
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
-
posColumns
protected Map<String,Column> posColumns
-
posColumnsInOrderBy
protected List<Column> posColumnsInOrderBy
-
-
Constructor Detail
-
WhereBuilder
public WhereBuilder(boolean isProxies)
-
-
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:
visitQueryin interfaceIVisitor- Overrides:
visitQueryin classDefaultQueryVisitor
-
visitSelectClause
public void visitSelectClause(SelectClause node)
- Specified by:
visitSelectClausein interfaceIVisitor- Overrides:
visitSelectClausein classDefaultQueryVisitor
-
visitMultiExpression
public void visitMultiExpression(MultiExpression node)
- Specified by:
visitMultiExpressionin interfaceIVisitor- Overrides:
visitMultiExpressionin classDefaultQueryVisitor
-
visitExpression
public void visitExpression(Expression node)
- Specified by:
visitExpressionin interfaceIVisitor- Overrides:
visitExpressionin classDefaultQueryVisitor
-
getBooleanLiteral
protected Operand getBooleanLiteral(Operand rvalue)
-
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:
visitOperatorin interfaceIVisitor- Overrides:
visitOperatorin classDefaultQueryVisitor
-
visitReference
public void visitReference(Reference node)
- Specified by:
visitReferencein interfaceIVisitor- Overrides:
visitReferencein classDefaultQueryVisitor
-
visitReference
protected void visitReference(Column column)
-
visitReference
protected void visitReference(Column column, String cast)
-
visitReference
protected void visitReference(Column column, int arrayElementIndex)
-
visitReference
protected void visitReference(Column column, String cast, int arrayElementIndex)
-
visitLiteralList
public void visitLiteralList(LiteralList node)
- Specified by:
visitLiteralListin interfaceIVisitor- Overrides:
visitLiteralListin classDefaultQueryVisitor
-
visitDateLiteral
public void visitDateLiteral(DateLiteral node)
- Specified by:
visitDateLiteralin interfaceIVisitor- Overrides:
visitDateLiteralin classDefaultQueryVisitor
-
visitStringLiteral
public void visitStringLiteral(StringLiteral node)
- Specified by:
visitStringLiteralin interfaceIVisitor- Overrides:
visitStringLiteralin classDefaultQueryVisitor
-
visitStringLiteral
public void visitStringLiteral(String string)
-
visitDoubleLiteral
public void visitDoubleLiteral(DoubleLiteral node)
- Specified by:
visitDoubleLiteralin interfaceIVisitor- Overrides:
visitDoubleLiteralin classDefaultQueryVisitor
-
visitIntegerLiteral
public void visitIntegerLiteral(IntegerLiteral node)
- Specified by:
visitIntegerLiteralin interfaceIVisitor- Overrides:
visitIntegerLiteralin classDefaultQueryVisitor
-
visitBooleanLiteral
public void visitBooleanLiteral(BooleanLiteral node)
- Specified by:
visitBooleanLiteralin interfaceIVisitor- Overrides:
visitBooleanLiteralin classDefaultQueryVisitor
-
visitFunction
public void visitFunction(Function node)
- Specified by:
visitFunctionin interfaceIVisitor- Overrides:
visitFunctionin classDefaultQueryVisitor
-
visitScore
protected void visitScore()
-
getAggregateType
protected ColumnType getAggregateType(String func, ColumnType arg)
-
visitOrderByList
public void visitOrderByList(OrderByList node)
- Specified by:
visitOrderByListin interfaceIVisitor- Overrides:
visitOrderByListin classDefaultQueryVisitor
-
visitOrderByPosColumns
public void visitOrderByPosColumns()
-
visitOrderByExpr
public void visitOrderByExpr(OrderByExpr node)
- Specified by:
visitOrderByExprin interfaceIVisitor- Overrides:
visitOrderByExprin classDefaultQueryVisitor
-
-