/*
 * Copyright 2011 Konrad Malawski <konrad.malawski@project13.pl>
 *
 * 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 pl.project13.janbanery.core.flow;

import pl.project13.janbanery.core.dao.ColumnsImpl;
import pl.project13.janbanery.resources.Column;

import java.io.IOException;

/**
 * @author Konrad Malawski
 */
public class ColumnCreateFlowImpl implements ColumnCreateFlow {

  private ColumnsImpl columns;

  private Column column;

  public ColumnCreateFlowImpl(ColumnsImpl columns, Column column) {
    this.columns = columns;
    this.column = column;
  }

  @Override
  public Column after(Column thatColumn) throws IOException {
    Integer newPosition = thatColumn.getPosition() + 1;
    return onPosition(newPosition);
  }

  @Override
  public Column afterFirst() throws IOException {
    return after(columns.first());
  }

  @Override
  public Column before(Column thatColumn) throws IOException {
    Integer newPosition = thatColumn.getPosition();
    return onPosition(newPosition);
  }

  @Override
  public Column beforeLast() throws IOException {
    return before(columns.last());
  }

  @Override
  public Column onPosition(Integer position) throws IOException {
    column.setPosition(position);

    return call();
  }

  public Column call() throws IOException {
    return columns.doCreate(column);
  }
}

@@ -1078,24 +1078,126 @@
 olumn;%0A  %7D%0A%0A
+  @Override%0A  public Column afterFirst() throws IOException %7B%0A    return after(columns.first());%0A  %7D%0A%0A
   @Override%0A
@@ -1250,32 +1250,32 @@
 s IOException %7B%0A
-
     Integer newP
@@ -1379,32 +1379,32 @@
 blic Column 
-afterFir
+beforeLa
 st() throws 
@@ -1420,37 +1420,38 @@
 on %7B%0A    return 
-after
+before
 (columns.first()
@@ -1435,35 +1435,34 @@
  before(columns.
-fir
+la
 st());%0A  %7D%0A%0A  @O
@@ -1629,110 +1629,8 @@
  %7D%0A%0A
-  @Override%0A  public Column beforeLast() throws IOException %7B%0A    return before(columns.last());%0A  %7D%0A%0A
   @O
@@ -1761,29 +1761,30 @@
 ();%0A  %7D%0A%0A  p
-ublic
+rivate
  Column call

reorder and privatize what's not needed public