Package org.geotools.appschema.jdbc
Class NestedFilterToSQL
Object
FilterToSQL
NestedFilterToSQL
- All Implemented Interfaces:
ExpressionVisitor,FilterVisitor
FilterToSQL decorator capable of encoding filters on nested attributes.
Currently, the filters that can be translated to SQL are:
- BBOX
- Contains
- Touches
- Intersects
- Overlaps
- Within
- Crosses
- Disjoint
- Equals
- Beyond
- DWithin
- PropertyIsEqualTo
- PropertyIsNotEqualTo
- PropertyIsLessThan
- PropertyIsLessThanOrEqualTo
- PropertyIsGreaterThan
- PropertyIsGreaterThanOrEqualTo
- PropertyIsLike
- PropertyIsNull
- PropertyIsBetween
Note that, in order to be successfully encoded, the filter must not involve more than one nested attribute (i.e. comparing nested attributes is not supported), nor attributes that are chained via polymorphic mappings.
If the visited filter does not involve nested attributes, its encoding is delegated to the wrapped
FilterToSQL instance.
- Author:
- Mauro Bartolomeoli, GeoSolutions, Stefano Costa, GeoSolutions
-
Nested Class Summary
Nested classes/interfaces inherited from class FilterToSQL
FilterToSQL.FieldEncoder -
Field Summary
Fields inherited from class FilterToSQL
capabilities, currentDimension, currentGeometry, currentSRID, databaseSchema, encodingFunction, escapeBackslash, featureType, fieldEncoder, filterFactory, inEncodingEnabled, inline, IO_ERROR, LOGGER, out, primaryKey, sqlNameEscape -
Constructor Summary
ConstructorsConstructorDescriptionNestedFilterToSQL(FeatureTypeMapping rootMapping, FilterToSQL original) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidPerforms the encoding, sends the encoded sql to the writer passed in.static booleanisNestedFilter(Filter filter) A filter is considered nested if it operates on at least one nested attribute.booleanvoidsetReplaceOrWithUnion(boolean replaceOrWithUnion) voidsetSelectClause(String selectClause) protected Objectvisit(BinaryLogicOperator filter, Object extraData) If replaceOrWithUnion flag is enabled this method will build main OR condition in the form of UNION queries like: SELECT id, name FROM table WHERE name = "Alf" OR name = "Rick" -> SELECT id, name FROM table WHERE name = "Alf" UNION SELECT id, name FROM table WHERE name = "Rick"Write the SQL for an Or filtervisit(PropertyIsBetween filter, Object extraData) Writes the SQL for the PropertyIsBetween Filter.visit(PropertyIsEqualTo filter, Object extraData) Write the SQL for this kind of filtervisit(PropertyIsGreaterThanOrEqualTo filter, Object extraData) Write the SQL for this kind of filtervisit(PropertyIsGreaterThan filter, Object extraData) Write the SQL for this kind of filtervisit(PropertyIsLessThanOrEqualTo filter, Object extraData) Write the SQL for this kind of filtervisit(PropertyIsLessThan filter, Object extraData) Write the SQL for this kind of filtervisit(PropertyIsLike filter, Object extraData) Writes the SQL for the Like Filter.visit(PropertyIsNotEqualTo filter, Object extraData) Write the SQL for this kind of filtervisit(PropertyIsNull filter, Object extraData) Writes the SQL for the Null Filter.visit(Intersects filter, Object extraData) protected ObjectvisitNestedFilter(Filter filter, Object extraData, String xpath) Methods inherited from class FilterToSQL
cast, createFilterCapabilities, encode, encodeBinaryComparisonOperator, encodeToString, encodeToString, escapeLiteral, escapeName, evaluateLiteral, getCapabilities, getDatabaseSchema, getDistanceInNativeUnits, getExpressionType, getFeatureType, getFunctionName, getFunctionReturnType, getParameter, getPrimaryKey, getSqlNameEscape, isBinaryExpression, isEscapeBackslash, isInEncodingEnabled, processLikeLeftOperand, setCapabilities, setDatabaseSchema, setEscapeBackslash, setFeatureType, setFieldEncoder, setInEncodingEnabled, setInline, setPrimaryKey, setSqlNameEscape, setWriter, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitBinaryComparisonOperator, visitBinarySpatialOperator, visitBinarySpatialOperator, visitBinarySpatialOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitInFunction, visitLiteralGeometry, visitLiteralTimePeriod, visitNullFilter, writeBinaryExpression, writeBinaryExpressionMember, writeLiteral
-
Constructor Details
-
NestedFilterToSQL
Constructor.- Parameters:
rootMapping- the feature type being queriedoriginal- the wrapped filter-to-SQL encoder
-
-
Method Details
-
encode
Description copied from class:FilterToSQLPerforms the encoding, sends the encoded sql to the writer passed in.- Overrides:
encodein classFilterToSQL- Parameters:
filter- the Filter to be encoded.- Throws:
FilterToSQLException- If filter type not supported, or if there were io problems.
-
visitNestedFilter
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
Description copied from class:FilterToSQLWrite the SQL for an Or filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
If replaceOrWithUnion flag is enabled this method will build main OR condition in the form of UNION queries like: SELECT id, name FROM table WHERE name = "Alf" OR name = "Rick" -> SELECT id, name FROM table WHERE name = "Alf" UNION SELECT id, name FROM table WHERE name = "Rick"- Overrides:
visitin classFilterToSQL- Parameters:
filter- the logic statement to be turned into SQL.extraData- extra filter data. Not modified directly by this method.
-
visit
- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL
-
visit
Description copied from class:FilterToSQLWrite the SQL for this kind of filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
Description copied from class:FilterToSQLWrites the SQL for the PropertyIsBetween Filter.- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the Filter to be visited.- Throws:
RuntimeException- for io exception with writer
-
visit
Description copied from class:FilterToSQLWrites the SQL for the Like Filter. Assumes the current java implemented wildcards for the Like Filter: . for multi and .? for single. And replaces them with the SQL % and _, respectively.- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the Like Filter to be visited.
-
visit
Description copied from class:FilterToSQLWrite the SQL for this kind of filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
Description copied from class:FilterToSQLWrite the SQL for this kind of filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
Description copied from class:FilterToSQLWrite the SQL for this kind of filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
Description copied from class:FilterToSQLWrite the SQL for this kind of filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
Description copied from class:FilterToSQLWrite the SQL for this kind of filter- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the filter to visitextraData- extra data (unused by this method)
-
visit
Description copied from class:FilterToSQLWrites the SQL for the Null Filter.- Specified by:
visitin interfaceFilterVisitor- Overrides:
visitin classFilterToSQL- Parameters:
filter- the null filter to be written to SQL.- Throws:
RuntimeException- for io exception with writer
-
isNestedFilter
A filter is considered nested if it operates on at least one nested attribute.Technically, this means that at least one of the expressions in it is an instance of
NestedAttributeExpression.- Parameters:
filter- the filter to test- Returns:
trueif the filter involves at least one nested attribute,falseotherwise
-
setSelectClause
-
isReplaceOrWithUnion
public boolean isReplaceOrWithUnion() -
setReplaceOrWithUnion
public void setReplaceOrWithUnion(boolean replaceOrWithUnion)
-