Documentation:EMF Mapping Generator

From Tom

Jump to: navigation, search
Doc : Tools

Installation  > Compiling from sources  > Using Tom  > Using Gom  > Configuring your environment  > Tom Server  > EMF Mapping Generator

EMF mappings generator is an automatic mappings generator for Eclipse Modeling Framework.

Using EMF mapping generator

The EMF mappings generator has been integrated in the current stable stable version (2.9). To use it, just install Tom, Tom-EMF will also be installed. Two scripts compose Tom-EMF:

  • emf-generate-mappings is equivalent to the command java TomMappingFromEcore. It takes one (or several) EPackage name(s) as argument(s) which are used to name the generated mappings (you have to use the full qualified EPackage name)). The mappings are generated in the current directory,
  • emf-generate-xmi is equivalent to the command java EcoreMappingToXMI. It takes an argument (the package name) and generates an XMI file which is printed on the standard output

Use case: Let's say you want to generate the mapping for the petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage used in the SimplePDLToPetrinet example. Just type the following command (you obviously have to download the petrinet jar file):

emf-generate-mappings -cp petrinetsemantics.jar petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage

Note: To run correctly Tom-EMF, it is mandatory to have those two EMF libraries:

  • org.eclipse.emf.ecore_2.5.0.v200906151043.jar
  • org.eclipse.emf.common_2.5.0.v200906151043.jar

We distribute them in lib/tools, and emf-generate-mappings is able to find them alone. However, if you want to compile a Tom/Java program using EMF, you will have to add them to your CLASSPATH. If you work with EMF, you should have Eclipse installed on your computer, therefore you should also have those two libraries in eclipse/plugins/ by default. For Windows users, the tom-2.9 installer adds them automatically to your CLASSPATH. .

The '-nt' option allows to generate constructs with subtyping:

emf-generate-mappings -cp petrinetsemantics.1.0.0.jar -nt petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage

After enabling the '-nt' option, '%typeterm' constructs will integrate subtyping as following:

%typeterm Place extends Node {

Note: This option is experimental and you have to use the Tom -nt option when compiling your code if you want that those constructs to be taken in account.

Note: To successfully use Tom-EMF, you have to execute Tom-EMF on a complete jar archive. For instance, if you generate code for a subpackage with Eclipse instead of the whole code, there may be references to other subpackages which could not be resolved by Tom-EMF.

Then, if you want to have a serialization, just use the following command:

emf-generate-xmi petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage > DDMMPetriNetPackage.xmi

Tom-EMF reference page

A description of how the generators work is available in the Section EMF.

How to use the generators and the generated mappings

To see an use of the EMF mappings generator with an example, please look at the library example and SimplePDLToPetrinet example. As we are trying to write an usable documentation, this page is still under construction. If you think that some information are missing, juste create an account and modify the page by adding a question.


Tools

Installation  > Compiling from sources  > Using Tom  > Using Gom  > Configuring your environment  > Tom Server  > EMF Mapping Generator

Tom Documentation
Guided Tour :: Tutorial :: Language Reference :: Tools
Personal tools
Create a book