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.ast.statement.SQLCommitStatement;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.SQLStatementImpl;
20 import hunt.sql.visitor.SQLASTVisitor;
21 import hunt.Boolean;
22 
23 public class SQLCommitStatement : SQLStatementImpl {
24 
25     // oracle
26     private bool write;
27     private Boolean wait;
28     private Boolean immediate;
29 
30     // mysql
31     private bool work = false;
32     private Boolean chain;
33     private Boolean release;
34 
35     // sql server
36     private SQLExpr transactionName;
37     private SQLExpr delayedDurability;
38 
39     public this() {
40 
41     }
42 
43     override public SQLCommitStatement clone() {
44         SQLCommitStatement x = new SQLCommitStatement();
45         x.write = write;
46         x.wait = wait;
47         x.immediate = immediate;
48         x.work = work;
49         x.chain = chain;
50         x.release = release;
51 
52         if(transactionName !is null) {
53             x.setTransactionName(transactionName.clone());
54         }
55         if (delayedDurability !is null) {
56             x.setDelayedDurability(delayedDurability.clone());
57         }
58         return x;
59     }
60 
61     override public void accept0(SQLASTVisitor visitor) {
62         if (visitor.visit(this)) {
63             acceptChild(visitor, transactionName);
64             acceptChild(visitor, delayedDurability);
65         }
66         visitor.endVisit(this);
67     }
68 
69     // oracle
70     public bool isWrite() {
71         return write;
72     }
73 
74     public void setWrite(bool write) {
75         this.write = write;
76     }
77 
78     public Boolean getWait() {
79         return wait;
80     }
81 
82     public void setWait(Boolean wait) {
83         this.wait = wait;
84     }
85 
86     public Boolean getImmediate() {
87         return immediate;
88     }
89 
90     public void setImmediate(Boolean immediate) {
91         this.immediate = immediate;
92     }
93 
94     // mysql
95     public Boolean getChain() {
96         return chain;
97     }
98 
99     public void setChain(Boolean chain) {
100         this.chain = chain;
101     }
102 
103     public Boolean getRelease() {
104         return release;
105     }
106 
107     public void setRelease(Boolean release) {
108         this.release = release;
109     }
110 
111     public bool isWork() {
112         return work;
113     }
114 
115     public void setWork(bool work) {
116         this.work = work;
117     }
118 
119     // sql server
120     public SQLExpr getTransactionName() {
121         return transactionName;
122     }
123 
124     public void setTransactionName(SQLExpr transactionName) {
125         if (transactionName !is null) {
126             transactionName.setParent(this);
127         }
128         this.transactionName = transactionName;
129     }
130 
131     public SQLExpr getDelayedDurability() {
132         return delayedDurability;
133     }
134 
135     public void setDelayedDurability(SQLExpr delayedDurability) {
136         if (delayedDurability !is null) {
137             delayedDurability.setParent(this);
138         }
139         this.delayedDurability = delayedDurability;
140     }
141 }