/*
* Copyright 2014-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the “License”);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an “AS IS” BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wplatform.ddal.command.dml;
import com.wplatform.ddal.command.CommandInterface;
import com.wplatform.ddal.command.ddl.SchemaCommand;
import com.wplatform.ddal.command.expression.Expression;
import com.wplatform.ddal.dbobject.schema.Schema;
import com.wplatform.ddal.dbobject.schema.Sequence;
import com.wplatform.ddal.dbobject.table.Column;
import com.wplatform.ddal.dbobject.table.Table;
import com.wplatform.ddal.engine.Session;
import com.wplatform.ddal.message.DbException;
import com.wplatform.ddal.message.ErrorCode;
/**
* This class represents the statement
* ALTER SEQUENCE
*/
public class AlterSequence extends SchemaCommand {
private Table table;
private Sequence sequence;
private Expression start;
private Expression increment;
private Boolean cycle;
private Expression minValue;
private Expression maxValue;
private Expression cacheSize;
public AlterSequence(Session session, Schema schema) {
super(session, schema);
}
public void setSequence(Sequence sequence) {
this.sequence = sequence;
}
@Override
public boolean isTransactional() {
return true;
}
public void setColumn(Column column) {
table = column.getTable();
sequence = column.getSequence();
if (sequence == null) {
throw DbException.get(ErrorCode.SEQUENCE_NOT_FOUND_1, column.getSQL());
}
}
public void setStartWith(Expression start) {
this.start = start;
}
public void setIncrement(Expression increment) {
this.increment = increment;
}
public void setCycle(Boolean cycle) {
this.cycle = cycle;
}
public void setMinValue(Expression minValue) {
this.minValue = minValue;
}
public void setMaxValue(Expression maxValue) {
this.maxValue = maxValue;
}
public void setCacheSize(Expression cacheSize) {
this.cacheSize = cacheSize;
}
@Override
public int update() {
throw DbException.getUnsupportedException("TODO");
}
@Override
public int getType() {
return CommandInterface.ALTER_SEQUENCE;
}
public Table getTable() {
return table;
}
public Sequence getSequence() {
return sequence;
}
public Expression getStart() {
return start;
}
public Expression getIncrement() {
return increment;
}
public Boolean getCycle() {
return cycle;
}
public Expression getMinValue() {
return minValue;
}
public Expression getMaxValue() {
return maxValue;
}
public Expression getCacheSize() {
return cacheSize;
}
}