01: package liquibase.parser.filter;
02:
03: import liquibase.ChangeSet;
04: import liquibase.RanChangeSet;
05:
06: import java.util.Date;
07: import java.util.HashSet;
08: import java.util.List;
09: import java.util.Set;
10:
11: public class ExecutedAfterChangeSetFilter implements ChangeSetFilter {
12:
13: private Set<String> changeLogsAfterDate = new HashSet<String>();
14:
15: public ExecutedAfterChangeSetFilter(Date date,
16: List<RanChangeSet> ranChangeSets) {
17: for (RanChangeSet ranChangeSet : ranChangeSets) {
18: if (ranChangeSet.getDateExecuted() != null
19: && ranChangeSet.getDateExecuted().getTime() > date
20: .getTime()) {
21: changeLogsAfterDate.add(changeLogToString(ranChangeSet
22: .getId(), ranChangeSet.getAuthor(),
23: ranChangeSet.getChangeLog()));
24: }
25: }
26: }
27:
28: private String changeLogToString(String id, String author,
29: String changeLog) {
30: return id + ":" + author + ":" + changeLog;
31: }
32:
33: public boolean accepts(ChangeSet changeSet) {
34: return changeLogsAfterDate.contains(changeLogToString(changeSet
35: .getId(), changeSet.getAuthor(), changeSet
36: .getFilePath()));
37: }
38: }
|