Schema2XMI is a generator that will read a database schema and write your schema into an XMI model. This is useful for a couple of reasons:
The produced XMI model will possess the following attributes:
Schema2XMI is a command line utility that you'll pass arguments to and then execute the main Schema2XMI class. The usage is defined below:
usage: org.andromda.schema2xmi.Schema2XMI [options] ...]]
Options:
-C,--classStereotypes <arg> Comma seperated list of stereotype
names to add to the created class
-I,--identifierStereotypes <arg> Comma seperated list of stereotype
names to add to any class identifiers
-P,--package <arg> The package to output classifiers
-V,--tableTaggedValue <arg> The tagged value to use for storing
the table name
-a,--columnPattern <arg> The column name pattern of columns to
process (regular expression)
-c,--connectionUrl <arg> JDBC connection URL
-d,--driver <arg> JDBC driver class
-h,--help Display help information
-i,--input <arg> Input model file (to which model
elements will be added)
-m,--mappings <arg> The type mappings URI (i.e.
file:${basedir}/DataypeMappings.xml)
-o,--output <arg> Output location to which the result of
the transformation will be written
-p,--password <arg> Schema user password
-s,--schema <arg> The name of the schema where the
tables can be found
-t,--tablePattern <arg> The table name pattern of tables to
process (regular expression)
-u,--user <arg> Schema user name
-v,--columnTaggedValue <arg> The tagged value to use for storing
the column name
-x,--xmi <arg> Specifies the XMI version that will be
produced
Here's an example of how you could use Schema2XMI with
an Oracle schema from Ant with the java task .
<javaclassname="org.andromda.schema2xmi.Schema2XMI"fork="true"> <classpath> <pathrefid="schema2xmi.classpath"/> </classpath> <argvalue="-i"/> <argvalue="jar:file:${src.dir}/test/uml/SomeModel.xml.zip!/SomeModel.xml"/> <argvalue="-u"/> <argvalue="someuser"/> <argvalue="-p"/> <argvalue="somepassword"/> <argvalue="-c"/> <argvalue="jdbc:oracle:oci:@yoursid"/> <argvalue="-d"/> <argvalue="oracle.jdbc.driver.OracleDriver"/> <argvalue="-m"/> <argvalue="file:${conf.dir}/mappings/DatatypeMappings.xml"/> <argvalue="-o"/> <argvalue="${build.dir}/schema2xmi/transformed.xmi"/> <argvalue="-t"/> <argvalue="[\p{Lower}\p{Upper}[_]]*"/> <argvalue="-P"/> <argvalue="org::andromda::sample"/> <argvalue="-C"/> <argvalue="entity,persistent"/> <antvalue="-I"/> <argvalue="identifier"/> <argvalue="-V"/> <argvalue="@andromda.persistence.table"/> <argvalue="-v"/> <argvalue="@andromda.persistence.column"/> </java>
IMPORTANT: The datatype mappings file that you specify with the -m argument, must be structured like the example directly below:
<!-- This is used to map SQL Types to model datatypes for Schema2XMI --><mappingsname="DatatypeMappings"> <mapping> <from>DECIMAL</from> <to>datatype::Decimal</to> </mapping> <mapping> <from>VARCHAR</from> <to>datatype::String</to> </mapping> <mapping> <from>TIMESTAMP</from> <to>datatype::Timestamp</to> </mapping> <mapping> <from>BLOB</from> <to>datatype::Blob</to> </mapping> </mappings>