org.biomage.tools.generate_er
Class CreateMageER

java.lang.Object
  extended by org.biomage.tools.generate_er.CreateMageER

public class CreateMageER
extends java.lang.Object


Field Summary
static java.lang.String ABSTRACT
          the object (table) is abstract
static java.lang.String aLine
          a line for seperation
static java.lang.String DATA
          table type is data
static java.lang.String FALSE
          the foreign key does not cause a cascade action
static java.lang.String FIRSTLINE
          first line in the MAGE_ER.xml file
static java.lang.String FOREIGNKEY
          indicate the column is a one_to_one foreign key.
static java.lang.String HALF_INDENT
          one indent: a tab key
static java.lang.String ID
          name of the primary key for tables
static java.lang.String INDENT
          one indent: a tab key
static java.lang.String INTEGER
          association column type is int, and also columns in linking table
static java.lang.String LINKING
          table type is linking
static java.lang.String LINKING_FKEY
          foreign key type is many to many
static java.lang.String LOOKUP_FKEY
          foreign key type is for look up table
static java.lang.String NEWLINE
          a new line character
static java.lang.String NO_BASE_CLASS
          the object (table) does not have base class
static java.lang.String NOT_ABSTRACT
          the object (table) is not abstract
static java.lang.String NOT_NULL
          the column can not be null
static java.lang.String NULL
          the column can be null
static java.lang.String ONE_TO_MANY
          foreign key type is one to many
static java.lang.String ONE_TO_ONE
          foreign key type is one to one
static java.lang.String oneIndent
          one indent: a tab key
static java.lang.String PRIMARY_KEY
          full name of the primary key for tables
static java.lang.String SECONDLINE
          second line in the MAGE_ER.xml file
static java.lang.String SERIAL
          type of the primary key for tables
static java.lang.String SUBSET
          table type is subset
static java.lang.String TRUE
          the foreign key causes a cascade action
static java.lang.String VALIDATION
          table type is validation
static java.lang.String VIEW
          table type is view
 
Constructor Summary
CreateMageER()
          Description: Constructor for the CreateMageER object.
 
Method Summary
protected  java.lang.String alphabetLinkingTabelName(java.lang.String string1, java.lang.String string2)
          Description: compare two strings and link them alphabetically if string1 < string2: negative number
 void buildTables(java.lang.String outputDir, java.util.Vector classes)
           
protected  boolean CheckRelationship(java.util.Vector otmVector, java.lang.String oriType, boolean owner)
          Description: check to see if there is the case that A has two one_to_many relationships with B and get the same name
protected  Index createIndex(AssociationColumn column, java.lang.String tableName, java.lang.String columnName)
          Description: create a Index object for a foreign key fk_oto does not have index fk_mto has index fk_mtm has index
protected  AssociationColumn createLinkColumn(java.lang.String className)
          Description: create a column for a linking table
protected  LinkingKey createLinkingKey(AssociationColumn link1, AssociationColumn link2)
          Description: create a linkingKey object and set into the table
protected  Table createLinkingTable(CreateFile createFile, java.lang.String oriType)
          Description: create a linking table
protected  Unique createUnique(java.util.Vector uniqueVector)
          Description: create a Unique object which takes a vector of columns
protected  java.lang.String getDatatype(CreateFile.AttrInformation attr)
          Description: Pass through get method for datatype.
protected  java.lang.String getFullName(java.lang.String name)
          Description: change the first letter to be capitalized and insert a space between words dataType to Data Type
protected  java.lang.String lowerCaseFirstLetter(java.lang.String name)
          Description: change the first letter of a string to be lower case
protected  void ManyToMany(CreateFile createFile, java.lang.String oriType)
          Description: create an association column for many to many relationship
protected  void ManyToOne(Table table, AssociationColumn column, CreateFile createFile, CreateFile.AssociationAttrInformation attr, java.io.FileWriter w)
          Description: create an association column for one to one relationship
