org.geotools.arcsde.filter
Class FilterToSQLSDE

Object
  extended by FilterToSQL
      extended by FilterToSQLSDE
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor

public class FilterToSQLSDE
extends FilterToSQL
implements FilterVisitor

Encodes an attribute filter into a SQL WHERE statement for arcsde.

Although not all filters support is coded yet, the strategy to filtering queries for ArcSDE datasources is separated in two parts, the SQL where clause construction, provided here and the spatial filters (or spatial constraints, in SDE vocabulary) provided by GeometryEncoderSDE; mirroring the java SDE api approach for easy programing

Author:
Saul Farber, Gabriel Roldan
See Also:
org.geotools.data.sde.GeometryEncoderSDE

Nested Class Summary
 
Nested classes/interfaces inherited from class FilterToSQL
FilterToSQL.FieldEncoder
 
Field Summary
 
Fields inherited from class FilterToSQL
capabilities, currentGeometry, currentSRID, databaseSchema, encodingFunction, featureType, fieldEncoder, filterFactory, inline, IO_ERROR, mapper, out, primaryKey
 
Constructor Summary
FilterToSQLSDE(String layerQName, String layerFidColName, SimpleFeatureType ft, PlainSelect definitionQuery, ISession session)
           
 
Method Summary
protected  FilterCapabilities createFilterCapabilities()
          Overrides the superclass implementation to indicate that we support pushing FeatureId filters down into the data store.
 void encode(Filter filter)
          overrides just to avoid the "WHERE" keyword
 String getColumnDefinition(String alias)
          Returns the full qualifed name of sql expression that is registered as the source of the attribute named alias.
protected  Object visit(BinaryLogicOperator filter, Object extraData)
          Overrides to avoid encoding an empty operator if filter has no children.
 Object visit(ExcludeFilter filter, Object extraData)
          Visit Filter.EXCLUDE (often used during data structure transformations).
 Object visit(Id filter, Object unused)
          This only exists the fulfill the interface - unless There is a way of determining the FID column in the database...
 Object visit(IncludeFilter filter, Object extraData)
          Visit Filter.INCLUDE (often used during data structure transformations).
 Object visit(PropertyName expression, Object extraData)
          Writes the SQL for the attribute Expression.
protected  void writeLiteral(Object literal)
          Writes out a non null, non geometry literal.
 
Methods inherited from class FilterToSQL
cast, encode, encodeToString, encodeToString, escapeName, evaluateLiteral, getCapabilities, getDatabaseSchema, getFIDMapper, getFunctionName, getParameter, getPrimaryKey, setCapabilities, setDatabaseSchema, setFeatureType, setFIDMapper, setFieldEncoder, 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, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitBinaryComparisonOperator, visitBinarySpatialOperator, visitBinarySpatialOperator, visitBinarySpatialOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitBinaryTemporalOperator, visitLiteralGeometry, visitLiteralTimePeriod, visitNullFilter
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FilterVisitor
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, visit, visit, visit, visit, visit, visit, visit, visit, visitNullFilter
 

Constructor Detail

FilterToSQLSDE

public FilterToSQLSDE(String layerQName,
                      String layerFidColName,
                      SimpleFeatureType ft,
                      PlainSelect definitionQuery,
                      ISession session)
Parameters:
layerQName - full qualified name of the ArcSDE layer
layerFidColName - name of the column that holds fids
ft -
definitionQuery -
conn2 - only used to encode date literals in a RDBMS specific format according to SeDate.toWhereStr(SeConnection)
Method Detail

getColumnDefinition

public String getColumnDefinition(String alias)
Returns the full qualifed name of sql expression that is registered as the source of the attribute named alias.

Parameters:
alias -
Returns:

createFilterCapabilities

protected FilterCapabilities createFilterCapabilities()
Overrides the superclass implementation to indicate that we support pushing FeatureId filters down into the data store.

Overrides:
createFilterCapabilities in class FilterToSQL
Returns:
FilterCapabilities for this Filter

encode

public void encode(Filter filter)
            throws FilterToSQLException
overrides just to avoid the "WHERE" keyword

Overrides:
encode in class FilterToSQL
Parameters:
filter - the Filter to be encoded.
Throws:
FilterToSQLException

visit

public Object visit(Id filter,
                    Object unused)
This only exists the fulfill the interface - unless There is a way of determining the FID column in the database...

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
filter - the Fid Filter.

visit

public Object visit(PropertyName expression,
                    Object extraData)
             throws RuntimeException
Writes the SQL for the attribute Expression. NOTE: If the feature type is the product of an in process sql query, the attribute name encoded will be the actual one, not the alias (if any) used in the sql query.

Specified by:
visit in interface ExpressionVisitor
Overrides:
visit in class FilterToSQL
Parameters:
expression - the attribute to turn to SQL.
Throws:
RuntimeException - for io exception with writer

visit

protected Object visit(BinaryLogicOperator filter,
                       Object extraData)
Overrides to avoid encoding an empty operator if filter has no children.

Overrides:
visit in class FilterToSQL
Parameters:
filter - the logic statement to be turned into SQL.
extraData - extra filter data. Not modified directly by this method.

visit

public Object visit(ExcludeFilter filter,
                    Object extraData)
Description copied from interface: FilterVisitor
Visit Filter.EXCLUDE (often used during data structure transformations).

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
the - filter to be visited
Returns:
subclass supplied
See Also:
FilterVisitor#visit(ExcludeFilter, Object)} Writes the SQL for the IncludeFilter by writing "FALSE".

visit

public Object visit(IncludeFilter filter,
                    Object extraData)
Description copied from interface: FilterVisitor
Visit Filter.INCLUDE (often used during data structure transformations).

Specified by:
visit in interface FilterVisitor
Overrides:
visit in class FilterToSQL
Parameters:
the - filter to be visited
Returns:
subclass supplied
See Also:
FilterVisitor#visit(IncludeFilter, Object)} Writes the SQL for the IncludeFilter by writing "TRUE".

writeLiteral

protected void writeLiteral(Object literal)
                     throws IOException
Description copied from class: FilterToSQL
Writes out a non null, non geometry literal. The base class properly handles null, numeric and booleans (true|false), and turns everything else into a string. Subclasses are expected to override this shall they need a different treatment (e.g. for dates)

Overrides:
writeLiteral in class FilterToSQL
Throws:
IOException


Copyright © 1996-2014 Geotools. All Rights Reserved.