1 /*
2  * Copyright 2015-2018 HuntLabs.cn
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 module hunt.sql.dialect.mysql.ast.statement.MySqlCreateEventStatement;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.SQLName;
20 import hunt.sql.ast.SQLStatement;
21 import hunt.sql.ast.statement.SQLAlterStatement;
22 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor;
23 import hunt.sql.util.DBType;
24 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
25 import hunt.sql.dialect.mysql.ast.statement.MySqlEventSchedule;
26 import hunt.Boolean;
27 
28 public class MySqlCreateEventStatement : MySqlStatementImpl , SQLAlterStatement {
29 
30     alias accept0 = MySqlStatementImpl.accept0;
31     
32     private SQLName            definer;
33     private SQLName            name;
34 
35     private bool            ifNotExists;
36 
37     private MySqlEventSchedule schedule;
38     private bool            onCompletionPreserve;
39     private SQLName            renameTo;
40     private Boolean            enable;
41     private bool            disableOnSlave;
42     private SQLExpr            comment;
43     private SQLStatement       eventBody;
44 
45     public this() {
46         setDbType(DBType.MYSQL.name);
47     }
48 
49     public SQLName getDefiner() {
50         return definer;
51     }
52 
53     public void setDefiner(SQLName definer) {
54         if (definer !is null) {
55             definer.setParent(this);
56         }
57         this.definer = definer;
58     }
59 
60     public SQLName getName() {
61         return name;
62     }
63 
64     public void setName(SQLName name) {
65         if (name !is null) {
66             name.setParent(this);
67         }
68         this.name = name;
69     }
70 
71     public MySqlEventSchedule getSchedule() {
72         return schedule;
73     }
74 
75     public void setSchedule(MySqlEventSchedule schedule) {
76         if (schedule !is null) {
77             schedule.setParent(this);
78         }
79         this.schedule = schedule;
80     }
81 
82     public bool isOnCompletionPreserve() {
83         return onCompletionPreserve;
84     }
85 
86     public void setOnCompletionPreserve(bool onCompletionPreserve) {
87         this.onCompletionPreserve = onCompletionPreserve;
88     }
89 
90     public SQLName getRenameTo() {
91         return renameTo;
92     }
93 
94     public void setRenameTo(SQLName renameTo) {
95         if (renameTo !is null) {
96             renameTo.setParent(this);
97         }
98         this.renameTo = renameTo;
99     }
100 
101     public Boolean getEnable() {
102         return enable;
103     }
104 
105     public void setEnable(Boolean enable) {
106         this.enable = enable;
107     }
108 
109     public bool isDisableOnSlave() {
110         return disableOnSlave;
111     }
112 
113     public void setDisableOnSlave(bool disableOnSlave) {
114         this.disableOnSlave = disableOnSlave;
115     }
116 
117     public SQLExpr getComment() {
118         return comment;
119     }
120 
121     public void setComment(SQLExpr comment) {
122         if (comment !is null) {
123             comment.setParent(this);
124         }
125         this.comment = comment;
126     }
127 
128     public SQLStatement getEventBody() {
129         return eventBody;
130     }
131 
132     public void setEventBody(SQLStatement eventBody) {
133         if (eventBody !is null) {
134             eventBody.setParent(this);
135         }
136         this.eventBody = eventBody;
137     }
138 
139     public bool isIfNotExists() {
140         return ifNotExists;
141     }
142 
143     public void setIfNotExists(bool ifNotExists) {
144         this.ifNotExists = ifNotExists;
145     }
146 
147     override public void accept0(MySqlASTVisitor visitor) {
148         if (visitor.visit(this)) {
149             acceptChild(visitor, definer);
150             acceptChild(visitor, name);
151             acceptChild(visitor, schedule);
152             acceptChild(visitor, renameTo);
153             acceptChild(visitor, comment);
154             acceptChild(visitor, eventBody);
155         }
156         visitor.endVisit(this);
157     }
158 
159 }