View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2004/08/15 18:00:19
    6    */
    7   package org.asyrinx.joey.gen.command.rdb;
    8
    9   import org.asyrinx.joey.gen.model.rdb.Column;
    10  import org.asyrinx.joey.gen.model.rdb.ColumnType;
    11  import org.asyrinx.joey.gen.model.rdb.ForeignKeyEntry;
    12
    13  /***
    14   * @author akima
    15   */
    16  public class CheckFkColumnType extends RdbCommand {
    17
    18      /*
    19       * (non-Javadoc)
    20       *
    21       * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.ForeignKeyEntry)
    22       */
    23      public void visit(ForeignKeyEntry entry) {
    24          final Column localColumn = entry.getLocalColumn();
    25          if (localColumn == null)
    26              addError(entry, "local column not found. " + entry.getLocal());
    27
    28          final Column foreignColumn = entry.getForeignColumn();
    29          if (foreignColumn == null)
    30              addError(entry, "foreign column not found. " + entry.getForeign());
    31          //
    32          if (!localColumn.getType().equals(foreignColumn.getType()))
    33              addError(entry, "column type different between " + localColumn.getType() + "(" + localColumn.getFullName()
    34                      + ") and " + foreignColumn.getType() + "(" + foreignColumn.getFullName() + ")");
    35          final ColumnType type = ColumnType.get(localColumn.getType());
    36          if (type == null)
    37              addError(localColumn, "type not found. " + localColumn.getType());
    38          if (type.isRequiredSize()) {
    39              if (localColumn.getSize() != foreignColumn.getSize())
    40                  addError(entry, "column size different between " + localColumn.getSize() + "("
    41                          + localColumn.getFullName() + ") and " + foreignColumn.getSize() + "("
    42                          + foreignColumn.getFullName() + ")");
    43          }
    44      }
    45
    46  }