Class JDBCFeatureStore
- All Implemented Interfaces:
FeatureLocking<SimpleFeatureType,,SimpleFeature> FeatureSource<SimpleFeatureType,,SimpleFeature> FeatureStore<SimpleFeatureType,,SimpleFeature> SimpleFeatureLocking,SimpleFeatureSource,SimpleFeatureStore
All read only methods are delegated to JDBCFeatureSource.
- Author:
- Justin Deoliveira, The Open Planning Project
-
Nested Class Summary
Nested classes/interfaces inherited from interface FeatureLocking
FeatureLocking.Response -
Field Summary
FieldsModifier and TypeFieldDescriptionjdbc feature source to delegate to, we do this b/c we can't inherit from both ContentFeatureStore and JDBCFeatureSource at the same timeFields inherited from class ContentFeatureStore
ORIGINAL_FEATURE_KEY, WRITER_ADD, WRITER_COMMIT, WRITER_UPDATEFields inherited from class ContentFeatureSource
entry, hints, lock, query, queryCapabilities, schema, transaction -
Constructor Summary
ConstructorsConstructorDescriptionJDBCFeatureStore(ContentEntry entry, Query query) Creates the new feature store. -
Method Summary
Modifier and TypeMethodDescriptionprotected SimpleFeatureTypeCreates the feature type or schema for the feature source.protected booleancanEvent()We handle events internallyprotected booleanDetermines if the datastore can natively perform a filtering.protected booleanDetermines if the datastore can natively limit the number of features returned in a query.protected booleanDetermines if the datastore can natively skip the firstoffsetnumber of features returned in a query.protected booleanDetermines if the datastore can natively perform "retyping" which includes limiting the number of attributes returned and reordering of those attributesprotected booleanDetermines if the datastore can natively perform sorting.protected booleanDetermines if the store can natively manage transactions.protected ReferencedEnvelopegetBoundsInternal(Query query) Calculates the bounds of a specified query.protected intgetCountInternal(Query query) Calculates the number of features of a specified query.The datastore that this feature source originated from.getEntry()The entry for the feature source.getInfo()A default ResourceInfo with a generic description.getName()Returns the same name than the feature type (ie,getSchema().getName()to honor the simple feature land common practice of calling the same both the Features produces and their typesSimpleFeatureCollection optimized for read-only access.protected FeatureReader<SimpleFeatureType,SimpleFeature> getReaderInternal(Query query) Subclass method for returning a native reader from the datastore.getState()The current state for the feature source.The current transaction the feature source is working against.protected FeatureWriter<SimpleFeatureType,SimpleFeature> getWriterInternal(Query query, int flags) Subclass method for returning a native writer from the datastore.protected booleanhandleVisitor(Query query, FeatureVisitor visitor) Subclass method which allows subclasses to natively handle a visitor.booleanThe flag which will expose columns which compose a tables identifying or primary key, through feature type attributes.voidmodifyFeatures(Name[] names, Object[] values, Filter filter) Modifies/updates the features of the store which match the specified filter.voidremoveFeatures(Filter filter) Removes the features from the store which match the specified filter.voidsetExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns) Sets the flag which will expose columns which compose a tables identifying or primary key, through feature type attributes.voidsetTransaction(Transaction transaction) Sets the current transaction the feature source is working against.Methods inherited from class ContentFeatureStore
addFeatures, addFeatures, getWriter, getWriter, getWriter, getWriter, modifyFeatures, modifyFeatures, modifyFeatures, modifyFeatures, modifyFeatures, setFeaturesMethods inherited from class ContentFeatureSource
accepts, addFeatureListener, addHints, buildQueryCapabilities, canFilter, canLimit, canLock, canOffset, canReproject, canRetype, canSort, doLockInternal, doUnlockInternal, getAbsoluteSchema, getBounds, getBounds, getCount, getFeatures, getFeatures, getFeatures, getReader, getReader, getReader, getSchema, getSupportedHints, getView, getView, isView, joinQuery, lockFeatures, lockFeatures, lockFeatures, processLock, removeFeatureListener, resolvePropertyNames, resolvePropertyNames, setFeatureLock, unLockFeatures, unLockFeatures, unLockFeaturesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FeatureLocking
lockFeatures, lockFeatures, lockFeatures, setFeatureLock, unLockFeatures, unLockFeatures, unLockFeaturesMethods inherited from interface FeatureSource
addFeatureListener, getBounds, getBounds, getCount, getSchema, getSupportedHints, removeFeatureListenerMethods inherited from interface SimpleFeatureStore
getFeatures, getFeatures, getFeatures
-
Field Details
-
delegate
jdbc feature source to delegate to, we do this b/c we can't inherit from both ContentFeatureStore and JDBCFeatureSource at the same time
-
-
Constructor Details
-
JDBCFeatureStore
Creates the new feature store.- Parameters:
entry- The datastore entry.query- The defining query.- Throws:
IOException
-
-
Method Details
-
canEvent
protected boolean canEvent()We handle events internally- Overrides:
canEventin classContentFeatureSource- Returns:
- true if event notification has custom implementation
-
getDataStore
Description copied from class:ContentFeatureSourceThe datastore that this feature source originated from.Subclasses may wish to extend this method in order to type narrow its return type.
- Specified by:
getDataStorein interfaceFeatureSource<SimpleFeatureType,SimpleFeature> - Overrides:
getDataStorein classContentFeatureSource- Returns:
- the data source providing this
FeatureSource
-
getFeatureSource
-
getEntry
Description copied from class:ContentFeatureSourceThe entry for the feature source.- Overrides:
getEntryin classContentFeatureSource
-
getInfo
Description copied from class:ContentFeatureSourceA default ResourceInfo with a generic description.Subclasses should override to provide an explicit ResourceInfo object for their content.
- Specified by:
getInfoin interfaceFeatureSource<SimpleFeatureType,SimpleFeature> - Overrides:
getInfoin classContentFeatureSource- Returns:
- description of features contents
-
getName
Description copied from class:ContentFeatureSourceReturns the same name than the feature type (ie,getSchema().getName()to honor the simple feature land common practice of calling the same both the Features produces and their types- Specified by:
getNamein interfaceFeatureSource<SimpleFeatureType,SimpleFeature> - Overrides:
getNamein classContentFeatureSource- Returns:
- the name of the features accessible through this
FeatureSource - See Also:
-
getQueryCapabilities
Description copied from class:ContentFeatureSourceSimpleFeatureCollection optimized for read-only access.Available via getView( filter ):
- getFeatures().sort( sort )
- getFeatures( filter ).sort( sort )
In particular this method of data access is intended for rendering and other high speed operations; care should be taken to optimize the use of FeatureVisitor.
- Specified by:
getQueryCapabilitiesin interfaceFeatureSource<SimpleFeatureType,SimpleFeature> - Overrides:
getQueryCapabilitiesin classContentFeatureSource- Returns:
- readonly access
-
getState
Description copied from class:ContentFeatureSourceThe current state for the feature source.This value is derived from current transaction of the feature source.
- Overrides:
getStatein classContentFeatureSource
-
getTransaction
Description copied from class:ContentFeatureSourceThe current transaction the feature source is working against.This transaction is used to derive the state for the feature source. A
nullvalue for a transaction represents the auto commit transaction:Transaction.AUTO_COMMIT.- Specified by:
getTransactionin interfaceFeatureStore<SimpleFeatureType,SimpleFeature> - Overrides:
getTransactionin classContentFeatureSource- Returns:
- Transaction in use, or Transaction.AUTO_COMMIT
-
setTransaction
Description copied from class:ContentFeatureSourceSets the current transaction the feature source is working against.transaction may be
null. This signifies that the auto-commit transaction is used:Transaction.AUTO_COMMIT.- Specified by:
setTransactionin interfaceFeatureStore<SimpleFeatureType,SimpleFeature> - Overrides:
setTransactionin classContentFeatureSource- Parameters:
transaction- The new transaction, ornull.
-
getPrimaryKey
-
setExposePrimaryKeyColumns
public void setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns) Sets the flag which will expose columns which compose a tables identifying or primary key, through feature type attributes.Note: setting this flag which affect all feature sources created from or working against the current transaction.
-
isExposePrimaryKeyColumns
public boolean isExposePrimaryKeyColumns()The flag which will expose columns which compose a tables identifying or primary key, through feature type attributes. -
buildFeatureType
Description copied from class:ContentFeatureSourceCreates the feature type or schema for the feature source.Implementations should use
SimpleFeatureTypeBuilderto build the feature type. Also, the builder should be injected with the feature factory which has been set on the DataStore (seeContentDataStore.getFeatureFactory(). Example:SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setFeatureTypeFactory( getDataStore().getFeatureTypeFactory() ); //build the feature type ...
- Specified by:
buildFeatureTypein classContentFeatureSource- Throws:
IOException
-
getCountInternal
Description copied from class:ContentFeatureSourceCalculates the number of features of a specified query. Subclasses must implement this method. If the computation is not fast, it's possible to return -1.- Specified by:
getCountInternalin classContentFeatureSource- Throws:
IOException
-
getBoundsInternal
Description copied from class:ContentFeatureSourceCalculates the bounds of a specified query. Subclasses must implement this method. If the computation is not fast, subclasses can returnnull.- Specified by:
getBoundsInternalin classContentFeatureSource- Throws:
IOException
-
canFilter
Description copied from class:ContentFeatureSourceDetermines if the datastore can natively perform a filtering.If the subclass can handle filtering natively it should override this method to return
true. In this case it must do the filtering or throw an exception. This includes the case of partial native filtering where the datastore can only handle part of the filter natively. In these cases it is up to the subclass to apply a decorator to the reader it returns which will handle any part of the filter can was not applied natively. SeeFilteringFeatureReader.Not overriding this method or returning
falsewill cause the feature reader created by the subclass to be wrapped in a filtering feature reader when the query specifies a filter. SeeFilteringFeatureReader.- Overrides:
canFilterin classContentFeatureSource
-
canSort
Description copied from class:ContentFeatureSourceDetermines if the datastore can natively perform sorting.If the subclass can handle retyping natively it should override this method to return
true. In this case it must do the retyping or throw an exception.Not overriding this method or returning
falsewill cause an exception to be thrown when the query specifies sorting.- Overrides:
canSortin classContentFeatureSource- See Also:
-
canRetype
Description copied from class:ContentFeatureSourceDetermines if the datastore can natively perform "retyping" which includes limiting the number of attributes returned and reordering of those attributesIf the subclass can handle retyping natively it should override this method to return
true. In this case it must do the retyping or throw an exception.Not overriding this method or returning
falsewill cause the feature reader created by the subclass to be wrapped in a retyping feature reader when the query specifies a retype.- Overrides:
canRetypein classContentFeatureSource- See Also:
-
canLimit
Description copied from class:ContentFeatureSourceDetermines if the datastore can natively limit the number of features returned in a query.If the subclass can handle a map feature cap natively then it should override this method to return
true. In this case it must do the cap or throw an exception.Not overriding this method or returning
falsewill case the feature reader created by the subclass to be wrapped in a max feature capping decorator when the query specifies a max feature cap.- Overrides:
canLimitin classContentFeatureSource- See Also:
-
canOffset
Description copied from class:ContentFeatureSourceDetermines if the datastore can natively skip the firstoffsetnumber of features returned in a query.If the subclass can handle a map feature cap natively then it should override this method to return
true. In this case it must do the cap or throw an exception.Not overriding this method or returning
falsewill case the feature reader created by the subclass to be accessed offset times before being returned to the caller.- Overrides:
canOffsetin classContentFeatureSource
-
canTransact
protected boolean canTransact()Description copied from class:ContentFeatureSourceDetermines if the store can natively manage transactions.If a subclass can handle transactions natively it should override this method to return
trueand deal with transactions on its own, including firing feature modifications events.- Overrides:
canTransactin classContentFeatureSource- Returns:
- true if transaction independence has custom implementation
-
getReaderInternal
protected FeatureReader<SimpleFeatureType,SimpleFeature> getReaderInternal(Query query) throws IOException Description copied from class:ContentFeatureSourceSubclass method for returning a native reader from the datastore.It is important to note that if the native reader intends to handle any of the following natively:
- reprojection
- filtering
- max feature limiting
- sorting
- locking
- transactions
true:ContentFeatureSource.canReproject()- handlesQuery.getCoordinateSystemReproject()internally. Example would be PostGIS using Proj to handle reproejction internallyContentFeatureSource.canFilter(Query)- handlesinternally.</li> <li>{@link #canLimit(Query)} - handles {@link Query#getMaxFeatures()} and {@link Query#getStartIndex()} internally.</li> <li>{@link #canSort(Query)} - handles {@link Query#getSortBy()} natively.</li> <li>{@link #canRetype(Query)} - handles {@link Query#getProperties()} natively. Example would be only parsing the properties the user asks for from an XML file</li> <li>{@link #canLock()} - handles read-locks natively</li> <li>{@link #canTransact()} - handles transactions natively</li> </ul> </p>
- Specified by:
getReaderInternalin classContentFeatureSource- Throws:
IOException
-
handleVisitor
Description copied from class:ContentFeatureSourceSubclass method which allows subclasses to natively handle a visitor.Subclasses would override this method and return true in cases where the specific visitor could be handled without iterating over the entire result set of query. An example would be handling visitors that calculate aggregate values.
- Overrides:
handleVisitorin classContentFeatureSource- Parameters:
query- The query being made.visitor- The visitor to- Returns:
- true if the visitor can be handled natively, otherwise false.
- Throws:
IOException
-
getWriterInternal
protected FeatureWriter<SimpleFeatureType,SimpleFeature> getWriterInternal(Query query, int flags) throws IOException Description copied from class:ContentFeatureStoreSubclass method for returning a native writer from the datastore.It is important to note that if the native writer intends to handle any of the following natively:
- reprojection
- filtering
- events
- max feature limiting
- sorting
- locking
true:- Specified by:
getWriterInternalin classContentFeatureStore- Parameters:
query- Queryflags- SeeContentFeatureStore.WRITER_ADDandContentFeatureStore.WRITER_UPDATE- Throws:
IOException
-
modifyFeatures
Description copied from class:ContentFeatureStoreModifies/updates the features of the store which match the specified filter.This method operates by obtaining an updating feature writer based on the specified filter and writing the updated values to it.
The filter must not be
null, in this case this method will throw anIllegalArgumentException.- Specified by:
modifyFeaturesin interfaceFeatureStore<SimpleFeatureType,SimpleFeature> - Overrides:
modifyFeaturesin classContentFeatureStore- Parameters:
names- the attributes to modifyvalues- the new values for the attributesfilter- an OpenGIS filter- Throws:
IOException- if the attribute and object arrays are not equal in length; if the value types do not match the attribute types; if modification is not supported; or if there errors accessing the data source
-
removeFeatures
Description copied from class:ContentFeatureStoreRemoves the features from the store which match the specified filter.This method operates by obtaining an updating feature writer based on the specified filter and removing every feature from it.
The filter must not be
null, in this case this method will throw anIllegalArgumentException.- Specified by:
removeFeaturesin interfaceFeatureStore<SimpleFeatureType,SimpleFeature> - Overrides:
removeFeaturesin classContentFeatureStore- Parameters:
filter- an OpenGIS filter- Throws:
IOException- if an error occurs modifying the data source
-