|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.architect.SQLObject
ca.sqlpower.architect.SQLRelationship
public class SQLRelationship
The SQLRelationship class represents a foriegn key relationship between two SQLTable objects or two groups of columns within the same table.
| Nested Class Summary | |
|---|---|
static class |
SQLRelationship.ColumnMapping
|
static class |
SQLRelationship.ColumnMappingFKColumnOrderComparator
Comparator that orders ColumnMapping objects by FK column position. |
static class |
SQLRelationship.Deferrability
The enumeration of all referential integrity constraint checking policies. |
protected class |
SQLRelationship.RelationshipManager
Listens to all activity at and under the pkTable and fkTable. |
static class |
SQLRelationship.UpdateDeleteRule
Enumeration of the various rules allowed for (foreign/imported/child) columns when their parent value is updated or deleted. |
| Field Summary | |
|---|---|
protected SQLRelationship.Deferrability |
deferrability
The deferrability rule for constraint checking on this relationship. |
protected SQLRelationship.UpdateDeleteRule |
deleteRule
The rule for what the DBMS should do to the child (imported) key value when its parent table (exported) row is deleted. |
protected int |
fkCardinality
|
static int |
FKCOLUMN
|
protected SQLRelationship.RelationshipManager |
fkColumnManager
|
protected SQLTable |
fkTable
|
protected boolean |
identifying
Value should be true if this relationship is identifying, and false if otherwise. |
static int |
MANY
|
static int |
ONE
|
protected java.lang.String |
physicalName
|
protected int |
pkCardinality
|
static int |
PKCOLUMN
|
protected SQLTable |
pkTable
|
protected SQLRelationship.UpdateDeleteRule |
updateRule
The rule for what the DBMS should do to the child (imported) key value when its parent table (exported) key value changes. |
static int |
ZERO
|
| Fields inherited from class ca.sqlpower.architect.SQLObject |
|---|
children, magicDisableCount, populated, undoEventListeners |
| Constructor Summary | |
|---|---|
SQLRelationship()
|
|
SQLRelationship(SQLRelationship relationshipToCopy)
A copy constructor that returns a copy of the provided SQLRelationship with the following properties copied: Name Identifying status Update rule Delete rule Deferrability |
|
| Method Summary | |
|---|---|
void |
addMapping(SQLColumn pkColumn,
SQLColumn fkColumn)
Convenience method for adding a SQLRelationship.ColumnMapping child to this relationship. |
boolean |
allowsChildren()
Relationships have ColumnMapping children. |
void |
attachRelationship(SQLTable pkTable,
SQLTable fkTable,
boolean autoGenerateMapping)
Associates an SQLRelationship with the given SQLTable
objects. |
void |
checkColumnLocked(SQLColumn col)
Throws a column locked exception if col is in a columnmapping of this relationship |
boolean |
containsFkColumn(SQLColumn col)
|
boolean |
containsPkColumn(SQLColumn col)
|
boolean |
determineIdentifyingStatus()
Some SQLRelationship objects may not have their identifying
property set properly which is particularly the case then creating
SQLRelationships for source database objects and then reverse
engineering, so this method will determine for certain if a relationship
is identifying or non-identifying. |
java.lang.Class<? extends SQLObject> |
getChildType()
|
SQLRelationship.Deferrability |
getDeferrability()
|
SQLRelationship.UpdateDeleteRule |
getDeleteRule()
|
int |
getFkCardinality()
Gets the value of fkCardinality |
SQLTable |
getFkTable()
|
SQLRelationship.ColumnMapping |
getMappingByFkCol(SQLColumn fkcol)
|
SQLRelationship.ColumnMapping |
getMappingByPkCol(SQLColumn pkcol)
|
java.util.List<SQLRelationship.ColumnMapping> |
getMappings()
Convenience method that casts children to List<ColumnMapping>. |
SQLObject |
getParent()
Returns the table that holds the primary keys (the imported table). |
int |
getPkCardinality()
Gets the value of pkCardinality |
SQLTable |
getPkTable()
|
SQLRelationship.RelationshipManager |
getRelationshipManager()
This method is for the benefit of the unit tests. |
java.lang.String |
getShortDisplayName()
Returns the foreign key name. |
SQLRelationship.UpdateDeleteRule |
getUpdateRule()
|
boolean |
isIdentifying()
Gets the value of identifying |
boolean |
isPopulated()
Returns true. |
void |
populate()
This class is not a lazy-loading class. |
java.lang.String |
printKeyColumns(int keyType)
|
void |
setDeferrability(SQLRelationship.Deferrability argDeferrability)
|
void |
setDeleteRule(SQLRelationship.UpdateDeleteRule rule)
|
void |
setFkCardinality(int argFkCardinality)
Sets the value of fkCardinality |
void |
setFkTable(SQLTable fkt)
|
void |
setIdentifying(boolean argIdentifying)
Sets the value of identifying, and moves the FK columns into or out of the FK Table's primary key as appropriate. |
protected void |
setParent(SQLObject newParent)
This method is useful, and has side effects. |
void |
setPkCardinality(int argPkCardinality)
Sets the value of pkCardinality |
void |
setPkTable(SQLTable pkt)
|
void |
setUpdateRule(SQLRelationship.UpdateDeleteRule rule)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int ZERO
public static final int ONE
public static final int MANY
public static final int PKCOLUMN
public static final int FKCOLUMN
protected SQLTable pkTable
protected SQLTable fkTable
protected SQLRelationship.UpdateDeleteRule updateRule
protected SQLRelationship.UpdateDeleteRule deleteRule
protected SQLRelationship.Deferrability deferrability
protected int pkCardinality
protected int fkCardinality
protected boolean identifying
Here is our definition of identifying relationships and non-identifying relationships (as discussed in the Architect Developer's mailing list).
An 'identifying' relationship is: A foreign key relationship in which the whole primary key of the parent table is entirely contained in the primary key of the child table.
A 'non-identifying' relationship is: A foreign key relationship in which the whole primary key of the parent table is NOT entirely contained in the primary key of the child table.
protected java.lang.String physicalName
protected SQLRelationship.RelationshipManager fkColumnManager
| Constructor Detail |
|---|
public SQLRelationship()
public SQLRelationship(SQLRelationship relationshipToCopy)
throws ArchitectException
relationshipToCopy - The SQLRelationship object to copy
ArchitectException| Method Detail |
|---|
public SQLRelationship.RelationshipManager getRelationshipManager()
public void attachRelationship(SQLTable pkTable,
SQLTable fkTable,
boolean autoGenerateMapping)
throws ArchitectException
SQLRelationship with the given SQLTable
objects. Also automatically generates the PK to FK column mapping if
autoGenerateMapping is set to true.
pkTable - The parent table in this relationship.fkTable - The child table in this relationship that contains the foreign
key.autoGenerateMapping - Automatically generates the PK to FK column mapping if true
ArchitectExceptionpublic SQLRelationship.ColumnMapping getMappingByPkCol(SQLColumn pkcol)
public boolean containsPkColumn(SQLColumn col)
public SQLRelationship.ColumnMapping getMappingByFkCol(SQLColumn fkcol)
public boolean containsFkColumn(SQLColumn col)
public java.util.List<SQLRelationship.ColumnMapping> getMappings()
XXX: should be removed when SQLObject API gets generics
public java.lang.String printKeyColumns(int keyType)
public void addMapping(SQLColumn pkColumn,
SQLColumn fkColumn)
throws ArchitectException
ArchitectExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic SQLObject getParent()
XXX this should return the parent folder of the pk table!
getParent in class SQLObjectprotected void setParent(SQLObject newParent)
setParent in class SQLObjectnewParent - If this is the same as pkTable or fkTable,
this method returns normally. Otherwise, this method throws
IllegalArgumentException.
ArchitectException
java.lang.IllegalArgumentException - if newParent is anything other
than this relationship's pkTable.exportedKeysFolder or
fkTable.importedKeysFolderpublic java.lang.String getShortDisplayName()
getShortDisplayName in class SQLObjectpublic boolean allowsChildren()
allowsChildren in class SQLObjectpublic void populate()
populate in class SQLObjectpublic boolean isPopulated()
isPopulated in class SQLObjectpublic SQLRelationship.UpdateDeleteRule getUpdateRule()
public void setUpdateRule(SQLRelationship.UpdateDeleteRule rule)
public SQLRelationship.UpdateDeleteRule getDeleteRule()
public void setDeleteRule(SQLRelationship.UpdateDeleteRule rule)
public SQLRelationship.Deferrability getDeferrability()
public void setDeferrability(SQLRelationship.Deferrability argDeferrability)
public int getPkCardinality()
public void setPkCardinality(int argPkCardinality)
argPkCardinality - Value to assign to this.pkCardinalitypublic int getFkCardinality()
public void setFkCardinality(int argFkCardinality)
argFkCardinality - Value to assign to this.fkCardinalitypublic boolean isIdentifying()
public void setIdentifying(boolean argIdentifying)
throws ArchitectException
argIdentifying - Value to assign to this.identifying
ArchitectExceptionpublic SQLTable getPkTable()
public void setPkTable(SQLTable pkt)
throws ArchitectException
ArchitectExceptionpublic SQLTable getFkTable()
public void setFkTable(SQLTable fkt)
throws ArchitectException
ArchitectExceptionpublic java.lang.Class<? extends SQLObject> getChildType()
getChildType in class SQLObject
public void checkColumnLocked(SQLColumn col)
throws LockedColumnException
col -
LockedColumnException
public boolean determineIdentifyingStatus()
throws ArchitectException
identifying
property set properly which is particularly the case then creating
SQLRelationships for source database objects and then reverse
engineering, so this method will determine for certain if a relationship
is identifying or non-identifying. This is currently primarily being used
for determining the identifying status of reverse-engineered
relationships.
ArchitectException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||