deegree 2.5 (2011/06/29 09:44 build-8-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: 27361 $, $Date: 2010-10-18 20:38:36 +0200 (Mo, 18 Okt 2010) $
Author:
Markus Schneider , Torsten Friebe , last edited by: $Author: apoth $

Field Summary
 
Fields inherited from class org.deegree.io.datastore.sql.AbstractSQLDatastore
pool, SRS_UNDEFINED
 
Constructor Summary
OracleDatastore()
           
 
Method Summary
protected  java.sql.Connection acquireConnection()
          Returns the database connection requested for.
 SQLFunctionCall buildSRSTransformCall(MappedGeometryPropertyType geoProperty, java.lang.String targetSRS)
          Returns an SQLFunctionCall that refers to the given MappingGeometryField in the specified target SRS using a database specific SQL function.
 java.lang.String buildSRSTransformCall(java.lang.String geomIdentifier, int nativeSRSCode)
          Builds an SQL fragment that converts the given geometry to the specified SRS.
protected  boolean canTransformTo(java.lang.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(java.lang.Object value, CoordinateSystem targetCS, java.sql.Connection conn)
          Converts an Oracle specific geometry Object from the ResultSet to a deegree Geometry.
 oracle.sql.STRUCT convertDeegreeToDBGeometry(Geometry geometry, int nativeSRSCode, java.sql.Connection conn)
          Converts a deegree Geometry to an Oracle specific geometry object.
 java.lang.Object convertFromDBType(java.lang.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 java.lang.String fromOracleSRIDCode(int srid)
           
 int getNativeSRSCode(java.lang.String srsName)
          Returns the database specific code for the given SRS name.
static int getOracleSRIDCode(java.lang.String code)
           
 java.lang.Object getSequenceCurrValPlusOffset(java.sql.Connection conn, java.lang.String sequence, int offset)
          Returns the current value (plus an offset) of the given SQL sequence.
 java.lang.Object getSequenceNextVal(java.sql.Connection conn, java.lang.String sequence)
          Returns the next value of the given SQL sequence.
 WhereBuilder getWhereBuilder(MappedFeatureType[] rootFts, java.lang.String[] aliases, Filter filter, SortProperty[] sortProperties, TableAliasGenerator aliasGenerator, VirtualContentProvider vcProvider)
          Returns a specific WhereBuilder implementation for Oracle Spatial.
 java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, StatementBuffer statementBuffer)
          Converts the StatementBuffer into a PreparedStatement, which is initialized and ready to be performed.
 void releaseConnection(java.sql.Connection conn)
          Releases the connection.
protected  Query transformQuery(Query query)
          Transforms the incoming Query so that the CoordinateSystem of all spatial arguments (BBOX, etc.)
protected  FeatureCollection transformResult(FeatureCollection fc, java.lang.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
acquireTransaction, appendGeometryColumnGet, close, configure, createTransaction, determineFidsToLock, getAnnotationParser, getMaxValue, performQuery, performQuery, performQuery, 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

acquireConnection

protected java.sql.Connection acquireConnection()
                                         throws DatastoreException
Returns the database connection requested for.

Overrides:
acquireConnection in class AbstractSQLDatastore
Returns:
Connection
Throws:
DatastoreException

releaseConnection

public void releaseConnection(java.sql.Connection conn)
                       throws DatastoreException
Releases the connection.

Overrides:
releaseConnection in class AbstractSQLDatastore
Parameters:
conn - connection to be released.
Throws:
DatastoreException

getOracleSRIDCode

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

fromOracleSRIDCode

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

getWhereBuilder

public WhereBuilder getWhereBuilder(MappedFeatureType[] rootFts,
                                    java.lang.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(java.lang.Object value,
                                           CoordinateSystem targetCS,
                                           java.sql.Connection conn)
                                    throws java.sql.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:
java.sql.SQLException

convertDeegreeToDBGeometry

public oracle.sql.STRUCT convertDeegreeToDBGeometry(Geometry geometry,
                                                    int nativeSRSCode,
                                                    java.sql.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 java.lang.Object convertFromDBType(java.lang.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 java.lang.Object getSequenceNextVal(java.sql.Connection conn,
                                           java.lang.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 java.lang.Object getSequenceCurrValPlusOffset(java.sql.Connection conn,
                                                     java.lang.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 java.sql.PreparedStatement prepareStatement(java.sql.Connection conn,
                                                   StatementBuffer statementBuffer)
                                            throws java.sql.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:
java.sql.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,
                                            java.lang.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(java.lang.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,
                                             java.lang.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 java.lang.String buildSRSTransformCall(java.lang.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(java.lang.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.5 (2011/06/29 09:44 build-8-official)

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