mil.nga.geopackage.db.master.SQLiteMasterType Java Examples

The following examples show how to use mil.nga.geopackage.db.master.SQLiteMasterType. 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: AlterTableUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the expected index count
 *
 * @param db        connection
 * @param tableName table name
 * @return index count
 */
private static int indexCount(GeoPackageCoreConnection db,
                              String tableName) {
    SQLiteMasterQuery indexQuery = SQLiteMasterQuery.createAnd();
    indexQuery.add(SQLiteMasterColumn.TBL_NAME, tableName);
    indexQuery.addIsNotNull(SQLiteMasterColumn.SQL);
    int count = SQLiteMaster.count(db, SQLiteMasterType.INDEX, indexQuery);
    return count;
}
 
Example #2
Source File: AlterTableUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Test the table schema counts
 *
 * @param db           connection
 * @param tableName    table name
 * @param tableCount   table count
 * @param indexCount   index count
 * @param triggerCount trigger count
 * @param viewCount    view count
 */
private static void testTableCounts(GeoPackageConnection db,
                                    String tableName, int tableCount, int indexCount, int triggerCount,
                                    int viewCount) {
    TestCase.assertEquals(tableCount,
            SQLiteMaster.count(db, SQLiteMasterType.TABLE, tableName));
    TestCase.assertEquals(indexCount, indexCount(db, tableName));
    TestCase.assertEquals(triggerCount,
            SQLiteMaster.count(db, SQLiteMasterType.TRIGGER, tableName));
    TestCase.assertEquals(viewCount,
            SQLiteMaster.countViewsOnTable(db, tableName));
}
 
Example #3
Source File: SQLExec.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Build a SQLite Master table query
 * 
 * @param tableName
 *            true to include table name
 * @param type
 *            SQLite Master type
 * @param name
 *            name LIKE value
 * @return SQL
 */
private static String buildSqlMasterQuery(boolean tableName,
		SQLiteMasterType type, String name) {

	StringBuilder sql = new StringBuilder("SELECT ");
	sql.append(SQLiteMasterColumn.NAME.name().toLowerCase());
	if (tableName) {
		sql.append(", ");
		sql.append(SQLiteMasterColumn.TBL_NAME.name().toLowerCase());
	}
	sql.append(" FROM ");
	sql.append(SQLiteMaster.TABLE_NAME);
	sql.append(" WHERE ");
	sql.append(SQLiteMasterColumn.TYPE.name().toLowerCase());
	sql.append(" = '");
	sql.append(type.name().toLowerCase());
	sql.append("' AND ");
	sql.append(SQLiteMasterColumn.NAME.name().toLowerCase());
	sql.append(" NOT LIKE 'sqlite_%'");

	if (name != null) {
		name = name.trim();
		if (!name.isEmpty()) {
			sql.append(" AND ");
			sql.append(SQLiteMasterColumn.NAME.name().toLowerCase());
			sql.append(" LIKE ");
			sql.append(CoreSQLUtils.quoteWrap(name));
		}
	}

	sql.append(" ORDER BY ");
	sql.append(SQLiteMasterColumn.NAME.name().toLowerCase());
	sql.append(";");

	return sql.toString();
}
 
Example #4
Source File: AlterTableUtils.java    From geopackage-java with MIT License 3 votes vote down vote up
/**
 * Get the expected index count
 * 
 * @param db
 *            connection
 * @param tableName
 *            table name
 * @return index count
 */
private static int indexCount(GeoPackageCoreConnection db,
		String tableName) {
	SQLiteMasterQuery indexQuery = SQLiteMasterQuery.createAnd();
	indexQuery.add(SQLiteMasterColumn.TBL_NAME, tableName);
	indexQuery.addIsNotNull(SQLiteMasterColumn.SQL);
	int count = SQLiteMaster.count(db, SQLiteMasterType.INDEX, indexQuery);
	return count;
}
 
Example #5
Source File: AlterTableUtils.java    From geopackage-java with MIT License 3 votes vote down vote up
/**
 * Test the table schema counts
 * 
 * @param db
 *            connection
 * @param tableName
 *            table name
 * @param tableCount
 *            table count
 * @param indexCount
 *            index count
 * @param triggerCount
 *            trigger count
 * @param viewCount
 *            view count
 */
private static void testTableCounts(GeoPackageConnection db,
		String tableName, int tableCount, int indexCount, int triggerCount,
		int viewCount) {
	TestCase.assertEquals(tableCount,
			SQLiteMaster.count(db, SQLiteMasterType.TABLE, tableName));
	TestCase.assertEquals(indexCount, indexCount(db, tableName));
	TestCase.assertEquals(triggerCount,
			SQLiteMaster.count(db, SQLiteMasterType.TRIGGER, tableName));
	TestCase.assertEquals(viewCount,
			SQLiteMaster.countViewsOnTable(db, tableName));
}
 
Example #6
Source File: GeoPackageCoreConnection.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Check if the table exists
 * 
 * @param tableName
 *            table name
 * @return true if exists
 */
public boolean tableExists(String tableName) {
	return SQLiteMaster.count(this, SQLiteMasterType.TABLE, tableName) > 0;
}