org.geotools.arcsde.data
Class ArcSDEAdapter

java.lang.Object
  extended by org.geotools.arcsde.data.ArcSDEAdapter

public class ArcSDEAdapter
extends java.lang.Object

Utility class to deal with SDE specifics such as creating SeQuery objects from geotool's Query's, mapping SDE types to Java ones and JTS Geometries, etc.

Version:
$Id: ArcSDEAdapter.java 33585 2009-07-17 23:39:49Z groldan $
Author:
Gabriel Roldan

Constructor Summary
ArcSDEAdapter()
           
 
Method Summary
static org.geotools.arcsde.data.FeatureTypeInfo createInprocessViewSchema(ISession session, java.lang.String typeName, java.lang.String namespace, net.sf.jsqlparser.statement.select.PlainSelect qualifiedSelect, SeQueryInfo queryInfo)
          Creates a schema for the "SQL SELECT" like view definition
static void createSchema(org.opengis.feature.simple.SimpleFeatureType featureType, java.util.Map hints, ISession session)
          Creates the given featuretype in the underlying ArcSDE database.
static SeColumnDefinition createSeColumnDefinition(org.opengis.feature.type.AttributeDescriptor type)
          Creates the column definition as used by the ArcSDE Java API, for the given AttributeType.
static org.geotools.arcsde.data.FeatureTypeInfo fetchSchema(java.lang.String typeName, java.lang.String namespace, ISession session)
          Fetches the schema of a given ArcSDE featureclass and creates its corresponding Geotools FeatureType
static java.lang.Class getGeometryTypeFromLayerMask(int seShapeType)
          Returns the mapping JTS geometry type for the ArcSDE Shape type given by the bitmask seShapeType
static java.lang.Class<? extends com.vividsolutions.jts.geom.Geometry> getGeometryTypeFromSeShape(SeShape shape)
          Returns the most appropriate Geometry class that matches the shape's type.
static java.lang.Class<?> getJavaBinding(java.lang.Integer sdeType)
          Returns the Java class binding for a given SDE column type.
static long getNumericFid(org.opengis.filter.identity.Identifier id)
          Returns the numeric identifier of a FeatureId, given by the full qualified name of the featureclass prepended to the ArcSDE feature id.
static long getNumericFid(java.lang.String fid)
          Returns the numeric identifier of a FeatureId, given by the full qualified name of the featureclass prepended to the ArcSDE feature id.
static long[] getNumericFids(java.util.Set identifiers)
          DOCUMENT ME!
static int guessShapeTypes(org.opengis.feature.type.GeometryDescriptor attribute)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArcSDEAdapter

public ArcSDEAdapter()
Method Detail

guessShapeTypes

public static int guessShapeTypes(org.opengis.feature.type.GeometryDescriptor attribute)
DOCUMENT ME!

Parameters:
attribute - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.NullPointerException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

createSeColumnDefinition

public static SeColumnDefinition createSeColumnDefinition(org.opengis.feature.type.AttributeDescriptor type)
                                                   throws SeException
Creates the column definition as used by the ArcSDE Java API, for the given AttributeType.

Parameters:
type - the source attribute definition.
Returns:
an SeColumnDefinition object matching the properties of the source AttributeType.
Throws:
SeException - if the SeColumnDefinition constructor throws it due to some invalid parameter

fetchSchema

public static org.geotools.arcsde.data.FeatureTypeInfo fetchSchema(java.lang.String typeName,
                                                                   java.lang.String namespace,
                                                                   ISession session)
                                                            throws java.io.IOException
Fetches the schema of a given ArcSDE featureclass and creates its corresponding Geotools FeatureType

Returns:
the feature type info representing the ArcSDE feature class given by the layer and table.
Throws:
java.io.IOException - if an exception is caught accessing the sde feature class metadata.

createInprocessViewSchema

public static org.geotools.arcsde.data.FeatureTypeInfo createInprocessViewSchema(ISession session,
                                                                                 java.lang.String typeName,
                                                                                 java.lang.String namespace,
                                                                                 net.sf.jsqlparser.statement.select.PlainSelect qualifiedSelect,
                                                                                 SeQueryInfo queryInfo)
                                                                          throws java.io.IOException
Creates a schema for the "SQL SELECT" like view definition

Throws:
java.io.IOException

getJavaBinding

public static java.lang.Class<?> getJavaBinding(java.lang.Integer sdeType)
Returns the Java class binding for a given SDE column type.

Mappings are:

Currently there're no bindings defined for:

To obtain the JTS Geometry class binding for an sde column of type SeColumnDefinition.TYPE_SHAPE use getGeometryTypeFromLayerMask(int).

Parameters:
sdeType -
Returns:
the java binding for the given sde data type or null if its not supported

getGeometryTypeFromLayerMask

public static java.lang.Class getGeometryTypeFromLayerMask(int seShapeType)
Returns the mapping JTS geometry type for the ArcSDE Shape type given by the bitmask seShapeType

This bitmask is composed of a combination of the following shape types, as defined in the ArcSDE Java API:

 SE_NIL_TYPE_MASK = 1;
 SE_POINT_TYPE_MASK = 2;
 SE_LINE_TYPE_MASK = 4;
 SE_AREA_TYPE_MASK = 16;
 SE_MULTIPART_TYPE_MASK = 262144;
 
(Note that the type SE_SIMPLE_LINE_TYPE_MASK is not used)

Parameters:
seShapeType - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

getGeometryTypeFromSeShape

public static java.lang.Class<? extends com.vividsolutions.jts.geom.Geometry> getGeometryTypeFromSeShape(SeShape shape)
                                                                                                  throws SeException
Returns the most appropriate Geometry class that matches the shape's type.

Parameters:
shape - SeShape instance for which to infer the matching geometry class, can't be null
Returns:
the Geometry subclass corresponding to the shape type
Throws:
SeException - propagated if thrown by SeShape.getType()
java.lang.IllegalArgumentException - if none of the JTS geometry classes can be matched to the shape type (shouldnt happen as for the types defined in the esri arcsde java api 9.0)

getNumericFid

public static long getNumericFid(org.opengis.filter.identity.Identifier id)
                          throws java.lang.IllegalArgumentException
Returns the numeric identifier of a FeatureId, given by the full qualified name of the featureclass prepended to the ArcSDE feature id. ej: SDE.SDE.SOME_LAYER.1

Parameters:
id - a geotools FeatureID
Returns:
an ArcSDE feature ID
Throws:
java.lang.IllegalArgumentException - If the given string is not properly formatted [anystring].[long value]

getNumericFid

public static long getNumericFid(java.lang.String fid)
                          throws java.lang.IllegalArgumentException
Returns the numeric identifier of a FeatureId, given by the full qualified name of the featureclass prepended to the ArcSDE feature id. ej: SDE.SDE.SOME_LAYER.1

Parameters:
id - a geotools FeatureID
Returns:
an ArcSDE feature ID
Throws:
java.lang.IllegalArgumentException - If the given string is not properly formatted [anystring].[long value]

getNumericFids

public static long[] getNumericFids(java.util.Set identifiers)
                             throws java.lang.IllegalArgumentException
DOCUMENT ME!

Parameters:
identifiers - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

createSchema

public static void createSchema(org.opengis.feature.simple.SimpleFeatureType featureType,
                                java.util.Map hints,
                                ISession session)
                         throws java.io.IOException,
                                java.lang.IllegalArgumentException
Creates the given featuretype in the underlying ArcSDE database.

The common use case to create an ArcSDE layer is to setup the SeTable object with all the non-geometry attributes first, then create the SeLayer and set the geometry column name and its properties. This approach brings a nice problem, since we need to create the attributes in exactly the same order as specified in the passed FeatureType, which means that the geometry attribute needs not to be the last one.

To avoid this, the following workaround is performed: instead of creating the schema as described above, we will first create the SeTable with a single, temporary column, since it is not possible to create a table without columns. The, we will iterate over the AttributeTypes and add them as they appear using SeTable.addColumn(SeColumnDefinition). But if we found that the current AttributeType is geometric, instead of adding the column we just create the SeLayer object. This way, the geometric attribute is inserted at the end, and then we keep iterating and adding the rest of the columns. Finally, the first column is removed, since it was temporary (note that I advertise it, it is a _workaround_).

Sometimes some 'extra' information is required to correctly create the underlying ArcSDE SeLayer. For instance, a specific configuration keyword might be required to be used (instead of "DEFAULTS"), or a particular column might need to be marked as the rowid column for the featuretype. A non-null hints parameter contains a mapping from a list of well-known String keys to values. The possible keys are listed in the table below. keys with any other values are ignored.

Parameters:
featureType - the feature type containing the name, attributes and coordinate reference system of the new ArcSDE layer.
hints - A map containing extra ArcSDE-specific hints about how to create the underlying ArcS DE SeLayer and SeTable objects from this FeatureType.
session - connection to use in order to create the layer and table on the server. The connection shall be managed by this method caller.
Throws:
java.io.IOException - see throws DataSourceException bellow
java.lang.IllegalArgumentException - if the passed feature type does not contains at least one geometric attribute, or if the type name contains '.' (dots).
java.lang.NullPointerException - if featureType is null
DataSourceException - if there is not an available (free) connection to the ArcSDE instance(in that case maybe you need to increase the maximun number of connections for the connection pool), or an SeException exception is catched while creating the feature type at the ArcSDE instance (e.g. a table with that name already exists).

key name key value type default value (if applicable)
configuration.keyword String "DEFAULTS"
rowid.column.type String - "NONE", "USER" and "SDE" are the only valid values "NONE"
rowid.column.name String null

Copyright © 1996-2010 Geotools. All Rights Reserved.