liquibase.executor.AbstractExecutor Maven / Gradle / Ivy
package liquibase.executor;
import liquibase.change.Change;
import liquibase.database.Database;
import liquibase.exception.DatabaseException;
import liquibase.sql.Sql;
import liquibase.sql.visitor.SqlVisitor;
import liquibase.sqlgenerator.SqlGeneratorFactory;
import liquibase.statement.SqlStatement;
import java.util.ArrayList;
import java.util.List;
/**
* Code common to all Executor services / blueprint for Executor service classes.
*/
public abstract class AbstractExecutor implements Executor {
protected Database database;
public void setDatabase(Database database) {
this.database = database;
}
protected String[] applyVisitors(SqlStatement statement, List sqlVisitors) throws DatabaseException {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, database);
if (sql == null) {
return new String[0];
}
String[] returnSql = new String[sql.length];
for (int i=0; i());
}
@Override
public void execute(Change change, List sqlVisitors) throws DatabaseException {
SqlStatement[] sqlStatements = change.generateStatements(database);
if (sqlStatements != null) {
for (SqlStatement statement : sqlStatements) {
execute(statement, sqlVisitors);
}
}
}
}