com.altair.hwm.database.dbmodel
Class HWMDBModel

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

public class HWMDBModel
extends java.lang.Object
implements java.beans.VetoableChangeListener

Title: HWMDBModel

Description: This class represents all database model. It will contain all the classes.

Company: Altair Engineering, Inc.


Field Summary
static java.lang.String DM_TBL_DM_ATTRIB
          The attribute name for the dm as a blob
static java.lang.String DM_TBL_NAME
          The table in the DB where the database model object is stored as a blob
static java.lang.String PROP_DM_CLASS_ADD
          The name of the property (class added) which when added, an event is fired
static java.lang.String PROP_DM_CLASS_DEL
          The name of the property (class removed) which when removed, an event is fired
static java.lang.String PROP_MODEL_CLEAR
          The property name for the event fired when the database model is cleared
static java.lang.String PROP_MODEL_NAME
          The property name for the name of this model
 
Constructor Summary
HWMDBModel(java.lang.String strName)
          Constructor
 
Method Summary
 HWMClass AddClass(java.lang.String strClassName, boolean bRelationClass)
          Add a class to the database model
 void addPropertyChangeListener(java.beans.PropertyChangeListener propChangeListener)
          Add property change listener
 void addVetoableChangeListener(java.beans.VetoableChangeListener vetoableListener)
          Add vetoable change listener
 void ClearAll()
          This is called when database model is being deleted
 void Export(org.jdom.Element elemDM)
          Creates XML element representation of this model
 void Export(java.io.OutputStream os)
          Export to the given output stream
 void Export(java.lang.String strFileName)
          Export to the given file
 int GetClassCount()
          Gets the number of classes
 DBServerComm GetDBServerComm()
          Gets the class to be used to communicate with the database server
 HWMClass GetHWMClass(java.lang.String strClassName)
          Gets the class with the given name
 java.util.Vector GetHWMClasses()
          Gets all the classes in the database model.
 java.lang.String GetName()
          Gets the name for the database model
 java.util.Vector GetOrderedHWMClasses()
          Gets all the classes in a order such that a referenced class comes ahead of the class that references it.
 void Import(org.jdom.Element elemDM)
          Recreates the database model
 void Import(java.io.InputStream is)
          Import the DM from the given input stream
 void Import(java.lang.String strFileName)
          Import the given file
 void Init()
          Init creates the required attributes
 void RemoveClass(java.lang.String strClassName)
          Removes a class from the class
 void removePropertyChangeListener(java.beans.PropertyChangeListener propChangeListener)
          Remove property change listener
 void removeVetoableChangeListener(java.beans.VetoableChangeListener vetoableListener)
          Remove vetoable change listener
 void Resolve()
          Resolves the relationship classes and constraints.
 HWMClass ResolveDependencies(HWMClass hwmClassToAdd, java.util.Vector vectClasses)
          Addes the class to the vector in an ordered way such that any class that it depend on is ahead in the vector
 void SetDBServerComm(DBServerComm dbServerComm)
          Sets the class to be used to communicate with the database server
 void SetName(java.lang.String strName)
          Sets the name for the database model
 java.lang.String toString()
          Returns the name for this class
 void vetoableChange(java.beans.PropertyChangeEvent propChangeEvt)
          This event is fired whenever an class name is changed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_MODEL_CLEAR

public static final java.lang.String PROP_MODEL_CLEAR
The property name for the event fired when the database model is cleared

See Also:
Constant Field Values

PROP_MODEL_NAME

public static final java.lang.String PROP_MODEL_NAME
The property name for the name of this model

See Also:
Constant Field Values

PROP_DM_CLASS_ADD

public static final java.lang.String PROP_DM_CLASS_ADD
The name of the property (class added) which when added, an event is fired

See Also:
Constant Field Values

PROP_DM_CLASS_DEL

public static final java.lang.String PROP_DM_CLASS_DEL
The name of the property (class removed) which when removed, an event is fired

See Also:
Constant Field Values

DM_TBL_NAME

public static final java.lang.String DM_TBL_NAME
The table in the DB where the database model object is stored as a blob

See Also:
Constant Field Values

DM_TBL_DM_ATTRIB

public static final java.lang.String DM_TBL_DM_ATTRIB
The attribute name for the dm as a blob

See Also:
Constant Field Values
Constructor Detail

HWMDBModel

public HWMDBModel(java.lang.String strName)
Constructor

Parameters:
strName - The name for the database model.
Method Detail

Init

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

Throws:
java.lang.Exception

SetDBServerComm

public void SetDBServerComm(DBServerComm dbServerComm)
Sets the class to be used to communicate with the database server

Parameters:
dbServerComm - The class that helps in communicating with the database server

GetDBServerComm

public DBServerComm GetDBServerComm()
                             throws java.lang.Exception
