butler.sql.metadata
Class ForeignKey

java.lang.Object
  extended by butler.sql.metadata.ForeignKey
Direct Known Subclasses:
ConstantFilterFK, DomainPrefixForeignKey, TemporalForeignKey

public class ForeignKey
extends java.lang.Object

Foreign key in a relational database.

Author:
Fredrik Bertilsson

Constructor Summary
ForeignKey(java.lang.String name, Schema schema)
           
ForeignKey(java.lang.String pkTable, Table fkTable)
           
ForeignKey(java.lang.String pkTable, Table fkTable, java.lang.String name)
           
ForeignKey(Table pkTable, java.lang.String fkTable)
           
ForeignKey(Table pkTable, java.lang.String fkTable, java.lang.String name)
          Creates a foreign key to use in the pktable.
ForeignKey(Table pkTable, Table fkTable)
           
ForeignKey(Table pkTable, Table fkTable, java.lang.String name)
          Creates a foreign key to use in the fktable.
 
Method Summary
 void add(Column column)
          Adds a column to this foreign key
 void add(Column pkColumn, Column column)
          Adds a column in the foreign key, when the foreign key columns does not correspond to the primary key columns in the pk table.
 boolean equals(ForeignKey other)
           
 boolean equals(java.lang.Object other)
           
 RecordList findAllPKRecords()
           
 java.lang.String getCaption()
           
 java.util.List getColumns()
           
 Table getFKTable()
           
 Filter getJoinFilter(boolean oneToMany, java.lang.String startAlias, java.lang.String joinAlias)
           
 butler.util.LocalizedText getLocalizedCaption()
           
 java.lang.String getName()
           
 java.lang.String getPhysicalName()
           
 java.util.List getPKColumns()
           
 Table getPKTable()
           
 java.lang.String getQualifiedName()
           
 Schema getSchema()
           
 int hashCode()
           
 boolean isInPK()
           
 boolean isOneToOne()
           
static ForeignKey parse(org.dom4j.Element fkElement, Table tab)
           
 void setFKTable(Table tab)
           
 void setPKTable(Table tab)
           
 void setSchema(Schema schema)
           
 void toXML(org.xml.sax.ContentHandler handler, boolean pk)
          Returns fk's which has this pk table as a fk table and which columns is all pk columns but one.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForeignKey

public ForeignKey(Table pkTable,
                  Table fkTable,
                  java.lang.String name)
           throws java.lang.Exception
Creates a foreign key to use in the fktable. If this constructor is used, calls to method add(Column) has do be done to define the foreign key columns.

Parameters:
pkTable - Primary key table
fkTable - Foreign key table name
name - Foreign key name
Throws:
java.lang.Exception

ForeignKey

public ForeignKey(Table pkTable,
                  Table fkTable)
           throws java.lang.Exception
Throws:
java.lang.Exception

ForeignKey

public ForeignKey(java.lang.String name,
                  Schema schema)
           throws java.lang.Exception
Throws:
java.lang.Exception

ForeignKey

public ForeignKey(Table pkTable,
                  java.lang.String fkTable,
                  java.lang.String name)
           throws java.lang.Exception
Creates a foreign key to use in the pktable. If this constructor is used, no calls to method add(Column) has do be done. Foreign key column will be copied from the foreign key definition in the fktable.

Parameters:
pkTable - Primary key table
fkTable - Foreign key table name
name - Foreign key name
Throws:
java.lang.Exception

ForeignKey

public ForeignKey(Table pkTable,
                  java.lang.String fkTable)
           throws java.lang.Exception
Throws:
java.lang.Exception

ForeignKey

public ForeignKey(java.lang.String pkTable,
                  Table fkTable,
                  java.lang.String name)
           throws java.lang.Exception
Throws:
java.lang.Exception

ForeignKey

public ForeignKey(java.lang.String pkTable,
                  Table fkTable)
           throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

add

public void add(Column column)
         throws java.lang.Exception
Adds a column to this foreign key

Parameters:
column - Column in the fk table
Throws:
java.lang.Exception

add

public void add(Column pkColumn,
                Column column)
         throws java.lang.Exception
Adds a column in the foreign key, when the foreign key columns does not correspond to the primary key columns in the pk table.

Parameters:
pkColumn - Column in the pk table
column - Column in the fk table
Throws:
java.lang.Exception

setSchema

public void setSchema(Schema schema)

getSchema

public Schema getSchema()

getName

public java.lang.String getName()

getPhysicalName

public java.lang.String getPhysicalName()

getPKTable

public Table getPKTable()
                 throws java.lang.Exception
Throws:
java.lang.Exception

setPKTable

public void setPKTable(Table tab)

getFKTable

public Table getFKTable()
                 throws java.lang.Exception
Throws:
java.lang.Exception

setFKTable

public void setFKTable(Table tab)

getColumns

public java.util.List getColumns()
                          throws java.lang.Exception
Throws:
java.lang.Exception

getPKColumns

public java.util.List getPKColumns()
                            throws java.lang.Exception
Throws:
java.lang.Exception

equals

public boolean equals(ForeignKey other)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getQualifiedName

public java.lang.String getQualifiedName()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

toXML

public void toXML(org.xml.sax.ContentHandler handler,
                  boolean pk)
           throws java.lang.Exception
Returns fk's which has this pk table as a fk table and which columns is all pk columns but one.

Throws:
java.lang.Exception

getCaption

public java.lang.String getCaption()
                            throws java.lang.Exception
Throws:
java.lang.Exception

getLocalizedCaption

public butler.util.LocalizedText getLocalizedCaption()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

isOneToOne

public boolean isOneToOne()
                   throws java.lang.Exception
Throws:
java.lang.Exception

parse

public static ForeignKey parse(org.dom4j.Element fkElement,
                               Table tab)
                        throws java.lang.Exception
Throws:
java.lang.Exception

getJoinFilter

public Filter getJoinFilter(boolean oneToMany,
                            java.lang.String startAlias,
                            java.lang.String joinAlias)
                     throws java.lang.Exception
Throws:
java.lang.Exception

findAllPKRecords

public RecordList findAllPKRecords()
                            throws java.lang.Exception
Throws:
java.lang.Exception

isInPK

public boolean isInPK()
               throws java.lang.Exception
Throws:
java.lang.Exception