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/11/08 23:54:54
    6    */
    7   package org.asyrinx.joey.gen.command.rdb;
    8
    9   import java.util.HashMap;
    10  import java.util.Iterator;
    11  import java.util.Map;
    12
    13  import org.asyrinx.joey.gen.model.rdb.Database;
    14  import org.asyrinx.joey.gen.model.rdb.Databases;
    15
    16  /***
    17   * @author takeshi
    18   */
    19  public class MergeDatabases extends RdbCommand {
    20
    21      public void visit(Databases databases) {
    22          final Map dbMap = new HashMap();
    23          //final List dbList = databases.getDatabases().toList();
    24          for (final Iterator i = databases.getDatabases().iterator(); i.hasNext();) {
    25              final Database db = (Database) i.next();
    26              final Database committed = (Database) dbMap.get(db.getName());
    27              if (committed == null) {
    28                  dbMap.put(db.getName(), db);
    29              } else {
    30                  db.moveTables(committed);
    31                  db.moveEnumerations(committed);
    32                  i.remove();
    33              }
    34          }
    35      }
    36  }