com.altair.hwm.database.dbmodel
Class HWMRelationClass

java.lang.Object
  extended by com.altair.hwm.database.dbmodel.HWMClass
      extended by com.altair.hwm.database.dbmodel.HWMRelationClass
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.beans.VetoableChangeListener, java.util.EventListener

public class HWMRelationClass
extends HWMClass

Title: HWMRelationClass

Description: This class represents a relationship between any two classes A and B

Company: Altair Engineering, Inc.


Field Summary
static java.lang.String PROP_REL_AB
          The name of the property (name for relationship from class A to B) which when changed, an event is fired
static java.lang.String PROP_REL_BA
          The name of the property (name for relationship from class B to A) which when changed, an event is fired
 
Fields inherited from class com.altair.hwm.database.dbmodel.HWMClass
HWM_UNIQUE_ID, MANDATORY_ATTRIB_COUNT, PROP_CLASS_ATTRIB, PROP_CLASS_ATTRIB_ADD, PROP_CLASS_ATTRIB_DEL, PROP_CLASS_CONST, PROP_CLASS_DISPLAY, PROP_CLASS_NAME
 
Method Summary
 HWMAttribute AddAttribute(java.lang.String strAttribName)
          Please use AddAttributeA and AddAttributeB to add the attributes.
 void AddAttributes(java.lang.String strAttribA, HWMAttribute hwmAttribA, java.lang.String strAttribB, HWMAttribute hwmAttribB)
          Add attributes A, B in the relationship class
 HWMForeignAttribute AddFgnAttrib(java.lang.String strName, HWMAttribute hwmAttrib)
          Add a foreign attribute to the class
 HWMForeignAttribute AddForeignAttribute(java.lang.String strName, HWMAttribute hwmAttrib)
          Please use AddAttributeA and AddAttributeB to add the attributes.
 void Export(org.jdom.Element elemClass)
          Creates XML element representation of this class
 HWMAttribute GetAttributeA()
          Returns the attribute A
 HWMAttribute GetAttributeB()
          Returns the attribute B
 java.sql.ResultSet GetRelationshipAB(java.lang.Object objValue)
          Given A's value, get all B
 java.sql.ResultSet GetRelationshipBA(java.lang.Object objValue)
          Given B's value, get all A
 java.lang.String GetRelationshipNameAToB()
          Get the name for relation from Class A to B
 java.lang.String GetRelationshipNameBToA()
          Get the name for relation from Class B to A
 void Import(org.jdom.Element elemClass)
          Recreates the class.
 void Init()
          Init creates the required attributes
 void RemoveAttribute(java.lang.String strAttribName)
          Use RemoveAttributes instead of this method.
 void RemoveAttributes()
          Removes attributes A, B in the relationship class
 void Resolve()
          Resolves the foreign attribs and constraints.
 void SetRelationshipNameAToB(java.lang.String strNameAToB)
          Set the name for relation from Class A to B
 void SetRelationshipNameBToA(java.lang.String strNameBToA)
          Set the name for relation from Class B to A
 
Methods inherited from class com.altair.hwm.database.dbmodel.HWMClass
AddData, addPropertyChangeListener, addVetoableChangeListener, GetAttribute, GetAttributeCount, GetAttributes, GetConstraints, GetData, GetData, GetData, GetDataModel, GetDisplayName, GetForeignAttributes, GetName, GetPrimaryAttribute, GetRelatedClasses, GetSQLRepresentation, IsEditable, IsRelated, IsVisible, propertyChange, RemoveData, removePropertyChangeListener, removeVetoableChangeListener, SetDisplayName, SetEditable, SetName, SetVisible, toString, UpdateData, vetoableChange
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_REL_AB

public static final java.lang.String PROP_REL_AB
The name of the property (name for relationship from class A to B) which when changed, an event is fired

See Also:
Constant Field Values

PROP_REL_BA

public static final java.lang.String PROP_REL_BA
The name of the property (name for relationship from class B to A) which when changed, an event is fired

See Also:
Constant Field Values
Method Detail

Init

public void Init()
          throws java.lang.Exception
Init creates the required attributes

Overrides:
Init in class HWMClass
Throws:
java.lang.Exception

GetRelationshipNameAToB

public java.lang.String GetRelationshipNameAToB()
Get the name for relation from Class A to B

Returns:
String The name for the relationship form class A to B

SetRelationshipNameAToB

public void SetRelationshipNameAToB(java.lang.String strNameAToB)
Set the name for relation from Class A to B

Parameters:
strNameAToB - The name for the relationship form class A to B

