Java Reference
In-Depth Information
As mentioned earlier, to have our workspace
mindmap.ecore
available to
the editor, engine, and metamodel browser, we need to provide a metamodel
mapping. In the project properties of
org.eclipse.dsl.mindmap
, add an
entry in the
Metamodel Mappings
section using the
Browse
button to locate your
mindmap.ecore
model in the workspace. Likewise, you need to register the tar-
get
requirements.ecore
model, similar to what is shown in Section 6.5.1,
“QVT Project.”
Select the
/transformations
folder in our mindmap DSL project and
invoke the Operational QVT Transformation wizard from
File
→
New
→
Other
→
Operational QVT Transformation
. Note that when
not using the DSL Toolkit, the wizard is found in
File
Model Transformation
→
→
New
→
Other
→
Model
to Model Transformation
Operational QVT Transformation
. Create a new
mindmap2requirements.qvto
transformation in the selected
/transforma-
tions
folder and select
Finish
to complete the wizard.
In the opened editor, you'll see the skeleton QVT, which is a simple trans-
formation declaration statement with empty main mapping. Fill out this skeleton
with the following to make it more complete:
→
modeltype
mindmap 'strict'
uses
'http://www.eclipse.org/2008/mindmap';
modeltype
requirements 'strict'
uses
'http://www.eclipse.org/2008/requirements';
transformation
mindmap2requirements(
in
inModel:mindmap,
out
outModel:requirements);
main
()
{
inModel.rootObjects()[Map]->
map
toRequirementsModel();
}
At the top, we find the
transformation
declaration, along with
model-
type
entries for our source and target models. The
modeltype
declarations
include the
strict
qualifier, indicating that only models that conform with the
specified URI will be accepted as inputs. The
main
entry point contains the stan-
dard form for obtaining the root model object and invoking our first mapping
toRequirementsModel()
. The use of brackets around the input model's
Map
class is shorthand notation for combined collect and select operations, which
Section 13.5.3, “Imperative Iterate Expressions,” covers. We expect to find a
Map
object at the root of our model, which we obtain and use as the input to the map-
ping that returns a requirements
Model
instance. To begin, let's just map our
Search WWH ::
Custom Search