|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.deegree.sqldialect.filter.AbstractWhereBuilder
public abstract class AbstractWhereBuilder
Base class for creating SQL predicates from Filter expressions. Such an expression restricts an SQL
ResultSet to those rows that contain objects that match the given filter. Also handles the creation of
ORDER BY clauses.
Note that the generated WHERE and ORDER-BY expressions are sometimes not sufficient to guarantee that a
ResultSet only contains the targeted objects and/or keeps the requested order. This happens when the
ValueReferences used in the filter/sort criteria are not mappable to columns in the database or the contained
XPath expressions are not mappable to an equivalent SQL expression. In these cases, one or both of the methods
getPostFilter()/getPostSortCriteria() return not null and the objects extracted from
the corresponding ResultSet must be filtered/sorted in memory to guarantee the requested constraints/order.
TODO: Implement partial backend filtering / sorting. Currently, filtering / sorting is performed completely by the database or by the post filter / criteria (if any property name has been encountered that could not be mapped).
| Field Summary | |
|---|---|
protected TableAliasManager |
aliasManager
Keeps track of all generated table aliases. |
protected SQLDialect |
dialect
|
protected OperatorFilter |
filter
|
protected PropertyNameMapper |
mapper
|
protected SQLExpression |
orderByClause
|
protected OperatorFilter |
postFilter
|
protected SortProperty[] |
postSortCrit
|
protected List<PropertyNameMapping> |
propNameMappingList
Keeps track of all successfully mapped property names. |
protected SortProperty[] |
sortCrit
|
protected SQLExpression |
whereClause
|
| Constructor Summary | |
|---|---|
protected |
AbstractWhereBuilder(SQLDialect dialect,
PropertyNameMapper mapper,
OperatorFilter filter,
SortProperty[] sortCrit)
Creates a new AbstractWhereBuilder instance. |
| Method Summary | |
|---|---|
protected void |
assertNotMultiValued(SQLExpression expr)
Ensures that the given SQLExpression is not an SQLExpression that is multi-valued. |
protected void |
build(boolean allowPartialMappings)
Invokes the building of the internal variables that store filter and sort criteria. |
TableAliasManager |
getAliasManager()
Returns the TableAliasManager that keeps track of the used table aliases. |
List<PropertyNameMapping> |
getMappedPropertyNames()
Returns the mappings of all ValueReferences from the filter / sort criteria that have been mapped to the
relational model. |
SQLExpression |
getOrderBy()
Returns the expression for the SQL-ORDER-BY clause. |
OperatorFilter |
getPostFilter()
Returns a Filter that contains all constraints from the input filter that could not be expressed in the
WHERE clause. |
SortProperty[] |
getPostSortCriteria()
Returns the sort criteria that contains all parts from the input sort criteria that could not be expressed in the ORDER-BY clause. |
SQLExpression |
getWhere()
Returns the expression for the SQL-WHERE clause. |
protected SQLExpression |
toProtoSQL(ComparisonOperator op)
Translates the given ComparisonOperator into an SQLExpression. |
protected SQLExpression |
toProtoSQL(Expression expr)
Translates the given Expression into an SQLExpression. |
protected SQLExpression |
toProtoSQL(Expression expr,
boolean assertNotMultiValued)
|
protected SQLExpression |
toProtoSQL(Function function)
Translates the given Function into an SQLExpression. |
protected SQLExpression |
toProtoSQL(Literal<?> literal)
Translates the given Literal into an SQLExpression. |
protected SQLOperation |
toProtoSQL(LogicalOperator op)
Translates the given LogicalOperator into an SQLOperation. |
protected SQLExpression |
toProtoSQL(Operator op)
Translates the given Operator into an SQLExpression. |
protected SQLOperation |
toProtoSQL(PropertyIsLike op)
Translates the given PropertyIsLike into an SQLOperation. |
protected SQLExpression |
toProtoSQL(SortProperty[] sortCrits)
Translates the given SortProperty array into an SQLExpression. |
protected abstract SQLOperation |
toProtoSQL(SpatialOperator op)
Translates the given SpatialOperator into an SQLOperation. |
protected SQLExpression |
toProtoSQL(ValueReference propName)
Translates the given ValueReference into an SQLExpression. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final SQLDialect dialect
protected final PropertyNameMapper mapper
protected final OperatorFilter filter
protected final SortProperty[] sortCrit
protected final TableAliasManager aliasManager
protected final List<PropertyNameMapping> propNameMappingList
protected SQLExpression whereClause
protected SQLExpression orderByClause
protected OperatorFilter postFilter
protected SortProperty[] postSortCrit
| Constructor Detail |
|---|
protected AbstractWhereBuilder(SQLDialect dialect,
PropertyNameMapper mapper,
OperatorFilter filter,
SortProperty[] sortCrit)
throws FilterEvaluationException
AbstractWhereBuilder instance.
dialect - SQL dialect, can be null (TODO refactor code, so not null is always used)mapper - provides the mapping from ValueReferences to DB columns, must not be nullfilter - Filter to use for generating the WHERE clause, can be nullsortCrit - criteria to use for generating the ORDER-BY clause, can be null
FilterEvaluationException - if the filter contains invalid ValueReferences| Method Detail |
|---|
protected void build(boolean allowPartialMappings)
throws FilterEvaluationException,
UnmappableException
allowPartialMappings - if false, any unmappable expression will cause an UnmappableException to be thrown
FilterEvaluationException
UnmappableException - if allowPartialMappings is false and an expression could not be mapped to the dbpublic SQLExpression getWhere()
nullpublic SQLExpression getOrderBy()
nullpublic OperatorFilter getPostFilter()
Filter that contains all constraints from the input filter that could not be expressed in the
WHERE clause.
ResultSet, may be null (no
post-filtering necessary)public SortProperty[] getPostSortCriteria()
ResultSet, may be null (no
post-sorting necessary)public TableAliasManager getAliasManager()
TableAliasManager that keeps track of the used table aliases.
The returned manager may also be used for generating additional aliases that are needed for creating the final SQL statement.
nullpublic List<PropertyNameMapping> getMappedPropertyNames()
ValueReferences from the filter / sort criteria that have been mapped to the
relational model.
null
protected SQLExpression toProtoSQL(Operator op)
throws UnmappableException,
FilterEvaluationException
Operator into an SQLExpression.
op - operator to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLExpression toProtoSQL(ComparisonOperator op)
throws UnmappableException,
FilterEvaluationException
ComparisonOperator into an SQLExpression.
op - comparison operator to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLOperation toProtoSQL(PropertyIsLike op)
throws UnmappableException,
FilterEvaluationException
PropertyIsLike into an SQLOperation.
op - comparison operator to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLOperation toProtoSQL(LogicalOperator op)
throws UnmappableException,
FilterEvaluationException
LogicalOperator into an SQLOperation.
op - logical operator to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected abstract SQLOperation toProtoSQL(SpatialOperator op)
throws UnmappableException,
FilterEvaluationException
SpatialOperator into an SQLOperation.
op - spatial operator to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLExpression toProtoSQL(Expression expr)
throws UnmappableException,
FilterEvaluationException
Expression into an SQLExpression.
expr - expression to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLExpression toProtoSQL(Expression expr,
boolean assertNotMultiValued)
throws UnmappableException,
FilterEvaluationException
UnmappableException
FilterEvaluationException
protected SQLExpression toProtoSQL(Function function)
throws UnmappableException,
FilterEvaluationException
Function into an SQLExpression.
function - function to be translated, must not be null
null if function can not be mapped to an SQL function call
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLExpression toProtoSQL(Literal<?> literal)
throws UnmappableException,
FilterEvaluationException
Literal into an SQLExpression.
The returned literal does not have any type information. Literal types are inferred in
toProtoSQL(ComparisonOperator).
literal - literal to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLExpression toProtoSQL(ValueReference propName)
throws UnmappableException,
FilterEvaluationException
ValueReference into an SQLExpression.
expr - expression to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected SQLExpression toProtoSQL(SortProperty[] sortCrits)
throws UnmappableException,
FilterEvaluationException
SortProperty array into an SQLExpression.
sortCrits - sort criteria to be translated, must not be null
null
UnmappableException - if translation is not possible (usually due to unmappable property names)
FilterEvaluationException - if the filter contains invalid ValueReferences
protected void assertNotMultiValued(SQLExpression expr)
throws UnmappableException
SQLExpression is not an SQLExpression that is multi-valued.
expr - SQL expression, must not be null
UnmappableException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||