Search in sources :

Example 6 with FailedPrecondition

use of liquibase.precondition.FailedPrecondition in project liquibase by liquibase.

the class OrPrecondition method check.

@Override
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException {
    boolean onePassed = false;
    List<FailedPrecondition> failures = new ArrayList<FailedPrecondition>();
    for (Precondition precondition : getNestedPreconditions()) {
        try {
            precondition.check(database, changeLog, changeSet);
            onePassed = true;
            break;
        } catch (PreconditionFailedException e) {
            failures.addAll(e.getFailedPreconditions());
        }
    }
    if (!onePassed) {
        throw new PreconditionFailedException(failures);
    }
}
Also used : FailedPrecondition(liquibase.precondition.FailedPrecondition) Precondition(liquibase.precondition.Precondition) FailedPrecondition(liquibase.precondition.FailedPrecondition) ArrayList(java.util.ArrayList) PreconditionFailedException(liquibase.exception.PreconditionFailedException)

Example 7 with FailedPrecondition

use of liquibase.precondition.FailedPrecondition in project liquibase by liquibase.

the class OrPrecondition method check.

@Override
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet, ChangeExecListener changeExecListener) throws PreconditionFailedException, PreconditionErrorException {
    boolean onePassed = false;
    List<FailedPrecondition> failures = new ArrayList<>();
    for (Precondition precondition : getNestedPreconditions()) {
        try {
            precondition.check(database, changeLog, changeSet, changeExecListener);
            onePassed = true;
            break;
        } catch (PreconditionFailedException e) {
            failures.addAll(e.getFailedPreconditions());
        }
    }
    if (!onePassed) {
        throw new PreconditionFailedException(failures);
    }
}
Also used : FailedPrecondition(liquibase.precondition.FailedPrecondition) Precondition(liquibase.precondition.Precondition) FailedPrecondition(liquibase.precondition.FailedPrecondition) ArrayList(java.util.ArrayList) PreconditionFailedException(liquibase.exception.PreconditionFailedException)

Example 8 with FailedPrecondition

use of liquibase.precondition.FailedPrecondition in project liquibase by liquibase.

the class AndPrecondition method check.

@Override
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet, ChangeExecListener changeExecListener) throws PreconditionFailedException, PreconditionErrorException {
    boolean allPassed = true;
    List<FailedPrecondition> failures = new ArrayList<>();
    for (Precondition precondition : getNestedPreconditions()) {
        try {
            precondition.check(database, changeLog, changeSet, changeExecListener);
        } catch (PreconditionFailedException e) {
            failures.addAll(e.getFailedPreconditions());
            allPassed = false;
            break;
        }
    }
    if (!allPassed) {
        throw new PreconditionFailedException(failures);
    }
}
Also used : FailedPrecondition(liquibase.precondition.FailedPrecondition) Precondition(liquibase.precondition.Precondition) FailedPrecondition(liquibase.precondition.FailedPrecondition) ArrayList(java.util.ArrayList) PreconditionFailedException(liquibase.exception.PreconditionFailedException)

Aggregations

FailedPrecondition (liquibase.precondition.FailedPrecondition)8 PreconditionFailedException (liquibase.exception.PreconditionFailedException)5 ArrayList (java.util.ArrayList)4 ErrorPrecondition (liquibase.precondition.ErrorPrecondition)4 Precondition (liquibase.precondition.Precondition)4 Executor (liquibase.executor.Executor)3 ExecutorService (liquibase.executor.ExecutorService)2 EmptyChange (liquibase.change.core.EmptyChange)1 RawSQLChange (liquibase.change.core.RawSQLChange)1 ChangeSet (liquibase.changelog.ChangeSet)1 PreconditionErrorException (liquibase.exception.PreconditionErrorException)1 LoggingExecutor (liquibase.executor.LoggingExecutor)1 Logger (liquibase.logging.Logger)1 ParsedNodeException (liquibase.parser.core.ParsedNodeException)1