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
FieldsFields inherited from class com.luciad.model.TLcdFeaturedModelDescriptor
fFeatureClasses, fFeatureNames -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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()voidclose()Closes theConnectionof 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 singleStringof 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 singleStringof comma-separated column names.Concatenates the main column name and type, and the feature column names and types into a singleStringof 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 singleStringof 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.intReturns the primary feature index.Returns the string representing the selection filter.Returns the names of the additional tables used in the select queryintgetSRID()Returns the Spatial Reference ID number.Returns the name of the database table.getURL()Returns the JDBC connection URL.booleanReturns whether a connection is always closed after a query has been performed.booleanisAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationClass) Returns true if an annotation for the specified class is present on this element, else false.booleanReturns 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.voidsetAlwaysCloseConnection(boolean aAlwaysCloseConnection) Specifies to always close the connection after a query has been performed.voidsetBounds(ILcdBounds aBounds) Sets the bounds of the geometry.voidsetConnectionProperties(Properties aConnectionProperties) Sets the connection properties.voidSets the JDBC driver name.voidsetEllipsoid(ILcdEllipsoid aEllipsoid) Sets the ellipsoid of the database object's reference.voidsetFeatureClasses(Class[] aFeatureClasses) Sets the classes of the features that are decoded.voidsetFeatureDisplayNames(String[] aFeatureDisplayNames) Sets the display names of the features that are decoded.voidsetFeatureNames(String[] aFeatureNames) Sets the names of the features to be selected.voidsetFeatureTypes(String[] aFeatureTypes) Sets the types of the features.voidsetGeometryColumnName(String aName) Sets the name of the column containing the database geometry object.voidsetGeometryQueryColumnName(String aName) Sets an optional table column containing the geometry on which the spatial queries will be performed.voidsetGeometryType(String aGeometryType) Sets the type of the geometry.voidsetPrimaryFeatureAutoGenerated(boolean aPrimaryFeatureAutoGenerated) Sets whether the primary key is automatically generated by the database.voidsetPrimaryFeatureIndex(int aPrimaryFeatureIndex) Sets the primary feature indexvoidsetSelectionFilter(String aSelectionFilter) A selection filter string , normally appended to the WHERE part of the select query.voidsetSelectionTables(String aSelectionTables) Sets the names of additional tables used in the select query.voidsetSRID(int aSRID) Sets the Spatial Reference ID number.voidsetTableName(String aName) Sets the name of the database table.voidsetTypeName(String aTypeName) Sets the type name.voidSets the JDBC connection URL.Methods inherited from class com.luciad.model.TLcdFeaturedModelDescriptor
getFeatureClass, getFeatureCount, getFeaturedDescriptor, getFeatureIndex, getFeatureNameMethods inherited from class com.luciad.model.TLcdModelDescriptor
getDisplayName, getSourceName, getTypeName, setDisplayName, setSourceName, sourceNameToDisplayNameMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.format.database.ILcdDatabaseModelDescriptor
getFeatureNameMethods inherited from interface com.luciad.util.ILcdFeaturedDescriptor
getFeatureClass, getFeatureCount, getFeatureIndex, getFeatureUnitOfMeasureMethods inherited from interface com.luciad.model.ILcdModelDescriptor
getDisplayName, getSourceName, getTypeNameMethods 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:
setTypeNamein classTLcdModelDescriptor- Parameters:
aTypeName- The new type name
-
setConnectionProperties
Sets the connection properties. -
getConnectionProperties
Returns the connection properties. -
setTableName
Description copied from interface:ILcdDatabaseModelDescriptorSets the name of the database table.- Specified by:
setTableNamein interfaceILcdDatabaseModelDescriptor- Parameters:
aName- the name of the database table.
-
getTableName
Description copied from interface:ILcdDatabaseModelDescriptorReturns the name of the database table.- Specified by:
getTableNamein interfaceILcdDatabaseModelDescriptor- Returns:
- a table name.
-
setGeometryColumnName
Description copied from interface:ILcdDatabaseModelDescriptorSets the name of the column containing the database geometry object.- Specified by:
setGeometryColumnNamein interfaceILcdDatabaseModelDescriptor- Parameters:
aName- the name of the table column containing the geometry.
-
getGeometryColumnName
Description copied from interface:ILcdDatabaseModelDescriptorReturns the name of the table column containing the geometry.- Specified by:
getGeometryColumnNamein 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:ILcdDatabaseModelDescriptorSets the names of the features to be selected.- Specified by:
setFeatureNamesin 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:ILcdDatabaseModelDescriptorSets the primary feature index- Specified by:
setPrimaryFeatureIndexin interfaceILcdDatabaseModelDescriptor- Parameters:
aPrimaryFeatureIndex- the primary feature index
-
getPrimaryFeatureIndex
public int getPrimaryFeatureIndex()Description copied from interface:ILcdDatabaseModelDescriptorReturns the primary feature index.- Specified by:
getPrimaryFeatureIndexin 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:ILcdDatabaseModelDescriptorSets the names of additional tables used in the select query.- Specified by:
setSelectionTablesin interfaceILcdDatabaseModelDescriptor- Parameters:
aSelectionTables- a list of additional tables separated by columns.
-
getSelectionTables
Description copied from interface:ILcdDatabaseModelDescriptorReturns the names of the additional tables used in the select query- Specified by:
getSelectionTablesin interfaceILcdDatabaseModelDescriptor- Returns:
- a list of additional tables, separated by columns.
-
setSelectionFilter
Description copied from interface:ILcdDatabaseModelDescriptorA selection filter string , normally appended to the WHERE part of the select query.- Specified by:
setSelectionFilterin interfaceILcdDatabaseModelDescriptor- Parameters:
aSelectionFilter- a selection filter string.
-
getSelectionFilter
Description copied from interface:ILcdDatabaseModelDescriptorReturns the string representing the selection filter.- Specified by:
getSelectionFilterin 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:
isAlwaysCloseConnectionin interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2
-
setSRID
public void setSRID(int aSRID) Description copied from interface:ILcdDatabaseModelDescriptorSets the Spatial Reference ID number.- Specified by:
setSRIDin interfaceILcdDatabaseModelDescriptor- Parameters:
aSRID- a spatial reference ID.
-
getSRID
public int getSRID()Description copied from interface:ILcdDatabaseModelDescriptorReturns the Spatial Reference ID number.- Specified by:
getSRIDin interfaceILcdDatabaseModelDescriptor- Returns:
- the Spatial reference ID number.
-
setEllipsoid
Description copied from interface:ILcdDatabaseModelDescriptorSets the ellipsoid of the database object's reference.- Specified by:
setEllipsoidin interfaceILcdDatabaseModelDescriptor- Parameters:
aEllipsoid- the ellipsoid of the database object's reference.
-
getEllipsoid
Description copied from interface:ILcdDatabaseModelDescriptorReturns the ellipsoid of the database object reference.- Specified by:
getEllipsoidin interfaceILcdDatabaseModelDescriptor- Returns:
- an ellipsoid
-
setBounds
Description copied from interface:ILcdDatabaseModelDescriptorSets the bounds of the geometry.- Specified by:
setBoundsin interfaceILcdDatabaseModelDescriptor- Parameters:
aBounds- the bounds of the geometry.
-
getBounds
Description copied from interface:ILcdDatabaseModelDescriptorreturns the bounds of the geometry.- Specified by:
getBoundsin interfaceILcdDatabaseModelDescriptor- Returns:
- the bounds of the geometry.
-
setGeometryType
Description copied from interface:ILcdDatabaseModelDescriptorSets the type of the geometry.- Specified by:
setGeometryTypein interfaceILcdDatabaseModelDescriptor- Parameters:
aGeometryType- type of the geometry.
-
getGeometryType
Description copied from interface:ILcdDatabaseModelDescriptorReturns the type of the geometry.- Specified by:
getGeometryTypein interfaceILcdDatabaseModelDescriptor- Returns:
- type of the geometry.
-
setFeatureTypes
Description copied from interface:ILcdDatabaseModelDescriptorSets the types of the features.- Specified by:
setFeatureTypesin interfaceILcdDatabaseModelDescriptor- Parameters:
aFeatureTypes- the types of the features.
-
getFeatureType
Description copied from interface:ILcdDatabaseModelDescriptorReturns the type of a given feature.- Specified by:
getFeatureTypein interfaceILcdDatabaseModelDescriptor- Parameters:
aIndex- the feature index.- Returns:
- the feature type.
-
getColumnNames
Description copied from interface:ILcdDatabaseModelDescriptorConcatenates the main column name and the feature column names into a singleStringof comma-separated column names.- Specified by:
getColumnNamesin interfaceILcdDatabaseModelDescriptor- Specified by:
getColumnNamesin 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 singleStringof comma-separated column names.- Specified by:
getColumnNamesin 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:ILcdDatabaseModelDescriptorConcatenates the main column name and type, and the feature column names and types into a singleStringof comma-separated column names and types.- Specified by:
getColumnNamesAndTypesin 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 singleStringof 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.ILinDatabaseModelDescriptor2Returns the database connection.- Specified by:
getConnectionin interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2- Returns:
- the connection
- Throws:
SQLException
-
close
public void close()Description copied from interface:ILcdDatabaseModelDescriptorCloses theConnectionof this descriptor, if it was opened.- Specified by:
closein interfaceILcdDatabaseModelDescriptor
-
clone
- Specified by:
clonein interfaceILcdDatabaseModelDescriptor- Overrides:
clonein classObject
-
getDataModel
Description copied from interface:ILcdDataModelDescriptorReturns 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:
getDataModelin interfaceILcdDataModelDescriptor- Returns:
- the data model that describes the elements of the model
-
getModelElementTypes
Description copied from interface:ILcdDataModelDescriptorReturns 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
nullin 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:
getModelElementTypesin 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:ILcdDataModelDescriptorReturns 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
nullin case they don't know which types are present in the model.- Specified by:
getModelTypesin 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:
getModelElementTypein interfacecom.luciad.internal.format.database.ILinDatabaseModelDescriptor2- Returns:
- the type of all the model elements.
- See Also:
-
addAnnotation
Description copied from interface:ILcdAnnotatedElementAdds the given annotation to this element.- Specified by:
addAnnotationin 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:ILcdAnnotatedElementRemoves 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
nullis returned.- Specified by:
removeAnnotationin 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:ILcdAnnotatedElementReturns 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,
nullis returned.- Specified by:
getAnnotationin 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:ILcdAnnotatedElementReturns all annotations present on this element as an unmodifiable collection.- Specified by:
getAnnotationsin interfaceILcdAnnotatedElement- Returns:
- all annotations present on this element
-
isAnnotationPresent
Description copied from interface:ILcdAnnotatedElementReturns 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,
falseis returned.- Specified by:
isAnnotationPresentin 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
-