com.finalist.jaggenerator.modules
Class Relation

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended bycom.finalist.jaggenerator.modules.Relation
All Implemented Interfaces:
java.lang.Cloneable, JagBean, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class Relation
extends javax.swing.tree.DefaultMutableTreeNode
implements JagBean

This class models a container-managed relation. A Relation maintains three views: a DefaultMutableTreeNode, an XML view and a Swing JPanel. Unfortunately this class is kind of a Model, View and Controller rolled into one, but that's just the way JagBeans have been designed...

The relation data is initially generated using foreign key information read from a database table (or just filled in by hand from the GUI).

Author:
Michael O'Connor - Finalist IT Group
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.tree.DefaultMutableTreeNode
 
Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
Relation(Entity localEntity)
          Constructs a new Relation from scratch.
Relation(Entity localEntity, org.w3c.dom.Element el)
          (Re-)Constructs a Relation from an XML element.
Relation(Entity localEntity, ForeignKey fk)
          Constructs a Relation from a ForeignKey object.
Relation(Entity localEntity, ForeignKey fk, boolean waitForInitSignal)
          Constructs a Relation from a ForeignKey object.
 
Method Summary
 TemplateString getFieldName()
          Gets the name of the imported foreign key field in the parent entity bean on the 'local' side of this relation.
 Field getFkField()
           
 java.lang.String getForeignColumn()
          Gets 'foreignColumn' : the name of the primary key column at the other end of the relation.
 Field getForeignPkField()
           
 TemplateString getForeignPkFieldName()
          Gets the name of the exported primary key field at the other end of the relation.
 java.lang.String getForeignTable()
          Gets 'foreignTable' : the name of the table at the other end of the relation.
 java.lang.String getLocalColumn()
          Gets 'localColumn' : the name of the column at the local end of the relation.
 Entity getLocalEntity()
           
 java.lang.String getName()
          Gets 'name' : the name of this relation.
 javax.swing.JPanel getPanel()
          Gets the Swing JPanel view of this relation.
 java.lang.String getRefName()
           
 Entity getRelatedEntity()
          Gets the Entity object that this Relation relates to.
 java.lang.String getTargetName()
          Gets 'targetName' : the name given to the reciprocal end of this relation (if it is bidirectional).
 void getXML(org.w3c.dom.Element parent)
          Creates the XML view of this relation and appends it as a new child to the specified XML element.
 boolean isBidirectional()
          Gets 'bidirectional' : whether or not this relation is also navigable the other way round.
 boolean isTargetMultiple()
          Gets 'targetMultiple' : whether or not this relation maps to multiple entities at the 'foreign' end.
 void notifyFieldNameChanged(java.lang.String oldName, java.lang.String text)
           
 void notifyLocalEntityIsComplete()
          RelationPanels can't finish initialising themselves until the local-side entity is completely generated (until all the entity's fields are generated).
 void setBidirectional(boolean bidirectional)
           
 void setFieldName(java.lang.String fieldName)
           
 void setFkField(Field field)
           
 void setForeignColumn(java.lang.String foreignColumn)
           
 void setForeignPkField(Field foreignPkField)
           
 void setForeignPkFieldName(java.lang.String foreignField)
           
 void setForeignTable(java.lang.String foreignTable)
           
 void setLocalColumn(java.lang.String localColumn)
           
 void setName(java.lang.String name)
           
 void setTargetMultiple(boolean targetMultiple)
           
 void setTargetName(java.lang.String targetName)
           
 java.lang.String toString()
           
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Relation

public Relation(Entity localEntity)
Constructs a new Relation from scratch.

Parameters:
localEntity - the parent entity bean on the local side of this relation.

Relation

public Relation(Entity localEntity,
                ForeignKey fk)
Constructs a Relation from a ForeignKey object.

Parameters:
localEntity - the parent entity bean on the local side of this relation.
fk - the foreign key.

Relation

