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      public void visit(ForeignKeyEntry entry) {
    19          final Column localColumn = entry.getLocalColumn();
    20          if (localColumn == null)
    21              addError(entry, "local column not found. " + entry.getLocal());
    22
    23          final Column foreignColumn = entry.getForeignColumn();
    24          if (foreignColumn == null)
    25              addError(entry, "foreign column not found. " + entry.getForeign());
    26          //
    27          if (!localColumn.getType().equals(foreignColumn.getType()))
    28              addError(entry, "column type different between " + localColumn.getType() + "(" + localColumn.getFullName()
    29                      + ") and " + foreignColumn.getType() + "(" + foreignColumn.getFullName() + ")");
    30          final ColumnType type = ColumnType.get(localColumn.getType());
    31          if (type == null)
    32              addError(localColumn, "type not found. " + localColumn.getType());
    33          if (type.isRequiredSize()) {
    34              if (localColumn.getSize() != foreignColumn.getSize())
    35                  addError(entry, "column size different between " + localColumn.getSize() + "("
    36                          + localColumn.getFullName() + ") and " + foreignColumn.getSize() + "("
    37                          + foreignColumn.getFullName() + ")");
    38          }
    39      }
    40
    41  }