org.unitils.dbunit.dataset
Class SchemaFactory

java.lang.Object
  extended by org.unitils.dbunit.dataset.SchemaFactory

public class SchemaFactory
extends Object

A builder for creating data set schemas.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
SchemaFactory()
           
 
Method Summary
protected  void addRows(org.dbunit.dataset.ITable dbUnitTable, Table table, List<String> primaryKeyColumnNames)
          Adds the rows of the DbUnit table to the given table.
protected  void addTables(org.dbunit.dataset.IDataSet dbUnitDataSet, Schema schema)
          Adds the tables of the DbUnit dataset to the given schema.
 Schema createSchemaForDbUnitDataSet(String schemaName, org.dbunit.dataset.IDataSet dbUnitDataSet)
          Creates a data set schema for the given DbUnit dataset.
 Schema createSchemaForDbUnitDataSet(String schemaName, org.dbunit.dataset.IDataSet dbUnitDataSet, List<String> tablesToInclude)
          Creates a data set schema for the given DbUnit dataset.
protected  List<String> getPrimaryKeyColumnNames(org.dbunit.dataset.ITable dbUnitTable)
          Gets the primary key column names for the given DbUnit table.
protected  boolean shouldIgnoreTable(String tableName, List<String> tablesToInclude)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaFactory

public SchemaFactory()
Method Detail

createSchemaForDbUnitDataSet

public Schema createSchemaForDbUnitDataSet(String schemaName,
                                           org.dbunit.dataset.IDataSet dbUnitDataSet)
Creates a data set schema for the given DbUnit dataset.

Parameters:
schemaName - The schema name that this data set is for, not null
dbUnitDataSet - The DbUnit data set, not null
Returns:
The data set schema, not null

createSchemaForDbUnitDataSet

public Schema createSchemaForDbUnitDataSet(String schemaName,
                                           org.dbunit.dataset.IDataSet dbUnitDataSet,
                                           List<String> tablesToInclude)
Creates a data set schema for the given DbUnit dataset.

Parameters:
schemaName - The schema name that this data set is for, not null
dbUnitDataSet - The DbUnit data set, not null
tablesToInclude - Only tables with these names will be returned the rest will be ignored, null for all tables
Returns:
The data set schema, not null

addTables

protected void addTables(org.dbunit.dataset.IDataSet dbUnitDataSet,
                         Schema schema)
                  throws org.dbunit.dataset.DataSetException
Adds the tables of the DbUnit dataset to the given schema.

Parameters:
dbUnitDataSet - The DbUnit dataset containing the tables, not null
schema - The schema to add the tables to, not null
Throws:
org.dbunit.dataset.DataSetException

shouldIgnoreTable

protected boolean shouldIgnoreTable(String tableName,
                                    List<String> tablesToInclude)
Parameters:
tableName - The table name to check, not null
tablesToInclude - Names of tables to include, null for all tables
Returns:
True if the table name should be included

addRows

protected void addRows(org.dbunit.dataset.ITable dbUnitTable,
                       Table table,
                       List<String> primaryKeyColumnNames)
                throws org.dbunit.dataset.DataSetException
Adds the rows of the DbUnit table to the given table.

Parameters:
dbUnitTable - The DbUnit table containing the rows, not null
table - The table to add the rows to, not null
primaryKeyColumnNames - The names of the pk columns, empty if there are none
Throws:
org.dbunit.dataset.DataSetException

getPrimaryKeyColumnNames

protected List<String> getPrimaryKeyColumnNames(org.dbunit.dataset.ITable dbUnitTable)
                                         throws org.dbunit.dataset.DataSetException
Gets the primary key column names for the given DbUnit table.

Parameters:
dbUnitTable - The DbUnit table, not null
Returns:
The pk column names, empty if none found
Throws:
org.dbunit.dataset.DataSetException


Copyright © 2011. All Rights Reserved.