org.geotools.arcsde.data
Class ArcSDEDataStore

Object
  extended by ArcSDEDataStore
All Implemented Interfaces:
DataAccess<SimpleFeatureType,SimpleFeature>, DataStore

public class ArcSDEDataStore
extends Object
implements DataStore

DataStore implementation to work upon an ArcSDE spatial database gateway.

Takes ownership of the provided ISessionPool so make sure to call dispose() in order to release resources (ArcSDE connections).

Author:
Gabriel Roldan (TOPP)
Module:

Constructor Summary
ArcSDEDataStore(ISessionPool connPool)
          Creates a new ArcSDE DataStore working over the given connection pool
ArcSDEDataStore(ISessionPool connPool, String namespaceUri, String versionName, boolean allowNonSpatialTables)
          Creates a new ArcSDE DataStore working over the given connection pool
 
Method Summary
 void createSchema(SimpleFeatureType featureType)
          Creates a new ArcSDE FeatureClass if featureType has at least one geometry attribute, or an ObjectClass (aka, non spatial registered table) if this data store instance allows non spatial tables and there's no geometry attribute in featureType.
 void createSchema(SimpleFeatureType featureType, Map<String,String> hints)
          Creates a given FeatureType on the ArcSDE instance this DataStore is running over.
 void dispose()
          Disposes this ArcSDEDataStore, which means disposing its session pool and hence closing all the SeConnection objects held.
protected  void finalize()
           
 FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction)
          Returns an ArcSDEFeatureReader Preconditions: query !
 FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction, SimpleFeatureType featureType)
           
 FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(Name typeName)
          Delegates to getFeatureSource(String) with name.getLocalPart()
 FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
          Access a FeatureSource for typeName providing a high-level API.
 ArcSdeFeatureWriter getFeatureWriter(String typeName, Filter filter, Transaction transaction)
          Access FeatureWriter for modification of existing DataStore contents.
 ArcSdeFeatureWriter getFeatureWriter(String typeName, Transaction transaction)
          Delegates to getFeatureWriter(typeName, Filter.INCLUDE, transaction)
 ArcSdeFeatureWriter getFeatureWriterAppend(String typeName, Transaction transaction)
          Delegates to getFeatureWriter(typeName, Filter.EXCLUDE, transaction)
 ServiceInfo getInfo()
          Information about this service.
 LockingManager getLockingManager()
          Retrieve a per featureID based locking service from this DataStore.
 List<Name> getNames()
          Returns the same list of names than getTypeNames() meaning the returned Names have no namespace set.
 SimpleFeatureType getQueryType(Query query)
           
 SimpleFeatureType getSchema(Name name)
          Delegates to getSchema(String) with name.getLocalPart()
 SimpleFeatureType getSchema(String typeName)
          Obtains the schema for the given featuretype name.
 ISession getSession(Transaction transaction)
          Retrieve the connection for the provided transaction.
 String[] getTypeNames()
          List of type names; should be a list of all feature classes.
 FeatureSource<SimpleFeatureType,SimpleFeature> getView(Query query)
          Access a FeatureSource for Query providing a high-level API.
 void updateSchema(Name typeName, SimpleFeatureType featureType)
          Delegates to updateSchema(String, SimpleFeatureType) with name.getLocalPart()
 void updateSchema(String typeName, SimpleFeatureType featureType)
          This operation is not supported at this version of the GeoTools ArcSDE plugin.
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArcSDEDataStore

public ArcSDEDataStore(ISessionPool connPool)
                throws IOException
Creates a new ArcSDE DataStore working over the given connection pool

Parameters:
connPool - pool of Session this datastore works upon.
Throws:
IOException

ArcSDEDataStore

public ArcSDEDataStore(ISessionPool connPool,
                       String namespaceUri,
                       String versionName,
                       boolean allowNonSpatialTables)
                throws IOException
Creates a new ArcSDE DataStore working over the given connection pool

Parameters:
connPool - pool of Session this datastore works upon.
namespaceUri - namespace URI for the SimpleFeatureTypes, AttributeTypes, and AttributeDescriptors created by this datastore. May be null.
versionName - the name of the ArcSDE version to work upon, or null for the DEFAULT version
allowNonSpatialTables - whether ArcSDE registered, non-spatial tables are to be published
Throws:
IOException
Method Detail

getSession

public ISession getSession(Transaction transaction)
                    throws IOException
Retrieve the connection for the provided transaction.

The connection is held open until while the transaction is underway. A a Transaction.State is registered for this SessionPool in order to hold the session.

Parameters:
transaction -
Returns:
the session associated with the transaction
Throws:
IOException

createSchema

public void createSchema(SimpleFeatureType featureType)
                  throws IOException
Creates a new ArcSDE FeatureClass if featureType has at least one geometry attribute, or an ObjectClass (aka, non spatial registered table) if this data store instance allows non spatial tables and there's no geometry attribute in featureType.

