Class RelatedTablesCoreExtension

    • Field Detail

      • EXTENSION_NAME_NO_AUTHOR

        public static final String EXTENSION_NAME_NO_AUTHOR
        Extension name without the author
        See Also:
        Constant Field Values
      • EXTENSION_NAME

        public static final String EXTENSION_NAME
        Extension, with author and name
      • EXTENSION_DEFINITION

        public static final String EXTENSION_DEFINITION
        Extension definition URL
    • Constructor Detail

      • RelatedTablesCoreExtension

        protected RelatedTablesCoreExtension​(GeoPackageCore geoPackage)
        Constructor
        Parameters:
        geoPackage - GeoPackage
    • Method Detail

      • has

        public boolean has()
        Determine if the GeoPackage has the extension
        Returns:
        true if has extension
      • has

        public boolean has​(String mappingTable)
        Determine if the GeoPackage has the extension for the mapping table
        Overrides:
        has in class BaseExtension
        Parameters:
        mappingTable - mapping table name
        Returns:
        true if has extension
      • getExtendedRelationsDao

        public ExtendedRelationsDao getExtendedRelationsDao()
        Get a Extended Relations DAO
        Returns:
        extended relations dao
      • getExtendedRelationsDao

        public static ExtendedRelationsDao getExtendedRelationsDao​(GeoPackageCore geoPackage)
        Get a Extended Relations DAO
        Parameters:
        geoPackage - GeoPackage
        Returns:
        extended relations dao
        Since:
        4.0.0
      • getExtendedRelationsDao

        public static ExtendedRelationsDao getExtendedRelationsDao​(GeoPackageCoreConnection db)
        Get a Extended Relations DAO
        Parameters:
        db - database connection
        Returns:
        extended relations dao
        Since:
        4.0.0
      • createExtendedRelationsTable

        public boolean createExtendedRelationsTable()
        Create the Extended Relations Table if it does not exist
        Returns:
        true if created
        Since:
        4.0.0
      • getPrimaryKeyColumnName

        public String getPrimaryKeyColumnName​(String tableName)
        Get the primary key of a table
        Parameters:
        tableName - table name
        Returns:
        the column name
      • setContents

        public void setContents​(UserTable<? extends UserColumn> table)
        Set the contents in the user table
        Parameters:
        table - user table
      • getRelationships

        public List<ExtendedRelation> getRelationships()
        Returns the relationships defined through this extension
        Returns:
        a list of ExtendedRelation objects
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                String relatedTableName,
                                                String mappingTableName,
                                                RelationType relationType)
        Adds a relationship between the base and related table. Creates a default user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        mappingTableName - mapping table name
        relationType - relation type
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                String relatedTableName,
                                                String mappingTableName,
                                                String relationAuthor,
                                                String relationName)
        Adds a relationship between the base and related table. Creates a default user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        mappingTableName - mapping table name
        relationAuthor - relation author
        relationName - relation name
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                String relatedTableName,
                                                String mappingTableName,
                                                String relationName)
        Adds a relationship between the base and related table. Creates a default user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        mappingTableName - mapping table name
        relationName - relation name
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                String relatedTableName,
                                                UserMappingTable userMappingTable,
                                                RelationType relationType)
        Adds a relationship between the base and related table. Creates the user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        userMappingTable - user mapping table
        relationType - relation type
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                String relatedTableName,
                                                UserMappingTable userMappingTable,
                                                String relationAuthor,
                                                String relationName)
        Adds a relationship between the base and related table. Creates the user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        userMappingTable - user mapping table
        relationAuthor - relation author
        relationName - relation name
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                String relatedTableName,
                                                UserMappingTable userMappingTable,
                                                String relationName)
        Adds a relationship between the base and related table. Creates the user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        userMappingTable - user mapping table
        relationName - relation name
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                UserRelatedTable relatedTable,
                                                String mappingTableName)
        Adds a relationship between the base and user related table. Creates a default user mapping table and the related table if needed.
        Parameters:
        baseTableName - base table name
        relatedTable - user related table
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                UserRelatedTable relatedTable,
                                                UserMappingTable userMappingTable)
        Adds a relationship between the base and user related table. Creates the user mapping table and related table if needed.
        Parameters:
        baseTableName - base table name
        relatedTable - user related table
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                UserTable<? extends UserColumn> relatedTable,
                                                String mappingTableName)
        Adds a relationship between the base and user related table. Creates a default user mapping table and the related table if needed.
        Parameters:
        baseTableName - base table name
        relatedTable - user related table
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                UserTable<? extends UserColumn> relatedTable,
                                                UserMappingTable userMappingTable)
        Adds a relationship between the base and user related table. Creates the user mapping table and related table if needed.
        Parameters:
        baseTableName - base table name
        relatedTable - user related table
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                UserTable<? extends UserColumn> relatedTable,
                                                String relationName,
                                                String mappingTableName)
        Adds a relationship between the base and user related table. Creates a default user mapping table and the related table if needed.
        Parameters:
        baseTableName - base table name
        relatedTable - user related table
        relationName - relation name
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addRelationship

        public ExtendedRelation addRelationship​(String baseTableName,
                                                UserTable<? extends UserColumn> relatedTable,
                                                String relationName,
                                                UserMappingTable userMappingTable)
        Adds a relationship between the base and user related table. Creates the user mapping table and related table if needed.
        Parameters:
        baseTableName - base table name
        relatedTable - user related table
        relationName - relation name
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addFeaturesRelationship

        public ExtendedRelation addFeaturesRelationship​(String baseFeaturesTableName,
                                                        String relatedFeaturesTableName,
                                                        String mappingTableName)
        Adds a features relationship between the base feature and related feature table. Creates a default user mapping table if needed.
        Parameters:
        baseFeaturesTableName - base features table name
        relatedFeaturesTableName - related features table name
        mappingTableName - mapping table name
        Returns:
        The relationship that was added
      • addFeaturesRelationship

        public ExtendedRelation addFeaturesRelationship​(String baseFeaturesTableName,
                                                        String relatedFeaturesTableName,
                                                        UserMappingTable userMappingTable)
        Adds a features relationship between the base feature and related feature table. Creates the user mapping table if needed.
        Parameters:
        baseFeaturesTableName - base features table name
        relatedFeaturesTableName - related features table name
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
      • addMediaRelationship

        public ExtendedRelation addMediaRelationship​(String baseTableName,
                                                     MediaTable mediaTable,
                                                     String mappingTableName)
        Adds a media relationship between the base table and user media related table. Creates a default user mapping table and the media table if needed.
        Parameters:
        baseTableName - base table name
        mediaTable - user media table
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
      • addMediaRelationship

        public ExtendedRelation addMediaRelationship​(String baseTableName,
                                                     MediaTable mediaTable,
                                                     UserMappingTable userMappingTable)
        Adds a media relationship between the base table and user media related table. Creates the user mapping table and media table if needed.
        Parameters:
        baseTableName - base table name
        mediaTable - user media table
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
      • addSimpleAttributesRelationship

        public ExtendedRelation addSimpleAttributesRelationship​(String baseTableName,
                                                                SimpleAttributesTable simpleAttributesTable,
                                                                String mappingTableName)
        Adds a simple attributes relationship between the base table and user simple attributes related table. Creates a default user mapping table and the simple attributes table if needed.
        Parameters:
        baseTableName - base table name
        simpleAttributesTable - user simple attributes table
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
      • addSimpleAttributesRelationship

        public ExtendedRelation addSimpleAttributesRelationship​(String baseTableName,
                                                                SimpleAttributesTable simpleAttributesTable,
                                                                UserMappingTable userMappingTable)
        Adds a simple attributes relationship between the base table and user simple attributes related table. Creates the user mapping table and simple attributes table if needed.
        Parameters:
        baseTableName - base table name
        simpleAttributesTable - user simple attributes table
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
      • addAttributesRelationship

        public ExtendedRelation addAttributesRelationship​(String baseTableName,
                                                          String relatedAttributesTableName,
                                                          String mappingTableName)
        Adds an attributes relationship between the base table and related attributes table. Creates a default user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedAttributesTableName - related attributes table name
        mappingTableName - mapping table name
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addAttributesRelationship

        public ExtendedRelation addAttributesRelationship​(String baseTableName,
                                                          String relatedAttributesTableName,
                                                          UserMappingTable userMappingTable)
        Adds an attributes relationship between the base table and related attributes table. Creates the user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedAttributesTableName - related attributes table name
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addAttributesRelationship

        public ExtendedRelation addAttributesRelationship​(String baseTableName,
                                                          AttributesTable attributesTable,
                                                          String mappingTableName)
        Adds an attributes relationship between the base table and user attributes related table. Creates a default user mapping table and the attributes table if needed.
        Parameters:
        baseTableName - base table name
        attributesTable - user attributes table
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addAttributesRelationship

        public ExtendedRelation addAttributesRelationship​(String baseTableName,
                                                          AttributesTable attributesTable,
                                                          UserMappingTable userMappingTable)
        Adds an attributes relationship between the base table and user attributes related table. Creates the user mapping table and an attributes table if needed.
        Parameters:
        baseTableName - base table name
        attributesTable - user attributes table
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addTilesRelationship

        public ExtendedRelation addTilesRelationship​(String baseTableName,
                                                     String relatedTilesTableName,
                                                     String mappingTableName)
        Adds a tiles relationship between the base table and related tiles table. Creates a default user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTilesTableName - related tiles table name
        mappingTableName - mapping table name
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addTilesRelationship

        public ExtendedRelation addTilesRelationship​(String baseTableName,
                                                     String relatedTilesTableName,
                                                     UserMappingTable userMappingTable)
        Adds a tiles relationship between the base table and related tiles table. Creates the user mapping table if needed.
        Parameters:
        baseTableName - base table name
        relatedTilesTableName - related tiles table name
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addTilesRelationship

        public ExtendedRelation addTilesRelationship​(String baseTableName,
                                                     TileTable tileTable,
                                                     String mappingTableName)
        Adds a tiles relationship between the base table and user tiles related table. Creates a default user mapping table and the tile table if needed.
        Parameters:
        baseTableName - base table name
        tileTable - user tile table
        mappingTableName - user mapping table name
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • addTilesRelationship

        public ExtendedRelation addTilesRelationship​(String baseTableName,
                                                     TileTable tileTable,
                                                     UserMappingTable userMappingTable)
        Adds a tiles relationship between the base table and user tiles related table. Creates the user mapping table and a tile table if needed.
        Parameters:
        baseTableName - base table name
        tileTable - user tile table
        userMappingTable - user mapping table
        Returns:
        The relationship that was added
        Since:
        3.2.0
      • createUserMappingTable

        public boolean createUserMappingTable​(String mappingTableName)
        Create a default user mapping table and extension row if either does not exist. When not created, there is no guarantee that an existing table has the same schema as the provided tabled.
        Parameters:
        mappingTableName - user mapping table name
        Returns:
        true if table was created, false if the table already existed
      • createUserMappingTable

        public boolean createUserMappingTable​(UserMappingTable userMappingTable)
        Create a user mapping table and extension row if either does not exist. When not created, there is no guarantee that an existing table has the same schema as the provided tabled.
        Parameters:
        userMappingTable - user mapping table
        Returns:
        true if table was created, false if the table already existed
      • createRelatedTable

        public boolean createRelatedTable​(UserTable<? extends UserColumn> relatedTable)
        Create a user related table if it does not exist. When not created, there is no guarantee that an existing table has the same schema as the provided tabled.
        Parameters:
        relatedTable - user related table
        Returns:
        true if created, false if the table already existed
        Since:
        3.2.0
      • removeRelationship

        public void removeRelationship​(String baseTableName,
                                       String relatedTableName,
                                       RelationType relationType)
        Remove a specific relationship from the GeoPackage
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        relationType - relation type
      • removeRelationship

        public void removeRelationship​(String baseTableName,
                                       String relatedTableName,
                                       String relationAuthor,
                                       String relationName)
        Remove a specific relationship from the GeoPackage
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        relationAuthor - relation author
        relationName - relation name
      • removeRelationship

        public void removeRelationship​(ExtendedRelation extendedRelation)
        Remove a specific relationship from the GeoPackage
        Parameters:
        extendedRelation - extended relation
      • removeRelationship

        public void removeRelationship​(String baseTableName,
                                       String relatedTableName,
                                       String relationName)
        Remove a specific relationship from the GeoPackage
        Parameters:
        baseTableName - base table name
        relatedTableName - related table name
        relationName - relation name
      • removeRelationships

        public void removeRelationships​(String table)
        Remove all relationships that include the table
        Parameters:
        table - base or related table name
        Since:
        3.2.0
      • removeRelationshipsWithMappingTable

        public void removeRelationshipsWithMappingTable​(String mappingTable)
        Remove all relationships with the mapping table
        Parameters:
        mappingTable - mapping table
        Since:
        3.2.0
      • removeExtension

        public void removeExtension()
        Remove all trace of the extension
      • hasRelations

        public boolean hasRelations​(String baseTable,
                                    String relatedTable)
                             throws SQLException
        Determine if has one or more relations matching the base table and related table
        Parameters:
        baseTable - base table name
        relatedTable - related table name
        Returns:
        true if has relations
        Throws:
        SQLException - upon failure
        Since:
        3.2.0
      • getRelations

        public List<ExtendedRelation> getRelations​(String baseTable,
                                                   String relatedTable)
        Get the relations to the base table and related table
        Parameters:
        baseTable - base table name
        relatedTable - related table name
        Returns:
        extended relations
        Since:
        3.2.0
      • hasRelations

        public boolean hasRelations​(String baseTable,
                                    String relatedTable,
                                    String mappingTable)
                             throws SQLException
        Determine if has one or more relations matching the non null provided values
        Parameters:
        baseTable - base table name
        relatedTable - related table name
        mappingTable - mapping table name
        Returns:
        true if has relations
        Throws:
        SQLException - upon failure
        Since:
        3.2.0
      • getRelations

        public List<ExtendedRelation> getRelations​(String baseTable,
                                                   String relatedTable,
                                                   String mappingTable)
                                            throws SQLException
        Get the relations matching the non null provided values
        Parameters:
        baseTable - base table name
        relatedTable - related table name
        mappingTable - mapping table name
        Returns:
        extended relations
        Throws:
        SQLException - upon failure
        Since:
        3.2.0
      • hasRelations

        public boolean hasRelations​(String baseTable,
                                    String relatedTable,
                                    String relation,
                                    String mappingTable)
        Determine if has one or more relations matching the non null provided values
        Parameters:
        baseTable - base table name
        relatedTable - related table name
        relation - relation name
        mappingTable - mapping table name
        Returns:
        true if has relations
        Since:
        3.2.0
      • getRelations

        public List<ExtendedRelation> getRelations​(String baseTable,
                                                   String relatedTable,
                                                   String relation,
                                                   String mappingTable)
                                            throws SQLException
        Get the relations matching the non null provided values
        Parameters:
        baseTable - base table name
        relatedTable - related table name
        relation - relation name
        mappingTable - mapping table name
        Returns:
        extended relations
        Throws:
        SQLException - upon failure
        Since:
        3.2.0
      • hasRelations

        public boolean hasRelations​(String baseTable,
                                    String baseColumn,
                                    String relatedTable,
                                    String relatedColumn,
                                    String relation,
                                    String mappingTable)
        Determine if has one or more relations matching the non null provided values
        Parameters:
        baseTable - base table name
        baseColumn - base primary column name
        relatedTable - related table name
        relatedColumn - related primary column name
        relation - relation name
        mappingTable - mapping table name
        Returns:
        true if has relations
        Since:
        3.2.0
      • getRelations

        public List<ExtendedRelation> getRelations​(String baseTable,
                                                   String baseColumn,
                                                   String relatedTable,
                                                   String relatedColumn,
                                                   String relation,
                                                   String mappingTable)
        Get the relations matching the non null provided values
        Parameters:
        baseTable - base table name
        baseColumn - base primary column name
        relatedTable - related table name
        relatedColumn - related primary column name
        relation - relation name
        mappingTable - mapping table name
        Returns:
        extended relations
        Since:
        3.2.0
      • buildRelationName

        public String buildRelationName​(String author,
                                        String name)
        Build the custom relation name with author
        Parameters:
        author - relation author
        name - base relation name
        Returns:
        custom relation name
      • getBaseTableRelations

        public List<ExtendedRelation> getBaseTableRelations​(String baseTable)
                                                     throws SQLException
        Get the relations to the base table
        Parameters:
        baseTable - base table name
        Returns:
        extended relations
        Throws:
        SQLException - upon failure
        Since:
        6.3.0
      • hasBaseTableRelations

        public boolean hasBaseTableRelations​(String baseTable)
                                      throws SQLException
        Determine if there are relations to the base table
        Parameters:
        baseTable - base table name
        Returns:
        true if has extended relations
        Throws:
        SQLException - upon failure
        Since:
        6.3.0
      • getRelatedTableRelations

        public List<ExtendedRelation> getRelatedTableRelations​(String relatedTable)
                                                        throws SQLException
        Get the relations to the related table
        Parameters:
        relatedTable - related table name
        Returns:
        extended relations
        Throws:
        SQLException - upon failure
        Since:
        6.3.0
      • hasRelatedTableRelations

        public boolean hasRelatedTableRelations​(String relatedTable)
                                         throws SQLException
        Determine if there are relations to the related table
        Parameters:
        relatedTable - related table name
        Returns:
        true if has extended relations
        Throws:
        SQLException - upon failure
        Since:
        6.3.0
      • hasTableRelations

        public boolean hasTableRelations​(String table)
                                  throws SQLException
        Determine if there are relations to the table
        Parameters:
        table - table name
        Returns:
        true if has extended relations
        Throws:
        SQLException - upon failure
        Since:
        6.3.0