Package org.dbunit.database.search
Class TablesDependencyHelper
java.lang.Object
org.dbunit.database.search.TablesDependencyHelper
Helper for the graph-search based classes used to calculate dependency
among tables.
- Since:
- Aug 26, 2005
- Version:
- $Revision$ $Date$
- Author:
- Felipe Leme (dbunit@felipeal.net), Last changed by: $Author$
-
Method Summary
Modifier and TypeMethodDescriptionstatic IDataSetgetAllDataset(IDatabaseConnection connection, String rootTable, Set allowedPKs) Returns a dataset with the given root table plus every table that directly or transitively depends on or is depended on by it, filtered to the given allowed primary keys.static IDataSetgetAllDataset(IDatabaseConnection connection, PrimaryKeyFilter.PkTableMap rootTables) Returns a dataset with the given root tables plus every table that directly or transitively depends on or is depended on by them, filtered to the given allowed primary keys.static String[]getAllDependentTables(IDatabaseConnection connection, String rootTable) Get the name of all tables that depend on a root table ( i.e, all tables whose PK is a FK for the root table) and also the tables the root table depends on (i.e., all tables which have a FK for the root table's PK).static String[]getAllDependentTables(IDatabaseConnection connection, String[] rootTables) Get the name of all tables that depend on the root tables ( i.e, all tables whose PK is a FK for any of the root tables) and also the tables the root tables depends on (i.e., all tables which have a FK for any of the root table's PK).static IDataSetgetDataset(IDatabaseConnection connection, String rootTable, Set allowedIds) Returns a dataset containing the given root table and all tables that depend on it, filtered to the given allowed primary key values of the root table.static IDataSetgetDataset(IDatabaseConnection connection, PrimaryKeyFilter.PkTableMap rootTables) Returns a dataset containing the given root tables and all tables that depend on them, filtered to the given allowed primary key values.static String[]getDependentTables(IDatabaseConnection connection, String rootTable) Get the name of all tables that depend on the root tables (i.e, all tables that have FKs pointing to the PK of the root table).static String[]getDependentTables(IDatabaseConnection connection, String[] rootTables) Get the name of all tables that depend on the root tables (i.e, all tables that have FKs pointing to the PK of one of the root tables).static String[]getDependsOnTables(IDatabaseConnection connection, String rootTable) Get the name of all tables that the given rootTable depends on (i.e, all tables whose PK is a FK for the root table).static SetgetDirectDependentTables(IDatabaseConnection connection, String tableName) Returns a set of tables which directly depend on the given table.static SetgetDirectDependsOnTables(IDatabaseConnection connection, String tableName) Returns a set of tables on which the given table directly depends on.
-
Method Details
-
getDependentTables
public static String[] getDependentTables(IDatabaseConnection connection, String rootTable) throws SearchException Get the name of all tables that depend on the root tables (i.e, all tables that have FKs pointing to the PK of the root table).- Parameters:
connection- database connectionrootTable- root table described above- Returns:
- name of all tables that depend on the root table (including the root table), in the right order for insertions
- Throws:
SearchException- if an exception occurred while calculating the order
-
getDependentTables
public static String[] getDependentTables(IDatabaseConnection connection, String[] rootTables) throws SearchException Get the name of all tables that depend on the root tables (i.e, all tables that have FKs pointing to the PK of one of the root tables).- Parameters:
connection- database connectionrootTables- array of root tables described above- Returns:
- name of all tables that depend on the root tables (including the root tables), in the right order for insertions
- Throws:
SearchException- if an exception occurred while calculating the order
-
getDependsOnTables
public static String[] getDependsOnTables(IDatabaseConnection connection, String rootTable) throws SearchException Get the name of all tables that the given rootTable depends on (i.e, all tables whose PK is a FK for the root table).- Parameters:
connection- database connectionrootTable- root table described above- Returns:
- name of all tables that the rootTable depends on (including the rootTable itself), in the right order for insertions
- Throws:
SearchException- if an exception occurred while calculating the order- Since:
- 2.4
-
getAllDependentTables
public static String[] getAllDependentTables(IDatabaseConnection connection, String rootTable) throws SearchException Get the name of all tables that depend on a root table ( i.e, all tables whose PK is a FK for the root table) and also the tables the root table depends on (i.e., all tables which have a FK for the root table's PK).- Parameters:
connection- database connectionrootTable- root table described above- Returns:
- name of all tables that depend on the root table (including the root table), in the right order for insertions
- Throws:
SearchException- if an exception occurred while calculating the order
-
getAllDependentTables
public static String[] getAllDependentTables(IDatabaseConnection connection, String[] rootTables) throws SearchException Get the name of all tables that depend on the root tables ( i.e, all tables whose PK is a FK for any of the root tables) and also the tables the root tables depends on (i.e., all tables which have a FK for any of the root table's PK).- Parameters:
connection- database connectionrootTables- root tables described above- Returns:
- name of all tables that depend on the root tables (including the root tables), in the right order for insertions
- Throws:
SearchException- if an exception occurred while calculating the order
-
getDataset
public static IDataSet getDataset(IDatabaseConnection connection, String rootTable, Set allowedIds) throws SearchException, SQLException, DataSetException Returns a dataset containing the given root table and all tables that depend on it, filtered to the given allowed primary key values of the root table.- Parameters:
connection- database connection.rootTable- root table described above.allowedIds- the allowed primary key values of the root table.- Returns:
- a dataset containing the root table and its dependent tables, filtered by the allowed ids.
- Throws:
SearchException- if an exception occurred while calculating the order.SQLException- if a database access error occurs.DataSetException- if the dataset cannot be created.
-
getDataset
public static IDataSet getDataset(IDatabaseConnection connection, PrimaryKeyFilter.PkTableMap rootTables) throws SearchException, SQLException, DataSetException Returns a dataset containing the given root tables and all tables that depend on them, filtered to the given allowed primary key values.- Parameters:
connection- database connection.rootTables- map of root tables to their allowed primary key values.- Returns:
- a dataset containing the root tables and their dependent tables, filtered by the allowed ids.
- Throws:
SearchException- if an exception occurred while calculating the order.SQLException- if a database access error occurs.DataSetException- if the dataset cannot be created.
-
getAllDataset
public static IDataSet getAllDataset(IDatabaseConnection connection, String rootTable, Set allowedPKs) throws SearchException, SQLException, DataSetException Returns a dataset with the given root table plus every table that directly or transitively depends on or is depended on by it, filtered to the given allowed primary keys.- Parameters:
connection- The connection to be used for the database lookup.rootTable- The table to start the search from.allowedPKs- The primary keys of the root table to allow in the result.- Returns:
- the resulting dataset.
- Throws:
SearchException- if the search fails.SQLException- if a database access error occurs.DataSetException- if the resulting dataset cannot be built.
-
getAllDataset
public static IDataSet getAllDataset(IDatabaseConnection connection, PrimaryKeyFilter.PkTableMap rootTables) throws SearchException, SQLException, DataSetException Returns a dataset with the given root tables plus every table that directly or transitively depends on or is depended on by them, filtered to the given allowed primary keys.- Parameters:
connection- The connection to be used for the database lookup.rootTables- The tables to start the search from, mapped to their allowed primary keys.- Returns:
- the resulting dataset.
- Throws:
SearchException- if the search fails.SQLException- if a database access error occurs.DataSetException- if the resulting dataset cannot be built.
-
getDirectDependsOnTables
public static Set getDirectDependsOnTables(IDatabaseConnection connection, String tableName) throws SearchException Returns a set of tables on which the given table directly depends on.- Parameters:
connection- The connection to be used for the database lookup.tableName- The table to look up direct dependencies for.- Returns:
- a set of tables on which the given table directly depends on.
- Throws:
SearchException- if the search fails.- Since:
- 2.4
-
getDirectDependentTables
public static Set getDirectDependentTables(IDatabaseConnection connection, String tableName) throws SearchException Returns a set of tables which directly depend on the given table.- Parameters:
connection- The connection to be used for the database lookup.tableName- The table to look up direct dependents for.- Returns:
- a set of tables on which the given table directly depends on.
- Throws:
SearchException- if the search fails.- Since:
- 2.4
-