Java Reference
In-Depth Information
name. Also, the sample uses the URI declared by the models in their EMF regis-
tration, which align better with the EMF convention. It would be possible to
import each model into the project and add
Metamodel Mappings
in the project
properties and assign the original URI, as shown next. The only other difference
is the model names, which, in this case, reflect the names assigned in the Ecore
models.
modeltype
UML
uses
simpleuml("omg.qvt-samples.SimpleUML");
modeltype
RDBMS
uses
rdb("omg.qvt-samples.SimpleRDBMS");
transformation
Uml2Rdb(
in
srcModel:UML,
out
RDBMS);
Looking at the
transformation
declaration, because only one transforma-
tion is defined in the file, no braces are required to surround its contents. Note
also that a name is assigned to the input UML model but not to the RDBMS out-
put model.
The entry point of a QVTO transformation is its
main
mapping. As you can
see here, the
UML::Model
class is passed in as the root object, and the
out
parameter instantiates and returns an
RDB::Model
object. Both the input and
output parameters are given a name to be accessed by within the body of the
mapping.
main
(
in
model: UML::Model,
out
rdbModel: RDB::Model) {
rdbModel:= model.
map
model2RDBModel();
}
In the body, the
rdbModel
output is assigned the results of the
model2RDBModel()
mapping, which is invoked by appending
.map
to the
model element, indicating that it will be passed as the input to the mapping.
The
model2RDBModel()
mapping is straightforward and could have been
folded into the main mapping. The
name
of the UML model is mapped to the
name
of the RDB model, and the
UML::Model
element is passed to the
pack-
age2schemas
query.
mapping
UML::Model::model2RDBModel() : RDB::Model {
name :=
self
.name;
schemas :=
self
.package2schemas();
}
The
package2schemas()
query returns an
OrderedSet
of Schema
objects, which are created from the package and its subpackages. In the body of
the query, the
UML::Package
is mapped to an
RDB::Schema
object by the
package2schema()
mapping. The result is unioned with a mapping of
Search WWH ::
Custom Search