protected  void OneToMany(Table table, AssociationColumn column, CreateFile createFile, CreateFile.AssociationAttrInformation attr)
          Description: create an association column for one to one relationship
protected  void OneToOne(Table table, AssociationColumn column, CreateFile createFile, CreateFile.AssociationAttrInformation attr)
          Description: create an association column for one to one relationship
 void writeAbstractInfo(CreateFile createFile, Table table)
          Description: set the if the the class (table) is abstract
 void writeAssociationInfo(CreateFile createFile, Table table, java.io.FileWriter w)
          Description: set an association's name, scope, and data type.
 void writeAttrInfo(CreateFile createFile, Table table)
          Description: set an attribute's name, scope, and data type.
 void writeBaseClassName(CreateFile createFile, Table table)
          Description: set the base class name for the class
protected  void WriteMAGEER(java.util.Map tableMap, java.io.FileWriter f3, java.io.FileWriter w)
          Description: traverse the map and write out the MAGEER.xml
protected  void WriteOneTable(Table table, java.io.FileWriter f3)
          Description: write one table to the output file
 void writeTableName(CreateFile createFile, Table table)
          Description: set the table name and create primary key column and set the primary key into the table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEWLINE

public static final java.lang.String NEWLINE
a new line character


oneIndent

public static final java.lang.String oneIndent
one indent: a tab key


INDENT

public static final java.lang.String INDENT
one indent: a tab key

See Also:
Constant Field Values

HALF_INDENT

public static final java.lang.String HALF_INDENT
one indent: a tab key

See Also:
Constant Field Values

aLine

public static final java.lang.String aLine
a line for seperation

See Also:
Constant Field Values

FOREIGNKEY

public static final java.lang.String FOREIGNKEY
indicate the column is a one_to_one foreign key. append at the end for the column name

See Also:
Constant Field Values

ID

public static final java.lang.String ID
name of the primary key for tables

See Also:
Constant Field Values

SERIAL

public static final java.lang.String SERIAL
type of the primary key for tables

See Also:
Constant Field Values

PRIMARY_KEY

public static final java.lang.String PRIMARY_KEY
full name of the primary key for tables

See Also:
Constant Field Values

NOT_NULL

public static final java.lang.String NOT_NULL
the column can not be null

See Also:
Constant Field Values

NULL

public static final java.lang.String NULL
the column can be null

See Also:
Constant Field Values

ABSTRACT

public static final java.lang.String ABSTRACT
the object (table) is abstract

See Also:
Constant Field Values

NOT_ABSTRACT

public static final java.lang.String NOT_ABSTRACT
the object (table) is not abstract

See Also:
Constant Field Values

NO_BASE_CLASS

public static final java.lang.String NO_BASE_CLASS
the object (table) does not have base class

See Also:
Constant Field Values

TRUE

public static final java.lang.String TRUE
the foreign key causes a cascade action

See Also:
Constant Field Values

FALSE

public static final java.lang.String FALSE
the foreign key does not cause a cascade action

See Also:
Constant Field Values

INTEGER

public static final java.lang.String INTEGER
association column type is int, and also columns in linking table

See Also:
Constant Field Values

DATA

public static final java.lang.String DATA
table type is data

See Also:
Constant Field Values

VALIDATION

public static final java.lang.String VALIDATION
table type is validation

See Also:
Constant Field Values

LINKING

public static final java.lang.String LINKING
table type is linking

See Also:
Constant Field Values

VIEW

public static final java.lang.String VIEW
table type is view

See Also:
Constant Field Values

SUBSET

public static final java.lang.String SUBSET
table type is subset

See Also:
Constant Field Values

ONE_TO_ONE

public static final java.lang.String ONE_TO_ONE
foreign key type is one to one

See Also:
Constant Field Values

ONE_TO_MANY

public static final java.lang.String ONE_TO_MANY
foreign key type is one to many

See Also:
Constant Field Values

LINKING_FKEY

public static final java.lang.String LINKING_FKEY
foreign key type is many to many

See Also:
Constant Field Values

LOOKUP_FKEY

