Package org.dbunit.database
Class PrimaryKeyFilter
java.lang.Object
org.dbunit.dataset.filter.AbstractTableFilter
org.dbunit.database.PrimaryKeyFilter
- All Implemented Interfaces:
ITableFilter,ITableFilterSimple
Filter a table given a map of the allowed rows based on primary key values.
It uses a depth-first algorithm (although not recursive - it might be refactored in the future) to define which rows are allowed, as well which rows are necessary (and hence allowed) because of dependencies with the allowed rows.
NOTE: multi-column primary keys are not supported at the moment. TODO: test cases
It uses a depth-first algorithm (although not recursive - it might be refactored in the future) to define which rows are allowed, as well which rows are necessary (and hence allowed) because of dependencies with the allowed rows.
NOTE: multi-column primary keys are not supported at the moment. TODO: test cases
- Since:
- Sep 9, 2005
- Version:
- $Revision$ $Date$
- Author:
- Felipe Leme (dbunit@felipeal.net), Last changed by: $Author$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMap that associates a table with a set of primary key objects. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPrimaryKeyFilter(IDatabaseConnection connection, PrimaryKeyFilter.PkTableMap allowedPKs, boolean reverseDependency) Default constructor, it takes as input a map with desired rows in a final dataset; the filter will ensure that the rows necessary by these initial rows are also allowed (and so on...). -
Method Summary
Modifier and TypeMethodDescriptionvoidRecords the given foreign key relationship in the direct and reverse edge caches.booleanisValidName(String tableName) Returnstrueif specified table is allowed by this filter.Returns iterator of tables allowed by this filter from the specified dataset.voidRecords the given node as a known table name.toString()Methods inherited from class org.dbunit.dataset.filter.AbstractTableFilter
accept, getTableNames
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger for this class.
-
-
Constructor Details
-
PrimaryKeyFilter
public PrimaryKeyFilter(IDatabaseConnection connection, PrimaryKeyFilter.PkTableMap allowedPKs, boolean reverseDependency) Default constructor, it takes as input a map with desired rows in a final dataset; the filter will ensure that the rows necessary by these initial rows are also allowed (and so on...).- Parameters:
connection- database connectionallowedPKs- map of allowed rows, based on the primary keys (key is the name of a table; value is a Set with allowed primary keys for that table)reverseDependency- flag indicating if the rows that depend on a row should also be allowed by the filter
-
-
Method Details
-
nodeAdded
Records the given node as a known table name.- Parameters:
node- the table name node added to the dependency graph.
-
edgeAdded
Records the given foreign key relationship in the direct and reverse edge caches.- Parameters:
edge- the foreign key relationship added to the dependency graph.
-
isValidName
Description copied from class:AbstractTableFilterReturnstrueif specified table is allowed by this filter. This legacy method, now replaced by accept, still exist for compatibily with older environment- Specified by:
isValidNamein classAbstractTableFilter- Parameters:
tableName- the name of the table to check.- Returns:
trueif specified table is allowed by this filter.- Throws:
DataSetException- if the check fails.- See Also:
-
iterator
Description copied from interface:ITableFilterReturns iterator of tables allowed by this filter from the specified dataset.- Specified by:
iteratorin interfaceITableFilter- Overrides:
iteratorin classAbstractTableFilter- Parameters:
dataSet- the filtered datasetreversed-trueto iterate in reverse order.- Returns:
- the iterator of tables allowed by this filter.
- Throws:
DataSetException- if creating the iterator fails.
-
toString
-