Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.deegree.io.datastore.sql.wherebuilder
Class WhereBuilder

    java.lang.Object
      org.deegree.io.datastore.sql.wherebuilder.WhereBuilder

Direct Known Subclasses:
  GenericSQLWhereBuilder, MySQLWhereBuilder, OracleSpatialWhereBuilder, PostGISWhereBuilder

    public class WhereBuilder

extends Object

Creates SQL-WHERE clauses from OGC filter expressions (to restrict SQL statements to all stored features that match a given filter).

Also handles the creation of ORDER-BY clauses.

Version:
  $Revision: 23585 $, $Date: 2010-04-13 14:07:18 +0200 (Di, 13. Apr 2010) $
Author:
  Torsten Friebe , Markus Schneider , last edited by: $Author: aschmitz $

Field Summary
`protected Filter` | `filter` `Filter` for which the corresponding WHERE-clause will be generated.
`protected List<PropertyPath>` | `filterPropertyPaths`
`protected QueryTableTree` | `queryTableTree`
`protected MappedFeatureType[]` | `rootFts` Targeted feature types.
`protected SortProperty[]` | `sortProperties`
`protected List<PropertyPath>` | `sortPropertyPaths`
`protected static int` | `SRS_UNDEFINED`
`protected VirtualContentProvider` | `vcProvider`

Constructor Summary
`WhereBuilder(MappedFeatureType[] rootFts, String[] aliases, Filter filter, SortProperty[] sortProperties, TableAliasGenerator aliasGenerator, VirtualContentProvider vcProvider)` Creates a new `WhereBuilder` instance.

Method Summary
`protected void` | `appendArithmeticExpressionAsSQL(StatementBuffer query, ArithmeticExpression expression, int targetSqlType)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendComparisonOperationAsSQL(StatementBuffer query, ComparisonOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendComplexFilterAsSQL(StatementBuffer query, ComplexFilter filter)` Appends an SQL fragment for the given object.
`protected void` | `appendExpressionAsSQL(StatementBuffer query, Expression expression, int targetSqlType)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendFeatureFilterAsSQL(StatementBuffer query, FeatureFilter filter)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendFunctionAsSQL(StatementBuffer query, Function function, int targetSqlType)` Appends an SQL fragment for the given object to the given sql statement.
`void` | `appendJoinTableList(StatementBuffer query)` Appends the alias-qualified, comma separated list of all tables to be joined in order to represent the associated filter expression (and possibly feature type joins).
`protected void` | `appendLiteralAsSQL(StatementBuffer query, Literal literal, int targetSqlType)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendLogicalOperationAsSQL(StatementBuffer query, LogicalOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendOperationAsSQL(StatementBuffer query, Operation operation)` Appends an SQL fragment for the given object to the given sql statement.
`void` | `appendOrderByCondition(StatementBuffer query)` Appends an SQL "ORDER BY"-condition that corresponds to the sort properties of the query to the given SQL statement.
`protected void` | `appendPropertyIsBetweenOperationAsSQL(StatementBuffer query, PropertyIsBetweenOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendPropertyIsCOMPOperationAsSQL(StatementBuffer query, PropertyIsCOMPOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendPropertyIsLikeOperationAsSQL(StatementBuffer query, PropertyIsLikeOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendPropertyIsNullOperationAsSQL(StatementBuffer query, PropertyIsNullOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendPropertyNameAsSQL(StatementBuffer query, PropertyName propertyName)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendPropertyPathAsSQL(StatementBuffer query, PropertyPath propertyPath)` Appends an SQL fragment for the given object to the given sql statement.
`protected void` | `appendSpatialOperationAsSQL(StatementBuffer query, SpatialOperation operation)` Appends an SQL fragment for the given object to the given sql statement.
`void` | `appendWhereCondition(StatementBuffer query)` Appends an SQL WHERE-condition corresponding to the `Filter` to the given SQL statement.
`protected void` | `buildFilterPropertyNameMap()`
`protected void` | `fillFunctionNameMap()` Prepares the function map for functions with implementation specific names, e.g. upper case conversion in ORACLE = UPPER(string); POSTGRES = UPPER(string), and MS Access = UCase(string).
`Filter` | `getFilter()` Returns the associated `Filter` instance.
`protected String` | `getFunctionName(String name)` Get the function with the specified name.
`protected MappedGeometryPropertyType` | `getGeometryProperty(PropertyName propName)`
`protected int` | `getPropertyNameSQLType(PropertyName propertyName)`
`String` | `getRootTableAlias(int i)` Returns the table alias used for the specified root feature type.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SRS_UNDEFINED

    protected static final int SRS_UNDEFINED

