Eclipse Modeling Tools tutorial - Creating a Simple Model [screencast]

Series: 
Eclipse Version: 

In this tutorial I present how to create a simple model using EMF. The goal is to make you learn the basics of metamodeling using EMF, so that you can move further to more advanced concepts. The tutorial first presents a small domain and then shows how to model it. If you need assistance creating your project you can check out my tutorial on getting started here.

 

Transcript

Hi I'm Edmundo and welcome to my Eclipse Modeling tutorial. In this lesson I'm showing how to create a simple model.

I'm using Eclipse Modeling Tools Luna SR 1. In this lesson I'll create simple metamodel using Eclipse. I'll first present the domain that I'm modeling, and then I show how to model it using the Eclipse Modeling Framework.

The domain

For this example I'm modeling a chart of accounts.

What's a chart of accounts? A chart of accounts is a term from accounting. You can look up the wikipedia page if you are interested in what it is for.

For now, we are interested only in its properties. A chart of accounts is composed of accounts.

Each account can have subaccounts, which are themselves accounts.

Each account is identified by a code and a name.;

That's all we need to know for the rest of this tutorial.

Modeling a chart of accounts

An account is modeled by a class.

To create a class I use the Class tool in the palette. I click the tool and put the class on the canvas by clicking in the location where I want it.

I can edit the name of my class by clicking on the class name.

I also need a class for sub accounts. This time I use the properties view to rename the class. To open the properties view I go to Windows->Show view->Properties.

Finally, I create the ChartOfAccounts class.

Then, I need to model the fact that the chart of accounts is composed by accounts. For that I use a Composition relation.

I just choose the composition tool from the palette and then connect both classes. I use the Properties view to set the name of the relation.

I also set some constraints in the composition. A chart of accounts always has at least one account. So, I set a lower bound on the number of accounts.

To do that I use the properties view.

Now I model the fact that a sub account is an account. For that I use the super type relation from the palette and then I choose the subtype and connect it to the super type.

I also need to model the fact that an account can have several subaccounts. This one is tricky, we can use either a reference or a composition. The choice depends on the usage that you'll later make of your model. I choose composition.

Finally, I model the attributes of the the accounts. To do this I use the menu that appears when I hover the mouse over a class and select the attribute. I set the name and the type in the Properties View.

I do the same with the name attribute.

Conclusion

So, I shown you how to create a model and use most basic features of EMF for modeling. Now it's up to you to create your own models.

If you have questions. Please do not hesitate to leave a comment. Also, you can subscribe to my mailing list in the sidebar of this page.

tweet: