Class TLcdDatabaseModelDescriptor
- All Implemented Interfaces:
ILcdAnnotatedElement
,ILcdDatabaseModelDescriptor
,com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
,ILcdDataModelDescriptor
,ILcdModelDescriptor
,ILcdFeaturedDescriptor
,ILcdFeaturedDescriptorProvider
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdDB2SpatialModelDescriptor
,TLcdInformixGeodeticModelDescriptor
,TLcdInformixSpatialModelDescriptor
,TLcdMSSQLModelDescriptor
,TLcdOracleSpatialModelDescriptor
,TLcdPostGISModelDescriptor
,TLcdSpatiaLiteModelDescriptor
ILcdDatabaseModelDescriptor
describes a spatial database.
For accessing an existing spatial table, the following information is required:
- a database driver,
- a database URL,
- connection properties, including 'user' and 'password',
- a table name,
- a column name containing the geometries,
- a list of feature names, along with the index of the feature that can be used as a primary key on the spatial table.
Optionally, the descriptor can have additional properties set:
- a column name containing the geometries on which spatial queries are performed, should it be different from the column that is decoded.
- a selection filter, along with a comma-separated list of tables that are required for the filter. The filter is added to the WHERE part of the spatial database queries. The table list is added to the FROM part of the queries.
- a boolean flag that indicates whether the connection should be closed after each query. Setting this flag can be useful for database drivers that pool connections, so the connections are reused instead of really being closed.
For creating a new spatial table, the following additional information is required:
- a Spatial Reference ID,
- global bounds of the set of geometries,
- an SQL data type corresponding to the geometry column.
- a list of SQL data types corresponding to the optional feature names.
- See Also:
-
Field Summary
Fields inherited from class com.luciad.model.TLcdFeaturedModelDescriptor
fFeatureClasses, fFeatureNames
-
Constructor Summary
ConstructorDescriptionConstructs a new (invalid) database table descriptor with default properties.TLcdDatabaseModelDescriptor
(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName) Constructs a new database table descriptor, based on a JDBC driver and URL.TLcdDatabaseModelDescriptor
(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName, String[] aFeatureNames, int aPrimaryFeatureIndex) Constructs a new database table descriptor, based on a JDBC driver and URL.TLcdDatabaseModelDescriptor
(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName, String[] aFeatureNames, int aPrimaryFeatureIndex, boolean aPrimaryFeatureAutoGenerated) Constructs a new database table descriptor, based on a JDBC driver and URL. -
Method Summary
Modifier and TypeMethodDescription<T extends ILcdAnnotation>
TaddAnnotation
(ILcdAnnotation aAnnotation) Adds the given annotation to this element.clone()
void
close()
Closes theConnection
of this descriptor, if it was opened.<T extends ILcdAnnotation>
TgetAnnotation
(Class<T> aAnnotationClass) Returns the element's annotation for the specified class if such an annotation is present, else null.Returns all annotations present on this element as an unmodifiable collection.returns the bounds of the geometry.Concatenates the main column name and the feature column names into a singleString
of comma-separated column names.getColumnNames
(boolean aIncludeGeometryColumn, boolean aIncludePrimaryFeatureColumn) Concatenates the main column name (optionally) and the feature column names (optionally excluding the primary feature column) into a singleString
of comma-separated column names.Concatenates the main column name and type, and the feature column names and types into a singleString
of comma-separated column names and types.getColumnNamesAndTypes
(boolean aIncludeGeometryColumn, boolean aIncludePrimaryFeatureColumn, boolean aMarkPrimaryFeatureColumn) Concatenates the main column name and type (optionally), and the feature column names and types (optionally excluding the primary feature column) into a singleString
of comma-separated column names and types.Returns the database connection.Returns the connection properties.Returns the data model that describes the elements of the model.Returns the JDBC driver name.Returns the ellipsoid of the database object reference.getFeatureDisplayName
(int aIndex) Returns the display name name of a specified feature.getFeatureType
(int aIndex) Returns the type of a given feature.Returns the name of the table column containing the geometry.Returns the optional table column containing the geometry on which the spatial queries are be performed.Returns the type of the geometry.Returns the type of all the model elements.Returns a set containing all the data types of which instances can be elements in the model associated with this descriptor.Returns a set containing all the types of which instances can be used (including both top-level elements and child objects) in the model associated with this descriptor.int
Returns the primary feature index.Returns the string representing the selection filter.Returns the names of the additional tables used in the select queryint
getSRID()
Returns the Spatial Reference ID number.Returns the name of the database table.getURL()
Returns the JDBC connection URL.boolean
Returns whether a connection is always closed after a query has been performed.boolean
isAnnotationPresent
(Class<? extends ILcdAnnotation> aAnnotationClass) Returns true if an annotation for the specified class is present on this element, else false.boolean
Returns whether the primary key is automatically generated by the database.<T extends ILcdAnnotation>
TremoveAnnotation
(Class<T> aAnnotationClass) Removes the annotation of the given class from this element.void
setAlwaysCloseConnection
(boolean aAlwaysCloseConnection) Specifies to always close the connection after a query has been performed.void
setBounds
(ILcdBounds aBounds) Sets the bounds of the geometry.void
setConnectionProperties
(Properties aConnectionProperties) Sets the connection properties.void
Sets the JDBC driver name.void
setEllipsoid
(ILcdEllipsoid aEllipsoid) Sets the ellipsoid of the database object's reference.void
setFeatureClasses
(Class[] aFeatureClasses) Sets the classes of the features that are decoded.void
setFeatureDisplayNames
(String[] aFeatureDisplayNames) Sets the display names of the features that are decoded.void
setFeatureNames
(String[] aFeatureNames) Sets the names of the features to be selected.void
setFeatureTypes
(String[] aFeatureTypes) Sets the types of the features.void
setGeometryColumnName
(String aName) Sets the name of the column containing the database geometry object.void
setGeometryQueryColumnName
(String aName) Sets an optional table column containing the geometry on which the spatial queries will be performed.void
setGeometryType
(String aGeometryType) Sets the type of the geometry.void
setPrimaryFeatureAutoGenerated
(boolean aPrimaryFeatureAutoGenerated) Sets whether the primary key is automatically generated by the database.void
setPrimaryFeatureIndex
(int aPrimaryFeatureIndex) Sets the primary feature indexvoid
setSelectionFilter
(String aSelectionFilter) A selection filter string , normally appended to the WHERE part of the select query.void
setSelectionTables
(String aSelectionTables) Sets the names of additional tables used in the select query.void
setSRID
(int aSRID) Sets the Spatial Reference ID number.void
setTableName
(String aName) Sets the name of the database table.void
setTypeName
(String aTypeName) Sets the type name.void
Sets the JDBC connection URL.Methods inherited from class com.luciad.model.TLcdFeaturedModelDescriptor
getFeatureClass, getFeatureCount, getFeaturedDescriptor, getFeatureIndex, getFeatureName
Methods inherited from class com.luciad.model.TLcdModelDescriptor
getDisplayName, getSourceName, getTypeName, setDisplayName, setSourceName, sourceNameToDisplayName
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.format.database.ILcdDatabaseModelDescriptor
getFeatureName
Methods inherited from interface com.luciad.util.ILcdFeaturedDescriptor
getFeatureClass, getFeatureCount, getFeatureIndex, getFeatureUnitOfMeasure
Methods inherited from interface com.luciad.model.ILcdModelDescriptor
getDisplayName, getSourceName, getTypeName
Methods inherited from interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
closeConnection
-
Field Details
-
TYPE_NAME
- See Also:
-
fConnection
-
-
Constructor Details
-
TLcdDatabaseModelDescriptor
public TLcdDatabaseModelDescriptor()Constructs a new (invalid) database table descriptor with default properties. -
TLcdDatabaseModelDescriptor
public TLcdDatabaseModelDescriptor(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName) Constructs a new database table descriptor, based on a JDBC driver and URL.- Parameters:
aDriver
- the JDBC driver name.aURL
- the JDBC connection URL.aConnectionProperties
- the connection properties, including 'user' and 'password'.aTableName
- the database table name.aGeometryColumnName
- the name of the column containing spatial objects.
-
TLcdDatabaseModelDescriptor
public TLcdDatabaseModelDescriptor(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName, String[] aFeatureNames, int aPrimaryFeatureIndex) Constructs a new database table descriptor, based on a JDBC driver and URL.- Parameters:
aDriver
- the JDBC driver name.aURL
- the JDBC connection URL.aConnectionProperties
- the connection properties, including 'user' and 'password'.aTableName
- the database table name.aGeometryColumnName
- the name of the column containing spatial objects.aFeatureNames
- the column names of the features that should be retrieved.aPrimaryFeatureIndex
- the index of the feature that can be used a a primary key on the spatial table.
-
TLcdDatabaseModelDescriptor
public TLcdDatabaseModelDescriptor(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName, String[] aFeatureNames, int aPrimaryFeatureIndex, boolean aPrimaryFeatureAutoGenerated) Constructs a new database table descriptor, based on a JDBC driver and URL.- Parameters:
aDriver
- the JDBC driver name.aURL
- the JDBC connection URL.aConnectionProperties
- the connection properties, including 'user' and 'password'.aTableName
- the database table name.aGeometryColumnName
- the name of the column containing spatial objects.aFeatureNames
- the column names of the features that should be retrieved.aPrimaryFeatureIndex
- the index of the feature that can be used a a primary key on the spatial table.aPrimaryFeatureAutoGenerated
- specifies whether the primary key is automatically generated by the database.
-
-
Method Details
-
setDriver
Sets the JDBC driver name. -
getDriver
Returns the JDBC driver name. -
setURL
Sets the JDBC connection URL. -
getURL
Returns the JDBC connection URL. -
setTypeName
Sets the type name.- Overrides:
setTypeName
in classTLcdModelDescriptor
- Parameters:
aTypeName
- The new type name
-
setConnectionProperties
Sets the connection properties. -
getConnectionProperties
Returns the connection properties. -
setTableName
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the name of the database table.- Specified by:
setTableName
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aName
- the name of the database table.
-
getTableName
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the name of the database table.- Specified by:
getTableName
in interfaceILcdDatabaseModelDescriptor
- Returns:
- a table name.
-
setGeometryColumnName
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the name of the column containing the database geometry object.- Specified by:
setGeometryColumnName
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aName
- the name of the table column containing the geometry.
-
getGeometryColumnName
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the name of the table column containing the geometry.- Specified by:
getGeometryColumnName
in interfaceILcdDatabaseModelDescriptor
- Returns:
- the name of the column containing the geometry.
-
setGeometryQueryColumnName
Sets an optional table column containing the geometry on which the spatial queries will be performed. By default it isnull
, meaning that it is the same a the table column containing the geometry that is decoded. -
getGeometryQueryColumnName
Returns the optional table column containing the geometry on which the spatial queries are be performed. -
setFeatureNames
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the names of the features to be selected.- Specified by:
setFeatureNames
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aFeatureNames
- a list of feature names.
-
setFeatureDisplayNames
Sets the display names of the features that are decoded. -
getFeatureDisplayName
Returns the display name name of a specified feature. -
setFeatureClasses
Sets the classes of the features that are decoded. -
setPrimaryFeatureIndex
public void setPrimaryFeatureIndex(int aPrimaryFeatureIndex) Description copied from interface:ILcdDatabaseModelDescriptor
Sets the primary feature index- Specified by:
setPrimaryFeatureIndex
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aPrimaryFeatureIndex
- the primary feature index
-
getPrimaryFeatureIndex
public int getPrimaryFeatureIndex()Description copied from interface:ILcdDatabaseModelDescriptor
Returns the primary feature index.- Specified by:
getPrimaryFeatureIndex
in interfaceILcdDatabaseModelDescriptor
- Returns:
- the primary feature index.
-
setPrimaryFeatureAutoGenerated
public void setPrimaryFeatureAutoGenerated(boolean aPrimaryFeatureAutoGenerated) Sets whether the primary key is automatically generated by the database. -
isPrimaryFeatureAutoGenerated
public boolean isPrimaryFeatureAutoGenerated()Returns whether the primary key is automatically generated by the database. -
setSelectionTables
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the names of additional tables used in the select query.- Specified by:
setSelectionTables
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aSelectionTables
- a list of additional tables separated by columns.
-
getSelectionTables
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the names of the additional tables used in the select query- Specified by:
getSelectionTables
in interfaceILcdDatabaseModelDescriptor
- Returns:
- a list of additional tables, separated by columns.
-
setSelectionFilter
Description copied from interface:ILcdDatabaseModelDescriptor
A selection filter string , normally appended to the WHERE part of the select query.- Specified by:
setSelectionFilter
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aSelectionFilter
- a selection filter string.
-
getSelectionFilter
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the string representing the selection filter.- Specified by:
getSelectionFilter
in interfaceILcdDatabaseModelDescriptor
- Returns:
- the selection filter.
-
setAlwaysCloseConnection
public void setAlwaysCloseConnection(boolean aAlwaysCloseConnection) Specifies to always close the connection after a query has been performed. -
isAlwaysCloseConnection
public boolean isAlwaysCloseConnection()Returns whether a connection is always closed after a query has been performed.- Specified by:
isAlwaysCloseConnection
in interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2
-
setSRID
public void setSRID(int aSRID) Description copied from interface:ILcdDatabaseModelDescriptor
Sets the Spatial Reference ID number.- Specified by:
setSRID
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aSRID
- a spatial reference ID.
-
getSRID
public int getSRID()Description copied from interface:ILcdDatabaseModelDescriptor
Returns the Spatial Reference ID number.- Specified by:
getSRID
in interfaceILcdDatabaseModelDescriptor
- Returns:
- the Spatial reference ID number.
-
setEllipsoid
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the ellipsoid of the database object's reference.- Specified by:
setEllipsoid
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aEllipsoid
- the ellipsoid of the database object's reference.
-
getEllipsoid
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the ellipsoid of the database object reference.- Specified by:
getEllipsoid
in interfaceILcdDatabaseModelDescriptor
- Returns:
- an ellipsoid
-
setBounds
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the bounds of the geometry.- Specified by:
setBounds
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aBounds
- the bounds of the geometry.
-
getBounds
Description copied from interface:ILcdDatabaseModelDescriptor
returns the bounds of the geometry.- Specified by:
getBounds
in interfaceILcdDatabaseModelDescriptor
- Returns:
- the bounds of the geometry.
-
setGeometryType
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the type of the geometry.- Specified by:
setGeometryType
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aGeometryType
- type of the geometry.
-
getGeometryType
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the type of the geometry.- Specified by:
getGeometryType
in interfaceILcdDatabaseModelDescriptor
- Returns:
- type of the geometry.
-
setFeatureTypes
Description copied from interface:ILcdDatabaseModelDescriptor
Sets the types of the features.- Specified by:
setFeatureTypes
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aFeatureTypes
- the types of the features.
-
getFeatureType
Description copied from interface:ILcdDatabaseModelDescriptor
Returns the type of a given feature.- Specified by:
getFeatureType
in interfaceILcdDatabaseModelDescriptor
- Parameters:
aIndex
- the feature index.- Returns:
- the feature type.
-
getColumnNames
Description copied from interface:ILcdDatabaseModelDescriptor
Concatenates the main column name and the feature column names into a singleString
of comma-separated column names.- Specified by:
getColumnNames
in interfaceILcdDatabaseModelDescriptor
- Specified by:
getColumnNames
in interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2
- Returns:
- a String containing the comma-separated column names.
-
getColumnNames
Concatenates the main column name (optionally) and the feature column names (optionally excluding the primary feature column) into a singleString
of comma-separated column names.- Specified by:
getColumnNames
in interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2
- Parameters:
aIncludeGeometryColumn
- specifies whether the geometry column name should be included.aIncludePrimaryFeatureColumn
- specifies whether the primary feature column name should be included.- Returns:
- a String containing the comma-separated column names.
-
getColumnNamesAndTypes
Description copied from interface:ILcdDatabaseModelDescriptor
Concatenates the main column name and type, and the feature column names and types into a singleString
of comma-separated column names and types.- Specified by:
getColumnNamesAndTypes
in interfaceILcdDatabaseModelDescriptor
- Returns:
- a String containing the main column name and type, and the feature column names and types, separated by commas.
- Throws:
IllegalArgumentException
-
getColumnNamesAndTypes
public String getColumnNamesAndTypes(boolean aIncludeGeometryColumn, boolean aIncludePrimaryFeatureColumn, boolean aMarkPrimaryFeatureColumn) throws IllegalArgumentException Concatenates the main column name and type (optionally), and the feature column names and types (optionally excluding the primary feature column) into a singleString
of comma-separated column names and types.- Parameters:
aIncludeGeometryColumn
- specifies whether the geometry column name and type should be included.aIncludePrimaryFeatureColumn
- specifies whether the primary feature column name and type should be included.aMarkPrimaryFeatureColumn
- specifies whether the primary feature column name should be marked with the string "PRIMARY KEY".- Returns:
- a String containing the comma-separated column names and types.
- Throws:
IllegalArgumentException
-
getConnection
Description copied from interface:com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
Returns the database connection.- Specified by:
getConnection
in interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2
- Returns:
- the connection
- Throws:
SQLException
-
close
public void close()Description copied from interface:ILcdDatabaseModelDescriptor
Closes theConnection
of this descriptor, if it was opened.- Specified by:
close
in interfaceILcdDatabaseModelDescriptor
-
clone
- Specified by:
clone
in interfaceILcdDatabaseModelDescriptor
- Overrides:
clone
in classObject
-
getDataModel
Description copied from interface:ILcdDataModelDescriptor
Returns the data model that describes the elements of the model. Note that not necessarily all data in the model will be of a type of this data model. Very likely, types from the dependencies of the returned data model are used as well.
In case the model accepts objects from multiple data models, an anonymous data model that depends on all these data models should be returned (see
TLcdDataModelBuilder.createAnonymousDataModel(java.util.Collection)
).- Specified by:
getDataModel
in interfaceILcdDataModelDescriptor
- Returns:
- the data model that describes the elements of the model
-
getModelElementTypes
Description copied from interface:ILcdDataModelDescriptor
Returns a set containing all the data types of which instances can be elements in the model associated with this descriptor. Implementations are free to limit the result to only include the types of which there are actually elements in the model; but they are not required to do so.
Implementations should return
null
in case they don't know which element types are present in the model.For each element of the model associated with this model descriptor, the following holds true :
getModelElementTypes().contains( element.getDataType() )
.- Specified by:
getModelElementTypes
in interfaceILcdDataModelDescriptor
- Returns:
- a set containing all the data types of which instances can be elements in the model associated with this descriptor
-
getModelTypes
Description copied from interface:ILcdDataModelDescriptor
Returns a set containing all the types of which instances can be used (including both top-level elements and child objects) in the model associated with this descriptor. Implementations are free to limit the result to only include the types of which there are actually instances in the model; but they are not required to do so.
A simple and correct implementation would be to return
getDataModel().getTypes()
. Implementations are encouraged to return a subset of this set if they can do so without spending an unreasonable amount of resources.Implementations should return
null
in case they don't know which types are present in the model.- Specified by:
getModelTypes
in interfaceILcdDataModelDescriptor
- Returns:
- a set containing all the data types of which instances can be used in the model associated with this descriptor
-
getModelElementType
Returns the type of all the model elements. Note thatgetModelElementType()
returns a set that contains this type as single element.- Specified by:
getModelElementType
in interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2
- Returns:
- the type of all the model elements.
- See Also:
-
addAnnotation
Description copied from interface:ILcdAnnotatedElement
Adds the given annotation to this element.- Specified by:
addAnnotation
in interfaceILcdAnnotatedElement
- Parameters:
aAnnotation
- the annotation to add- Returns:
- the previous annotation of the same class as the given annotation associated with this element, or null if there was no annotation for that class.
-
removeAnnotation
Description copied from interface:ILcdAnnotatedElement
Removes the annotation of the given class from this element.
Note that the exact annotation class needs to be passed as parameter. In other words, in case the element is only annotated with instances of subclasses of the given annotation class, nothing is removed and
null
is returned.- Specified by:
removeAnnotation
in interfaceILcdAnnotatedElement
- Parameters:
aAnnotationClass
- the class of annotation to remove- Returns:
- the annotation of the given class that was associated with this element, or null if there was no annotation for that class.
-
getAnnotation
Description copied from interface:ILcdAnnotatedElement
Returns the element's annotation for the specified class if such an annotation is present, else null.
Note that the exact annotation class needs to be passed as parameter. In other words, in case the element is only annotated with instances of subclasses of the given annotation class,
null
is returned.- Specified by:
getAnnotation
in interfaceILcdAnnotatedElement
- Parameters:
aAnnotationClass
- - the Class object corresponding to the annotation type- Returns:
- this element's annotation for the specified annotation class if present on this element, else null
-
getAnnotations
Description copied from interface:ILcdAnnotatedElement
Returns all annotations present on this element as an unmodifiable collection.- Specified by:
getAnnotations
in interfaceILcdAnnotatedElement
- Returns:
- all annotations present on this element
-
isAnnotationPresent
Description copied from interface:ILcdAnnotatedElement
Returns true if an annotation for the specified class is present on this element, else false. This method is designed primarily for convenient access to marker annotations.
Note that the exact annotation class needs to be passed as parameter. In other words, in case the element is only annotated with instances of subclasses of the given annotation class,
false
is returned.- Specified by:
isAnnotationPresent
in interfaceILcdAnnotatedElement
- Parameters:
aAnnotationClass
- the Class object corresponding to the annotation class- Returns:
- true if an annotation for the specified annotation class is present on this element, else false
-