Gets the class to be used to communicate with the database server

Returns:
DBServerComm The class that helps in communicating with the database server
Throws:
java.lang.Exception

GetName

public java.lang.String GetName()
Gets the name for the database model

Returns:
String Name of this database model.

SetName

public void SetName(java.lang.String strName)
             throws java.beans.PropertyVetoException
Sets the name for the database model

Throws:
java.beans.PropertyVetoException - The exception thrown if a class with similar name already exists

GetClassCount

public int GetClassCount()
Gets the number of classes

Returns:
int The number of classes present.

GetHWMClass

public HWMClass GetHWMClass(java.lang.String strClassName)
Gets the class with the given name

Returns:
strClassName The name of the class. Returns null if the class with given name is not present

GetHWMClasses

public java.util.Vector GetHWMClasses()
Gets all the classes in the database model.

Returns:
Vector Returns a vector of all the classes in the model.

GetOrderedHWMClasses

public java.util.Vector GetOrderedHWMClasses()
Gets all the classes in a order such that a referenced class comes ahead of the class that references it.

Returns:
Vector Returns a vector of all the classes in the model arranged in a ordered way.

ResolveDependencies

public HWMClass ResolveDependencies(HWMClass hwmClassToAdd,
                                    java.util.Vector vectClasses)
                             throws java.lang.Exception
Addes the class to the vector in an ordered way such that any class that it depend on is ahead in the vector

Parameters:
hwmClassToAdd - The class to add to the vector
vectOrder - The vector of classes in an order such that all dependent classes are ahead
Returns:
HWMClass Returns the newly created HWMClass object
Throws:
java.lang.Exception - If a class with given name already exists, an exception is thrown

AddClass

public HWMClass AddClass(java.lang.String strClassName,
                         boolean bRelationClass)
                  throws java.lang.Exception
Add a class to the database model

Parameters:
strClassName - The name of the class that should be added to this database model
bRelationClass - If this flag is true, a relationship class is created else a plain info class is created
Returns:
HWMClass Returns the newly created HWMClass object
Throws:
java.lang.Exception - If a class with given name already exists, an exception is thrown

RemoveClass

public void RemoveClass(java.lang.String strClassName)
Removes a class from the class

Parameters:
strClassName - The name of the class to be removed

ClearAll

public void ClearAll()
This is called when database model is being deleted


Export

public void Export(java.lang.String strFileName)
            throws java.io.IOException
Export to the given file

Parameters:
strFileName - The file name to export to
Throws:
java.io.IOException

Export

public void Export(java.io.OutputStream os)
            throws java.io.IOException
Export to the given output stream

Parameters:
os - The output stream to which the data should be written to
Throws:
java.io.IOException

Import

public void Import(java.lang.String strFileName)
            throws java.io.IOException,
                   org.jdom.JDOMException,
                   java.lang.Exception
Import the given file

Parameters:
strFileName - The file name to import
Throws:
java.io.IOException
org.jdom.JDOMException
java.lang.Exception

Import

public void Import(java.io.InputStream is)
            throws java.lang.Exception
Import the DM from the given input stream

Parameters:
is - The input stream from which the data should be retrieved
Throws:
java.lang.Exception

Export

public void Export(org.jdom.Element elemDM)
            throws java.io.IOException
Creates XML element representation of this model

Parameters:
elemDM - The element representing this database model
Throws:
java.io.IOException

Import

public void Import(org.jdom.Element elemDM)
            throws java.lang.Exception
Recreates the database model

Parameters:
elemDM - The element representing this database model
Throws:
java.lang.Exception

Resolve

public void Resolve()
             throws java.lang.Exception
Resolves the relationship classes and constraints. This can be treated as the second pass

Throws:
java.lang.Exception

toString

public java.lang.String toString()
Returns the name for this class

Overrides:
toString in class java.lang.Object
Returns:
String The namefor this class

vetoableChange

public void vetoableChange(java.beans.PropertyChangeEvent propChangeEvt)
                    throws java.beans.PropertyVetoException
This event is fired whenever an class name is changed. Check if the name clashes with anyother class's name within the same database model. If it does then throw an exception.

Specified by:
vetoableChange in interface java.beans.VetoableChangeListener
Parameters:
propChangeEvt - The property change event object
Throws:
java.beans.PropertyVetoException - The exception is thrown when the class's name clashes with someother class's name

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener propChangeListener)
Add property change listener

Parameters:
propChangeListener - The listener for property change events fired by this class

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener propChangeListener)
Remove property change listener

Parameters:
propChangeListener - The listener to be removed

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener vetoableListener)
Add vetoable change listener

Parameters:
vetoableChangeListener - The listener for vetoable change events fired by this class

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener vetoableListener)
Remove vetoable change listener

Parameters:
vetoableListener - The listener to be removed