Search in sources :

Example 1 with Precondition

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

the class AndPrecondition method check.

@Override
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException {
    boolean allPassed = true;
    List<FailedPrecondition> failures = new ArrayList<FailedPrecondition>();
    for (Precondition precondition : getNestedPreconditions()) {
        try {
            precondition.check(database, changeLog, changeSet);
        } 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)

Example 2 with Precondition

use of liquibase.precondition.Precondition 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)

Aggregations

ArrayList (java.util.ArrayList)2 PreconditionFailedException (liquibase.exception.PreconditionFailedException)2 FailedPrecondition (liquibase.precondition.FailedPrecondition)2 Precondition (liquibase.precondition.Precondition)2