1 | |
package liquibase.precondition.core; |
2 | |
|
3 | |
import liquibase.changelog.DatabaseChangeLog; |
4 | |
import liquibase.changelog.ChangeSet; |
5 | |
import liquibase.database.Database; |
6 | |
import liquibase.exception.PreconditionErrorException; |
7 | |
import liquibase.exception.PreconditionFailedException; |
8 | |
import liquibase.exception.ValidationErrors; |
9 | |
import liquibase.exception.Warnings; |
10 | |
import liquibase.precondition.Precondition; |
11 | |
import liquibase.precondition.PreconditionLogic; |
12 | |
|
13 | |
import java.util.ArrayList; |
14 | |
import java.util.List; |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | 10 | public class OrPrecondition extends PreconditionLogic { |
20 | |
|
21 | |
public Warnings warn(Database database) { |
22 | 0 | return new Warnings(); |
23 | |
} |
24 | |
|
25 | |
public ValidationErrors validate(Database database) { |
26 | 0 | return new ValidationErrors(); |
27 | |
} |
28 | |
|
29 | |
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) |
30 | |
throws PreconditionFailedException, PreconditionErrorException { |
31 | 0 | boolean onePassed = false; |
32 | 0 | List<FailedPrecondition> failures = new ArrayList<FailedPrecondition>(); |
33 | 0 | for (Precondition precondition : getNestedPreconditions()) { |
34 | |
try { |
35 | 0 | precondition.check(database, changeLog, changeSet); |
36 | 0 | onePassed = true; |
37 | 0 | break; |
38 | 0 | } catch (PreconditionFailedException e) { |
39 | 0 | failures.addAll(e.getFailedPreconditions()); |
40 | 0 | } |
41 | |
} |
42 | 0 | if (!onePassed) { |
43 | 0 | throw new PreconditionFailedException(failures); |
44 | |
} |
45 | 0 | } |
46 | |
|
47 | |
public String getName() { |
48 | 10 | return "or"; |
49 | |
} |
50 | |
} |