Class TableHierarchy

java.lang.Object
org.apache.sis.metadata.sql.TableHierarchy

final class TableHierarchy extends Object
Utility methods for handling the inheritance between tables. This features is partially supported in PostgreSQL database.

This class is a work around for databases that support table inheritances, but not yet index inheritance. For example, in PostgreSQL 9.5.13, we cannot yet declare a foreigner key to the super table and find the entries in inherited tables that way.

An alternative to current workaround would be to repeat a search in all child tables. We could use DatabaseMetaData.getSuperTables(String, String, String) for getting the list of child tables.

Since:
1.0
Version:
1.0
  • Field Details

    • TYPE_OPEN

      static final char TYPE_OPEN
      Delimiter characters for the table name in identifier. Table names are prefixed to identifiers only if the type represented by the table is a subtype. For example, since Organisation is a subtype of Party, identifiers for organizations need to be prefixed by {Organisation} in order to allow MetadataSource to know in which table to search for such party.
      See Also:
    • TYPE_CLOSE

      static final char TYPE_CLOSE
      Delimiter characters for the table name in identifier. Table names are prefixed to identifiers only if the type represented by the table is a subtype. For example, since Organisation is a subtype of Party, identifiers for organizations need to be prefixed by {Organisation} in order to allow MetadataSource to know in which table to search for such party.
      See Also:
    • ABBREVIATIONS

      private static final Map<String,String> ABBREVIATIONS
      Abbreviations for commonly-used tables. We use those abbreviations because table names like "VectorSpatialRepresentation" consume a lot of space, which leave few spaces left for actual identifiers when we want to limit the length to a relatively small value.
    • TABLES

      private static final Map<String,String> TABLES
      The reverse of ABBREVIATIONS.
  • Constructor Details

    • TableHierarchy

      private TableHierarchy()
      Do not allow instantiation of this class.
  • Method Details

    • add

      private static void add(String table, String abbreviation)
      Adds an abbreviation. For class initialization only.
    • encode

      static String encode(String table, String identifier)
      Encode table name in the given identifier.
    • subType

      static Class<?> subType(Class<?> type, String identifier)
      If the given identifier specifies a subtype of the given type, then returns that subtype. For example if the given type is Party.class and the given identifier is "{Organisation}EPSG", then this method returns Organisation.class. Otherwise this method returns type unchanged.
      Parameters:
      type - base metadata type.
      identifier - primary key in the database.
      Returns:
      actual type of the metadata object.