private void initialize() { if (!initialized) { isActionSupported = dbCtx.doesTableExist("actions"); isWayBboxSupported = dbCtx.doesColumnExist("ways", "bbox"); isWayLinestringSupported = dbCtx.doesColumnExist("ways", "linestring"); initialized = true; } }
/** * Truncates all data from the database. */ public void run() { try { schemaVersionValidator.validateVersion(PostgreSqlVersionConstants.SCHEMA_VERSION); LOG.fine("Truncating tables."); for (int i = 0; i < SQL_TABLE_NAMES.length; i++) { if (dbCtx.doesTableExist(SQL_TABLE_NAMES[i])) { LOG.finer("Truncating table " + SQL_TABLE_NAMES[i] + "."); dbCtx.executeStatement("TRUNCATE " + SQL_TABLE_NAMES[i]); } else { LOG.finer("Skipping table " + SQL_TABLE_NAMES[i] + " which doesn't exist in the current schema."); } } LOG.fine("Committing changes."); dbCtx.commit(); LOG.fine("Vacuuming database."); dbCtx.setAutoCommit(true); dbCtx.executeStatement("VACUUM ANALYZE"); LOG.fine("Complete."); } finally { dbCtx.close(); } } }