|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.andromda.schema2xmi.SchemaTransformer
public class SchemaTransformer
Performs the transformation of database schema to XMI.
| Constructor Summary | |
|---|---|
SchemaTransformer(java.lang.String jdbcDriver,
java.lang.String jdbcConnectionUrl,
java.lang.String jdbcUser,
java.lang.String jdbcPassword)
Constructs a new instance of this SchemaTransformer. |
|
| Method Summary | |
|---|---|
protected void |
addForeignKey(java.lang.String tableName,
java.lang.String columnName)
Adds a foreign key column name to the foreignKeys Map. |
protected java.util.Collection |
createAssociations(java.sql.DatabaseMetaData metadata,
org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String tableName)
Creates and returns a collection of associations by determing foreign tables to the table having the given tableName. |
protected org.omg.uml.foundation.datatypes.Multiplicity |
createAttributeMultiplicity(org.omg.uml.foundation.datatypes.DataTypesPackage dataTypes,
boolean required)
Creates an attributes multiplicity, if required is true,
then multiplicity is set to 1, if required is false, then
multiplicity is set to 0..1. |
protected java.util.Collection |
createAttributes(java.sql.DatabaseMetaData metadata,
org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String tableName)
Creates and returns a collection of attributes from creating an attribute from every column on the table having the give tableName. |
protected org.omg.uml.foundation.core.UmlClass |
createClass(org.omg.uml.modelmanagement.UmlPackage modelPackage,
java.sql.DatabaseMetaData metadata,
org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String tableName)
Creates and returns a UmlClass with the given name using
the corePackage to create it. |
protected void |
createClasses(java.sql.Connection connection,
org.omg.uml.foundation.core.CorePackage corePackage,
org.omg.uml.modelmanagement.UmlPackage modelPackage)
Creates all classes from the tables found in the schema. |
protected org.omg.uml.foundation.datatypes.Multiplicity |
createMultiplicity(org.omg.uml.foundation.datatypes.DataTypesPackage dataTypes,
int lower,
int upper)
Creates a multiplicity, from lower and upper
ranges. |
protected org.omg.uml.foundation.core.TaggedValue |
createTaggedValue(org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String name,
java.lang.String value)
Creates a tagged value given the specfied name. |
protected org.omg.uml.foundation.core.DataType |
getOrCreateDataType(org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String type)
Gets or creates a new data type instance having the given fully qualified type name. |
protected org.omg.uml.modelmanagement.UmlPackage |
getOrCreatePackage(org.omg.uml.modelmanagement.ModelManagementPackage modelManagementPackage,
org.omg.uml.modelmanagement.UmlPackage modelPackage,
java.lang.String packageName)
Gets or creates a package having the specified packageName
using the given modelManagementPackage, places it on the
model and returns the last leaf package. |
protected java.util.Collection |
getOrCreateStereotypes(org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String names,
java.lang.String baseClass)
Gets or creates a stereotypes given the specfied comma seperated list of names. |
protected java.util.Collection |
getPrimaryKeyColumns(java.sql.DatabaseMetaData metadata,
java.lang.String tableName)
Returns a collection of all primary key column names for the given tableName. |
protected boolean |
hasForeignKey(java.lang.String tableName,
java.lang.String columnName)
Returns true if the table with the given tableName has a
foreign key with the specified columnName. |
protected boolean |
isColumnNullable(java.sql.DatabaseMetaData metadata,
java.lang.String tableName,
java.lang.String columnName)
This method just checks to see if a column is null able or not, if so, returns true, if not returns false. |
void |
setClassStereotypes(java.lang.String classStereotypes)
Sets the stereotype name for the new classes. |
void |
setColumnNamePattern(java.lang.String columnNamePattern)
Sets the regular expression pattern to match on when deciding what attributes ti create in the XMI. |
void |
setColumnTaggedValue(java.lang.String columnTaggedValue)
Sets the name of the column tagged value to use for storing the name of the column. |
void |
setIdentifierStereotypes(java.lang.String identifierStereotypes)
Sets the stereotype name for the identifiers on the new classes. |
void |
setPackageName(java.lang.String packageName)
Sets the name of the package to which the model elements will be created. |
void |
setSchema(java.lang.String schema)
Sets the name of the schema (where the tables can be found). |
void |
setTableNamePattern(java.lang.String tableNamePattern)
Sets the regular expression pattern to match on when deciding what table names to add to the transformed XMI. |
void |
setTableTaggedValue(java.lang.String tableTaggedValue)
Sets the name of the table tagged value to use for storing the name of the table. |
void |
setTypeMappings(java.lang.String typeMappingsUri)
Sets the mappingsUri which is the URI to the sql types to
model type mappings. |
void |
setXmiVersion(java.lang.String xmiVersion)
Sets the version of XMI that will be produced. |
void |
transform(java.lang.String inputModel,
java.lang.String outputLocation)
Transforms the Schema file and writes it to the location given by outputLocation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SchemaTransformer(java.lang.String jdbcDriver,
java.lang.String jdbcConnectionUrl,
java.lang.String jdbcUser,
java.lang.String jdbcPassword)
| Method Detail |
|---|
public void transform(java.lang.String inputModel,
java.lang.String outputLocation)
outputLocation. The inputModel must be a
valid URL, otherwise an exception will be thrown.
inputModel - the location of the input model to start with (if there
is one)outputLocation - The location to where the transformed output will
be written.public void setTypeMappings(java.lang.String typeMappingsUri)
mappingsUri which is the URI to the sql types to
model type mappings.
typeMappingsUri - The typeMappings to set.public void setPackageName(java.lang.String packageName)
packageName - The packageName to set.public void setSchema(java.lang.String schema)
schema - The schema to set.public void setTableNamePattern(java.lang.String tableNamePattern)
tableNamePattern - The tableNamePattern to set.public void setColumnNamePattern(java.lang.String columnNamePattern)
columnNamePattern - The pattern for filtering the column name.public void setClassStereotypes(java.lang.String classStereotypes)
classStereotypes - The classStereotypes to set.public void setIdentifierStereotypes(java.lang.String identifierStereotypes)
identifierStereotypes - The identifierStereotypes to set.public void setColumnTaggedValue(java.lang.String columnTaggedValue)
columnTaggedValue - The columnTaggedValue to set.public void setTableTaggedValue(java.lang.String tableTaggedValue)
tableTaggedValue - The tableTaggedValue to set.public void setXmiVersion(java.lang.String xmiVersion)
xmiVersion - The xmiVersion to set.
protected org.omg.uml.modelmanagement.UmlPackage getOrCreatePackage(org.omg.uml.modelmanagement.ModelManagementPackage modelManagementPackage,
org.omg.uml.modelmanagement.UmlPackage modelPackage,
java.lang.String packageName)
packageName
using the given modelManagementPackage, places it on the
model and returns the last leaf package.
modelManagementPackage - from which we retrieve the UmlPackageClass
to create a UmlPackage.modelPackage - the root UmlPackage
protected void createClasses(java.sql.Connection connection,
org.omg.uml.foundation.core.CorePackage corePackage,
org.omg.uml.modelmanagement.UmlPackage modelPackage)
throws java.sql.SQLException
connection - the Connection used to retrieve the schema metadata.corePackage - the CorePackage instance we use to create the classes.modelPackage - the package which the classes are added.
java.sql.SQLException
protected org.omg.uml.foundation.core.UmlClass createClass(org.omg.uml.modelmanagement.UmlPackage modelPackage,
java.sql.DatabaseMetaData metadata,
org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String tableName)
name using
the corePackage to create it.
corePackage - used to create the class.tableName - to tableName for which we'll create the appropriate
class.
protected java.util.Collection createAttributes(java.sql.DatabaseMetaData metadata,
org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String tableName)
throws java.sql.SQLException
tableName.
metadata - the DatabaseMetaData from which to retrieve the columns.corePackage - used to create the class.tableName - the tableName for which to find columns.
java.sql.SQLException
protected org.omg.uml.foundation.core.DataType getOrCreateDataType(org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String type)
type name.
corePackage - the core packagetype - the fully qualified type name.
protected boolean isColumnNullable(java.sql.DatabaseMetaData metadata,
java.lang.String tableName,
java.lang.String columnName)
throws java.sql.SQLException
metadata - the DatabaseMetaData instance used to retrieve the column
information.tableName - the name of the table on which the column exists.columnName - the name of the column.true/false - on whether or not column is nullable.
java.sql.SQLException
protected java.util.Collection getPrimaryKeyColumns(java.sql.DatabaseMetaData metadata,
java.lang.String tableName)
throws java.sql.SQLException
tableName.
metadata - tableName -
java.sql.SQLException
protected java.util.Collection createAssociations(java.sql.DatabaseMetaData metadata,
org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String tableName)
throws java.sql.SQLException
tableName.
metadata - the DatabaseMetaData from which to retrieve the columns.corePackage - used to create the class.tableName - the tableName for which to find columns.
java.sql.SQLException
protected org.omg.uml.foundation.core.TaggedValue createTaggedValue(org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String name,
java.lang.String value)
name.
name - the name of the tagged value to create.value - the value to populate on the tagged value.
protected java.util.Collection getOrCreateStereotypes(org.omg.uml.foundation.core.CorePackage corePackage,
java.lang.String names,
java.lang.String baseClass)
names. If any of the stereotypes can't be found, they
will be created.
names - comma seperated list of stereotype namesbaseClass - the base class for which the stereotype applies.
protected void addForeignKey(java.lang.String tableName,
java.lang.String columnName)
foreignKeys Map. The
map stores a collection of foreign key names keyed by the given
tableName
tableName - the name of the table for which to store the keys.columnName - the name of the foreign key column name.
protected boolean hasForeignKey(java.lang.String tableName,
java.lang.String columnName)
tableName has a
foreign key with the specified columnName.
tableName - the name of the table to check for the foreign keycolumnName - the naem of the foreign key column.
columnName.
protected org.omg.uml.foundation.datatypes.Multiplicity createAttributeMultiplicity(org.omg.uml.foundation.datatypes.DataTypesPackage dataTypes,
boolean required)
required is true,
then multiplicity is set to 1, if required is false, then
multiplicity is set to 0..1.
dataTypes - used to create the Multiplicityrequired - whether or not the attribute is required therefore
determining the multiplicity value created.
protected org.omg.uml.foundation.datatypes.Multiplicity createMultiplicity(org.omg.uml.foundation.datatypes.DataTypesPackage dataTypes,
int lower,
int upper)
lower and upper
ranges.
dataTypes - used to create the Multiplicitylower - the lower range of the multiplicityupper - the upper range of the multiplicity
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||