01: package liquibase.change.custom;
02:
03: import liquibase.FileOpener;
04: import liquibase.database.Database;
05: import liquibase.database.sql.RawSqlStatement;
06: import liquibase.database.sql.SqlStatement;
07: import liquibase.database.structure.DatabaseObject;
08: import liquibase.exception.RollbackImpossibleException;
09: import liquibase.exception.SetupException;
10: import liquibase.exception.UnsupportedChangeException;
11:
12: import java.util.Set;
13:
14: public class ExampleCustomSqlChange implements CustomSqlChange,
15: CustomSqlRollback {
16:
17: private String tableName;
18: private String columnName;
19: private String newValue;
20:
21: @SuppressWarnings({"UnusedDeclaration","FieldCanBeLocal"})
22: private FileOpener fileOpener;
23:
24: public String getTableName() {
25: return tableName;
26: }
27:
28: public void setTableName(String tableName) {
29: this .tableName = tableName;
30: }
31:
32: public String getColumnName() {
33: return columnName;
34: }
35:
36: public void setColumnName(String columnName) {
37: this .columnName = columnName;
38: }
39:
40: public String getNewValue() {
41: return newValue;
42: }
43:
44: public void setNewValue(String newValue) {
45: this .newValue = newValue;
46: }
47:
48: public SqlStatement[] generateStatements(Database database)
49: throws UnsupportedChangeException {
50: return new SqlStatement[] { new RawSqlStatement("update "
51: + tableName + " set " + columnName + " = " + newValue) };
52: }
53:
54: public SqlStatement[] generateRollbackStatements(Database database)
55: throws UnsupportedChangeException,
56: RollbackImpossibleException {
57: return new SqlStatement[] { new RawSqlStatement("update "
58: + tableName + " set " + columnName + " = null") };
59: }
60:
61: public String getConfirmationMessage() {
62: return "Custom class updated " + tableName + "." + columnName;
63: }
64:
65: public void setUp() throws SetupException {
66: }
67:
68: public Set<DatabaseObject> getAffectedDatabaseObjects() {
69: return null;
70: }
71:
72: public void setFileOpener(FileOpener fileOpener) {
73: this.fileOpener = fileOpener;
74: }
75: }
|