Exemple #1
0
  /**
   * Adds the tables of the DbUnit dataset to the given schema.
   *
   * @param dbUnitDataSet The DbUnit dataset containing the tables, not null
   * @param schema The schema to add the tables to, not null
   */
  protected void addTables(IDataSet dbUnitDataSet, Schema schema) throws DataSetException {
    ITableIterator dbUnitTableIterator = dbUnitDataSet.iterator();
    while (dbUnitTableIterator.next()) {
      ITable dbUnitTable = dbUnitTableIterator.getTable();
      String tableName = dbUnitTable.getTableMetaData().getTableName();

      List<String> primaryKeyColumnNames = getPrimaryKeyColumnNames(dbUnitTable);

      Table table = schema.getTable(tableName);
      if (table == null) {
        table = new Table(tableName);
        schema.addTable(table);
      }
      addRows(dbUnitTable, table, primaryKeyColumnNames);
    }
  }
Exemple #2
0
  /**
   * Initializes the tables of this dataset
   *
   * @throws DataSetException
   * @since 2.4
   */
  private void initialize() throws DataSetException {
    logger.debug("initialize() - start");

    if (_orderedTableNameMap != null) {
      logger.debug("The table name map has already been initialized.");
      // already initialized
      return;
    }

    // Gather all tables in the OrderedTableNameMap which also makes the duplicate check
    _orderedTableNameMap = this.createTableNameMap();
    ITableIterator iterator = createIterator(false);
    while (iterator.next()) {
      ITable table = iterator.getTable();
      _orderedTableNameMap.add(table.getTableMetaData().getTableName(), table);
    }
  }