GetRelationshipNameBToA

public java.lang.String GetRelationshipNameBToA()
Get the name for relation from Class B to A

Returns:
String The name for the relationship form class B to A

SetRelationshipNameBToA

public void SetRelationshipNameBToA(java.lang.String strNameBToA)
Set the name for relation from Class B to A

Parameters:
strNameBToA - The name for the relationship form class B to A

AddAttribute

public HWMAttribute AddAttribute(java.lang.String strAttribName)
Please use AddAttributeA and AddAttributeB to add the attributes. This method does nothing.

Overrides:
AddAttribute in class HWMClass
Parameters:
strAttribName - The name of the attribute that should be added to this class.
Returns:
HWMAttribute Always returns null.

AddForeignAttribute

public HWMForeignAttribute AddForeignAttribute(java.lang.String strName,
                                               HWMAttribute hwmAttrib)
                                        throws java.lang.Exception
Please use AddAttributeA and AddAttributeB to add the attributes.

Overrides:
AddForeignAttribute in class HWMClass
Parameters:
strName - The name for the fgn attribute
hwmAttrib - An attribute to be contained in this class
Returns:
HWMForeignAttribute Always returns null
Throws:
java.lang.Exception - If a class with given name already exists, an exception is thrown

AddFgnAttrib

public HWMForeignAttribute AddFgnAttrib(java.lang.String strName,
                                        HWMAttribute hwmAttrib)
                                 throws java.lang.Exception
Add a foreign attribute to the class

Parameters:
strName - The name for the fgn attribute
hwmAttrib - An attribute to be contained in this class
Returns:
HWMForeignAttribute Always returns null
Throws:
java.lang.Exception - If a class with given name already exists, an exception is thrown

RemoveAttribute

public void RemoveAttribute(java.lang.String strAttribName)
                     throws java.lang.Exception
Use RemoveAttributes instead of this method.

Overrides:
RemoveAttribute in class HWMClass
Parameters:
strAttribName - The name of the attribute to be removed
Throws:
java.lang.Exception

AddAttributes

public void AddAttributes(java.lang.String strAttribA,
                          HWMAttribute hwmAttribA,
                          java.lang.String strAttribB,
                          HWMAttribute hwmAttribB)
                   throws java.lang.Exception
Add attributes A, B in the relationship class

Parameters:
strAttribA - The name for fgn attrib A
hwmAttribA - An attribute to be contained in this class (A)
strAttribB - The name for fgn attrib B
hwmAttribB - An attribute to be contained in this class (B)
Throws:
java.lang.Exception - If the attribute cannot be added

RemoveAttributes

public void RemoveAttributes()
                      throws java.lang.Exception
Removes attributes A, B in the relationship class

Throws:
java.lang.Exception - If the attribute cannot be added

GetAttributeA

public HWMAttribute GetAttributeA()
Returns the attribute A

Returns:
HWMAttribute The first attribute (i.e. A) in this relationship

GetAttributeB

public HWMAttribute GetAttributeB()
Returns the attribute B

Returns:
HWMAttribute The second attribute (i.e. B) in this relationship

GetRelationshipAB

public java.sql.ResultSet GetRelationshipAB(java.lang.Object objValue)
                                     throws java.lang.Exception
Given A's value, get all B

Parameters:
objValue - The value of attribute A
Returns:
ResultSet The result set which has the data corresponding to the relation A-B
Throws:
java.lang.Exception - If the data cannot be retrieved

GetRelationshipBA

public java.sql.ResultSet GetRelationshipBA(java.lang.Object objValue)
                                     throws java.lang.Exception
Given B's value, get all A

Parameters:
objValue - The value of attribute B
Returns:
ResultSet The result set which has the data corresponding to the relation B-A
Throws:
java.lang.Exception - If the data cannot be retrieved

Export

public void Export(org.jdom.Element elemClass)
Creates XML element representation of this class

Overrides:
Export in class HWMClass
Parameters:
elemClass - The element representing this class

Import

public void Import(org.jdom.Element elemClass)
            throws java.lang.Exception
Recreates the class. This duplicates code from super class because the AddAttribute cannot be used for relation classes.

Overrides:
Import in class HWMClass
Parameters:
elemDM - The element representing this class
Throws:
java.lang.Exception

Resolve

public void Resolve()
             throws java.lang.Exception
Resolves the foreign attribs and constraints. The code is duplicated from the HWMClass 'cause AddForeignAttribute cannot be called on a relation class

Overrides:
Resolve in class HWMClass
Throws:
java.lang.Exception