See Also:
  Constant Field Values

### rootFts

    protected MappedFeatureType[] rootFts

  Targeted feature types.

### filter

    protected Filter filter

  `Filter` for which the corresponding WHERE-clause will be generated.

### sortProperties

    protected SortProperty[] sortProperties

### vcProvider

    protected VirtualContentProvider vcProvider

### queryTableTree

    protected QueryTableTree queryTableTree

### filterPropertyPaths

    protected List<PropertyPath> filterPropertyPaths

### sortPropertyPaths

    protected List<PropertyPath> sortPropertyPaths

Constructor Detail

### WhereBuilder

    public WhereBuilder(MappedFeatureType[] rootFts,
                        String[] aliases,
                        Filter filter,
                        SortProperty[] sortProperties,
                        TableAliasGenerator aliasGenerator,
                        VirtualContentProvider vcProvider)
                 throws DatastoreException

  Creates a new `WhereBuilder` instance.

  Parameters:
    `rootFts` - selected feature types, more than one type means that the types are joined
    `aliases` - aliases for the feature types, may be null (must have same length as rootFts otherwise)
    `filter` -
    `sortProperties` -
    `aliasGenerator` - aliasGenerator to be used to generate table aliases, may be null
    `vcProvider` -
  Throws:
    `DatastoreException`

Method Detail

### getRootTableAlias

    public String getRootTableAlias(int i)

  Returns the table alias used for the specified root feature type.

  Parameters:
    `i` - index of the requested root feature type
  Returns:
    the alias used for the root table

### getFilter

    public Filter getFilter()

  Returns the associated `Filter` instance.

  Returns:
    the associated `Filter` instance

### getGeometryProperty

    protected MappedGeometryPropertyType getGeometryProperty(PropertyName propName)

### getPropertyNameSQLType

    protected int getPropertyNameSQLType(PropertyName propertyName)

### buildFilterPropertyNameMap

    protected void buildFilterPropertyNameMap()
                                       throws PropertyPathResolvingException

  Throws:
    `PropertyPathResolvingException`

### appendJoinTableList

    public void appendJoinTableList(StatementBuffer query)

  Appends the alias-qualified, comma separated list of all tables to be joined in order to represent the associated filter expression (and possibly feature type joins).

  The list consist of left outer joins ("x LEFT OUTER JOIN y") and cross-product joins ("x,y"):

  - left outer joins are generated for each join that is necessary, because of filter expressions that target properties stored in related tables (condition joins)
  - cross-product joins are generated for all feature type root tables (feature type joins) that have not joined by filter expression joins before

  Parameters:
    `query` - the list is appended to this `SQLStatement`

### appendWhereCondition

    public final void appendWhereCondition(StatementBuffer query)
                                    throws DatastoreException

  Appends an SQL WHERE-condition corresponding to the `Filter` to the given SQL statement.

  Parameters:
    `query` -
  Throws:
    `DatastoreException`

### appendOrderByCondition

    public void appendOrderByCondition(StatementBuffer query)
                                throws DatastoreException

  Appends an SQL "ORDER BY"-condition that corresponds to the sort properties of the query to the given SQL statement.

  Parameters:
    `query` -
  Throws:
    `DatastoreException`

### appendComplexFilterAsSQL

    protected void appendComplexFilterAsSQL(StatementBuffer query,
                                            ComplexFilter filter)
                                     throws DatastoreException

  Appends an SQL fragment for the given object.

  Parameters:
    `query` -
    `filter` -
  Throws:
    `DatastoreException`

### appendOperationAsSQL

    protected void appendOperationAsSQL(StatementBuffer query,
                                        Operation operation)
                                 throws DatastoreException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `DatastoreException`

