Clover Coverage Report - Liquibase Core 2.0.3-SNAPSHOT
Coverage timestamp: Sat Aug 6 2011 11:33:15 EDT
../../img/srcFileCovDistChart7.png 19% of files have more coverage
39   145   29   1.95
12   110   0.74   20
20     1.45  
1    
 
  DatabaseChangeLog       Line # 19 39 0% 29 22 69% 0.69014084
 
  (27)
 
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    * Encapsulates the information stored in the change log XML file.
18    */
 
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   
 
27  34 toggle public DatabaseChangeLog() {
28    }
29   
 
30  2 toggle public DatabaseChangeLog(String physicalFilePath) {
31  2 this.physicalFilePath = physicalFilePath;
32    }
33   
 
34  38 toggle public PreconditionContainer getPreconditions() {
35  38 return preconditionContainer;
36    }
37   
 
38  2 toggle public void setPreconditions(PreconditionContainer precond) {
39  2 preconditionContainer = precond;
40    }
41   
 
42  0 toggle public ChangeLogParameters getChangeLogParameters() {
43  0 return changeLogParameters;
44    }
45   
 
46  16 toggle public void setChangeLogParameters(ChangeLogParameters changeLogParameters) {
47  16 this.changeLogParameters = changeLogParameters;
48    }
49   
 
50  31 toggle public String getPhysicalFilePath() {
51  31 return physicalFilePath;
52    }
53   
 
54  17 toggle public void setPhysicalFilePath(String physicalFilePath) {
55  17 this.physicalFilePath = physicalFilePath;
56    }
57   
 
58  10 toggle 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   
 
66  16 toggle public void setLogicalFilePath(String logicalFilePath) {
67  16 this.logicalFilePath = logicalFilePath;
68    }
69   
 
70  29 toggle public String getFilePath() {
71  29 if (logicalFilePath == null) {
72  28 return physicalFilePath;
73    } else {
74  1 return logicalFilePath;
75    }
76    }
77   
 
78  4 toggle @Override
79    public String toString() {
80  4 return getFilePath();
81    }
82   
 
83  0 toggle public int compareTo(DatabaseChangeLog o) {
84  0 return getFilePath().compareTo(o.getFilePath());
85    }
86   
 
87  0 toggle 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   
 
98  90 toggle public List<ChangeSet> getChangeSets() {
99  90 return changeSets;
100    }
101   
 
102  64 toggle public void addChangeSet(ChangeSet changeSet) {
103  64 this.changeSets.add(changeSet);
104    }
105   
 
106  1 toggle @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   
 
119  0 toggle @Override
120    public int hashCode() {
121  0 return getFilePath().hashCode();
122    }
123   
 
124  2 toggle 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   
 
142  0 toggle public ChangeSet getChangeSet(RanChangeSet ranChangeSet) {
143  0 return getChangeSet(ranChangeSet.getChangeLog(), ranChangeSet.getAuthor(), ranChangeSet.getId());
144    }
145    }