com.finalist.jaggenerator.modules
Class Entity

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended bycom.finalist.jaggenerator.modules.Entity
All Implemented Interfaces:
java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, JagBean, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class Entity
extends javax.swing.tree.DefaultMutableTreeNode
implements JagBean, java.awt.event.ActionListener

Author:
hillie
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.tree.DefaultMutableTreeNode
 
Field Summary
 javax.swing.JComboBox isCompositeCombo
           
(package private) static org.apache.commons.logging.Log log
           
 javax.swing.JTextField nameText
           
 javax.swing.JTextField pKeyText
           
 javax.swing.JTextField pKeyTypeText
           
 javax.swing.JTextField rootPackageText
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
Entity(org.w3c.dom.Element el)
           
Entity(java.lang.String rootPackage, java.lang.String tableName, java.lang.String pKey)
          Creates new form BeanForm
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addRelation(Relation relation)
          Inserts a relation in the correct position (relations are always positioned first amongst an Entity's children, because it looks nicer!).
 int countPrimaryKeyFields()
          Count the number of primary key fields.
 TemplateString getDescription()
           
 java.util.List getEntitiesRelations()
          Get a list of all Relations to this entity.
 java.util.List getFields()
           
 java.lang.String getFirstPrimaryKeyFieldName()
          Returns the First primary key field
 java.util.List getFkFields()
           
 boolean getHasRelations()
           
 java.lang.String getIsComposite()
           
 TemplateString getLocalTableName()
          Gets the name of the table represented by this Entity.
 TemplateString getName()
           
 java.util.List getNonFkFields()
           
 java.util.List getNonPkFields()
           
 java.util.List getNonPkRelationFields()
          Gets the fields that are neither primary keys, nor a foreign key involved in a container-managed relation.
 java.util.List getNonRelationFields()
           
 javax.swing.JPanel getPanel()
           
 java.util.List getPkFields()
           
 Field getPrimaryKey()
           
 java.lang.String getPrimaryKeyClass()
          Returns the class that represents the primary key type
 TemplateString getPrimaryKeyName()
           
 TemplateString getPrimaryKeyType()
           
 java.lang.String getRefName()
           
 java.util.List getRelatedEntities()
           
 java.util.List getRelationFieldNames()
          Gets the set of field names within this entity, which are used as relations to other CMR-related entity beans.
 java.util.List getRelations()
           
 TemplateString getRootPackage()
           
 java.lang.String getRootPath()
           
 java.lang.String getTableName()
           
 void getXML(org.w3c.dom.Element el)
           
 boolean isCompositeKey()
          Iterates over all the table columns and determines whether the table has a single key or a composite key.
 void notifyRelationsThatConstructionIsFinished()
          While an entity is being created, its constituent relations have to wait for the entity to finish being constructed before they can finish initialising themselves.
 void notifyRelationsThatFieldNameChanged(java.lang.String oldName, java.lang.String text)
          When a field name is changed, call this to tell all relations to update their lists.
 void setDescription(java.lang.String text)
           
 void setIsComposite(java.lang.String composite)
           
 void setName(java.lang.String text)
           
 void setPKeyType(java.lang.String pKeyType)
           
 void setPrimaryKey(Field field)
          Called by a field when it has been selected as primary key in the GUI.
 void setRefName(java.lang.String text)
           
 void setRootPackage(java.lang.String text)
           
 void setTableName(java.lang.String table)
           
 java.lang.String toString()
           
 void unsetPrimaryKey(Field field)
          Called by a field when it has been de-selected as primary key in the GUI.
 
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
 

Field Detail

log

static org.apache.commons.logging.Log log

isCompositeCombo

public javax.swing.JComboBox isCompositeCombo

nameText

public javax.swing.JTextField nameText

pKeyText

public javax.swing.JTextField pKeyText

pKeyTypeText

public javax.swing.JTextField pKeyTypeText

rootPackageText

public javax.swing.JTextField rootPackageText
Constructor Detail

Entity

public Entity(java.lang.String rootPackage,
              java.lang.String tableName,
              java.lang.String pKey)
Creates new form BeanForm


Entity

public Entity(org.w3c.dom.Element el)
Method Detail

getPanel

public javax.swing.JPanel getPanel()
Specified by:
getPanel in interface JagBean

getRefName

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

setRefName

public void setRefName(java.lang.String text)

setPKeyType

public void setPKeyType(java.lang.String pKeyType)

getXML

public void getXML(org.w3c.dom.Element el)
            throws javax.xml.parsers.ParserConfigurationException
Specified by:
getXML in interface JagBean
Throws:
javax.xml.parsers.ParserConfigurationException

getName

public TemplateString getName()

setName

public void setName(java.lang.String text)

getDescription

public TemplateString getDescription()

setDescription

public void setDescription(java.lang.String text)

getRootPackage

public TemplateString getRootPackage()

setRootPackage

public void setRootPackage(java.lang.String text)

getPrimaryKey

public Field getPrimaryKey()

setPrimaryKey

public void setPrimaryKey(Field field)
Called by a field when it has been selected as primary key in the GUI.

Parameters:
field -

unsetPrimaryKey

public void unsetPrimaryKey(Field field)
Called by a field when it has been de-selected as primary key in the GUI.

Parameters:
field -

getPrimaryKeyType

public TemplateString getPrimaryKeyType()

getPrimaryKeyName

public TemplateString getPrimaryKeyName()

getIsComposite

public java.lang.String getIsComposite()

setIsComposite

public void setIsComposite(java.lang.String composite)

getRootPath

public java.lang.String getRootPath()

getRelations

public java.util.List getRelations()

getEntitiesRelations

public java.util.List getEntitiesRelations()
Get a list of all Relations to this entity.

Returns:
list with relations.

getRelatedEntities

public java.util.List getRelatedEntities()

getRelationFieldNames

public java.util.List getRelationFieldNames()
Gets the set of field names within this entity, which are used as relations to other CMR-related entity beans.

Returns:
a Set of TemplateString objects.

getHasRelations

public boolean getHasRelations()

getFields

public java.util.List getFields()

getNonFkFields

public java.util.List getNonFkFields()

getFkFields

public java.util.List getFkFields()

getNonRelationFields

public java.util.List getNonRelationFields()

getPkFields

public java.util.List getPkFields()

getNonPkFields

public java.util.List getNonPkFields()

getNonPkRelationFields

public java.util.List getNonPkRelationFields()
Gets the fields that are neither primary keys, nor a foreign key involved in a container-managed relation.

Returns:

isCompositeKey

public boolean isCompositeKey()
Iterates over all the table columns and determines whether the table has a single key or a composite key. The key is said to be composite when more than one column is part of the key.

Returns:
true only when more the table has a composite key else false

countPrimaryKeyFields

public int countPrimaryKeyFields()
Count the number of primary key fields.

Returns:
int with the number of primary keys

getPrimaryKeyClass

public java.lang.String getPrimaryKeyClass()
Returns the class that represents the primary key type

Returns:
the class that represents the primary key type

getFirstPrimaryKeyFieldName

public java.lang.String getFirstPrimaryKeyFieldName()
Returns the First primary key field

Returns:
the field name of the first primary key field or an empty string if nothing was found.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getLocalTableName

public TemplateString getLocalTableName()
Gets the name of the table represented by this Entity.

Returns:
the table name.

setTableName

public void setTableName(java.lang.String table)

getTableName

public java.lang.String getTableName()

notifyRelationsThatConstructionIsFinished

public void notifyRelationsThatConstructionIsFinished()
While an entity is being created, its constituent relations have to wait for the entity to finish being constructed before they can finish initialising themselves. Call this method when the Entity is ready.


notifyRelationsThatFieldNameChanged

public void notifyRelationsThatFieldNameChanged(java.lang.String oldName,
                                                java.lang.String text)
When a field name is changed, call this to tell all relations to update their lists.

Parameters:
oldName -
text -

toString

public java.lang.String toString()

addRelation

public void addRelation(Relation relation)
Inserts a relation in the correct position (relations are always positioned first amongst an Entity's children, because it looks nicer!).

Parameters:
relation -


Copyright © 2003-2005 SourceForge. All Rights Reserved.