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