/** * Adds a media relationship between the base table and user media related * table. Creates the user mapping table and media table if needed. * * @param baseTableName * base table name * @param mediaTable * user media table * @param userMappingTable * user mapping table * @return The relationship that was added */ public ExtendedRelation addMediaRelationship(String baseTableName, MediaTable mediaTable, UserMappingTable userMappingTable) { return addRelationship(baseTableName, mediaTable, userMappingTable); }
/** * Adds a relationship between the base and related table. Creates the user * mapping table if needed. * * @param baseTableName * base table name * @param relatedTableName * related table name * @param userMappingTable * user mapping table * @param relationAuthor * relation author * @param relationName * relation name * @return The relationship that was added */ public ExtendedRelation addRelationship(String baseTableName, String relatedTableName, UserMappingTable userMappingTable, String relationAuthor, String relationName) { return addRelationship(baseTableName, relatedTableName, userMappingTable, buildRelationName(relationAuthor, relationName)); }
/** * {@inheritDoc} */ @Override public GeoPackage getGeoPackage() { return (GeoPackage) super.getGeoPackage(); }
/** * Remove a specific relationship from the GeoPackage * * @param baseTableName * base table name * @param relatedTableName * related table name * @param relationAuthor * relation author * @param relationName * relation name */ public void removeRelationship(String baseTableName, String relatedTableName, String relationAuthor, String relationName) { removeRelationship(baseTableName, relatedTableName, buildRelationName(relationAuthor, relationName)); }
validateRelationship(baseTableName, relatedTableName, relationName); createUserMappingTable(userMappingTable); extendedRelation.setBaseTableName(baseTableName); extendedRelation .setBasePrimaryColumn(getPrimaryKeyColumnName(baseTableName)); extendedRelation.setRelatedTableName(relatedTableName); extendedRelation .setRelatedPrimaryColumn(getPrimaryKeyColumnName(relatedTableName)); extendedRelation.setMappingTableName(userMappingTable.getTableName()); extendedRelation.setRelationName(relationName);
/** * Adds a relationship between the base and user related table. Creates the * user mapping table and related table if needed. * * @param baseTableName * base table name * @param relatedTable * user related table * @param userMappingTable * user mapping table * @return The relationship that was added */ public ExtendedRelation addRelationship(String baseTableName, UserRelatedTable relatedTable, UserMappingTable userMappingTable) { // Create the related table if needed createRelatedTable(relatedTable); return addRelationship(baseTableName, relatedTable.getTableName(), userMappingTable, relatedTable.getRelationName()); }
/** * Get or create the extension * * @param mappingTable * mapping table name * @return extension */ private Extensions getOrCreate(String mappingTable) { getOrCreate(); Extensions extension = getOrCreate(EXTENSION_NAME, mappingTable, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
/** * Determine if the GeoPackage has the extension * * @return true if has extension */ public boolean has() { return has(EXTENSION_NAME, ExtendedRelation.TABLE_NAME, null); }
/** * Remove a specific relationship from the GeoPackage * * @param baseTableName * base table name * @param relatedTableName * related table name * @param relationType * relation type */ public void removeRelationship(String baseTableName, String relatedTableName, RelationType relationType) { removeRelationship(baseTableName, relatedTableName, relationType.getName()); }
/** * 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. * * @param mappingTableName * user mapping table name * @return true if table was created, false if the table already existed */ public boolean createUserMappingTable(String mappingTableName) { UserMappingTable userMappingTable = UserMappingTable .create(mappingTableName); return createUserMappingTable(userMappingTable); }
/** * Validate that the relation name is valid between the base and related * table * * @param baseTableName * base table name * @param relatedTableName * related table name * @param relationName * relation name */ private void validateRelationship(String baseTableName, String relatedTableName, String relationName) { // Verify the base and related tables exist if (!geoPackage.isTable(baseTableName)) { throw new GeoPackageException( "Base Relationship table does not exist: " + baseTableName + ", Relation: " + relationName); } if (!geoPackage.isTable(relatedTableName)) { throw new GeoPackageException( "Related Relationship table does not exist: " + relatedTableName + ", Relation: " + relationName); } // Verify spec defined relation types RelationType relationType = RelationType.fromName(relationName); if (relationType != null) { validateRelationship(baseTableName, relatedTableName, relationType); } }
/** * Get or create the extension * * @return extension */ private Extensions getOrCreate() { // Create table geoPackage.createExtendedRelationsTable(); Extensions extension = getOrCreate(EXTENSION_NAME, ExtendedRelation.TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
/** * Remove a specific relationship from the GeoPackage * * @param extendedRelation * extended relation */ public void removeRelationship(ExtendedRelation extendedRelation) { removeRelationship(extendedRelation.getBaseTableName(), extendedRelation.getRelatedTableName(), extendedRelation.getRelationName()); }
/** * Adds a features relationship between the base feature and related feature * table. Creates the user mapping table if needed. * * @param baseFeaturesTableName * base features table name * @param relatedFeaturesTableName * related features table name * @param userMappingTable * user mapping table * @return The relationship that was added */ public ExtendedRelation addFeaturesRelationship( String baseFeaturesTableName, String relatedFeaturesTableName, UserMappingTable userMappingTable) { return addRelationship(baseFeaturesTableName, relatedFeaturesTableName, userMappingTable, RelationType.FEATURES); }
/** * Adds a relationship between the base and related table. Creates a default * user mapping table if needed. * * @param baseTableName * base table name * @param relatedTableName * related table name * @param mappingTableName * mapping table name * @param relationAuthor * relation author * @param relationName * relation name * @return The relationship that was added */ public ExtendedRelation addRelationship(String baseTableName, String relatedTableName, String mappingTableName, String relationAuthor, String relationName) { return addRelationship(baseTableName, relatedTableName, mappingTableName, buildRelationName(relationAuthor, relationName)); }
/** * 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. * * @param userMappingTable * user mapping table * @return true if table was created, false if the table already existed */ public boolean createUserMappingTable(UserMappingTable userMappingTable) { boolean created = false; String userMappingTableName = userMappingTable.getTableName(); getOrCreate(userMappingTableName); if (!geoPackage.isTable(userMappingTableName)) { geoPackage.createUserTable(userMappingTable); created = true; } return created; }
/** * 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. * * @param baseTableName * base table name * @param mediaTable * user media table * @param mappingTableName * user mapping table name * @return The relationship that was added */ public ExtendedRelation addMediaRelationship(String baseTableName, MediaTable mediaTable, String mappingTableName) { return addRelationship(baseTableName, mediaTable, mappingTableName); }
/** * Adds a features relationship between the base feature and related feature * table. Creates a default user mapping table if needed. * * @param baseFeaturesTableName * base features table name * @param relatedFeaturesTableName * related features table name * @param mappingTableName * mapping table name * @return The relationship that was added */ public ExtendedRelation addFeaturesRelationship( String baseFeaturesTableName, String relatedFeaturesTableName, String mappingTableName) { return addRelationship(baseFeaturesTableName, relatedFeaturesTableName, mappingTableName, RelationType.FEATURES); }
/** * 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. * * @param baseTableName * base table name * @param simpleAttributesTable * user simple attributes table * @param mappingTableName * user mapping table name * @return The relationship that was added */ public ExtendedRelation addSimpleAttributesRelationship( String baseTableName, SimpleAttributesTable simpleAttributesTable, String mappingTableName) { return addRelationship(baseTableName, simpleAttributesTable, mappingTableName); }