All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
liquibase.changelog.visitor.UpdateVisitor Maven / Gradle / Ivy
package liquibase.changelog.visitor;
import liquibase.changelog.ChangeSet;
import liquibase.changelog.ChangeSet.ExecType;
import liquibase.changelog.ChangeSet.RunStatus;
import liquibase.changelog.DatabaseChangeLog;
import liquibase.changelog.filter.ChangeSetFilterResult;
import liquibase.database.Database;
import liquibase.database.ObjectQuotingStrategy;
import liquibase.exception.LiquibaseException;
import liquibase.exception.MigrationFailedException;
import liquibase.logging.LogService;
import liquibase.logging.LogType;
import liquibase.logging.Logger;
import java.util.Set;
public class UpdateVisitor implements ChangeSetVisitor {
private Database database;
private Logger log = LogService.getLog(getClass());
private ChangeExecListener execListener;
/**
* @deprecated - please use the constructor with ChangeExecListener, which can be null.
*/
@Deprecated
public UpdateVisitor(Database database) {
this.database = database;
}
public UpdateVisitor(Database database, ChangeExecListener execListener) {
this(database);
this.execListener = execListener;
}
@Override
public Direction getDirection() {
return ChangeSetVisitor.Direction.FORWARD;
}
@Override
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database,
Set filterResults) throws LiquibaseException {
ChangeSet.RunStatus runStatus = this.database.getRunStatus(changeSet);
log.debug(LogType.LOG, "Running Changeset:" + changeSet);
fireWillRun(changeSet, databaseChangeLog, database, runStatus);
ExecType execType = null;
ObjectQuotingStrategy previousStr = this.database.getObjectQuotingStrategy();
try {
execType = changeSet.execute(databaseChangeLog, execListener, this.database);
} catch (MigrationFailedException e) {
fireRunFailed(changeSet, databaseChangeLog, database, e);
throw e;
}
if (!runStatus.equals(ChangeSet.RunStatus.NOT_RAN)) {
execType = ChangeSet.ExecType.RERAN;
}
fireRan(changeSet, databaseChangeLog, database, execType);
// reset object quoting strategy after running changeset
this.database.setObjectQuotingStrategy(previousStr);
this.database.markChangeSetExecStatus(changeSet, execType);
this.database.commit();
}
protected void fireRunFailed(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, MigrationFailedException e) {
if (execListener != null) {
execListener.runFailed(changeSet, databaseChangeLog, database, e);
}
}
protected void fireWillRun(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database2, RunStatus runStatus) {
if (execListener != null) {
execListener.willRun(changeSet, databaseChangeLog, database, runStatus);
}
}
protected void fireRan(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database2, ExecType execType) {
if (execListener != null) {
execListener.ran(changeSet, databaseChangeLog, database, execType);
}
}
}