Overview of model transformation
Model transformation
J can be used to access model values for all sorts of applications, and is at its most powerful when transforming a model. Starting with an initial model, it is used to create associations, operations, generalization, links, …. The model is automatically transformed, just as if a designer, seeking to implement an analysis model, had manually carried out the transformation. J a particularly high performance tool for automating the building of design patterns.
"High
level" primitives
Any modification of the model must be carried out in a session (please see "Managing the Session").
For most metaclasses, creation or modification services (please see the "Constructor" paragraph for each metaclass) are provided.
High level
primitives use information from the metamodel to automatically create all the
necessary and easily deducible links. We strongly
recommend using these high level primitives instead of "low level"
primitives.
The advantages of high level primitives are as follows:
· easier creation of elements
· backward compatibility is guaranteed. Future developments linked to our model will be supported by these primitives, something which is not guaranteed for low level primitives.
For example, each element must be attached to a given set of "parent" elements. If there are omissions, there will be rejects at the end of a session. All classes must, for example, be attached to a package or a class. This must be remembered during "low level" creation of a class.
"Low level" primitives
J has a model element creation mechanism called "low level". This is implemented simply by using the names of classes, roles, attributes, etc. These primitives are called "low level", since all necessary links must be defined, and all necessary intermediary elements created.
We recommend that wherever possible "high level" primitives be used, since "high level" primitives are stable, regardless of whether or not the metamodel evolves in future versions.
Example of usage
In the
example below, a "print" method will be created on the current
class. Low level primitives are used
here, but more convenient high level primitives should be used instead.
Note: The "add a "print" operation" command on a class is used to run this program on classes.
Class:addPrint()
{
Operation
M ;
sessionBegin ("addPrintOperationExample",
true) ;
// beginning
of the "persistent" session
M =
Operation.new ();
// creation of
a method
M.setName
("print") ;
// Assignment
of the Name attribute
this.appendPart(M) ;
// the current
class is attached to the method
sessionEnd ();
// end of the
session,
// the current
class has an attached method
//after
execution of Objecteering's consistency
//check
}