### appendComparisonOperationAsSQL

    protected void appendComparisonOperationAsSQL(StatementBuffer query,
                                                  ComparisonOperation operation)
                                           throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `FilterEvaluationException`

### appendPropertyIsCOMPOperationAsSQL

    protected void appendPropertyIsCOMPOperationAsSQL(StatementBuffer query,
                                                      PropertyIsCOMPOperation operation)
                                               throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `FilterEvaluationException`

### appendPropertyIsLikeOperationAsSQL

    protected void appendPropertyIsLikeOperationAsSQL(StatementBuffer query,
                                                      PropertyIsLikeOperation operation)
                                               throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `FilterEvaluationException`

### appendPropertyIsNullOperationAsSQL

    protected void appendPropertyIsNullOperationAsSQL(StatementBuffer query,
                                                      PropertyIsNullOperation operation)

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -

### appendPropertyIsBetweenOperationAsSQL

    protected void appendPropertyIsBetweenOperationAsSQL(StatementBuffer query,
                                                         PropertyIsBetweenOperation operation)
                                                  throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `FilterEvaluationException`

### appendExpressionAsSQL

    protected void appendExpressionAsSQL(StatementBuffer query,
                                         Expression expression,
                                         int targetSqlType)
                                  throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `expression` -
    `targetSqlType` - sql type code to be used for literals at the bottom of the expression tree
  Throws:
    `FilterEvaluationException`

### appendLiteralAsSQL

    protected void appendLiteralAsSQL(StatementBuffer query,
                                      Literal literal,
                                      int targetSqlType)

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `literal` -
    `targetSqlType` -

### appendPropertyNameAsSQL

    protected void appendPropertyNameAsSQL(StatementBuffer query,
                                           PropertyName propertyName)

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `propertyName` -

### appendPropertyPathAsSQL

    protected void appendPropertyPathAsSQL(StatementBuffer query,
                                           PropertyPath propertyPath)

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `propertyPath` -

### appendArithmeticExpressionAsSQL

    protected void appendArithmeticExpressionAsSQL(StatementBuffer query,
                                                   ArithmeticExpression expression,
                                                   int targetSqlType)
                                            throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `expression` -
    `targetSqlType` -
  Throws:
    `FilterEvaluationException`

### appendFunctionAsSQL

    protected void appendFunctionAsSQL(StatementBuffer query,
                                       Function function,
                                       int targetSqlType)
                                throws FilterEvaluationException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `function` -
    `targetSqlType` -
  Throws:
    `FilterEvaluationException`

### appendLogicalOperationAsSQL

    protected void appendLogicalOperationAsSQL(StatementBuffer query,
                                               LogicalOperation operation)
                                        throws DatastoreException

  Appends an SQL fragment for the given object to the given sql statement.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `DatastoreException`

### appendFeatureFilterAsSQL

    protected void appendFeatureFilterAsSQL(StatementBuffer query,
                                            FeatureFilter filter)
                                     throws DatastoreException

  Appends an SQL fragment for the given object to the given sql statement. TODO Handle compound primary keys correctly.

  Parameters:
    `query` -
    `filter` -
  Throws:
    `DatastoreException`

### appendSpatialOperationAsSQL

    protected void appendSpatialOperationAsSQL(StatementBuffer query,
                                               SpatialOperation operation)
                                        throws DatastoreException

  Appends an SQL fragment for the given object to the given sql statement. As this depends on the handling of geometry data by the concrete database in use, this method must be overwritten by any datastore implementation that has spatial capabilities.

  Parameters:
    `query` -
    `operation` -
  Throws:
    `DatastoreException`

### fillFunctionNameMap

    protected void fillFunctionNameMap()

  Prepares the function map for functions with implementation specific names, e.g. upper case conversion in ORACLE = UPPER(string); POSTGRES = UPPER(string), and MS Access = UCase(string). Default SQL-function name map function 'UPPER' is 'UPPER'. If this function shall be used with user databases e.g. SQLServer a specialized WhereBuilder must override this method.

### getFunctionName

    protected String getFunctionName(String name)

  Get the function with the specified name.

  Parameters:
    `name` - the function name
  Returns:
    the mapped function name

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org