Package org.dbunit.database.search
Class AbstractMetaDataBasedSearchCallback
java.lang.Object
org.dbunit.util.search.AbstractNodesFilterSearchCallback
org.dbunit.database.search.AbstractMetaDataBasedSearchCallback
- All Implemented Interfaces:
ISearchCallback
- Direct Known Subclasses:
ExportedKeysSearchCallback,ImportedAndExportedKeysSearchCallback,ImportedKeysSearchCallback
Super-class for the ISearchCallback that implements the
getEdges() method using the database meta-data.- Since:
- Aug 25, 2005
- Version:
- $Revision$
- Author:
- Felipe Leme (dbunit@felipeal.net)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final int[]protected static final intprotected static final int[]protected static final int[]protected static final int[]indexes of the column names on the MetaData result sets.Fields inherited from class org.dbunit.util.search.AbstractNodesFilterSearchCallback
ALLOW_MODE, DENY_MODE, NO_MODE -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected static ForeignKeyRelationshipEdgeCreates an edge representing a foreign key relationship between 2 tables.Get the connection where the edges will be calculated from.protected SortedSetGet the nodes using the reverse foreign key dependency, i.e, if table C has a FK for a table A, then getNodesFromExportedKeys(A) will return C.
NOTE: this method should be used only as an auxiliary method for sub-classes that also usegetNodesFromImportedKeys()or something similar, otherwise the generated sequence of tables might not work when inserted in the database (as some tables might be missing).protected SortedSetGet the nodes using the both direct and reverse foreign key dependency, i.e, if table C has a FK for a table A and table A has a FK for a table B, then getNodesFromImportAndExportedKeys(A) will return B and C.protected SortedSetGet the nodes using the direct foreign key dependency, i.e, if table A has a FK for a table B, then getNodesFromImportedKeys(A) will return B.protected IEdgeThis method can be overwritten by the sub-classes if they need to decorate the edge (for instance, providing an Edge that contains the primary and foreign keys used).Methods inherited from class org.dbunit.util.search.AbstractNodesFilterSearchCallback
getFilteredNodes, getFilteringMode, nodeAdded, searchNode, setAllowedNodes, setAllowedNodes, setDeniedNodes, setDeniedNodesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dbunit.util.search.ISearchCallback
getEdges
-
Field Details
-
IMPORT
protected static final int IMPORT- See Also:
-
EXPORT
protected static final int EXPORT- See Also:
-
TABLENAME_INDEXES
protected static final int[] TABLENAME_INDEXESindexes of the column names on the MetaData result sets. -
SCHEMANAME_INDEXES
protected static final int[] SCHEMANAME_INDEXES -
PK_INDEXES
protected static final int[] PK_INDEXES -
FK_INDEXES
protected static final int[] FK_INDEXES
-
-
Constructor Details
-
AbstractMetaDataBasedSearchCallback
Default constructor.- Parameters:
connection- connection where the edges will be calculated from
-
-
Method Details
-
getConnection
Get the connection where the edges will be calculated from.- Returns:
- the connection where the edges will be calculated from
-
getNodesFromImportedKeys
Get the nodes using the direct foreign key dependency, i.e, if table A has a FK for a table B, then getNodesFromImportedKeys(A) will return B.- Parameters:
node- table name- Returns:
- tables with direct FK dependency from node
- Throws:
SearchException
-
getNodesFromExportedKeys
Get the nodes using the reverse foreign key dependency, i.e, if table C has a FK for a table A, then getNodesFromExportedKeys(A) will return C.
NOTE: this method should be used only as an auxiliary method for sub-classes that also usegetNodesFromImportedKeys()or something similar, otherwise the generated sequence of tables might not work when inserted in the database (as some tables might be missing).- Parameters:
node- table name- Returns:
- tables with reverse FK dependency from node
- Throws:
SearchException
-
getNodesFromImportAndExportKeys
Get the nodes using the both direct and reverse foreign key dependency, i.e, if table C has a FK for a table A and table A has a FK for a table B, then getNodesFromImportAndExportedKeys(A) will return B and C.- Parameters:
node- table name- Returns:
- tables with reverse and direct FK dependency from node
- Throws:
SearchException
-
createFKEdge
protected static ForeignKeyRelationshipEdge createFKEdge(ResultSet rs, int type, String from, String to, String fkColumn, String pkColumn) throws SearchException Creates an edge representing a foreign key relationship between 2 tables.- Parameters:
rs- database meta-data result settype- type of relationship (IMPORT or EXPORT)from- name of the table representing the 'from' nodeto- name of the table representing the 'to' nodefkColumn- name of the foreign key columnpkColumn- name of the primary key column- Returns:
- edge representing the relationship between the 2 tables, according to the type
- Throws:
SearchException- not thrown in this method (but might on sub-classes)
-
newEdge
protected IEdge newEdge(ResultSet rs, int type, String from, String to, String fkColumn, String pkColumn) throws SearchException This method can be overwritten by the sub-classes if they need to decorate the edge (for instance, providing an Edge that contains the primary and foreign keys used).- Parameters:
rs- database meta-data result settype- type of relationship (IMPORT or EXPORT)from- name of the table representing the 'from' nodeto- name of the table representing the 'to' nodefkColumn- name of the foreign key columnpkColumn- name of the primary key column- Returns:
- edge representing the relationship between the 2 tables, according to the type
- Throws:
SearchException- not thrown in this method (but might on sub-classes)
-