deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.io.datastore.sql.oracle
Class OracleDatastore

java.lang.Object
  extended by org.deegree.io.datastore.Datastore
      extended by org.deegree.io.datastore.sql.AbstractSQLDatastore
          extended by org.deegree.io.datastore.sql.oracle.OracleDatastore

public class OracleDatastore
extends AbstractSQLDatastore

Datastore implementation for Oracle Spatial database systems. Supports Oracle Spatial for Oracle 10g. TODO Which Oracle spatial versions are supported exactly?

Version:
$Revision: 20611 $, $Date: 2009-11-05 18:38:29 +0100 (Do, 05. Nov 2009) $
Author:
Markus Schneider , Torsten Friebe , last edited by: $Author: mschneider $

Field Summary
 
Fields inherited from class org.deegree.io.datastore.sql.AbstractSQLDatastore
pool
 
Constructor Summary
OracleDatastore()
           
 
Method Summary
 SQLFunctionCall buildSRSTransformCall(MappedGeometryPropertyType geoProperty, String targetSRS)
          Returns an SQLFunctionCall that refers to the given MappingGeometryField in the specified target SRS using a database specific SQL function.
 String buildSRSTransformCall(String geomIdentifier, int nativeSRSCode)
          Builds an SQL fragment that converts the given geometry to the specified SRS.
protected  boolean canTransformTo(String targetSRS)
          Returns whether the datastore is capable of performing a native coordinate transformation (using an SQL function call for example) into the given SRS.
 Geometry convertDBToDeegreeGeometry(Object value, CoordinateSystem targetCS, Connection conn)
          Converts an Oracle specific geometry Object from the ResultSet to a deegree Geometry.
 oracle.sql.STRUCT convertDeegreeToDBGeometry(Geometry geometry, int nativeSRSCode, Connection conn)
          Converts a deegree Geometry to an Oracle specific geometry object.
 Object convertFromDBType(Object rsObject, int sqlTypeCode)
          Converts the given object from a java.sql.ResultSet column to the common type to be used as a feature property.
static String fromOracleSRIDCode(int srid)
           
 int getNativeSRSCode(String srsName)
          Returns the database specific code for the given SRS name.
static int getOracleSRIDCode(String code)
           
 Object getSequenceCurrValPlusOffset(Connection conn, String sequence, int offset)
          Returns the current value (plus an offset) of the given SQL sequence.
 Object getSequenceNextVal(Connection conn, String sequence)
          Returns the next value of the given SQL sequence.
 WhereBuilder getWhereBuilder(MappedFeatureType[] rootFts, String[] aliases, Filter filter, SortProperty[] sortProperties, TableAliasGenerator aliasGenerator, VirtualContentProvider vcProvider)
          Returns a specific WhereBuilder implementation for Oracle Spatial.
 PreparedStatement prepareStatement(Connection conn, StatementBuffer statementBuffer)
          Converts the StatementBuffer into a PreparedStatement, which is initialized and ready to be performed.
protected  Query transformQuery(Query query)
          Transforms the incoming Query so that the CoordinateSystem of all spatial arguments (BBOX, etc.)
protected  FeatureCollection transformResult(FeatureCollection fc, String targetSRS)
          Transforms the FeatureCollection so that the geometries of all contained geometry properties use the requested SRS.
 
Methods inherited from class org.deegree.io.datastore.sql.AbstractSQLDatastore
acquireConnection, acquireTransaction, appendGeometryColumnGet, close, configure, createTransaction, determineFidsToLock, getAnnotationParser, getMaxValue, performQuery, performQuery, performQuery, releaseConnection, releaseTransaction
 
Methods inherited from class org.deegree.io.datastore.Datastore
bindSchema, getConfiguration, getFeatureType, getSchemas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDatastore

public OracleDatastore()
Method Detail

getOracleSRIDCode

public static int getOracleSRIDCode(String code)
Parameters:
code - an EPSG code
Returns:
the oracle code as stored in srs_codes_oracle.properties

fromOracleSRIDCode

public static String fromOracleSRIDCode(int srid)
Parameters:
srid -
Returns:
an EPSG code or "-1", if none was found

getWhereBuilder

public WhereBuilder getWhereBuilder(MappedFeatureType[] rootFts,
                                    String[] aliases,
                                    Filter filter,
                                    SortProperty[] sortProperties,
                                    TableAliasGenerator aliasGenerator,
                                    VirtualContentProvider vcProvider)
                             throws DatastoreException
Returns a specific WhereBuilder implementation for Oracle Spatial.

Overrides:
getWhereBuilder in class AbstractSQLDatastore
Parameters:
rootFts - involved (requested) feature types
aliases - aliases for the feature types, may be null
filter - filter that restricts the matched features
sortProperties - sort criteria for the result, may be null or empty
aliasGenerator - used to generate unique table aliases
vcProvider -
Returns:
WhereBuilder implementation for Oracle Spatial
Throws:
DatastoreException

convertDBToDeegreeGeometry

public Geometry convertDBToDeegreeGeometry(Object value,
                                           CoordinateSystem targetCS,
                                           Connection conn)
                                    throws SQLException
Converts an Oracle specific geometry Object from the ResultSet to a deegree Geometry.

Specified by:
convertDBToDeegreeGeometry in class AbstractSQLDatastore
Parameters:
value -
targetCS -
conn -
Returns:
corresponding deegree geometry
Throws:
SQLException

convertDeegreeToDBGeometry

