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.SQLCreateMaterializedViewStatement; 17 18 import hunt.sql.ast.SQLName; 19 import hunt.sql.ast.SQLObject; 20 import hunt.sql.ast.SQLPartitionBy; 21 import hunt.sql.ast.SQLStatementImpl; 22 // import hunt.sql.dialect.oracle.ast.OracleSegmentAttributes; 23 import hunt.sql.visitor.SQLASTVisitor; 24 import hunt.sql.ast.statement.SQLSelect; 25 import hunt.sql.ast.statement.SQLCreateStatement; 26 27 import hunt.collection; 28 import hunt.Integer; 29 import hunt.Boolean; 30 /** 31 * Created by wenshao on 30/06/2017. 32 */ 33 public class SQLCreateMaterializedViewStatement : SQLStatementImpl ,/* OracleSegmentAttributes, */SQLCreateStatement { 34 private SQLName name; 35 private List!SQLName columns; 36 37 private bool refreshFast; 38 private bool refreshComlete; 39 private bool refreshForce; 40 private bool refreshOnCommit; 41 private bool refreshOnDemand; 42 43 private bool buildImmediate; 44 private bool buildDeferred; 45 46 private SQLSelect query; 47 48 // oracle 49 private Integer pctfree; 50 private Integer pctused; 51 private Integer initrans; 52 53 private Integer maxtrans; 54 private Integer pctincrease; 55 private Integer freeLists; 56 private bool compress; 57 private Integer compressLevel; 58 private bool compressForOltp; 59 private Integer pctthreshold; 60 61 private bool logging; 62 private Boolean cache; 63 64 protected SQLName tablespace; 65 protected SQLObject storage; 66 67 private bool parallel; 68 private Integer parallelValue; 69 70 private Boolean enableQueryRewrite; 71 72 private SQLPartitionBy partitionBy; 73 74 private bool withRowId; 75 76 this() 77 { 78 columns = new ArrayList!SQLName(); 79 } 80 81 public SQLName getName() { 82 return name; 83 } 84 85 public void setName(SQLName name) { 86 if (name !is null) { 87 name.setParent(this); 88 } 89 this.name = name; 90 } 91 92 public List!SQLName getColumns() { 93 return columns; 94 } 95 96 public SQLSelect getQuery() { 97 return query; 98 } 99 100 public void setQuery(SQLSelect query) { 101 if (query !is null) { 102 query.setParent(this); 103 } 104 this.query = query; 105 } 106 107 public bool isBuildImmediate() { 108 return buildImmediate; 109 } 110 111 public void setBuildImmediate(bool buildImmediate) { 112 this.buildImmediate = buildImmediate; 113 } 114 115 public bool isBuildDeferred() { 116 return buildDeferred; 117 } 118 119 public void setBuildDeferred(bool buildDeferred) { 120 this.buildDeferred = buildDeferred; 121 } 122 123 public bool isRefresh() { 124 return this.refreshFast || refreshComlete || refreshForce || refreshOnDemand || refreshOnCommit; 125 } 126 127 public bool isRefreshFast() { 128 return refreshFast; 129 } 130 131 public void setRefreshFast(bool refreshFast) { 132 this.refreshFast = refreshFast; 133 } 134 135 public bool isRefreshComlete() { 136 return refreshComlete; 137 } 138 139 public void setRefreshComlete(bool refreshComlete) { 140 this.refreshComlete = refreshComlete; 141 } 142 143 public bool isRefreshForce() { 144 return refreshForce; 145 } 146 147 public void setRefreshForce(bool refreshForce) { 148 this.refreshForce = refreshForce; 149 } 150 151 public bool isRefreshOnCommit() { 152 return refreshOnCommit; 153 } 154 155 public void setRefreshOnCommit(bool refreshOnCommit) { 156 this.refreshOnCommit = refreshOnCommit; 157 } 158 159 public bool isRefreshOnDemand() { 160 return refreshOnDemand; 161 } 162 163 public void setRefreshOnDemand(bool refreshOnDemand) { 164 this.refreshOnDemand = refreshOnDemand; 165 } 166 167 public Integer getPctfree() { 168 return pctfree; 169 } 170 171 public void setPctfree(Integer pctfree) { 172 this.pctfree = pctfree; 173 } 174 175 public Integer getPctused() { 176 return pctused; 177 } 178 179 public void setPctused(Integer pctused) { 180 this.pctused = pctused; 181 } 182 183 public Integer getInitrans() { 184 return initrans; 185 } 186 187 public void setInitrans(Integer initrans) { 188 this.initrans = initrans; 189 } 190 191 public Integer getMaxtrans() { 192 return maxtrans; 193 } 194 195 public void setMaxtrans(Integer maxtrans) { 196 this.maxtrans = maxtrans; 197 } 198 199 public Integer getPctincrease() { 200 return pctincrease; 201 } 202 203 public void setPctincrease(Integer pctincrease) { 204 this.pctincrease = pctincrease; 205 } 206 207 public Integer getFreeLists() { 208 return freeLists; 209 } 210 211 public void setFreeLists(Integer freeLists) { 212 this.freeLists = freeLists; 213 } 214 215 public bool getCompress() { 216 return compress; 217 } 218 219 public void setCompress(bool compress) { 220 this.compress = compress; 221 } 222 223 public Integer getCompressLevel() { 224 return compressLevel; 225 } 226 227 public void setCompressLevel(Integer compressLevel) { 228 this.compressLevel = compressLevel; 229 } 230 231 public bool isCompressForOltp() { 232 return compressForOltp; 233 } 234 235 public void setCompressForOltp(bool compressForOltp) { 236 this.compressForOltp = compressForOltp; 237 } 238 239 public Integer getPctthreshold() { 240 return pctthreshold; 241 } 242 243 public void setPctthreshold(Integer pctthreshold) { 244 this.pctthreshold = pctthreshold; 245 } 246 247 public bool getLogging() { 248 return logging; 249 } 250 251 public void setLogging(bool logging) { 252 this.logging = logging; 253 } 254 255 public SQLName getTablespace() { 256 return tablespace; 257 } 258 259 public void setTablespace(SQLName tablespace) { 260 if (tablespace !is null) { 261 tablespace.setParent(this); 262 } 263 this.tablespace = tablespace; 264 } 265 266 public SQLObject getStorage() { 267 return storage; 268 } 269 270 public void setStorage(SQLObject storage) { 271 if (storage !is null) { 272 storage.setParent(this); 273 } 274 this.storage = storage; 275 } 276 277 public Boolean getParallel() { 278 return new Boolean(parallel); 279 } 280 281 public void setParallel(bool parallel) { 282 this.parallel = parallel; 283 } 284 285 public Integer getParallelValue() { 286 return parallelValue; 287 } 288 289 public void setParallelValue(Integer parallelValue) { 290 this.parallelValue = parallelValue; 291 } 292 293 public Boolean getEnableQueryRewrite() { 294 return enableQueryRewrite; 295 } 296 297 public void setEnableQueryRewrite(bool enableQueryRewrite) { 298 this.enableQueryRewrite = new Boolean(enableQueryRewrite); 299 } 300 301 public Boolean getCache() { 302 return cache; 303 } 304 305 public void setCache(bool cache) { 306 this.cache = new Boolean(cache); 307 } 308 309 public SQLPartitionBy getPartitionBy() { 310 return partitionBy; 311 } 312 313 public void setPartitionBy(SQLPartitionBy x) { 314 if (x !is null) { 315 x.setParent(this); 316 } 317 this.partitionBy = x; 318 } 319 320 public bool isWithRowId() { 321 return withRowId; 322 } 323 324 public void setWithRowId(bool withRowId) { 325 this.withRowId = withRowId; 326 } 327 328 329 override protected void accept0(SQLASTVisitor visitor) { 330 if (visitor.visit(this)) { 331 acceptChild(visitor, name); 332 acceptChild!SQLName(visitor, columns); 333 acceptChild(visitor, partitionBy); 334 acceptChild(visitor, query); 335 } 336 visitor.endVisit(this); 337 } 338 }