01: /*
02: *
03: * The DbUnit Database Testing Framework
04: * Copyright (C)2005, DbUnit.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: */
21:
22: package org.dbunit.database.search;
23:
24: import org.slf4j.Logger;
25: import org.slf4j.LoggerFactory;
26:
27: import org.dbunit.util.search.Edge;
28:
29: /**
30: * Implementation of an edge representing a foreign key (FK) relationship between two
31: * tables.<br>
32: * The <code>from</code> node is the table which have the FK, while the
33: * <code>to</code> node is the table with the PK. In other words, the edge
34: * A->B means FK(A) = PK(B).<br>
35: *
36: * <strong>NOTE:</strong> only single-column PKs are supported at this moment
37: *
38: * @author Felipe Leme <dbunit@felipeal.net>
39: * @version $Revision: 554 $
40: * @since Sep 9, 2005
41: */
42:
43: public class ForeignKeyRelationshipEdge extends Edge {
44:
45: /**
46: * Logger for this class
47: */
48: private static final Logger logger = LoggerFactory
49: .getLogger(ForeignKeyRelationshipEdge.class);
50:
51: private String fkColumn;
52: private String pkColumn;
53:
54: /**
55: * Creates an edge representing a FK.
56: * @param tableFrom table that has the FK
57: * @param tableTo table that has the PK
58: * @param fkColumn name of the FK column on tableFrom
59: * @param pkColumn name of the PK column on tableTo
60: */
61:
62: public ForeignKeyRelationshipEdge(String tableFrom, String tableTo,
63: String fkColumn, String pkColumn) {
64: super (tableFrom, tableTo);
65: this .fkColumn = fkColumn;
66: this .pkColumn = pkColumn;
67: }
68:
69: /**
70: * Gets the name of the foreign key column in the relationship.
71: * @return name of the foreign key column in the relationship.
72: */
73: public String getFKColumn() {
74: logger.debug("getFKColumn() - start");
75:
76: return fkColumn;
77: }
78:
79: /**
80: * Gets the name of the primary key column in the relationship.
81: * @return name of the primary key column in the relationship.
82: */
83: public String getPKColumn() {
84: logger.debug("getPKColumn() - start");
85:
86: return pkColumn;
87: }
88:
89: public String toString() {
90: logger.debug("toString() - start");
91:
92: return getFrom() + "(" + getFKColumn() + ")->" + getTo() + "("
93: + getPKColumn() + ")";
94: }
95:
96: }
|