use of liquibase.statement.core.RuntimeStatement in project liquibase by liquibase.
the class ExecuteShellCommandChange method generateStatements.
@Override
public SqlStatement[] generateStatements(final Database database) {
boolean shouldRun = true;
if (os != null && os.size() > 0) {
String currentOS = System.getProperty("os.name");
if (!os.contains(currentOS)) {
shouldRun = false;
LogFactory.getLogger().info("Not executing on os " + currentOS + " when " + os + " was specified");
}
}
// check if running under not-executed mode (logging output)
boolean nonExecutedMode = false;
Executor executor = ExecutorService.getInstance().getExecutor(database);
if (executor instanceof LoggingExecutor) {
nonExecutedMode = true;
}
this.finalCommandArray = createFinalCommandArray(database);
if (shouldRun && !nonExecutedMode) {
return new SqlStatement[] { new RuntimeStatement() {
@Override
public Sql[] generate(Database database) {
try {
executeCommand(database);
} catch (Exception e) {
throw new UnexpectedLiquibaseException("Error executing command: " + e.getLocalizedMessage(), e);
}
return null;
}
} };
}
if (nonExecutedMode) {
try {
return new SqlStatement[] { new CommentStatement(getCommandString()) };
} finally {
nonExecutedCleanup();
}
}
return new SqlStatement[0];
}
Aggregations