1 |
|
package liquibase.changelog; |
2 |
|
|
3 |
|
import liquibase.changelog.filter.ContextChangeSetFilter; |
4 |
|
import liquibase.changelog.filter.DbmsChangeSetFilter; |
5 |
|
import liquibase.changelog.visitor.ValidatingVisitor; |
6 |
|
import liquibase.database.Database; |
7 |
|
import liquibase.exception.LiquibaseException; |
8 |
|
import liquibase.exception.ValidationFailedException; |
9 |
|
import liquibase.logging.LogFactory; |
10 |
|
import liquibase.precondition.Conditional; |
11 |
|
import liquibase.precondition.core.PreconditionContainer; |
12 |
|
|
13 |
|
import java.util.ArrayList; |
14 |
|
import java.util.List; |
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
|
|
| 69% |
Uncovered Elements: 22 (71) |
Complexity: 29 |
Complexity Density: 0.74 |
|
19 |
|
public class DatabaseChangeLog implements Comparable<DatabaseChangeLog>, Conditional { |
20 |
|
private PreconditionContainer preconditionContainer = new PreconditionContainer(); |
21 |
|
private String physicalFilePath; |
22 |
|
private String logicalFilePath; |
23 |
|
|
24 |
|
private List<ChangeSet> changeSets = new ArrayList<ChangeSet>(); |
25 |
|
private ChangeLogParameters changeLogParameters; |
26 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
27 |
34
|
public DatabaseChangeLog() {... |
28 |
|
} |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
30 |
2
|
public DatabaseChangeLog(String physicalFilePath) {... |
31 |
2
|
this.physicalFilePath = physicalFilePath; |
32 |
|
} |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
38
|
public PreconditionContainer getPreconditions() {... |
35 |
38
|
return preconditionContainer; |
36 |
|
} |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
38 |
2
|
public void setPreconditions(PreconditionContainer precond) {... |
39 |
2
|
preconditionContainer = precond; |
40 |
|
} |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
0
|
public ChangeLogParameters getChangeLogParameters() {... |
43 |
0
|
return changeLogParameters; |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
16
|
public void setChangeLogParameters(ChangeLogParameters changeLogParameters) {... |
47 |
16
|
this.changeLogParameters = changeLogParameters; |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
31
|
public String getPhysicalFilePath() {... |
51 |
31
|
return physicalFilePath; |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
17
|
public void setPhysicalFilePath(String physicalFilePath) {... |
55 |
17
|
this.physicalFilePath = physicalFilePath; |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
58 |
10
|
public String getLogicalFilePath() {... |
59 |
10
|
String returnPath = logicalFilePath; |
60 |
10
|
if (logicalFilePath == null) { |
61 |
9
|
returnPath = physicalFilePath; |
62 |
|
} |
63 |
10
|
return returnPath.replaceAll("\\\\", "/"); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
16
|
public void setLogicalFilePath(String logicalFilePath) {... |
67 |
16
|
this.logicalFilePath = logicalFilePath; |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
70 |
29
|
public String getFilePath() {... |
71 |
29
|
if (logicalFilePath == null) { |
72 |
28
|
return physicalFilePath; |
73 |
|
} else { |
74 |
1
|
return logicalFilePath; |
75 |
|
} |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
4
|
@Override... |
79 |
|
public String toString() { |
80 |
4
|
return getFilePath(); |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
0
|
public int compareTo(DatabaseChangeLog o) {... |
84 |
0
|
return getFilePath().compareTo(o.getFilePath()); |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
87 |
0
|
public ChangeSet getChangeSet(String path, String author, String id) {... |
88 |
0
|
for (ChangeSet changeSet : changeSets) { |
89 |
0
|
if (changeSet.getFilePath().equalsIgnoreCase(path) && changeSet.getAuthor().equalsIgnoreCase(author) |
90 |
|
&& changeSet.getId().equalsIgnoreCase(id)) { |
91 |
0
|
return changeSet; |
92 |
|
} |
93 |
|
} |
94 |
|
|
95 |
0
|
return null; |
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
90
|
public List<ChangeSet> getChangeSets() {... |
99 |
90
|
return changeSets; |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
64
|
public void addChangeSet(ChangeSet changeSet) {... |
103 |
64
|
this.changeSets.add(changeSet); |
104 |
|
} |
105 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
106 |
1
|
@Override... |
107 |
|
public boolean equals(Object o) { |
108 |
1
|
if (this == o) |
109 |
0
|
return true; |
110 |
1
|
if (o == null || getClass() != o.getClass()) |
111 |
0
|
return false; |
112 |
|
|
113 |
1
|
DatabaseChangeLog that = (DatabaseChangeLog) o; |
114 |
|
|
115 |
1
|
return getFilePath().equals(that.getFilePath()); |
116 |
|
|
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
0
|
@Override... |
120 |
|
public int hashCode() { |
121 |
0
|
return getFilePath().hashCode(); |
122 |
|
} |
123 |
|
|
|
|
| 70% |
Uncovered Elements: 3 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
124 |
2
|
public void validate(Database database, String... contexts) throws LiquibaseException {... |
125 |
|
|
126 |
2
|
ChangeLogIterator logIterator = new ChangeLogIterator(this, new DbmsChangeSetFilter(database), |
127 |
|
new ContextChangeSetFilter(contexts)); |
128 |
|
|
129 |
2
|
ValidatingVisitor validatingVisitor = new ValidatingVisitor(database.getRanChangeSetList()); |
130 |
2
|
validatingVisitor.validate(database, this); |
131 |
2
|
logIterator.run(validatingVisitor, database); |
132 |
|
|
133 |
2
|
for (String message : validatingVisitor.getWarnings().getMessages()) { |
134 |
0
|
LogFactory.getLogger().warning(message); |
135 |
|
} |
136 |
|
|
137 |
2
|
if (!validatingVisitor.validationPassed()) { |
138 |
0
|
throw new ValidationFailedException(validatingVisitor); |
139 |
|
} |
140 |
|
} |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
0
|
public ChangeSet getChangeSet(RanChangeSet ranChangeSet) {... |
143 |
0
|
return getChangeSet(ranChangeSet.getChangeLog(), ranChangeSet.getAuthor(), ranChangeSet.getId()); |
144 |
|
} |
145 |
|
} |