< Previous | Next >

Lesson 1: Create a model-to-model transformation mapping project

This lesson shows you how to create a model-to-model transformation mapping project.

A model-to-model transformation mapping project is a standard Eclipse plug-in that specifies a transformation provider, which is the mechanism that defines transformations. A mapping project contains at least one mapping file, also called a mapping model. When you create a mapping project, a mapping model is created in the project automatically.

Model-to-model transformation mapping projects, also called mapping projects, are Eclipse plug-ins that extend the extension point named com.ibm.xtools.transform.core.transformationProviders. By creating model-to-model transformations in transformation mapping projects, you can specify how elements in the selected source and target models, or metamodels, are related, instead of creating code that represents the implementation details of the transformation.

A mapping project can contain more than one mapping file, which is also called a mapping model. You can iteratively generate transformation source code when you modify the mapping model. When you generate the transformation source code, one externally visible transform, called MainTransform, is registered automatically, and the Java source code for a transform is generated for each mapping declaration in the mapping model.

You can specify one or more source and target metamodels when you create a mapping project. You can specify metamodels, which have .ecore as a file name extension, or UML profiles, which have .epx or .uml as a file name extension. If you specify source and target metamodels when you create a project, the necessary dependencies are added to the plug-in manifest file automatically. If you add the metamodels by using the commands in the editor area after you create the mapping project, you must add any new required dependencies to the plug-in manifest file.

To create a model-to-model transformation mapping project:

  1. Open the Plug-in Development perspective: Click Window > Open Perspective > Other. In the Open Perspective window, click Plug-in Development and click OK.
  2. Click File > New > Project.
  3. In the New Project wizard, on the Select a wizard page, click Transformation Authoring and click Model to Model Mapping Transformation Project.
  4. Click Next.
  5. On the Plug-in Project page, in the Project name field, type Generalize Classes.
  6. Accept the default values for the other fields on the page and click Next.
  7. On the Plug-in Content page, review the values and click Next.
  8. On the Templates page, from the Available Templates list, select Plug-in with Transformation Mapping and click Next.
  9. On the Create a Mapping Model for a New Model-to-Model Transformation page, in the Mapping model name field, if the value does not exist already, type Generalize_Classes. This field specifies the name of the mapping model, which is located in the model folder of the project, and has .mapping as a file name extension.
  10. To specify the input and output model or models, complete the following steps:
    1. On the Create a Mapping Model for a New Model-to-Model Transformation page, in the "Mapping inputs: Ecore models and UML profiles" area, click Add Model.
    2. In the Select an Ecore Model or UML Profile window, specify the Uniform Resource Identifier (URI) of the input model for this tutorial: Beside the Model URI field, click Browse, and in the Browse for Ecore Models or UML profiles window, click Browse Registered Packages.
    3. In the Package Selection window, select the most recent version of the UML2 model that has a naming convention of http://www.eclipse.org/uml2/2.x.y/UML, and click OK. This step specifies that the transformation accepts a UML.ecore metamodel as the transformation source.
    4. In the Browse for Ecore Models or UML profiles window, click OK.
    5. In the Select an Ecore Model or UML Profile window, click OK.
    6. On the Create a Mapping Model for a New Model-to-Model Transformation page, in the "Mapping outputs: Ecore models and UML profiles" area, click Add Model.
    7. Repeat steps 10b to 10e to specify that the transformation output is a model of type UML.ecore.metamodel.
    If you specify input and output metamodels when you create a project, the necessary dependencies are added to the plug-in manifest file automatically. If you add the metamodels by using the commands in the editor area after you create the mapping project, you must add any new required dependencies to the plug-in manifest file.
  11. Optional: Click Next and view the information on the remaining pages of the wizard.
  12. Click Finish.
A mapping project is created in the workspace. In the next lesson, you examine the structure of the mapping project.
< Previous | Next >

Feedback