The new arcsde table created will have an SDE managed column to be used as primary key.

Specified by:
createSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
Parameters:
featureType - FetureType to add to DataStore
Throws:
IOException - If featureType cannot be created
See Also:
DataStore#createSchema(SimpleFeatureType), createSchema(SimpleFeatureType, Map)

getSchema

public SimpleFeatureType getSchema(String typeName)
                            throws IOException
Obtains the schema for the given featuretype name.

Specified by:
getSchema in interface DataStore
Parameters:
typeName - typeName of requested FeatureType
Returns:
FeatureType for the provided typeName
Throws:
IOException - If typeName cannot be found
See Also:
DataStore.getSchema(String)

getTypeNames

public String[] getTypeNames()
                      throws IOException
List of type names; should be a list of all feature classes.

Specified by:
getTypeNames in interface DataStore
Returns:
the list of full qualified feature class names on the ArcSDE database this DataStore works on. An ArcSDE full qualified class name is composed of three dot separated strings: "DATABASE.USER.CLASSNAME", wich is usefull enough to use it as namespace
Throws:
RuntimeException - if an exception occurs while retrieving the list of registeres feature classes on the backend, or while obtaining the full qualified name of one of them
IOException

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 interface DataAccess<SimpleFeatureType,SimpleFeature>
Returns:
SeviceInfo

dispose

public void dispose()
Disposes this ArcSDEDataStore, which means disposing its session pool and hence closing all the SeConnection objects held.

Specified by:
dispose in interface DataAccess<SimpleFeatureType,SimpleFeature>
See Also:
DataAccess.dispose()

finalize

protected void finalize()
Overrides:
finalize in class Object

getFeatureReader

public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query,
                                                                       Transaction transaction)
                                                                throws IOException
Returns an ArcSDEFeatureReader

Preconditions:

Specified by:
getFeatureReader in interface DataStore
Parameters:
query - Requested form of the returned Features and the filter used to constraints the results
transaction - Transaction this query operates against
Returns:
ArcSDEFeatureReader aware of the transaction state
Throws:
IOException
See Also:
DataStore.getFeatureReader(Query, Transaction)

getFeatureReader

public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query,
                                                                       Transaction transaction,
                                                                       SimpleFeatureType featureType)
                                                                throws IOException
Throws:
IOException

getQueryType

public SimpleFeatureType getQueryType(Query query)
                               throws IOException
Throws:
IOException

getFeatureSource

public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
                                                                throws IOException
Description copied from interface: DataStore
Access a FeatureSource for typeName providing a high-level API.

The resulting FeatureSource may implment more functionality:



 FeatureSource fsource = dataStore.getFeatureSource( "roads" );
 FeatureStore fstore = null;
 if( fsource instanceof FeatureLocking ){
     fstore = (FeatureStore) fs;
 }
 else {
     System.out.println("We do not have write access to roads");
 }
 
 

Specified by:
getFeatureSource in interface DataStore
Returns:
FeatureSource or FeatureStore depending on if the user has write permissions over typeName
Throws:
IOException
See Also:
DataStore.getFeatureSource(String)

getFeatureWriter

public ArcSdeFeatureWriter getFeatureWriter(String typeName,
                                            Transaction transaction)
                                     throws IOException
Delegates to getFeatureWriter(typeName, Filter.INCLUDE, transaction)

Specified by:
getFeatureWriter in interface DataStore
Parameters:
typeName - Indicates featureType to be modified
transaction - Transaction to operates against
Returns:
FeatureReader Allows Sequential Processing of featureType
Throws:
IOException
See Also:
DataStore.getFeatureWriter(String, Transaction)

getFeatureWriter

public ArcSdeFeatureWriter getFeatureWriter(String typeName,
                                            Filter filter,
                                            Transaction transaction)
                                     throws IOException
Description copied from interface: DataStore
Access FeatureWriter for modification of existing DataStore contents.

To limit FeatureWriter to the FeatureTypes defined by this DataStore, typeName is used to indicate FeatureType. The resulting feature writer will allow modifications against the same FeatureType provided by getSchema( typeName )

The FeatureWriter will provide access to the existing contents of the FeatureType referenced by typeName. The provided filter will be used to skip over Features as required.

Notes For Implementing DataStore

The returned FeatureWriter does not support the addition of new Features to FeatureType (it would need to police your modifications to agree with filer). As such it will return false for getNext() when it reaches the end of the Query and NoSuchElementException when next() is called.

Helper classes for implementing a FeatureWriter (in order):

  • InProcessLockingManager.checkedWriter( writer ) - provides a check against locks before allowing modification
  • FilteringFeatureWriter - filtering support for FeatureWriter (does not allow new content)
  • DiffFeatureWriter - In-Process Transaction Support (see TransactionStateDiff)
  • EmptyFeatureWriter - provides no content for Filter.EXCLUDE optimizations
  • Specified by:
    getFeatureWriter in interface DataStore
    Parameters:
    typeName - Indicates featureType to be modified
    filter - constraints used to limit the modification
    transaction - Transaction this query operates against
    Returns:
    FeatureWriter Allows Sequential Modification of featureType
    Throws:
    IOException
    See Also:
    DataStore.getFeatureWriter(String, Filter, Transaction)

    getFeatureWriterAppend

    public ArcSdeFeatureWriter getFeatureWriterAppend(String typeName,
                                                      Transaction transaction)
                                               throws IOException
    Delegates to getFeatureWriter(typeName, Filter.EXCLUDE, transaction)

    Specified by:
    getFeatureWriterAppend in interface DataStore
    Parameters:
    typeName - Indicates featureType to be modified
    transaction - Transaction to operates against
    Returns:
    FeatureWriter that may only be used to append new content
    Throws:
    IOException
    See Also:
    DataStore.getFeatureWriterAppend(String, Transaction)

    getLockingManager

    public LockingManager getLockingManager()
    Description copied from interface: DataStore
    Retrieve a per featureID based locking service from this DataStore.

    It is common to return an instanceof InProcessLockingManager for DataStores that do not provide native locking.

    AbstractFeatureLocking makes use of this service to provide locking support. You are not limitied by this implementation and may simply return null for this value.

    Specified by:
    getLockingManager in interface DataStore
    Returns:
    null, no locking yet
    See Also:
    DataStore.getLockingManager()

    getView

    public FeatureSource<SimpleFeatureType,SimpleFeature> getView(Query query)
                                                           throws IOException,
                                                                  SchemaException
    Description copied from interface: DataStore
    Access a FeatureSource for Query providing a high-level API.

    The provided Query does not need to completely cover the existing schema for Query.getTypeName(). The result will mostly likely only be a FeatureSource and probably wont' allow write access by the FeatureStore method.

    By using Query we allow support for reprojection, in addition to overriding the CoordinateSystem used by the native FeatureType.

    We may wish to limit this method to only support Queries using Filter.EXCLUDE.

    Update - GeoServer has an elegatent implementation of this functionality that we could steal. GeoServerFeatureSource, GeoServerFeatureStore and GeoServerFeatureLocking serve as a working prototype.

    Specified by:
    getView in interface DataStore
    Parameters:
    query - Query.getTypeName() locates FeatureType being viewed
    Returns:
    FeatureSource providing operations for featureType
    Throws:
    IOException - If FeatureSource is not available
    SchemaException - If fetureType is not covered by existing schema
    See Also:
    DataStore.getView(Query)

    updateSchema

    public void updateSchema(String typeName,
                             SimpleFeatureType featureType)
                      throws IOException
    This operation is not supported at this version of the GeoTools ArcSDE plugin.

    Specified by:
    updateSchema in interface DataStore
    Throws:
    IOException
    See Also:
    DataStore.updateSchema(String, SimpleFeatureType)

    getFeatureSource

    public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(Name typeName)
                                                                    throws IOException
    Delegates to getFeatureSource(String) with name.getLocalPart()

    Specified by:
    getFeatureSource in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Returns:
    Access to the named resource being made available
    Throws:
    IOException
    Since:
    2.5
    See Also:
    DataAccess.getFeatureSource(Name)

    getNames

    public List<Name> getNames()
                        throws IOException
    Returns the same list of names than getTypeNames() meaning the returned Names have no namespace set.

    Specified by:
    getNames in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Returns:
    Names of the available contents.
    Throws:
    IOException
    Since:
    2.5
    See Also:
    DataAccess.getNames()

    getSchema

    public SimpleFeatureType getSchema(Name name)
                                throws IOException
    Delegates to getSchema(String) with name.getLocalPart()

    Specified by:
    getSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Parameters:
    name - Type name a the resource from getNames()
    Returns:
    Description of the FeatureType being made avaialble
    Throws:
    IOException
    Since:
    2.5
    See Also:
    DataAccess.getSchema(Name)

    updateSchema

    public void updateSchema(Name typeName,
                             SimpleFeatureType featureType)
                      throws IOException
    Delegates to updateSchema(String, SimpleFeatureType) with name.getLocalPart()

    Specified by:
    updateSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Throws:
    IOException - if the operation failed
    Since:
    2.5
    See Also:
    DataAccess.getFeatureSource(Name)

    createSchema

    public void createSchema(SimpleFeatureType featureType,
                             Map<String,String> hints)
                      throws IOException,
                             IllegalArgumentException
    Creates a given FeatureType on the ArcSDE instance this DataStore is running over.

    This deviation from the DataStore#createSchema(SimpleFeatureType) API is to allow the specification of ArcSDE specific hints for the "Feature Class" to create:

    Parameters:
    featureType -
    hints -
    Throws:
    IOException
    IllegalArgumentException


    Copyright © 1996-2010 Geotools. All Rights Reserved.