In this tutorial you will learn how to import an EMF metamodel stored as an ecore file into Openflexo. Before you start, you must read the fisrt tutorial(How to install Openflexo). The prerequisite are:
Openflexo is able to use your EMF metamodel and CRUD models conforms to it. All EMF Resources available in defined resource centers are scanned.
In this tutorial we will learn how to export an ecore metamodel to a .jar, and how to import it in Openflexo.
In this tutorial we will use an ecore metamodel representing the “Universe”, but of course you can try on your own ecore metamodel.
First you have to create a genmodel file to generate java classes from this metamodel.
Then GenModel file is now created and you can open it.
In the genmodel select the package and edit its generation properties. Change the base package property has depicted by the screenshot below:
Now generate the java classes, to do this right click on the root element in the genmodel and “Generate Model”.
If the generation has been successfull, a set of java classes are generated in you project without any errors.
If you got errors, then right click on you ecore metamodel and select validate to check your metamodel design consistency.
In your computer create a new folder named “Universe” where you will put your exported metamodel as well as an attached property file. In order to be scanned by Open flexo you should put this folder in an Openflexo Resource center. You can also set later your resource center while using Openflexo.
To export your metamodel as a .jar:
In addition to the metamodel, the Openflexo EMF technology adaptor requires a simple property file name “emf.property”. This file must be placed in the same directory as the emf metamodel .jar. It consists of 4 key/value pairs. If your metamodel is visible in the information space but cannot be opened, one of these properties is probably not correctly filled.
As an example, for our metamodel, the properties are:
URI=http://org.openflexo.emf.universe
EXTENSION=universe
PACKAGE=org.openflexo.emf.universe.UniversePackage
RESOURCE_FACTORY=org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
You can download this property file here: emf.properties, and place it in the same directory as your .jar.