Step 1: Develop a Data Model
1. Meet the Default Data Model
Let’s take a look at the com.company.warehouse.datamodel
bundle.
It already contains a basic data model with Scenario
, Arc
, Node
, and Point
classes (see the model/datamodel.ecore file):

These are the classes to describe the main object (scenario) and the transport network.
The Scenario
is the root class.
A (singleton) Scenario
object 'contains' all other objects.
Node
, Arc
, and Point
are the data model classes whose instances form a transportation graph.
2. An Empty Scenario
The newly created application already supports editing the basic scenario properties:

You can also create the transport network using the Map part:

3. Enhance the Data Model
For this tutorial, we will also need other entities, so let’s add them to our data model.
3.1. Create a new Forklift
EClass
-
In the datamodel.ecore file editor, right-click on the
datamodel
item and select the New Child → EClass menu item. A new data model class is created. -
In its properties, set its
Name
to Forklift. -
Add the following fields to the
Forklift
EClass using its New Child context menu item:
Field type | Name | EType |
---|---|---|
EReference |
scenario |
Scenario |
EAttribute |
name |
EString |
EReference |
base |
Node |
EAttribute |
velocity |
EDouble |
EAttribute |
loadingTimeSec |
EDouble |
EAttribute |
unloadingTimeSec |
EDouble |
3.2. Create a new Direction
EEnum
-
In the datamodel.ecore file editor, right-click on the
datamodel
item and select the New Child → EEnum menu item. A new data model enumeration is created. -
In its properties, set its
Name
to Direction. -
Right-click the
Direction
enum and in its context menu choose New Child → EEnum Literal. Set the literal’sLiteral
andName
properties to 'IN', andValue
property to 0 (zero). -
In the same manner, add another literal to
Direction
, withLiteral
andName
equal to 'OUT' andValue
equal to 1. -
Set
Direction
enumDefault Value
property to 'IN (0)'.
If you’ve already got the idea of how we can define data model types and their properties in Eclipse Model Editor, and if you’ve had enough of filling all those fields, you can just:
|
3.3. Create a new Gate
EClass
-
Create a new data model
EClass
withname
= Gate -
Add new fields to
EClass
Gate
:
Field type | Name | EType | ID | Upper Bound |
---|---|---|---|---|
EReference |
scenario |
Scenario |
||
EAttribute |
id |
EString |
true |
|
EAttribute |
direction |
Direction |
||
EReference |
entrance |
Node |
||
EReference |
places |
Node |
-1 |
4. Generate Data Model Java Classes
With EMF, it is easy to map datamodel classes (described in the datamodel.ecore file) to Java classes.
In the datamodel.genmodel file (located next to the datamodel.ecore file) editor,
right-click the child Datamodel
element and choose Generate Model Code.
It might take a few seconds to generate the Java classes.
You can find the generated files in the src-gen folder of the datamodel
bundle.
Each time you change the datamodel.ecore file, these Java classes should be regenerated to reflect the changes.
5. Download & open template scenario
Here you can find the scenario that matches the up-to-date data model and contains some data: Warehouse_Scenario.xlsx
Download this excel file to your project’s root directory.
Open it from the application with File / Open menu.
If you get an error during opening the file, the most likely reason is that you made a mistake filling datamodel.ecore. Don’t despair, you can just download the ready-made correct file (datamodel.ecore). (Alt+Click the link) Remember to regenerate model Java classes when you change datamodel.ecore file. |
If everything goes right, you should see the following picture in the Map pane:
