org.geotools.data.jdbc
Class JDBCFeatureStore

java.lang.Object
  extended by org.geotools.data.jdbc.JDBCFeatureSource
      extended by org.geotools.data.jdbc.JDBCFeatureStore
All Implemented Interfaces:
FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>, FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Direct Known Subclasses:
JDBCFeatureLocking, OracleFeatureStore, PostgisFeatureStore

Deprecated. scheduled for removal in 2.7, use classes in org.geotools.jdbc

public class JDBCFeatureStore
extends JDBCFeatureSource
implements FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>

This is a starting point for providing your own FeatureStore implementation.

Author:
Jody Garnett, Refractions Research

Nested Class Summary
 
Nested classes/interfaces inherited from class org.geotools.data.jdbc.JDBCFeatureSource
JDBCFeatureSource.JDBCQueryCapabilities
 
Field Summary
protected  Transaction transaction
          Deprecated. Current Transaction this FeatureSource is opperating against
 
Fields inherited from class org.geotools.data.jdbc.JDBCFeatureSource
queryCapabilities
 
Constructor Summary
JDBCFeatureStore(JDBC1DataStore jdbcDataStore, org.opengis.feature.simple.SimpleFeatureType featureType)
          Deprecated.  
 
Method Summary
 java.util.List<org.opengis.filter.identity.FeatureId> addFeatures(FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection)
          Deprecated. Adds all features from the passed feature collection to the datasource.
 java.util.Set addFeatures(FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader)
          Deprecated. Add Features from reader to this FeatureStore.
protected  void assertFids(java.util.Set fids)
          Deprecated.  
protected  void assertFilter(org.opengis.filter.Filter filter)
          Deprecated.  
protected  java.util.Set fids(org.opengis.filter.Filter filter)
          Deprecated.  
protected  InProcessLockingManager getInProcessLockingManager()
          Deprecated. Used by subclasses to access locking manager.
 Transaction getTransaction()
          Deprecated. Retrieve the Transaction this FeatureSource is opperating against.
protected  void modifyFeatures(org.opengis.feature.type.AttributeDescriptor[] type, java.lang.Object[] value, FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> writer)
          Deprecated.  
 void modifyFeatures(org.opengis.feature.type.AttributeDescriptor[] type, java.lang.Object[] value, org.opengis.filter.Filter filter)
          Deprecated. Modifies features matching filter.
 void modifyFeatures(org.opengis.feature.type.AttributeDescriptor type, java.lang.Object value, org.opengis.filter.Filter filter)
          Deprecated. Modifies features matching filter.
 void removeFeatures(org.opengis.filter.Filter filter)
          Deprecated. Removes features indicated by provided filter.
 void setFeatures(FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader)
          Deprecated. Replace with contents of reader.
 void setTransaction(Transaction transaction)
          Deprecated. Provides a transaction for commit/rollback control of this FeatureStore.
 
Methods inherited from class org.geotools.data.jdbc.JDBCFeatureSource
addFeatureListener, close, close, close, count, getBounds, getBounds, getConnection, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getJDBCDataStore, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.data.FeatureSource
addFeatureListener, getBounds, getBounds, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 

Field Detail

transaction

protected Transaction transaction
Deprecated. 
Current Transaction this FeatureSource is opperating against

Constructor Detail

JDBCFeatureStore

public JDBCFeatureStore(JDBC1DataStore jdbcDataStore,
                        org.opengis.feature.simple.SimpleFeatureType featureType)
Deprecated. 
Method Detail

getTransaction

public Transaction getTransaction()
Deprecated. 
Description copied from class: JDBCFeatureSource
Retrieve the Transaction this FeatureSource is opperating against.

For a plain JDBCFeatureSource that cannot modify this will always be Transaction.AUTO_COMMIT.

Specified by:
getTransaction in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Overrides:
getTransaction in class JDBCFeatureSource
Returns:
DOCUMENT ME!

getInProcessLockingManager

protected InProcessLockingManager getInProcessLockingManager()
Deprecated. 
Used by subclasses to access locking manager.

All our implementations here are rely on FeatureWriter to check the locks.

When making your own SQL opperations, have a look at assertFids( Set fids ), and assertFids( Filter ). You may use these to check against the lockingManager if one is used.

If the lockingManager is not used, ie is null, it assumed that you are making use of native database locks. Or doing your own thing.

That is the assertFids functions only when lockingManager is non null.

Returns:
LockingManager

fids

protected java.util.Set fids(org.opengis.filter.Filter filter)
                      throws java.util.NoSuchElementException,
                             java.io.IOException,
                             IllegalAttributeException
Deprecated. 
Throws:
java.util.NoSuchElementException
java.io.IOException
IllegalAttributeException

assertFilter

protected void assertFilter(org.opengis.filter.Filter filter)
                     throws java.io.IOException
Deprecated. 
Throws:
java.io.IOException

assertFids

protected void assertFids(java.util.Set fids)
                   throws FeatureLockException
Deprecated. 
Throws:
FeatureLockException

modifyFeatures

public void modifyFeatures(org.opengis.feature.type.AttributeDescriptor type,
                           java.lang.Object value,
                           org.opengis.filter.Filter filter)
                    throws java.io.IOException
Deprecated. 
Modifies features matching filter.

Equivelent to:


 modifyFeatures( new AttributeDescriptor[]{ type, }, new Object[]{ value, }, filter );
 
 

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
modifyFeatures in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
type - Attribute to modify
value - Modification being made to type
filter - Identifies features to modify
Throws:
java.io.IOException

modifyFeatures

public void modifyFeatures(org.opengis.feature.type.AttributeDescriptor[] type,
                           java.lang.Object[] value,
                           org.opengis.filter.Filter filter)
                    throws java.io.IOException
Deprecated. 
Modifies features matching filter.

Equivelent to:


 FeatureWriter writer = dataStore.getFeatureWriter( typeName, filter, transaction );
 Feature feature;
 while( writer.hasNext() ){
    feature = writer.next();
    feature.setAttribute( type[0].getName(), value[0] );
    feature.setAttribute( type[1].getName(), value[1] );
    ...
    feature.setAttribute( type[N].getName(), value[N] ); 
    writer.write();
 }
 writer.close();
 
 

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
modifyFeatures in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
type - Attributes to modify
value - Modifications being made to type
filter - Identifies features to modify
Throws:
java.io.IOException

modifyFeatures

protected void modifyFeatures(org.opengis.feature.type.AttributeDescriptor[] type,
                              java.lang.Object[] value,
                              FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> writer)
                       throws DataSourceException,
                              java.io.IOException
Deprecated. 
Throws:
DataSourceException
java.io.IOException

addFeatures

public java.util.Set addFeatures(FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader)
                          throws java.io.IOException
Deprecated. 
Add Features from reader to this FeatureStore.

Equivelent to:


 Set set = new HashSet();
 FeatureWriter writer = dataStore.getFeatureWriter( typeName, true, transaction );
 Featrue feature, newFeature;
 while( reader.hasNext() ){
    feature = reader.next();
    newFeature = writer.next();
    newFeature.setAttributes( feature.getAttribtues( null ) );
    writer.write();
    set.add( newfeature.getID() );
 }
 reader.close();
 writer.close();
 
 return set;
 
 

(If you don't have a FeatureReader handy DataUtilities.reader() may be able to help out)

Subclasses may override this method to perform the appropriate optimization for this result.

Parameters:
reader -
Returns:
The Set of FeatureIDs added
Throws:
java.io.IOException
See Also:
org.geotools.data.FeatureStore#addFeatures(org.geotools.data.FeatureReader)

addFeatures

public java.util.List<org.opengis.filter.identity.FeatureId> addFeatures(FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection)
                                                                  throws java.io.IOException
Deprecated. 
Description copied from interface: FeatureStore
Adds all features from the passed feature collection to the datasource.

A list of FeatureIds is returned; one for each Feature in the order created. Please note that these FeatureIds may not be assigned until after a commit has been performed.

Specified by:
addFeatures in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
collection - The collection of features to add.
Returns:
the FeatureIds of the newly added features.
Throws:
java.io.IOException - if anything goes wrong.

removeFeatures

public void removeFeatures(org.opengis.filter.Filter filter)
                    throws java.io.IOException
Deprecated. 
Removes features indicated by provided filter.

Equivelent to:


 FeatureWriter writer = dataStore.getFeatureWriter( typeName, filter, transaction );
 Feature feature;
 while( writer.hasNext() ){
    feature = writer.next();
    writer.remove();
 }
 writer.close();
 
 

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
removeFeatures in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
filter - Identifies features to remove
Throws:
java.io.IOException

setFeatures

public void setFeatures(FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader)
                 throws java.io.IOException
Deprecated. 
Replace with contents of reader.

Equivelent to:


 FeatureWriter writer = dataStore.getFeatureWriter( typeName, false, transaction );
 Feature feature, newFeature;
 while( writer.hasNext() ){
    feature = writer.next();
    writer.remove();
 }
 while( reader.hasNext() ){
    newFeature = reader.next();
    feature = writer.next();
    newFeature.setAttributes( feature.getAttributes( null ) );
    writer.write();
 }
 reader.close();
 writer.close();
 
 

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
setFeatures in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
reader - Contents to replace with
Throws:
java.io.IOException

setTransaction

public void setTransaction(Transaction transaction)
Deprecated. 
Description copied from interface: FeatureStore
Provides a transaction for commit/rollback control of this FeatureStore.

This method operates as a replacement for setAutoCommitMode. When a transaction is provided you are no longer automatically committing.

In order to return to AutoCommit mode supply the Transaction.AUTO_COMMIT to this method. Since this represents a return to AutoCommit mode the previous Transaction will be commited.

Specified by:
setTransaction in interface FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
transaction - DOCUMENT ME!


Copyright © 1996-2010 Geotools. All Rights Reserved.