public static final java.lang.String LOOKUP_FKEY
foreign key type is for look up table

See Also:
Constant Field Values

FIRSTLINE

public static final java.lang.String FIRSTLINE
first line in the MAGE_ER.xml file

See Also:
Constant Field Values

SECONDLINE

public static final java.lang.String SECONDLINE
second line in the MAGE_ER.xml file

See Also:
Constant Field Values
Constructor Detail

CreateMageER

public CreateMageER()
             throws java.lang.Exception
Description: Constructor for the CreateMageER object.

Parameters:
Throws:
java.lang.Exception -

Method Detail

buildTables

public void buildTables(java.lang.String outputDir,
                        java.util.Vector classes)
                 throws java.lang.Exception
Parameters:
classes: - vector of CreateClassFiles, one per table (class).
Throws:
java.lang.Exception - for FileWriter


writeTableName

public void writeTableName(CreateFile createFile,
                           Table table)
                    throws java.lang.Exception
Description: set the table name and create primary key column and set the primary key into the table

Parameters:
createFile: - the object for the table we are creating f1: file writer object table: the table we are creating
Throws:
java.lang.Exception - for FileWriter


writeAttrInfo

public void writeAttrInfo(CreateFile createFile,
                          Table table)
                   throws java.lang.Exception
Description: set an attribute's name, scope, and data type. These are simple data type attributes.

Parameters:
createFile: - the object for the table we are creating f1: file writer object table: the table we are creating
Throws:
java.lang.Exception - for FileWriter


getDatatype

protected java.lang.String getDatatype(CreateFile.AttrInformation attr)
                                throws java.lang.Exception
Description: Pass through get method for datatype. Changes 'any' to 'Object'. This method is used by writeAttrInfo and writeAssociationInfo methods.

Parameters:
attr: - one simple data type attribute of the object
Returns:
data type of the attribute

Throws:
java.lang.Exception - for FileWriter


getFullName

protected java.lang.String getFullName(java.lang.String name)
                                throws java.lang.Exception
Description: change the first letter to be capitalized and insert a space between words dataType to Data Type

Parameters:
name - the string needs to be changed f1: file writer object
Returns:
the reformatted string

Throws:
java.lang.Exception - for FileWriter


writeBaseClassName

public void writeBaseClassName(CreateFile createFile,
                               Table table)
                        throws java.lang.Exception
Description: set the base class name for the class

Parameters:
createFile: - the object for the table we are creating f1: file writer object table: the table we are creating
Throws:
java.lang.Exception - for FileWriter


writeAbstractInfo

public void writeAbstractInfo(CreateFile createFile,
                              Table table)
                       throws java.lang.Exception
Description: set the if the the class (table) is abstract

Parameters:
createFile: - the object for the table we are creating f1: file writer object table: the table we are creating
Throws:
java.lang.Exception - for FileWriter


writeAssociationInfo

public void writeAssociationInfo(CreateFile createFile,
                                 Table table,
                                 java.io.FileWriter w)
                          throws java.lang.Exception
Description: set an association's name, scope, and data type. These are relationships between tables(classes)

Parameters:
createFile: - the object for the table we are creating f1: file writer object table: the table we are creating
Throws:
java.lang.Exception - for FileWriter


OneToOne

protected void OneToOne(Table table,
                        AssociationColumn column,
                        CreateFile createFile,
                        CreateFile.AssociationAttrInformation attr)
                 throws java.lang.Exception
Description: create an association column for one to one relationship

Parameters:
name - column name oriType class name of the assocaition owner if the association attribute owns this table table: the table we are creating column the column for the association createFile: the object for the table we are creating f1: file writer object
Throws:
java.lang.Exception - for FileWriter


ManyToMany

protected void ManyToMany(CreateFile createFile,
                          java.lang.String oriType)
                   throws java.lang.Exception
Description: create an association column for many to many relationship

Parameters:
createFile: - the object for the table we are creating oriType class name of the assocaition f1: file writer object
Throws:
java.lang.Exception - for FileWriter


