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      /***
    22       *
    23       */
    24      public MergeDatabases() {
    25          super();
    26      }
    27
    28      /*
    29       * (non-Javadoc)
    30       *
    31       * @see org.asyrinx.joey.gen.model.rdb.visitor.RdbVisitorMock#visit(org.asyrinx.joey.gen.model.rdb.Databases)
    32       */
    33      public void visit(Databases databases) {
    34          final Map dbMap = new HashMap();
    35          //final List dbList = databases.getDatabases().toList();
    36          for (final Iterator i = databases.getDatabases().iterator(); i.hasNext();) {
    37              final Database db = (Database) i.next();
    38              final Database committed = (Database) dbMap.get(db.getName());
    39              if (committed == null) {
    40                  dbMap.put(db.getName(), db);
    41              } else {
    42                  db.moveTables(committed);
    43                  db.moveEnumerations(committed);
    44                  i.remove();
    45              }
    46          }
    47      }
    48  }