Java Code Examples for mil.nga.geopackage.extension.ExtensionsDao#isTableExists()
The following examples show how to use
mil.nga.geopackage.extension.ExtensionsDao#isTableExists() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 6 votes |
/** * Delete the feature table index * * @return true if index deleted */ public boolean deleteIndex() { boolean deleted = false; ExtensionsDao extensionsDao = geoPackage.getExtensionsDao(); TableIndexDao tableIndexDao = geoPackage.getTableIndexDao(); try { // Delete geometry indices and table index if (tableIndexDao.isTableExists()) { deleted = tableIndexDao.deleteByIdCascade(tableName) > 0; } // Delete the extensions entry if (extensionsDao.isTableExists()) { deleted = extensionsDao.deleteByExtension(EXTENSION_NAME, tableName) > 0 || deleted; } } catch (SQLException e) { throw new GeoPackageException( "Failed to delete Table Index. GeoPackage: " + geoPackage.getName() + ", Table: " + tableName, e); } return deleted; }
Example 2
Source File: TileTableScaling.java From geopackage-core-java with MIT License | 6 votes |
/** * Delete the tile table scaling for the tile table * * @return true if deleted */ public boolean delete() { boolean deleted = false; ExtensionsDao extensionsDao = geoPackage.getExtensionsDao(); try { if (tileScalingDao.isTableExists()) { deleted = tileScalingDao.deleteById(tableName) > 0; } if (extensionsDao.isTableExists()) { deleted = extensionsDao.deleteByExtension(EXTENSION_NAME, tableName) > 0 || deleted; } } catch (SQLException e) { throw new GeoPackageException( "Failed to delete tile table scaling for GeoPackage: " + geoPackage.getName() + ", Table: " + tableName, e); } return deleted; }
Example 3
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public boolean createExtensionsTable() { verifyWritable(); boolean created = false; ExtensionsDao dao = getExtensionsDao(); try { if (!dao.isTableExists()) { created = tableCreator.createExtensions() > 0; } } catch (SQLException e) { throw new GeoPackageException( "Failed to check if " + Extensions.class.getSimpleName() + " table exists and create it", e); } return created; }
Example 4
Source File: ExtensionsUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); // Create new extensions String tableName = "CREATE_TABLE_NAME"; String columnName = "CREATE_COLUMN_NAME"; String author = "nga"; String extension = "create_extension"; String definition = "definition"; ExtensionScopeType scopeType = ExtensionScopeType.READ_WRITE; Extensions extensions = new Extensions(); extensions.setTableName(tableName); extensions.setColumnName(columnName); extensions.setExtensionName(author, extension); extensions.setDefinition(definition); extensions.setScope(scopeType); dao.create(extensions); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); // Verify saved extensions Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNotNull(queryExtensions); TestCase.assertEquals(tableName, queryExtensions.getTableName()); TestCase.assertEquals(columnName, queryExtensions.getColumnName()); TestCase.assertEquals(author + Extensions.EXTENSION_NAME_DIVIDER + extension, queryExtensions.getExtensionName()); TestCase.assertEquals(author, queryExtensions.getAuthor()); TestCase.assertEquals(extension, queryExtensions.getExtensionNameNoAuthor()); TestCase.assertEquals(definition, queryExtensions.getDefinition()); TestCase.assertEquals(scopeType, queryExtensions.getScope()); } }
Example 5
Source File: ExtensionsUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { List<Extensions> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata int random = (int) (Math.random() * results.size()); Extensions extensions = results.get(random); // Delete the extensions dao.delete(extensions); // Verify deleted Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNull(queryExtensions); // Choose prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata random = (int) (Math.random() * results.size()); extensions = results.get(random); // Find which metadata to delete QueryBuilder<Extensions, Void> qb = dao.queryBuilder(); qb.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedQuery<Extensions> query = qb.prepare(); List<Extensions> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<Extensions, Void> db = dao.deleteBuilder(); db.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedDelete<Extensions> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }
Example 6
Source File: ExtensionsUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); // Create new extensions String tableName = "CREATE_TABLE_NAME"; String columnName = "CREATE_COLUMN_NAME"; String author = "nga"; String extension = "create_extension"; String definition = "definition"; ExtensionScopeType scopeType = ExtensionScopeType.READ_WRITE; Extensions extensions = new Extensions(); extensions.setTableName(tableName); extensions.setColumnName(columnName); extensions.setExtensionName(author, extension); extensions.setDefinition(definition); extensions.setScope(scopeType); dao.create(extensions); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); // Verify saved extensions Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNotNull(queryExtensions); TestCase.assertEquals(tableName, queryExtensions.getTableName()); TestCase.assertEquals(columnName, queryExtensions.getColumnName()); TestCase.assertEquals(author + Extensions.EXTENSION_NAME_DIVIDER + extension, queryExtensions.getExtensionName()); TestCase.assertEquals(author, queryExtensions.getAuthor()); TestCase.assertEquals(extension, queryExtensions.getExtensionNameNoAuthor()); TestCase.assertEquals(definition, queryExtensions.getDefinition()); TestCase.assertEquals(scopeType, queryExtensions.getScope()); } }
Example 7
Source File: ExtensionsUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { List<Extensions> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata int random = (int) (Math.random() * results.size()); Extensions extensions = results.get(random); // Delete the extensions dao.delete(extensions); // Verify deleted Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNull(queryExtensions); // Choose prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata random = (int) (Math.random() * results.size()); extensions = results.get(random); // Find which metadata to delete QueryBuilder<Extensions, Void> qb = dao.queryBuilder(); qb.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedQuery<Extensions> query = qb.prepare(); List<Extensions> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<Extensions, Void> db = dao.deleteBuilder(); db.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedDelete<Extensions> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }