01: package liquibase.change;
02:
03: import liquibase.database.Database;
04: import liquibase.database.OracleDatabase;
05: import liquibase.database.sql.RawSqlStatement;
06: import liquibase.database.sql.SqlStatement;
07: import liquibase.database.structure.DatabaseObject;
08: import liquibase.exception.UnsupportedChangeException;
09: import org.w3c.dom.Document;
10: import org.w3c.dom.Element;
11:
12: import java.util.Set;
13:
14: public class CreateProcedureChange extends AbstractChange {
15: private String comments;
16: private String procedureBody;
17:
18: public CreateProcedureChange() {
19: super ("createProcedure", "Create Procedure");
20: }
21:
22: public String getProcedureBody() {
23: return procedureBody;
24: }
25:
26: public void setProcedureBody(String procedureBody) {
27: this .procedureBody = procedureBody;
28: }
29:
30: public String getComments() {
31: return comments;
32: }
33:
34: public void setComments(String comments) {
35: this .comments = comments;
36: }
37:
38: public SqlStatement[] generateStatements(Database database)
39: throws UnsupportedChangeException {
40: String endDelimiter = ";";
41: if (database instanceof OracleDatabase) {
42: endDelimiter = "\n/";
43: }
44: return new SqlStatement[] { new RawSqlStatement(
45: getProcedureBody(), endDelimiter), };
46: }
47:
48: public String getConfirmationMessage() {
49: return "Stored procedure created";
50: }
51:
52: public Element createNode(Document currentChangeLogFileDOM) {
53: Element sqlElement = currentChangeLogFileDOM
54: .createElement(getTagName());
55: sqlElement.appendChild(currentChangeLogFileDOM
56: .createTextNode(getProcedureBody()));
57:
58: return sqlElement;
59: }
60:
61: public Set<DatabaseObject> getAffectedDatabaseObjects() {
62: return null;
63: }
64: }
|