| java.lang.Object org.geotools.data.jdbc.JDBC1DataStore
All known Subclasses: org.geotools.data.jdbc.JDBC2DataStore, org.geotools.data.hsql.HsqlDataStore,
JDBC1DataStore | abstract public class JDBC1DataStore implements DataStore(Code) | | Abstract class for JDBC based DataStore implementations.
This class provides a default implementation of a JDBC data store. Support
for vendor specific JDBC data stores can be easily added to Geotools by
subclassing this class and overriding the hooks provided.
At a minimum subclasses should implement the following methods:
Additionally subclasses can optionally override the following:
Additionally subclasses may want to set the value of:
- sqlNameEscape - character (String) to surround names of SQL objects to
support mixed-case and non-English names.
author: Amr Alam, Refractions Research author: Sean Geoghegan, Defence Science and Technology Organisation author: Chris Holmes, TOPP author: Andrea Aime version: $Id: JDBC1DataStore.java 29442 2008-02-25 09:36:19Z jgarnett $ |
Method Summary | |
public boolean | allSameOrder(String[] requestedNames, FeatureType ft) returns true if the requested names list all the attributes in the
correct order. | protected boolean | allowTable(String tablename) Provides a hook for sub classes to filter out specific tables in the data
store that are not to be used as geospatial tables. | protected String[] | attributeNames(FeatureType featureType, Filter filter) Gets the list of attribute names required for both featureType and filter
Parameters: featureType - The FeatureType to get attribute names for. Parameters: filter - The filter which needs attributes to filter. | protected AttributeType | buildAttributeType(ResultSet rs) Constructs an AttributeType from a row in a ResultSet. | protected FIDMapper | buildFIDMapper(String typeName, FIDMapperFactory factory) | protected FIDMapperFactory | buildFIDMapperFactory(JDBCDataStoreConfig config) | protected FeatureType | buildSchema(String typeName, FIDMapper mapper) Builds the schema for a table in the database.
This works by retrieving the column information for the table from the
DatabaseMetaData object. | abstract protected Connection | createConnection() | protected FeatureReader | createFeatureReader(FeatureType schema, org.opengis.filter.Filter postFilter, QueryData queryData) Create a new FeatureReader based on attributeReaders.
The provided schema describes the attributes in the
queryData ResultSet. | protected JDBCFeatureWriter | createFeatureWriter(FeatureReader reader, QueryData queryData) | protected LockingManager | createLockingManager() Allows subclass to create LockingManager to support their needs. | public void | createSchema(FeatureType featureType) Create a new featureType. | protected String | determineFidColumnName(String typeName) Provides the default implementation of determining the FID column.
The default implementation of determining the FID column name is to use
the primary key as the FID column. | protected int | determineSRID(String tableName, String geometryColumnName) Provides a hook for subclasses to determine the SRID of a geometry
column.
This allows SRIDs to be determined in a Vendor specific way and to be
cached by the default implementation. | protected QueryData | executeQuery(FeatureTypeInfo featureTypeInfo, String tableName, String sqlQuery, Transaction transaction, boolean forWrite) | protected QueryData | executeQuery(FeatureTypeInfo featureTypeInfo, String tableName, String sqlQuery, Transaction transaction, boolean forWrite, Hints hints) Executes the SQL Query.
This is private in the expectation that subclasses should not need to
change this behaviour.
Jody with a question here - I have stopped this method from closing
connection shared by a Transaction. | protected AttributeIO | getAttributeIO(AttributeType type) | final protected AttributeType[] | getAttributeTypes(String typeName, String[] propertyNames) Gets the attribute types from from a given type.
Parameters: typeName - The name of the feature type to get the AttributeTypes for. Parameters: propertyNames - The list of propertyNames to get AttributeTypes for. | protected int | getConcurrency(boolean forWrite) | public Connection | getConnection(Transaction transaction) Gets a connection for the provided transaction. | public Envelope | getEnvelope(String typeName) Retrieve approx bounds of all Features. | public FIDMapper | getFIDMapper(String tableName) | public FIDMapperFactory | getFIDMapperFactory() | public FeatureReader | getFeatureReader(FeatureType requestType, Filter filter, Transaction transaction) This is a public entry point to the DataStore. | public FeatureReader | getFeatureReader(Query query, Transaction trans) The top level method for getting a FeatureReader.
Chris- I've gone with the Query object aswell. | public FeatureSource | getFeatureSource(String typeName) Default implementation based on getFeatureReader and getFeatureWriter. | protected FeatureTypeHandler | getFeatureTypeHandler(JDBCDataStoreConfig config) | public FeatureWriter | getFeatureWriter(String typeName, Transaction transaction) Retrieve a FeatureWriter over entire dataset. | public FeatureWriter | getFeatureWriter(String typeName, org.opengis.filter.Filter filter, Transaction transaction) Acquire FeatureWriter for modification of contents specifed by filter. | public FeatureWriter | getFeatureWriterAppend(String typeName, Transaction transaction) Retrieve a FeatureWriter for creating new content.
Subclass may wish to implement an optimized featureWriter for this
operation. | abstract protected AttributeIO | getGeometryAttributeIO(AttributeType type, QueryData queryData) Hook to create the geometry attribute IO for a vendor specific data
source. | protected JDBCFeatureReader | getJDBCFeatureReader(QueryData queryData) | public LockingManager | getLockingManager() Locking manager used for this DataStore. | public URI | getNameSpace() Gets the namespace of the data store. | protected int | getResultSetType(boolean forWrite) | public FeatureType | getSchema(String typeName) | public SQLBuilder | getSqlBuilder(String typeName) Hook for subclass to return a different sql builder.
Subclasses requiring a ClientTransactionAccessor should override
and instantiate an SQLBuilder with one in the constructor. | public String | getSqlNameEscape() Gets the SQL name escape string. | public Set | getSupportedHints() | public int | getTransactionIsolation() Obtain the transaction isolation level for connections. | public String[] | getTypeNames() | public FeatureSource | getView(Query query) | protected String[] | propertyNames(Query query) Get propertyNames in a safe manner. | protected boolean | requireAutoCommit() Return true if transaction is handled on client. | protected void | setAutoCommit(boolean forWrite, Connection conn) This method should be overridden to do nothing by DataStores where
setting autoCommit causes funky behaviour (ie. | public void | setFIDMapper(String featureTypeName, FIDMapper fidMapper) | public void | setFIDMapperFactory(FIDMapperFactory fmFactory) Allows to override the default FIDMapperFactory. | protected void | setSqlNameEscape(String sqlNameEscape) Sets the SQL name escape string. | public void | setTransactionIsolation(int value) Sets the transaction isolation level for connections. | public void | updateSchema(String typeName, FeatureType featureType) Used to provide support for changing the DataStore Schema.
Specifically this is intended to address updating the metadata Coordinate
System information.
If we can figure out the Catalog API for metadata we will not have to use
such a heavy handed approach.
Subclasses are free to implement various levels of support:
- None - table modification is not supported
- CS change - ensure that the attribtue types match and only update
metadata but not table structure.
|
LOGGER | final protected static Logger LOGGER(Code) | | The logger for the filter module.
|
TYPE_MAPPINGS | final public static Map TYPE_MAPPINGS(Code) | | Maps SQL types to Java classes. This might need to be fleshed out more
later, Ive ignored complex types such as ARRAY, BLOB and CLOB. It is
protected so subclasses can override it I guess.
These mappings were taken from
http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html#997737
|
allowWriteOnVolatileFIDs | protected boolean allowWriteOnVolatileFIDs(Code) | | When true, writes are allowed also on tables with volatile FID mappers.
False by default
See Also: FIDMapper.isVolatile |
sqlNameEscape | protected String sqlNameEscape(Code) | | The character(s) to surround schema, table and column names an SQL query
to support mixed-case and non-English names
|
transactionIsolation | protected int transactionIsolation(Code) | | The transaction isolation level to use in a transaction. One of
Connection.TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED,
TRANSACTION_REPEATABLE_READ, or SERIALIZABLE.
Connection.TRANSACTION_NONE may also be used to indicate "use default".
|
allSameOrder | public boolean allSameOrder(String[] requestedNames, FeatureType ft)(Code) | | returns true if the requested names list all the attributes in the
correct order.
Parameters: requestedNames - Parameters: ft - |
allowTable | protected boolean allowTable(String tablename)(Code) | | Provides a hook for sub classes to filter out specific tables in the data
store that are not to be used as geospatial tables. The default
implementation of this method is to allow all tables.
Parameters: tablename - A table name to check. True if the table should be exposed as a FeatureType, false if itshould be ignored. |
attributeNames | protected String[] attributeNames(FeatureType featureType, Filter filter) throws IOException(Code) | | Gets the list of attribute names required for both featureType and filter
Parameters: featureType - The FeatureType to get attribute names for. Parameters: filter - The filter which needs attributes to filter. The list of attribute names required by a filter. throws: IOException - If we can't get the schema. |
buildAttributeType | protected AttributeType buildAttributeType(ResultSet rs) throws IOException(Code) | | Constructs an AttributeType from a row in a ResultSet. The ResultSet
contains the information retrieved by a call to getColumns() on the
DatabaseMetaData object. This information can be used to construct an
Attribute Type.
The default implementation constructs an AttributeType using the default
JDBC type mappings defined in JDBCDataStore. These type mappings only
handle native Java classes and SQL standard column types, so to handle
Geometry columns, sub classes should override this to check if a column
is a geometry column, if it is a geometry column the appropriate
determination of the geometry type can be performed. Otherwise,
overriding methods should call super.buildAttributeType.
Note: Overriding methods must never move the current row pointer in the
result set.
Parameters: rs - The ResultSet containing the result of aDatabaseMetaData.getColumns call. The AttributeType built from the ResultSet or null if the columnshould be excluded from the schema. throws: IOException - If an error occurs processing the ResultSet. |
buildSchema | protected FeatureType buildSchema(String typeName, FIDMapper mapper) throws IOException(Code) | | Builds the schema for a table in the database.
This works by retrieving the column information for the table from the
DatabaseMetaData object. It then iterates over the information for each
column, calling buildAttributeType(ResultSet) to construct an
AttributeType for each column. The list of attribute types is then turned
into a FeatureType that defines the schema.
It is not intended that this method is overriden. It should provide the
required functionality for most sub-classes. To add AttributeType
construction for vendor specific SQL types, such as geometries, override
the buildAttributeType(ResultSet) method.
This may become final later. In fact Ill make it private because I don't
think It will need to be overriden.
Parameters: typeName - The name of the table to construct a feature type for. Parameters: mapper - The name of the column holding the fid. The FeatureType for the table. throws: IOException - throws: DataSourceException - This can occur if there is an SQL error or an errorconstructing the FeatureType. See Also: JDBC1DataStore.buildAttributeType(ResultSet) |
createFeatureReader | protected FeatureReader createFeatureReader(FeatureType schema, org.opengis.filter.Filter postFilter, QueryData queryData) throws IOException(Code) | | Create a new FeatureReader based on attributeReaders.
The provided schema describes the attributes in the
queryData ResultSet. This schema should cover the requirements of
filter .
Retyping to the users requested Schema will not happen in this method.
Parameters: schema - Parameters: postFilter - Filter for post processing, or null if notrequired. Parameters: queryData - Holds a ResultSet for attribute Readers throws: IOException - |
createLockingManager | protected LockingManager createLockingManager()(Code) | | Allows subclass to create LockingManager to support their needs.
|
determineFidColumnName | protected String determineFidColumnName(String typeName) throws IOException(Code) | | Provides the default implementation of determining the FID column.
The default implementation of determining the FID column name is to use
the primary key as the FID column. If no primary key is present, null
will be returned. Sub classes can override this behaviour to define
primary keys for vendor specific cases.
There is an unresolved issue as to what to do when there are multiple
primary keys. Maybe a restriction that table much have a single column
primary key is appropriate.
This should not be called by subclasses to retreive the FID column name.
Instead, subclasses should call getFeatureTypeInfo(String) to get the
FeatureTypeInfo for a feature type and get the fidColumn name from the
fidColumn name memeber.
Parameters: typeName - The name of the table to get a primary key for. The name of the primay key column or null if one does not exist. throws: IOException - This will only occur if there is an error getting aconnection to the Database. |
determineSRID | protected int determineSRID(String tableName, String geometryColumnName) throws IOException(Code) | | Provides a hook for subclasses to determine the SRID of a geometry
column.
This allows SRIDs to be determined in a Vendor specific way and to be
cached by the default implementation. To retreive these srids, get the
FeatureTypeInfo object for the table and call
getSRID(geometryColumnName). This will allow storage of SRIDs for
multiple geometry columns in each table.
If no SRID can be found, subclasses should return -1. The default
implementation always returns -1.
Parameters: tableName - The name of the table to get the SRID for. Parameters: geometryColumnName - The name of the geometry column within the table to get SRIDfor. The SRID for the geometry column in the table or -1. throws: IOException - |
executeQuery | protected QueryData executeQuery(FeatureTypeInfo featureTypeInfo, String tableName, String sqlQuery, Transaction transaction, boolean forWrite, Hints hints) throws IOException(Code) | | Executes the SQL Query.
This is private in the expectation that subclasses should not need to
change this behaviour.
Jody with a question here - I have stopped this method from closing
connection shared by a Transaction. It sill seems like we are leaving
connections open by using this method. I have also stopped QueryData from
doing the same thing.
Answer from Sean: Resources for successful queries are closed when close
is called on the AttributeReaders constructed with the QueryData. We
can't close them here since they need to be open to read from the
ResultSet.
Jody AttributeReader question: I looked at the code and Attribute Readers
do not close with respect to Transactions (they need to as we can issue a
Reader against a Transaction. I have changed the JDBCDataStore.close
method to force us to keep track of these things.
SG: I've marked this as final since I don't think it shoudl be overriden,
but Im not sure
Parameters: featureTypeInfo - Parameters: tableName - Parameters: sqlQuery - The SQL query to execute. Parameters: transaction - The Transaction is included here for handling transactionconnections at a later stage. It is not currently used. Parameters: forWrite - Parameters: hints - the Query hints The QueryData object that contains the resources for the query. throws: IOException - throws: DataSourceException - If an error occurs performing the query. |
getAttributeIO | protected AttributeIO getAttributeIO(AttributeType type)(Code) | | Returns the basic AttributeIO that can read and write all of the simple
data types
Parameters: type - |
getAttributeTypes | final protected AttributeType[] getAttributeTypes(String typeName, String[] propertyNames) throws IOException, SchemaException(Code) | | Gets the attribute types from from a given type.
Parameters: typeName - The name of the feature type to get the AttributeTypes for. Parameters: propertyNames - The list of propertyNames to get AttributeTypes for. the array of attribute types from the schema which matchpropertyNames. throws: IOException - If we can't get the schema. throws: SchemaException - if query contains a propertyName that is not a part of thistype's schema. |
getConcurrency | protected int getConcurrency(boolean forWrite)(Code) | | |
getEnvelope | public Envelope getEnvelope(String typeName)(Code) | | Retrieve approx bounds of all Features.
This result is suitable for a quick map display, illustrating the data.
This value is often stored as metadata in databases such as oraclespatial.
null as a generic implementation is not provided. |
getFIDMapperFactory | public FIDMapperFactory getFIDMapperFactory()(Code) | | Returns the FIDMapperFactory used for this data store
|
getFeatureReader | public FeatureReader getFeatureReader(FeatureType requestType, Filter filter, Transaction transaction) throws IOException(Code) | | This is a public entry point to the DataStore.
We have given some though to changing this api to be based on query.
Currently the is is the only way to retype your features to different
name spaces.
(non-Javadoc)
|
getFeatureReader | public FeatureReader getFeatureReader(Query query, Transaction trans) throws IOException(Code) | | The top level method for getting a FeatureReader.
Chris- I've gone with the Query object aswell. It just seems to make more
sense. This is pretty well split up across methods. The hooks for DB
specific AttributeReaders are createResultSetReader and
createGeometryReader.
JG- I have implemented getFeatureReader( FeatureType, Filter,
Transasction) ontop of this method, it will Retype as required
Parameters: query - The Query to get a FeatureReader for. Parameters: trans - The transaction this read operation is being performed in. A FeatureReader that contains features defined by the query. throws: IOException - If an error occurs executing the query. throws: DataSourceException - |
getFeatureWriter | public FeatureWriter getFeatureWriter(String typeName, org.opengis.filter.Filter filter, Transaction transaction) throws IOException(Code) | | Acquire FeatureWriter for modification of contents specifed by filter.
Quick notes: This FeatureWriter is often used to remove contents
specified by the provided filter, or perform summary calculations.
Subclasses are responsible for checking with the lockingManager unless
they are providing their own locking support.
Parameters: typeName - Parameters: filter - Parameters: transaction - throws: IOException - If typeName could not be located throws: NullPointerException - If the provided filter is null throws: DataSourceException - |
getGeometryAttributeIO | abstract protected AttributeIO getGeometryAttributeIO(AttributeType type, QueryData queryData) throws IOException(Code) | | Hook to create the geometry attribute IO for a vendor specific data
source.
Parameters: type - The AttributeType to read. Parameters: queryData - The connection holder The AttributeIO that will read and write the geometry from theresults. throws: IOException - DOCUMENT ME! |
getNameSpace | public URI getNameSpace()(Code) | | Gets the namespace of the data store. TODO: change config over to use URI
The namespace. |
getResultSetType | protected int getResultSetType(boolean forWrite)(Code) | | |
getSqlBuilder | public SQLBuilder getSqlBuilder(String typeName) throws IOException(Code) | | Hook for subclass to return a different sql builder.
Subclasses requiring a ClientTransactionAccessor should override
and instantiate an SQLBuilder with one in the constructor.
Parameters: typeName - The typename for the sql builder. A new sql builder. throws: IOException - if anything goes wrong. |
getSqlNameEscape | public String getSqlNameEscape()(Code) | | Gets the SQL name escape string.
The value of this string is prefixed and appended to table schema names,
table names and column names in an SQL statement to support mixed-case
and non-English names.
the value of the SQL name escape string. |
getSupportedHints | public Set getSupportedHints()(Code) | | |
getTransactionIsolation | public int getTransactionIsolation()(Code) | | Obtain the transaction isolation level for connections.
Connection.TRANSACTION_* value since: 2.2.0 See Also: setTransactionIsolation See Also: This web page |
propertyNames | protected String[] propertyNames(Query query) throws IOException(Code) | | Get propertyNames in a safe manner.
Method will figure out names from the schema for query.getTypeName(), if
query getPropertyNames() is null , or
query.retrieveAllProperties is true .
Parameters: query - throws: IOException - |
requireAutoCommit | protected boolean requireAutoCommit()(Code) | | Return true if transaction is handled on client. Usually this will not have to be overridden.
true if transaction is handled on client. Usually this will not have to be overridden. |
setAutoCommit | protected void setAutoCommit(boolean forWrite, Connection conn) throws SQLException(Code) | | This method should be overridden to do nothing by DataStores where
setting autoCommit causes funky behaviour (ie. anytime autoCommit is
changed, every thing up to that point is committed...this isn't good at
this stage)
Parameters: forWrite - Parameters: conn - throws: SQLException - |
setFIDMapper | public void setFIDMapper(String featureTypeName, FIDMapper fidMapper)(Code) | | Sets the FIDMapper for a specific type name
Parameters: featureTypeName - Parameters: fidMapper - |
setSqlNameEscape | protected void setSqlNameEscape(String sqlNameEscape)(Code) | | Sets the SQL name escape string.
The value of this string is prefixed and appended to table schema names,
table names and column names in an SQL statement to support mixed-case
and non-English names.
This value is typically only set once when the DataStore implementation
class is constructed.
Parameters: sqlNameEscape - the name escape character |
setTransactionIsolation | public void setTransactionIsolation(int value)(Code) | | Sets the transaction isolation level for connections.
Parameters: value - Connection.TRANSACTION_READ_UNCOMMITTED,Connection.TRANSACTION_READ_COMMITTED,Connection.TRANSACTION_REPEATABLE_READ,Connection.SERIALIZABLE, or Connection.TRANSACTION_NONE(for use default/do not set) since: 2.2.0 See Also: This web page |
updateSchema | public void updateSchema(String typeName, FeatureType featureType) throws IOException(Code) | | Used to provide support for changing the DataStore Schema.
Specifically this is intended to address updating the metadata Coordinate
System information.
If we can figure out the Catalog API for metadata we will not have to use
such a heavy handed approach.
Subclasses are free to implement various levels of support:
- None - table modification is not supported
- CS change - ensure that the attribtue types match and only update
metadata but not table structure.
- Allow table change opperations
See Also: org.geotools.data.DataStore.updateSchema(java.lang.Stringorg.geotools.feature.FeatureType) |
|
|