001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.datasetplugin.composer;
015:
016: import org.jetbrains.annotations.NotNull;
017: import org.jetbrains.annotations.Nullable;
018:
019: /**
020: * User: Martin
021: * Date: 06.03.2006
022: * Time: 08:51:38
023: */
024: public class JDBCRelationInfo {
025: /*
026: PKTABLE_CAT String => primary key table catalog being imported (may be null)
027: PKTABLE_SCHEM String => primary key table schema being imported (may be null)
028: PKTABLE_NAME String => primary key table name being imported
029: PKCOLUMN_NAME String => primary key column name being imported
030: FKTABLE_CAT String => foreign key table catalog (may be null)
031: FKTABLE_SCHEM String => foreign key table schema (may be null)
032: FKTABLE_NAME String => foreign key table name
033: FKCOLUMN_NAME String => foreign key column name
034: KEY_SEQ short => sequence number within a foreign key
035: UPDATE_RULE short => What happens to a foreign key when the primary key is updated:
036: importedNoAction - do not allow update of primary key if it has been imported
037: importedKeyCascade - change imported key to agree with primary key update
038: importedKeySetNull - change imported key to NULL if its primary key has been updated
039: importedKeySetDefault - change imported key to default values if its primary key has been updated
040: importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
041: DELETE_RULE short => What happens to the foreign key when primary is deleted.
042: importedKeyNoAction - do not allow delete of primary key if it has been imported
043: importedKeyCascade - delete rows that import a deleted key
044: importedKeySetNull - change imported key to NULL if its primary key has been deleted
045: importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
046: importedKeySetDefault - change imported key to default if its primary key has been deleted
047: FK_NAME String => foreign key name (may be null)
048: PK_NAME String => primary key name (may be null)
049: DEFERRABILITY short => can the evaluation of foreign key constraints be deferred until commit
050: importedKeyInitiallyDeferred - see SQL92 for definition
051: importedKeyInitiallyImmediate - see SQL92 for definition
052: importedKeyNotDeferrable - see SQL92 for definition
053: */
054:
055: //redundant fields (graph should know this too)
056: @Nullable
057: private String primaryKeyTableCatalog;
058: @Nullable
059: private String primaryKeyTableScheam;
060: @Nullable
061: private String primaryKeyColumnTable;
062: @Nullable
063: private String primaryKeyColumnName;
064: @Nullable
065: private String foreignKeyColumnCatalog;
066: @Nullable
067: private String foreignKeyColumnSchema;
068: @Nullable
069: private String foreignKeyColumnTable;
070: @Nullable
071: private String foreignKeyColumnName;
072:
073: private int sequenceNumber;
074: private int updateRule;
075: private int deleteRule;
076:
077: @Nullable
078: private String foreignKeyName;
079: @Nullable
080: private String primaryKeyName;
081: private int deferrability;
082:
083: public JDBCRelationInfo(@NotNull
084: String primaryKeyTableCatalog, @NotNull
085: String primaryKeyTableScheam, @NotNull
086: String primaryKeyColumnTable, @NotNull
087: String primaryKeyColumnName, @NotNull
088: String foreignKeyColumnCatalog, @NotNull
089: String foreignKeyColumnSchema, @NotNull
090: String foreignKeyColumnTable, @NotNull
091: String foreignKeyColumnName, int sequenceNumber, int updateRule,
092: int deleteRule, @NotNull
093: String foreignKeyName, @NotNull
094: String primaryKeyName, int deferrability) {
095: this .primaryKeyTableCatalog = primaryKeyTableCatalog;
096: this .primaryKeyTableScheam = primaryKeyTableScheam;
097: this .primaryKeyColumnTable = primaryKeyColumnTable;
098: this .primaryKeyColumnName = primaryKeyColumnName;
099: this .foreignKeyColumnCatalog = foreignKeyColumnCatalog;
100: this .foreignKeyColumnSchema = foreignKeyColumnSchema;
101: this .foreignKeyColumnTable = foreignKeyColumnTable;
102: this .foreignKeyColumnName = foreignKeyColumnName;
103: this .sequenceNumber = sequenceNumber;
104: this .updateRule = updateRule;
105: this .deleteRule = deleteRule;
106: this .foreignKeyName = foreignKeyName;
107: this .primaryKeyName = primaryKeyName;
108: this .deferrability = deferrability;
109: }
110:
111: @Nullable
112: public String getPrimaryKeyTableCatalog() {
113: return primaryKeyTableCatalog;
114: }
115:
116: @Nullable
117: public String getPrimaryKeyTableScheam() {
118: return primaryKeyTableScheam;
119: }
120:
121: @Nullable
122: public String getPrimaryKeyColumnTable() {
123: return primaryKeyColumnTable;
124: }
125:
126: @Nullable
127: public String getPrimaryKeyColumnName() {
128: return primaryKeyColumnName;
129: }
130:
131: @Nullable
132: public String getForeignKeyColumnCatalog() {
133: return foreignKeyColumnCatalog;
134: }
135:
136: @Nullable
137: public String getForeignKeyColumnSchema() {
138: return foreignKeyColumnSchema;
139: }
140:
141: @Nullable
142: public String getForeignKeyColumnTable() {
143: return foreignKeyColumnTable;
144: }
145:
146: @Nullable
147: public String getForeignKeyColumnName() {
148: return foreignKeyColumnName;
149: }
150:
151: public int getSequenceNumber() {
152: return sequenceNumber;
153: }
154:
155: public int getUpdateRule() {
156: return updateRule;
157: }
158:
159: public int getDeleteRule() {
160: return deleteRule;
161: }
162:
163: @Nullable
164: public String getForeignKeyName() {
165: return foreignKeyName;
166: }
167:
168: @Nullable
169: public String getPrimaryKeyName() {
170: return primaryKeyName;
171: }
172:
173: public int getDeferrability() {
174: return deferrability;
175: }
176:
177: public boolean equals(@Nullable
178: Object o) {
179: if (this == o)
180: return true;
181: if (o == null || getClass() != o.getClass())
182: return false;
183:
184: final JDBCRelationInfo that = (JDBCRelationInfo) o;
185:
186: if (deferrability != that.deferrability)
187: return false;
188: if (deleteRule != that.deleteRule)
189: return false;
190: if (sequenceNumber != that.sequenceNumber)
191: return false;
192: if (updateRule != that.updateRule)
193: return false;
194: if (foreignKeyColumnCatalog != null ? !foreignKeyColumnCatalog
195: .equals(that.foreignKeyColumnCatalog)
196: : that.foreignKeyColumnCatalog != null)
197: return false;
198: if (foreignKeyColumnName != null ? !foreignKeyColumnName
199: .equals(that.foreignKeyColumnName)
200: : that.foreignKeyColumnName != null)
201: return false;
202: if (foreignKeyColumnSchema != null ? !foreignKeyColumnSchema
203: .equals(that.foreignKeyColumnSchema)
204: : that.foreignKeyColumnSchema != null)
205: return false;
206: if (foreignKeyColumnTable != null ? !foreignKeyColumnTable
207: .equals(that.foreignKeyColumnTable)
208: : that.foreignKeyColumnTable != null)
209: return false;
210: if (foreignKeyName != null ? !foreignKeyName
211: .equals(that.foreignKeyName)
212: : that.foreignKeyName != null)
213: return false;
214: if (primaryKeyColumnName != null ? !primaryKeyColumnName
215: .equals(that.primaryKeyColumnName)
216: : that.primaryKeyColumnName != null)
217: return false;
218: if (primaryKeyColumnTable != null ? !primaryKeyColumnTable
219: .equals(that.primaryKeyColumnTable)
220: : that.primaryKeyColumnTable != null)
221: return false;
222: if (primaryKeyName != null ? !primaryKeyName
223: .equals(that.primaryKeyName)
224: : that.primaryKeyName != null)
225: return false;
226: if (primaryKeyTableCatalog != null ? !primaryKeyTableCatalog
227: .equals(that.primaryKeyTableCatalog)
228: : that.primaryKeyTableCatalog != null)
229: return false;
230: return !(primaryKeyTableScheam != null ? !primaryKeyTableScheam
231: .equals(that.primaryKeyTableScheam)
232: : that.primaryKeyTableScheam != null);
233:
234: }
235:
236: public int hashCode() {
237: int result;
238: result = (primaryKeyTableCatalog != null ? primaryKeyTableCatalog
239: .hashCode()
240: : 0);
241: result = 29
242: * result
243: + (primaryKeyTableScheam != null ? primaryKeyTableScheam
244: .hashCode()
245: : 0);
246: result = 29
247: * result
248: + (primaryKeyColumnTable != null ? primaryKeyColumnTable
249: .hashCode()
250: : 0);
251: result = 29
252: * result
253: + (primaryKeyColumnName != null ? primaryKeyColumnName
254: .hashCode() : 0);
255: result = 29
256: * result
257: + (foreignKeyColumnCatalog != null ? foreignKeyColumnCatalog
258: .hashCode()
259: : 0);
260: result = 29
261: * result
262: + (foreignKeyColumnSchema != null ? foreignKeyColumnSchema
263: .hashCode()
264: : 0);
265: result = 29
266: * result
267: + (foreignKeyColumnTable != null ? foreignKeyColumnTable
268: .hashCode()
269: : 0);
270: result = 29
271: * result
272: + (foreignKeyColumnName != null ? foreignKeyColumnName
273: .hashCode() : 0);
274: result = 29 * result + sequenceNumber;
275: result = 29 * result + updateRule;
276: result = 29 * result + deleteRule;
277: result = 29
278: * result
279: + (foreignKeyName != null ? foreignKeyName.hashCode()
280: : 0);
281: result = 29
282: * result
283: + (primaryKeyName != null ? primaryKeyName.hashCode()
284: : 0);
285: result = 29 * result + deferrability;
286: return result;
287: }
288:
289: @NotNull
290: public String toString() {
291: return "JDBCRelationInfo{" + "primaryKeyTableCatalog='"
292: + primaryKeyTableCatalog + "'"
293: + ", primaryKeyTableScheam='" + primaryKeyTableScheam
294: + "'" + ", primaryKeyColumnTable='"
295: + primaryKeyColumnTable + "'"
296: + ", primaryKeyColumnName='" + primaryKeyColumnName
297: + "'" + ", foreignKeyColumnCatalog='"
298: + foreignKeyColumnCatalog + "'"
299: + ", foreignKeyColumnSchema='" + foreignKeyColumnSchema
300: + "'" + ", foreignKeyColumnTable='"
301: + foreignKeyColumnTable + "'"
302: + ", foreignKeyColumnName='" + foreignKeyColumnName
303: + "'" + ", sequenceNumber=" + sequenceNumber
304: + ", updateRule=" + updateRule + ", deleteRule="
305: + deleteRule + ", foreignKeyName='" + foreignKeyName
306: + "'" + ", primaryKeyName='" + primaryKeyName + "'"
307: + ", deferrability=" + deferrability + "}";
308: }
309: }
|