public Relation(Entity localEntity,
                ForeignKey fk,
                boolean waitForInitSignal)
Constructs a Relation from a ForeignKey object.

Parameters:
localEntity - the parent entity bean on the local side of this relation.
fk - the foreign key.
waitForInitSignal - if true panel delays initialisation until notified.

Relation

public Relation(Entity localEntity,
                org.w3c.dom.Element el)
(Re-)Constructs a Relation from an XML element.

Parameters:
localEntity - the parent entity bean on the local side of this relation.
el - the XML element.
Method Detail

getRefName

public java.lang.String getRefName()
Specified by:
getRefName in interface JagBean

getPanel

public javax.swing.JPanel getPanel()
Gets the Swing JPanel view of this relation.

Specified by:
getPanel in interface JagBean
Returns:
the JPanel.

getXML

public void getXML(org.w3c.dom.Element parent)
Creates the XML view of this relation and appends it as a new child to the specified XML element.

Specified by:
getXML in interface JagBean
Parameters:
parent - the XML element to become parent to this relation child.

getName

public java.lang.String getName()
Gets 'name' : the name of this relation.

Returns:
name

setName

public void setName(java.lang.String name)

getFieldName

public TemplateString getFieldName()
Gets the name of the imported foreign key field in the parent entity bean on the 'local' side of this relation.

Returns:
field

setFieldName

public void setFieldName(java.lang.String fieldName)

getTargetName

public java.lang.String getTargetName()
Gets 'targetName' : the name given to the reciprocal end of this relation (if it is bidirectional).

Returns:
targetName

setTargetName

public void setTargetName(java.lang.String targetName)

isTargetMultiple

public boolean isTargetMultiple()
Gets 'targetMultiple' : whether or not this relation maps to multiple entities at the 'foreign' end.

Returns:
targetMultiple

setTargetMultiple

public void setTargetMultiple(boolean targetMultiple)

isBidirectional

public boolean isBidirectional()
Gets 'bidirectional' : whether or not this relation is also navigable the other way round.

Returns:
bidirectional

setBidirectional

public void setBidirectional(boolean bidirectional)

getForeignTable

public java.lang.String getForeignTable()
Gets 'foreignTable' : the name of the table at the other end of the relation.

Returns:
foreignTable

setForeignTable

public void setForeignTable(java.lang.String foreignTable)

getForeignPkFieldName

public TemplateString getForeignPkFieldName()
Gets the name of the exported primary key field at the other end of the relation.

Returns:
foreignPkFieldName

setForeignPkFieldName

public void setForeignPkFieldName(java.lang.String foreignField)

getForeignPkField

public Field getForeignPkField()

setForeignPkField

public void setForeignPkField(Field foreignPkField)

getForeignColumn

public java.lang.String getForeignColumn()
Gets 'foreignColumn' : the name of the primary key column at the other end of the relation.

Returns:
foreignTable

setForeignColumn

public void setForeignColumn(java.lang.String foreignColumn)

getLocalColumn

public java.lang.String getLocalColumn()
Gets 'localColumn' : the name of the column at the local end of the relation.

Returns:
String with local column.

setLocalColumn

public void setLocalColumn(java.lang.String localColumn)

getRelatedEntity

public Entity getRelatedEntity()
Gets the Entity object that this Relation relates to.

Returns:

toString

public java.lang.String toString()

setFkField

public void setFkField(Field field)

getFkField

public Field getFkField()

getLocalEntity

public Entity getLocalEntity()

notifyLocalEntityIsComplete

public void notifyLocalEntityIsComplete()
RelationPanels can't finish initialising themselves until the local-side entity is completely generated (until all the entity's fields are generated). Call this method to wake up the sleeping initialisers.


notifyFieldNameChanged

public void notifyFieldNameChanged(java.lang.String oldName,
                                   java.lang.String text)


Copyright © 2003-2005 SourceForge. All Rights Reserved.