Class DataStoreWrapper
- Object
-
- DataStoreWrapper
-
- All Implemented Interfaces:
DataAccess<SimpleFeatureType,SimpleFeature>
,DataStore
- Direct Known Subclasses:
OracleDatastoreWrapper
,PostgisDatastoreWrapper
,SQLServerDatastoreWrapper
public abstract class DataStoreWrapper extends Object implements DataStore
A data store wrapper around aDataStore
object.- Author:
- Daniele Romagnoli, GeoSolutions SAS @TODO move that class on gt-transform once ready
-
-
Field Summary
Fields Modifier and Type Field Description protected File
auxiliaryFolder
Auxiliary folder which contains properties file with mapping informationprotected static String
COORDINATE_REFERENCE_SYSTEM
protected DataStore
datastore
The underlying datastoreprotected static String
HIDDEN_FOLDER
protected static Logger
LOGGER
protected static String
MAPPEDNAME
protected Map<Name,FeatureTypeMapper>
mapping
Mapping between typeNames and FeatureTypeMapperprotected static String
NAME
protected static String
SCHEMA
-
Constructor Summary
Constructors Constructor Description DataStoreWrapper(DataStore datastore, String auxFolderPath)
Base constructorDataStoreWrapper(DataStore datastore, String auxFolderPath, String subFolderName)
Base constructor with custom hidden folder
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
createSchema(SimpleFeatureType featureType)
Creates storage for a newfeatureType
.void
dispose()
Disposes of this data store and releases any resource that it is using.FeatureReader<SimpleFeatureType,SimpleFeature>
getFeatureReader(Query query, Transaction transaction)
Gets aFeatureReader
for features selected by the givenQuery
.SimpleFeatureSource
getFeatureSource(String typeName)
Gets aSimpleFeatureSource
for features of the specified type.SimpleFeatureSource
getFeatureSource(Name typeName)
Gets aSimpleFeatureSource
for features of the type specified by a qualified name (namespace plus type name).protected FeatureTypeMapper
getFeatureTypeMapper(Properties props)
Return a specificFeatureTypeMapper
by parsing mapping properties contained within the specifiedProperties
objectprotected abstract FeatureTypeMapper
getFeatureTypeMapper(SimpleFeatureType featureType)
Return a specificFeatureTypeMapper
instance on top of an input featureTypeFeatureWriter<SimpleFeatureType,SimpleFeature>
getFeatureWriter(String typeName, Transaction transaction)
Gets aFeatureWriter
to modify features in thisDataStore
.FeatureWriter<SimpleFeatureType,SimpleFeature>
getFeatureWriter(String typeName, Filter filter, Transaction transaction)
Gets aFeatureWriter
to modify features in thisDataStore
.FeatureWriter<SimpleFeatureType,SimpleFeature>
getFeatureWriterAppend(String typeName, Transaction transaction)
Gets aFeatureWriter
that can add new features to theDataStore
.ServiceInfo
getInfo()
Information about this service.LockingManager
getLockingManager()
Retrieve a per featureID based locking service from thisDataStore
.List<Name>
getNames()
Names of the available Resources.SimpleFeatureType
getSchema(String typeName)
Gets the type information (schema) for the specified feature type.SimpleFeatureType
getSchema(Name name)
Description of the named resource.String[]
getTypeNames()
Gets the names of feature types available in thisDataStore
.void
removeSchema(String typeName)
Used to permanently remove a schema from the underlying storagevoid
removeSchema(Name typeName)
Used to permanently remove a schema from the underlying storageprotected void
storeMapper(FeatureTypeMapper mapper)
Store theFeatureTypeMapper
instanceprotected void
storeProperties(Properties properties, String typeName)
Store the properties on diskprotected SimpleFeatureSource
transformFeatureStore(SimpleFeatureStore source, FeatureTypeMapper mapper)
void
updateSchema(String typeName, SimpleFeatureType featureType)
Applies a new schema to the given feature type.void
updateSchema(Name typeName, SimpleFeatureType featureType)
Used to update a schema in place.
-
-
-
Field Detail
-
HIDDEN_FOLDER
protected static final String HIDDEN_FOLDER
- See Also:
- Constant Field Values
-
NAME
protected static final String NAME
- See Also:
- Constant Field Values
-
MAPPEDNAME
protected static final String MAPPEDNAME
- See Also:
- Constant Field Values
-
SCHEMA
protected static final String SCHEMA
- See Also:
- Constant Field Values
-
COORDINATE_REFERENCE_SYSTEM
protected static final String COORDINATE_REFERENCE_SYSTEM
- See Also:
- Constant Field Values
-
LOGGER
protected static final Logger LOGGER
-
auxiliaryFolder
protected File auxiliaryFolder
Auxiliary folder which contains properties file with mapping information
-
datastore
protected final DataStore datastore
The underlying datastore
-
mapping
protected final Map<Name,FeatureTypeMapper> mapping
Mapping between typeNames and FeatureTypeMapper
-
-
Method Detail
-
getInfo
public ServiceInfo getInfo()
Description copied from interface:DataAccess
Information about this service.This method offers access to a summary of header or metadata information describing the service. Subclasses may return a specific ServiceInfo instance that has additional information (such as FilterCapabilities).
- Specified by:
getInfo
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Returns:
- SeviceInfo
-
createSchema
public void createSchema(SimpleFeatureType featureType) throws IOException
Description copied from interface:DataAccess
Creates storage for a newfeatureType
.The provided
featureType
we be accessable by the typeName provided by featureType.getTypeName().- Specified by:
createSchema
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Parameters:
featureType
- FetureType to add to DataStore- Throws:
IOException
- If featureType cannot be created
-
storeProperties
protected void storeProperties(Properties properties, String typeName)
Store the properties on disk
-
updateSchema
public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException
Description copied from interface:DataAccess
Used to update a schema in place.This functionality is similar to an "alter table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
updateSchema
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Throws:
IOException
- if the operation failed
-
getNames
public List<Name> getNames() throws IOException
Description copied from interface:DataAccess
Names of the available Resources.For additional information please see getInfo( Name ) and getSchema( Name ).
- Specified by:
getNames
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Returns:
- Names of the available contents.
- Throws:
IOException
-
getSchema
public SimpleFeatureType getSchema(Name name) throws IOException
Description copied from interface:DataAccess
Description of the named resource.The FeatureType returned describes the contents being published. For additional metadata please review getInfo( Name ).
- Specified by:
getSchema
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Parameters:
name
- Type name a the resource from getNames()- Returns:
- Description of the FeatureType being made avaialble
- Throws:
IOException
-
getSchema
public SimpleFeatureType getSchema(String typeName) throws IOException
Description copied from interface:DataStore
Gets the type information (schema) for the specified feature type.- Specified by:
getSchema
in interfaceDataStore
- Parameters:
typeName
- the feature type name- Returns:
- the requested feature type
- Throws:
IOException
- iftypeName
is not available
-
dispose
public void dispose()
Description copied from interface:DataAccess
Disposes of this data store and releases any resource that it is using.A
DataStore
cannot be used afterdispose
has been called, neither can any data access object it helped create, such asFeatureReader
,FeatureSource
orFeatureCollection
.This operation can be called more than once without side effects.
There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.
- Specified by:
dispose
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
-
updateSchema
public void updateSchema(String typeName, SimpleFeatureType featureType) throws IOException
Description copied from interface:DataStore
Applies a new schema to the given feature type. This can be used to add or remove properties. The resulting update will be persistent.- Specified by:
updateSchema
in interfaceDataStore
- Parameters:
typeName
- name of the feature type to updatefeatureType
- the new schema to apply- Throws:
IOException
- on error
-
removeSchema
public void removeSchema(Name typeName) throws IOException
Description copied from interface:DataAccess
Used to permanently remove a schema from the underlying storageThis functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
removeSchema
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Throws:
IOException
- if the operation failed
-
removeSchema
public void removeSchema(String typeName) throws IOException
Description copied from interface:DataStore
Used to permanently remove a schema from the underlying storageThis functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
removeSchema
in interfaceDataStore
- Throws:
IOException
- if the operation failed
-
getTypeNames
public String[] getTypeNames() throws IOException
Description copied from interface:DataStore
Gets the names of feature types available in thisDataStore
. Please note that this is not guaranteed to return a list of unique names since the same unqualified name may be present in separate namespaces within theDataStore
.- Specified by:
getTypeNames
in interfaceDataStore
- Returns:
- names of feature types available in this
DataStore
- Throws:
IOException
- if data access errors occur
-
getFeatureSource
public SimpleFeatureSource getFeatureSource(String typeName) throws IOException
Description copied from interface:DataStore
Gets aSimpleFeatureSource
for features of the specified type.SimpleFeatureSource
provides a high-level API for feature operations.The resulting
SimpleFeatureSource
may implment more functionality as in this example:SimpleFeatureSource fsource = dataStore.getFeatureSource("roads"); if (fsource instanceof SimpleFeatureStore) { // we have write access to the feature data SimpleFeatureStore fstore = (SimpleFeatureStore) fs; } else { // System.out.println("We do not have write access to roads"); }
- Specified by:
getFeatureSource
in interfaceDataStore
- Parameters:
typeName
- the feature type- Returns:
- a
SimpleFeatureSource
(or possibly a subclass) providing operations for features of the specified type - Throws:
IOException
- if data access errors occur- See Also:
SimpleFeatureSource
,SimpleFeatureStore
-
getFeatureSource
public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException
Description copied from interface:DataStore
Gets aSimpleFeatureSource
for features of the type specified by a qualified name (namespace plus type name).- Specified by:
getFeatureSource
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Specified by:
getFeatureSource
in interfaceDataStore
- Parameters:
typeName
- the qualified name of the feature type- Returns:
- a
SimpleFeatureSource
(or possibly a subclass) providing operations for features of the specified type - Throws:
IOException
- if data access errors occur- See Also:
DataStore.getFeatureSource(String)
,SimpleFeatureSource
,SimpleFeatureStore
-
transformFeatureStore
protected SimpleFeatureSource transformFeatureStore(SimpleFeatureStore source, FeatureTypeMapper mapper) throws IOException
- Throws:
IOException
-
getFeatureReader
public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction) throws IOException
Description copied from interface:DataStore
Gets aFeatureReader
for features selected by the givenQuery
.FeatureReader
provies an iterator-style API to feature data.The
Query
provides the schema for the form of the returned features as well as aFilter
to constrain the features available via the reader.The
Transaction
can be used to externalize the state of theDataStore
. Examples of this include aJDBCDataStore
sharing a connection for use across severalFeatureReader
requests; and aShapefileDataStore
redirecting requests to an alternate file during the course of aTransaction
.- Specified by:
getFeatureReader
in interfaceDataStore
- Parameters:
query
- a query providing the schema and constraints for features that the reader will returntransaction
- a transaction that this reader will operate against- Returns:
- an instance of
FeatureReader
- Throws:
IOException
- if data access errors occur
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction transaction) throws IOException
Description copied from interface:DataStore
Gets aFeatureWriter
to modify features in thisDataStore
.FeatureWriter
provides an iterator style API to features.The returned writer does not allow features to be added.
- Specified by:
getFeatureWriter
in interfaceDataStore
- Parameters:
typeName
- the type name for features that will be accessiblefilter
- defines additional constraints on the features that will be accessibletransaction
- the transaction that the returned writer operates against- Returns:
- an instance of
FeatureWriter
- Throws:
IOException
- if data access errors occur- See Also:
DataStore.getFeatureWriterAppend(String, Transaction)
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction transaction) throws IOException
Description copied from interface:DataStore
Gets aFeatureWriter
to modify features in thisDataStore
.FeatureWriter
provides an iterator style API to features.The returned writer does not allow features to be added.
- Specified by:
getFeatureWriter
in interfaceDataStore
- Parameters:
typeName
- the type name for features that will be accessibletransaction
- the transaction that the returned writer operates against- Returns:
- an instance of
FeatureWriter
- Throws:
IOException
- if data access errors occur- See Also:
DataStore.getFeatureWriterAppend(String, Transaction)
-
getFeatureWriterAppend
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction transaction) throws IOException
Description copied from interface:DataStore
Gets aFeatureWriter
that can add new features to theDataStore
.The
FeatureWriter
will returnfalse
when itshasNext()
method is called, butnext()
can be used to acquire new features.- Specified by:
getFeatureWriterAppend
in interfaceDataStore
- Parameters:
typeName
- name of the feature type for which features will be addedtransaction
- the transaction to operate against- Returns:
- an instance of
FeatureWriter
that can only be used to append new features - Throws:
IOException
- if data access errors occur
-
getLockingManager
public LockingManager getLockingManager()
Description copied from interface:DataStore
Retrieve a per featureID based locking service from thisDataStore
.- Specified by:
getLockingManager
in interfaceDataStore
- Returns:
- an instance of
LockingManager
; ornull
if locking is handled by theDataStore
in a different fashion
-
storeMapper
protected void storeMapper(FeatureTypeMapper mapper)
Store theFeatureTypeMapper
instance
-
getFeatureTypeMapper
protected FeatureTypeMapper getFeatureTypeMapper(Properties props) throws Exception
Return a specificFeatureTypeMapper
by parsing mapping properties contained within the specifiedProperties
object- Throws:
Exception
-
getFeatureTypeMapper
protected abstract FeatureTypeMapper getFeatureTypeMapper(SimpleFeatureType featureType) throws Exception
Return a specificFeatureTypeMapper
instance on top of an input featureType- Throws:
Exception
-
-