CheckRelationship

protected boolean CheckRelationship(java.util.Vector otmVector,
                                    java.lang.String oriType,
                                    boolean owner)
Description: check to see if there is the case that A has two one_to_many relationships with B and get the same name

Parameters:
otmVector - a vector to hold names of all associations in the model oriType class name of the assocaition owner if the association attribute owns this table
Returns:
true if A has two one_to_many relationships with B and the same name false there is no such relationship in the model

Throws:
java.lang.Exception - for FileWriter


OneToMany

protected void OneToMany(Table table,
                         AssociationColumn column,
                         CreateFile createFile,
                         CreateFile.AssociationAttrInformation attr)
                  throws java.lang.Exception
Description: create an association column for one to one relationship

Parameters:
name - column name oriType class name of the assocaition owner if the association attribute owns this table table the table we are creating column the column for the association createFile the object for the table we are creating
Throws:
java.lang.Exception - for FileWriter


ManyToOne

protected void ManyToOne(Table table,
                         AssociationColumn column,
                         CreateFile createFile,
                         CreateFile.AssociationAttrInformation attr,
                         java.io.FileWriter w)
                  throws java.lang.Exception
Description: create an association column for one to one relationship

Parameters:
name - column name oriType class name of the assocaition owner if the association attribute owns this table table the table we are creating column the column for the association createFile the object for the table we are creating
Throws:
java.lang.Exception - for FileWriter


alphabetLinkingTabelName

protected java.lang.String alphabetLinkingTabelName(java.lang.String string1,
                                                    java.lang.String string2)
Description: compare two strings and link them alphabetically if string1 < string2: negative number

Parameters:
string1 - one string string2 another string
Returns:
the ordered, linked string used as name of linking table

Throws:
none -


createLinkingTable

protected Table createLinkingTable(CreateFile createFile,
                                   java.lang.String oriType)
Description: create a linking table

Parameters:
createFile - the object for the table we are creating oriType class name of the assocaition
Returns:
the linking table object

Throws:
none -


lowerCaseFirstLetter

protected java.lang.String lowerCaseFirstLetter(java.lang.String name)
Description: change the first letter of a string to be lower case

Parameters:
name - of the string sent in to be changed
Returns:
the changed string

Throws:
none -


createLinkColumn

protected AssociationColumn createLinkColumn(java.lang.String className)
Description: create a column for a linking table

Parameters:
name - of the class for a column
Returns:
a constructed column

Throws:
none -


createLinkingKey

protected LinkingKey createLinkingKey(AssociationColumn link1,
                                      AssociationColumn link2)
Description: create a linkingKey object and set into the table

Parameters:
link1 - one linking column link2 another linking column
Returns:
a linking key object

Throws:
none -


createUnique

protected Unique createUnique(java.util.Vector uniqueVector)
Description: create a Unique object which takes a vector of columns

Parameters:
uniqueVector - a vector has several columns these columns combined together uniquely identify a row
Returns:
a unique object

Throws:
none -


createIndex

protected Index createIndex(AssociationColumn column,
                            java.lang.String tableName,
                            java.lang.String columnName)
Description: create a Index object for a foreign key fk_oto does not have index fk_mto has index fk_mtm has index

Parameters:
column - the foreign key column
Returns:
an index object

Throws:
none -


WriteMAGEER

protected void WriteMAGEER(java.util.Map tableMap,
                           java.io.FileWriter f3,
                           java.io.FileWriter w)
                    throws java.lang.Exception
Description: traverse the map and write out the MAGEER.xml

Parameters:
Map - the map with all tables f2 file writer for just a list of table names f3 file for MAGEER.xml
Throws:
none -

java.lang.Exception

WriteOneTable

protected void WriteOneTable(Table table,
                             java.io.FileWriter f3)
                      throws java.lang.Exception
Description: write one table to the output file

Parameters:
f3 - file for MAGEER.xml table one table in the Map
Throws:
fileWriter - exception

java.lang.Exception