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

public class TLcdDatabaseModelDescriptor extends TLcdFeaturedModelDescriptor implements ILcdDatabaseModelDescriptor, com.luciad.internal.format.database.ILinDatabaseModelDescriptor2, ILcdAnnotatedElement
This 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 Details

  • 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

      public void setDriver(String aDriver)
      Sets the JDBC driver name.
    • getDriver

      public String getDriver()
      Returns the JDBC driver name.
    • setURL

      public void setURL(String aURL)
      Sets the JDBC connection URL.
    • getURL

      public String getURL()
      Returns the JDBC connection URL.
    • setTypeName

      public void setTypeName(String aTypeName)
      Sets the type name.
      Overrides:
      setTypeName in class TLcdModelDescriptor
      Parameters:
      aTypeName - The new type name
    • setConnectionProperties

      public void setConnectionProperties(Properties aConnectionProperties)
      Sets the connection properties.
    • getConnectionProperties

      public Properties getConnectionProperties()
      Returns the connection properties.
    • setTableName

      public void setTableName(String aName)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the name of the database table.
      Specified by:
      setTableName in interface ILcdDatabaseModelDescriptor
      Parameters:
      aName - the name of the database table.
    • getTableName

      public String getTableName()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the name of the database table.
      Specified by:
      getTableName in interface ILcdDatabaseModelDescriptor
      Returns:
      a table name.
    • setGeometryColumnName

      public void setGeometryColumnName(String aName)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the name of the column containing the database geometry object.
      Specified by:
      setGeometryColumnName in interface ILcdDatabaseModelDescriptor
      Parameters:
      aName - the name of the table column containing the geometry.
    • getGeometryColumnName

      public String getGeometryColumnName()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the name of the table column containing the geometry.
      Specified by:
      getGeometryColumnName in interface ILcdDatabaseModelDescriptor
      Returns:
      the name of the column containing the geometry.
    • setGeometryQueryColumnName

      public void setGeometryQueryColumnName(String aName)
      Sets an optional table column containing the geometry on which the spatial queries will be performed. By default it is null, meaning that it is the same a the table column containing the geometry that is decoded.
    • getGeometryQueryColumnName

      public String getGeometryQueryColumnName()
      Returns the optional table column containing the geometry on which the spatial queries are be performed.
    • setFeatureNames

      public void setFeatureNames(String[] aFeatureNames)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the names of the features to be selected.
      Specified by:
      setFeatureNames in interface ILcdDatabaseModelDescriptor
      Parameters:
      aFeatureNames - a list of feature names.
    • setFeatureDisplayNames

      public void setFeatureDisplayNames(String[] aFeatureDisplayNames)
      Sets the display names of the features that are decoded.
    • getFeatureDisplayName

      public String getFeatureDisplayName(int aIndex)
      Returns the display name name of a specified feature.
    • setFeatureClasses

      public void setFeatureClasses(Class[] aFeatureClasses)
      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 interface ILcdDatabaseModelDescriptor
      Parameters:
      aPrimaryFeatureIndex - the primary feature index
    • getPrimaryFeatureIndex

      public int getPrimaryFeatureIndex()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the primary feature index.
      Specified by:
      getPrimaryFeatureIndex in interface ILcdDatabaseModelDescriptor
      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

      public void setSelectionTables(String aSelectionTables)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the names of additional tables used in the select query.
      Specified by:
      setSelectionTables in interface ILcdDatabaseModelDescriptor
      Parameters:
      aSelectionTables - a list of additional tables separated by columns.
    • getSelectionTables

      public String getSelectionTables()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the names of the additional tables used in the select query
      Specified by:
      getSelectionTables in interface ILcdDatabaseModelDescriptor
      Returns:
      a list of additional tables, separated by columns.
    • setSelectionFilter

      public void setSelectionFilter(String aSelectionFilter)
      Description copied from interface: ILcdDatabaseModelDescriptor
      A selection filter string , normally appended to the WHERE part of the select query.
      Specified by:
      setSelectionFilter in interface ILcdDatabaseModelDescriptor
      Parameters:
      aSelectionFilter - a selection filter string.
    • getSelectionFilter

      public String getSelectionFilter()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the string representing the selection filter.
      Specified by:
      getSelectionFilter in interface ILcdDatabaseModelDescriptor
      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 interface com.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 interface ILcdDatabaseModelDescriptor
      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 interface ILcdDatabaseModelDescriptor
      Returns:
      the Spatial reference ID number.
    • setEllipsoid

      public void setEllipsoid(ILcdEllipsoid aEllipsoid)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the ellipsoid of the database object's reference.
      Specified by:
      setEllipsoid in interface ILcdDatabaseModelDescriptor
      Parameters:
      aEllipsoid - the ellipsoid of the database object's reference.
    • getEllipsoid

      public ILcdEllipsoid getEllipsoid()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the ellipsoid of the database object reference.
      Specified by:
      getEllipsoid in interface ILcdDatabaseModelDescriptor
      Returns:
      an ellipsoid
    • setBounds

      public void setBounds(ILcdBounds aBounds)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the bounds of the geometry.
      Specified by:
      setBounds in interface ILcdDatabaseModelDescriptor
      Parameters:
      aBounds - the bounds of the geometry.
    • getBounds

      public ILcdBounds getBounds()
      Description copied from interface: ILcdDatabaseModelDescriptor
      returns the bounds of the geometry.
      Specified by:
      getBounds in interface ILcdDatabaseModelDescriptor
      Returns:
      the bounds of the geometry.
    • setGeometryType

      public void setGeometryType(String aGeometryType)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the type of the geometry.
      Specified by:
      setGeometryType in interface ILcdDatabaseModelDescriptor
      Parameters:
      aGeometryType - type of the geometry.
    • getGeometryType

      public String getGeometryType()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the type of the geometry.
      Specified by:
      getGeometryType in interface ILcdDatabaseModelDescriptor
      Returns:
      type of the geometry.
    • setFeatureTypes

      public void setFeatureTypes(String[] aFeatureTypes)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Sets the types of the features.
      Specified by:
      setFeatureTypes in interface ILcdDatabaseModelDescriptor
      Parameters:
      aFeatureTypes - the types of the features.
    • getFeatureType

      public String getFeatureType(int aIndex)
      Description copied from interface: ILcdDatabaseModelDescriptor
      Returns the type of a given feature.
      Specified by:
      getFeatureType in interface ILcdDatabaseModelDescriptor
      Parameters:
      aIndex - the feature index.
      Returns:
      the feature type.
    • getColumnNames

      public String getColumnNames()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Concatenates the main column name and the feature column names into a single String of comma-separated column names.
      Specified by:
      getColumnNames in interface ILcdDatabaseModelDescriptor
      Specified by:
      getColumnNames in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
      Returns:
      a String containing the comma-separated column names.
    • getColumnNames

      public String getColumnNames(boolean aIncludeGeometryColumn, boolean aIncludePrimaryFeatureColumn)
      Concatenates the main column name (optionally) and the feature column names (optionally excluding the primary feature column) into a single String of comma-separated column names.
      Specified by:
      getColumnNames in interface com.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

      public String getColumnNamesAndTypes() throws IllegalArgumentException
      Description copied from interface: ILcdDatabaseModelDescriptor
      Concatenates the main column name and type, and the feature column names and types into a single String of comma-separated column names and types.
      Specified by:
      getColumnNamesAndTypes in interface ILcdDatabaseModelDescriptor
      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 single String 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

      public Connection getConnection() throws SQLException
      Description copied from interface: com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
      Returns the database connection.
      Specified by:
      getConnection in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
      Returns:
      the connection
      Throws:
      SQLException
    • close

      public void close()
      Description copied from interface: ILcdDatabaseModelDescriptor
      Closes the Connection of this descriptor, if it was opened.
      Specified by:
      close in interface ILcdDatabaseModelDescriptor
    • clone

      public Object clone()
      Specified by:
      clone in interface ILcdDatabaseModelDescriptor
      Overrides:
      clone in class Object
    • getDataModel

      public TLcdDataModel 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 interface ILcdDataModelDescriptor
      Returns:
      the data model that describes the elements of the model
    • getModelElementTypes

      public Set<TLcdDataType> 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 interface ILcdDataModelDescriptor
      Returns:
      a set containing all the data types of which instances can be elements in the model associated with this descriptor
    • getModelTypes

      public Set<TLcdDataType> 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 interface ILcdDataModelDescriptor
      Returns:
      a set containing all the data types of which instances can be used in the model associated with this descriptor
    • getModelElementType

      public TLcdDataType getModelElementType()
      Returns the type of all the model elements. Note that getModelElementType() returns a set that contains this type as single element.
      Specified by:
      getModelElementType in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
      Returns:
      the type of all the model elements.
      See Also:
    • addAnnotation

      public <T extends ILcdAnnotation> T addAnnotation(ILcdAnnotation aAnnotation)
      Description copied from interface: ILcdAnnotatedElement
      Adds the given annotation to this element.
      Specified by:
      addAnnotation in interface ILcdAnnotatedElement
      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

      public <T extends ILcdAnnotation> T removeAnnotation(Class<T> aAnnotationClass)
      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 interface ILcdAnnotatedElement
      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

      public <T extends ILcdAnnotation> T getAnnotation(Class<T> aAnnotationClass)
      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 interface ILcdAnnotatedElement
      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

      public Collection<ILcdAnnotation> getAnnotations()
      Description copied from interface: ILcdAnnotatedElement
      Returns all annotations present on this element as an unmodifiable collection.
      Specified by:
      getAnnotations in interface ILcdAnnotatedElement
      Returns:
      all annotations present on this element
    • isAnnotationPresent

      public boolean isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationClass)
      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 interface ILcdAnnotatedElement
      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