public oracle.sql.STRUCT convertDeegreeToDBGeometry(Geometry geometry,
                                                    int nativeSRSCode,
                                                    Connection conn)
                                             throws DatastoreException
Converts a deegree Geometry to an Oracle specific geometry object.

Specified by:
convertDeegreeToDBGeometry in class AbstractSQLDatastore
Parameters:
geometry -
nativeSRSCode -
conn -
Returns:
corresponding Oracle specific geometry object
Throws:
DatastoreException

convertFromDBType

public Object convertFromDBType(Object rsObject,
                                int sqlTypeCode)
                         throws DatastoreException
Converts the given object from a java.sql.ResultSet column to the common type to be used as a feature property.

NOTE: String- and boolean-valued results have a special conversion handling:

Overrides:
convertFromDBType in class AbstractSQLDatastore
Parameters:
rsObject -
sqlTypeCode -
Returns:
an object that is suitable for a table column of the specified SQL type
Throws:
DatastoreException

getSequenceNextVal

public Object getSequenceNextVal(Connection conn,
                                 String sequence)
                          throws DatastoreException
Returns the next value of the given SQL sequence.

Overrides:
getSequenceNextVal in class AbstractSQLDatastore
Parameters:
conn - JDBC connection to be used.
sequence - name of the SQL sequence
Returns:
next value of the given SQL sequence
Throws:
DatastoreException - if the value could not be retrieved

getSequenceCurrValPlusOffset

public Object getSequenceCurrValPlusOffset(Connection conn,
                                           String sequence,
                                           int offset)
                                    throws DatastoreException
Returns the current value (plus an offset) of the given SQL sequence.

Overrides:
getSequenceCurrValPlusOffset in class AbstractSQLDatastore
Parameters:
conn - JDBC connection to be used.
sequence - name of the SQL sequence
offset - offset added to the sequence value
Returns:
current value (plus offset) of the given SQL sequence
Throws:
DatastoreException - if the value could not be retrieved

prepareStatement

public PreparedStatement prepareStatement(Connection conn,
                                          StatementBuffer statementBuffer)
                                   throws SQLException
Converts the StatementBuffer into a PreparedStatement, which is initialized and ready to be performed. TODO remove this method (use super class method instead), change handling of JGeometry NOTE: String- and boolean-valued results have a special conversion handling:
  • Strings: because we encountered difficulties when inserting empty strings "" into String-type columns with NOT NULL constraints (for example in VARCHAR2 fields), "$EMPTY_STRING$" is used to mark them.
  • Boolean:because Oracle has no special boolean type, it is assumed that a CHAR(1) column is used instead (with values 'Y'=true and 'N'=false)

Overrides:
prepareStatement in class AbstractSQLDatastore
Parameters:
conn - connection to be used to create the PreparedStatement
statementBuffer -
Returns:
the PreparedStatment, ready to be performed
Throws:
SQLException - if a JDBC related error occurs

transformQuery

protected Query transformQuery(Query query)
Transforms the incoming Query so that the CoordinateSystem of all spatial arguments (BBOX, etc.) in the Filter match the SRS of the targeted MappingGeometryFields.

NOTE: If this transformation can be performed by the backend (e.g. by Oracle Spatial), this method should be overwritten to return the original input Query.

Overrides:
transformQuery in class Datastore
Parameters:
query - query to be transformed
Returns:
query with spatial arguments transformed to target SRS

transformResult

protected FeatureCollection transformResult(FeatureCollection fc,
                                            String targetSRS)
Transforms the FeatureCollection so that the geometries of all contained geometry properties use the requested SRS.

Overrides:
transformResult in class Datastore
Parameters:
fc - feature collection to be transformed
targetSRS - requested SRS
Returns:
transformed FeatureCollection

canTransformTo

protected boolean canTransformTo(String targetSRS)
Returns whether the datastore is capable of performing a native coordinate transformation (using an SQL function call for example) into the given SRS.

Overrides:
canTransformTo in class Datastore
Parameters:
targetSRS - target spatial reference system (usually "EPSG:XYZ")
Returns:
true, if the datastore can perform the coordinate transformation, false otherwise

buildSRSTransformCall

public SQLFunctionCall buildSRSTransformCall(MappedGeometryPropertyType geoProperty,
                                             String targetSRS)
                                      throws DatastoreException
Returns an SQLFunctionCall that refers to the given MappingGeometryField in the specified target SRS using a database specific SQL function.

Overrides:
buildSRSTransformCall in class AbstractSQLDatastore
Parameters:
geoProperty - geometry property
targetSRS - target spatial reference system (usually "EPSG:XYZ")
Returns:
an SQLFunctionCall that refers to the geometry in the specified srs
Throws:
DatastoreException

buildSRSTransformCall

public String buildSRSTransformCall(String geomIdentifier,
                                    int nativeSRSCode)
                             throws DatastoreException
Description copied from class: AbstractSQLDatastore
Builds an SQL fragment that converts the given geometry to the specified SRS.

Overrides:
buildSRSTransformCall in class AbstractSQLDatastore
Returns:
an SQL fragment that converts the given geometry to the specified SRS
Throws:
DatastoreException

getNativeSRSCode

public int getNativeSRSCode(String srsName)
Description copied from class: AbstractSQLDatastore
Returns the database specific code for the given SRS name.

Overrides:
getNativeSRSCode in class AbstractSQLDatastore
Parameters:
srsName - spatial reference system name (usually "EPSG:XYZ")
Returns:
the database specific SRS code, or -1 if no corresponding native code is known

deegree 2.3 (2010/04/09 10:10 build-4-official)

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