SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


Assignment 09: Model Driven Engineering - MOF, Xtext

Release date: Thursday, 19.12.13 - Due date: Sunday, 05.01.14, 23:59


Task 44. Prerequisite: Installing EMF & Xtext

0 Points

In this assignment sheet we want to create an Ecore meta-model and domain specific language (DSL) editor with the help of the Xtext framework. In the end it should be possible to define a transport descriptions (see the DDD lecture and Assignment 08).

a)

Installation of Eclipse Modeling Framework (EMF) can be done in Eclipse via the Eclipse Update Manager. Select the eclipse update site (Kepler in our case) and then select “Modeling” and install the “EMF – Eclipse Modeling Framework SDK”. If you would like to use a graphical diagram editor install the “Diagram Editor for Ecore (SDK)” as well.

A good tutorial on using the EMF framework for modeling is written by Lars Vogel:

b)

In the following tasks we will also use Xtext2.x for Eclipse. You can find more information and screencasts about the tool on their website

It can be either installed from an Eclipse Update Site, through the Eclipse Marketplace1) or by dragging this icon onto your Eclipse menu bar: To get acquainted with Xtext or if you feel you need more background on Xtext, you may read the following tutorial: DSL Creation with Xtext


Task 45. Define an Ecore Meta-model with EMF

9 Points

Your task is to build a meta-model based on Ecore for the transport model below. As a starting point you find the project A09_T45_Transports in your SVN. For this task you will only get the full points, when your model is very accurate (Attributes vs References, containment correct, types ok, multiplicities correct).

A transport description lists locations, a route and legs (transport and port). Locations have a name and may contain port-locations (i.e. locations within the port) which have a name as well. The route lists locations. A transport leg has a vehicle, the start location, start date and the end location as well as the end date. A port leg may have a load date, unload date, a vendor (who is responsible for the loading) and a port-location (where the goods are stored).

Check out the project A09_T45_Transports. All relevant files are stored in the model directory of it. After you have changed your Ecore transport.ecore file, you need to create or reload the EMF Generator file (.genmodel) and Java code (both required by Xtext). See Create EMF the Generator Model and Generate Java Code

The starting point is the System class, which contains all defined (toplevel) elements. This class will be used to define a Xtext entry rule in the following task.

Create a Java representation for your Ecore model

In the case you are using the diagram editor,

Tip for references between classes

If you want to gain more insights


Task 46. Using Xtext to define a DSL for the transport Ecore model

11 Points

Create a Xtext-based DSL based on the Ecore model defined in Task 45. Please submit only the *.xtext file as your solution for this task. (Otherwise we will reduce your points)

Your grammar should accept examples like the following:

location Hamburg
location Munich
location Leith {
	CLL12
}

route {
	Leith
	Hamburg
	Munich
}

port {
	location CLL12
	vendor C
	loading   2013-02-03, 12:40
}

transport {
	per ship
	from Leith  2013-02-03, 14:20
	to Hamburg  2013-02-05, 17:00
}

port {
	vendor XYZ
	unloaded  2013-02-05, 18:10
	loading   2013-02-05, 23:40
}

transport {
	per train
	from Hamburg 2013-02-06, 01:20
	to Munich    2013-02-07, 05:50
}

port {
	vendor AB
	unloaded  2013-02-07, 07:20
}

Please use the following names for your Xtext project and DSL fileextension:

Entry Rule System
Project name de.unibonn.se.atsc.transportDsl
Language name de.unibonn.se.atsc.TransportDsl
DSL-File extension transport

If you have a genmodel file for the Ecore model available, you can already let Xtext generate a Dsl for the Ecore model. Select “New→Project→Xtext Project from Existing Ecore Models”. Add as EPackage your transport.genmodel and select the System as Entry Rule. Afterwards, if you have used the above settings for the project and language name, adjust the Xtext file to match our provided Xtext file header and footer.

More information about cross-referencing

For specifying an EDate in your DSL

For guidance on creation of an editor with Xtext, take a look at what you have worked through during the last practical lecture.


Task 47. Using Xtext to define a DSL Editor without an existing Ecore Model (optional)

[6 Points]

Create a XText-based DSL. Your grammar should accept examples like the following:

component c
  	port p1 provided I1 I2
	port p2 
	  required I1 I2
	  provided I1 I2
	
interface I1
interface I2

For simplicity reasons, you can restrict the order in which elements (component, interface, etc.) are defined in the file.

Please use the following names for your Xtext project and DSL fileextension:

Project name de.unibonn.se.atsc.compdsl
Language name de.unibonn.se.atsc.dsl.Components
DSL-File extension comp

Task 48. Create a UML Profile for a Component Model (optional)

[6 Points]

This task will model ports and components according to the following description:

Components have ports, which have required and provided interfaces. An interface has a name and contains at least one method. An interface may be used in several components.

Your task is to define a meta-model with stereotypes for the elements. For the definition of the profile you can use a UML2 tool of your choice (or use a simple class diagram where you use a directed association with the stereotype «extension» instead of the extension arrows). See slide 25 of the Model Driven Engineering lecture for more details about UML Profiles.

Create an exemplary class diagram and annotate the model elements accordingly.

[Yes, UML knows already components, interfaces and ports. Let's just assume these were not there and we need to model them with stereotypes on classes and associations.]  


If you have question, feel free to ask questions on the mailing list. Enjoy the holiday time as well as the time working with this powerful technology. 8-)

teaching/lectures/atsc/2013/assignment_09.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2020