|
Dresden OCL Toolkit | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttudresden.ocl.sql.ORMappingImp
An implementation of the ORMapping interface. It generates a number of tables for classes and associations according some rules that are parameterized. The source of the object oriented information is a Model object that must be of rough quality. The rules are as follows:
Model
Field Summary | |
private HashMap |
addAssEnds
Maps class names to a Map (key-type String, element-type String) of association ends that result from the treatment of complex attributes. |
static String |
ASSTABNAME
|
private HashMap |
classesToTables
Maps class names to a List of table names (the element type of the List is String). |
private int |
classToTableMode
Mapping mode for classes to tables. |
static String |
JAVATYPES
|
private HashMap |
navGuides
Maps class names to a Map of navigation guides. |
private int |
numOfPKCols
The number of desired primary key columns (default is 1). |
private boolean |
oneTablePerAssociation
The flag to determine whether each association is mapped to a separate table or not (default is no or rather false). |
static String |
PACKID
|
private String |
pKColTypeName
The type name of the primary key columns (default is int). |
static String |
PRIMKEYNAME
|
static String |
SEPARATOR
|
private ArrayList |
tables
An array that contains all the tables from the object relational mapping. |
private Model |
theModel
The model containing the object oriented information. |
Constructor Summary | |
ORMappingImp(Model theModel)
A constructor to create the object relational mapping informations. |
|
ORMappingImp(Model theModel,
int classToTableMode,
int numOfPKCols,
String pKColTypeName,
boolean oneTablePerAssociation)
A constructor to create the object relational mapping informations. |
Method Summary | |
Map |
associationEnds(String classifier)
|
Set |
attributes(String classifier)
|
private Set |
buryForeignKeys(List pkTables,
List fkTables,
String assEndName,
Set fkSet)
Buries the primary keys of the pkTables to all fkTables as foreign keys. |
Set |
classifiers()
|
private void |
createClassTables()
Creates all the class tables with respect to the mapping mode. |
private List |
createGuideList(ModelClass startClass,
ModelClass endClass,
Table assTab,
boolean nTo1,
Set fkSet)
|
Set |
directSupertypeNames(String classifier)
|
private void |
generatePrimaryKeys()
Generates the primary keys for all classes. |
private Map |
getAssEndMap(ModelClass mc)
Helper methode. |
private String |
getAssociationName(ModelAssociation ma)
Helper methode. |
private String |
getClassName(ModelClass mc)
Important: does not care about package names yet ! |
List |
getClassTables(String classifier)
|
private String |
getColumnName(String attName,
Table table)
Mapping of attribute names to column names. |
private String |
getForeignKeyString(Table fkTable,
Table pkTable,
Set fkSet)
Helper methode. |
private String |
getPrimaryKeyString(Table t)
Helper methode. |
Table |
getTable(String tabName)
|
private List |
getTableList(List tableNames)
|
private String |
getTableName(ModelClass mc)
Mapping of class names to table names. |
private String |
getTableName(String className)
Mapping of class names to table names. |
List |
getTables(List tabNames)
|
Map |
guidesToAssociationEnds(String classifier)
|
List |
guidesToAssociationEnds(String classifier,
String assEnd)
|
private boolean |
isJavaType(String typeName)
|
private boolean |
isPackageMember(String typeName)
|
private void |
mapAssociations()
Mapping of Associations to foreign key relations and association tables. |
private void |
mapAttributes()
Mapping of the attributes for all classes. |
private void |
mapClassAttributes(ModelClass mc)
Does the attribute mapping for one class. |
private void |
mapClassToTable(ModelClass mc)
Maps one class to one table. |
Set |
operations(String classifier)
|
List |
tables()
|
void |
testBuryForeignKeys(boolean verbose)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private Model theModel
private ArrayList tables
private HashMap classesToTables
private HashMap navGuides
private HashMap addAssEnds
private int classToTableMode
private int numOfPKCols
private String pKColTypeName
private boolean oneTablePerAssociation
public static String JAVATYPES
public static String PRIMKEYNAME
public static String ASSTABNAME
public static String PACKID
public static String SEPARATOR
Constructor Detail |
public ORMappingImp(Model theModel) throws IllegalArgumentException
theModel
- a model for which isRough() must hold
IllegalArgumentException
- if the theModel.isRough() evaluates to falsepublic ORMappingImp(Model theModel, int classToTableMode, int numOfPKCols, String pKColTypeName, boolean oneTablePerAssociation) throws IllegalArgumentException
theModel
- a model for which isRough() must holdclassToTableMode
- see field description of classToTableModenumOfPKCols
- see field description of numOfPKColspKColTypeName
- see field description of pKColTypeNameoneTablePerAssociation
- see field description of oneTablePerAssociation
IllegalArgumentException
- if the theModel.isRough() evaluates to false or the parameters are not validMethod Detail |
public List tables()
tables
in interface ORMapping
Table
public List getClassTables(String classifier) throws IllegalArgumentException
getClassTables
in interface ORMapping
classifier
- a classifier
IllegalArgumentException
Table
public Set classifiers()
classifiers
in interface ORMapping
public Set directSupertypeNames(String classifier)
directSupertypeNames
in interface ORMapping
classifier
- a classifier
public Map associationEnds(String classifier)
associationEnds
in interface ORMapping
classifier
- a classifier
public Map guidesToAssociationEnds(String classifier)
public Set operations(String classifier)
operations
in interface ORMapping
classifier
- a classifier
public Set attributes(String classifier)
attributes
in interface ORMapping
classifier
- a classifier
public List guidesToAssociationEnds(String classifier, String assEnd)
guidesToAssociationEnds
in interface ORMapping
classifier
- a classifierassEnd
- the name of the association end
Guide
private void createClassTables()
private void generatePrimaryKeys()
private void mapClassAttributes(ModelClass mc)
mc
- the model classprivate void mapAttributes()
private void mapAssociations()
private boolean isJavaType(String typeName)
typeName
- a type name
private boolean isPackageMember(String typeName)
typeName
- a type name
private void mapClassToTable(ModelClass mc)
mc
- the classprivate String getTableName(String className)
private String getTableName(ModelClass mc)
private String getClassName(ModelClass mc)
private String getColumnName(String attName, Table table)
public Table getTable(String tabName) throws NoSuchElementException
NoSuchElementException
private List getTableList(List tableNames) throws NoSuchElementException
tableNames
- a List with table names
NoSuchElementException
- if a table to a given name does not existpublic List getTables(List tabNames)
NoSuchElementException
- if one of the tables does not existprivate List createGuideList(ModelClass startClass, ModelClass endClass, Table assTab, boolean nTo1, Set fkSet)
startClass
- the class to start fromendClass
- the class to lead toassTab
- a possible association Table or null, if such a table does not existnTo1
- a flag that indicates whether the association is a many-to-one association or notfkSet
- a Set of foreign key names that belong to the associationprivate String getPrimaryKeyString(Table t)
private String getForeignKeyString(Table fkTable, Table pkTable, Set fkSet)
private Map getAssEndMap(ModelClass mc)
private String getAssociationName(ModelAssociation ma)
private Set buryForeignKeys(List pkTables, List fkTables, String assEndName, Set fkSet)
pkTables
- a List of tables which contain the primary keysfkTables
- a List of tables to which the foreign keys are going to be buriedassEndName
- the name of the association end which belongs to the pkTablesfkSet
- a Set as initialization for the result Set
public void testBuryForeignKeys(boolean verbose) throws RuntimeException
RuntimeException
|
Dresden OCL Toolkit | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |