/** * Utility method for retrieving the login credentials for a database connection. * * @param taskConfig Contains all information required to instantiate and configure the task. * @return The value of the argument. */ protected DatabasePreferences getDatabasePreferences(TaskConfiguration taskConfig) { DatabasePreferences preferences; // Create a new preferences object with default values. preferences = new DatabasePreferences(DatabaseConstants.TASK_DEFAULT_VALIDATE_SCHEMA_VERSION, DatabaseConstants.TASK_ALLOW_INCORRECT_SCHEMA_VERSION); // Update the preferences with any explicit arguments provided on the // command line. preferences.setValidateSchemaVersion(getBooleanArgument(taskConfig, DatabaseConstants.TASK_ARG_VALIDATE_SCHEMA_VERSION, preferences.getValidateSchemaVersion())); preferences .setAllowIncorrectSchemaVersion(getBooleanArgument(taskConfig, DatabaseConstants.TASK_ARG_ALLOW_INCORRECT_SCHEMA_VERSION, preferences .getAllowIncorrectSchemaVersion())); return preferences; } }
if (preferences.getValidateSchemaVersion()) { try (DatabaseContext dbCtx = new DatabaseContext(credentials)) { Set<String> actualMigrationSet; if (preferences.getAllowIncorrectSchemaVersion()) { log.warning(errorMessage.toString()); } else {
/** * Performs the database lookup and validates the expected version. * * @param expectedVersion * The expected version number. */ private void validateDBVersion(int expectedVersion) { if (preferences.getValidateSchemaVersion()) { int dbVersion; dbVersion = jdbcTemplate.queryForObject(SELECT_SQL, Integer.class); if (dbVersion != expectedVersion) { throw new OsmosisRuntimeException( "The database schema version of " + dbVersion + " does not match the expected version of " + expectedVersion + "." ); } } } }
/** * Provides a fully configured set of database preferences based on the configuration. * * @return The database preferences. */ public DatabasePreferences getDatabasePreferences() { return new DatabasePreferences(getValidateSchemaVersion(), getAllowIncorrectSchemaVersion()); } }
if (preferences.getValidateSchemaVersion()) { try (DatabaseContext dbCtx = new DatabaseContext(credentials)) { Set<String> actualMigrationSet; if (preferences.getAllowIncorrectSchemaVersion()) { log.warning(errorMessage.toString()); } else {
if (preferences.getValidateSchemaVersion()) { try { Statement statement;
/** * Utility method for retrieving the login credentials for a database connection. * * @param taskConfig Contains all information required to instantiate and configure the task. * @return The value of the argument. */ protected DatabasePreferences getDatabasePreferences(TaskConfiguration taskConfig) { DatabasePreferences preferences; // Create a new preferences object with default values. preferences = new DatabasePreferences(DatabaseConstants.TASK_DEFAULT_VALIDATE_SCHEMA_VERSION, DatabaseConstants.TASK_ALLOW_INCORRECT_SCHEMA_VERSION); // Update the preferences with any explicit arguments provided on the // command line. preferences.setValidateSchemaVersion(getBooleanArgument(taskConfig, DatabaseConstants.TASK_ARG_VALIDATE_SCHEMA_VERSION, preferences.getValidateSchemaVersion())); preferences .setAllowIncorrectSchemaVersion(getBooleanArgument(taskConfig, DatabaseConstants.TASK_ARG_ALLOW_INCORRECT_SCHEMA_VERSION, preferences .getAllowIncorrectSchemaVersion())); return preferences; } }