Skip to content

SeelabFhdo/ewks2019

Repository files navigation

Eclipse Modeling Framework and UML Examples

This repository contains usage examples of tools from or based on the Eclipse Modeling Framework (EMF) [1], and UML examples. The usage examples show

  • the implementation of an abstract and concrete syntax for a textual language for modeling simple data structures (used tools: Xcore and Xtext [2,3]).
  • implementation of a model-to-text transformation that derives Java POJOs from models constructed with the aforementioned Data Structure Modeling Language (used tool: Acceleo [4]).
  • implementation of a model-to-model transformation that derives UML class diagrams from data structure models (used tool: ATL [5]).
  • models that represent different views on a microservice architecture and which are expressed with the Language Ecosystem for Modeling Microservice Architectures (LEMMA) [8].
  • UML diagrams for different viewpoints in Microservice Architecture (MSA) [9].

To play around with the provided examples, follow these steps:

  1. Download one of the predefined Eclipse packages depending on your OS:

  2. Clone/Download this repository to your harddrive.

  3. Run the eclipse executable in the package you downloaded in step 1, create a workspace as requested by the IDE, and import the projects you cloned/downloaded in step 2. Projects can be imported in Eclipse by hitting File > Open Projects from File System..., then choosing the parent folder of the cloned/downloaded projects as Import source, and after the projects were loaded hitting Finish.

  4. Download Visual Paradigm 15.2 Community Edition for your OS and install it.

Now that you have imported all projects into your workspace, you can try out the usage examples. The execution of the examples is technology-specific.

Running the Xcore and Xtext Usage Examples

To try out the Xcore and Xtext examples, you have to do the following:

  1. Right click on the project de.fhdo.ewks.ml_example.xtext which you imported into your workspace in step 3 above and from the context menu choose Run As > Eclipse Application. A new runtime Eclipse instance is opened.
  2. In the runtime Eclipse instance switch to the workbench and create a new Java Project entitled, e.g., Test.
  3. In the new Test project create a file with the extension .struct and the name MyStructure, i.e., the file's full name is MyStructure.struct. Confirm any subsequent dialogs with Yes.
  4. In the open editor showing the empty file MyStructure.struct, enter the following piece of code that conforms to the syntax of the Data Structure Modeling Language:
    context Accounting {
      structure ParkingSpace {
        string name,
        string description,
        boolean isOpen,
        double longitude,
        double latitude
      }
    }
    

The editor highlights the code according to what you have seen in MDE Part I.

Running the Acceleo Example

To try out the Acceleo example, you have to do the following:

  1. If you still have the runtime Eclipse instance, which you started in step (a) of the previous Xcore and Xtext instruction, close it. Switch to the Eclipse instance that you started in step 3 of the general introducton (see above).
  2. In the project de.fhdo.ewks.acceleo_example navigate to the file main.mtl, which is located in the project folder /src/de/fhdo/ewks/acceleo_example.
  3. Right click on the main.mtl file and choose Run As > Launch Acceleo Application. In the newly opened window enter the following values:
    • Project: de.fhdo.ewks.acceleo_example
    • Main class: de.fhdo.ewks.acceleo_example.Main (this is the Java-based runner for the Acceleo transformation)
    • Model: /de.fhdo.ewks.acceleo_example/model/MetamodelInstance.xmi (this a predefined instance of the Xcore metamodel for the Data Structure Modeling Language that reflects the model you created in step (d) in the previous section; if you want to create a new metamodel instance, i.e., a new model, with custom values (i) double click on the project file /de.fhdo.ewks.acceleo_example/model/ml_example.ecore, (ii) in the opened tree right click on Context and hit Create Dynamic Instance..., (iii) after that, follow the guide "Editing Ecore model instances" [6] to create new model elements with custom values)
    • Target: /de.fhdo.ewks.acceleo_example/output (this is the output folder of the Java code resulting from executing the transformation)
  4. Make sure you selected Java Application as "Runner" and hit Run. The transformation will produce a file called ParkingSpace.java in the project folder output. It corresponds to the model you created in step (d) of the previous section.

Running the ATL Example

To try out the ATL example, you have to do the following:

  1. If you still have the runtime Eclipse instance, which you started in step (a) of the previous Xcore and Xtext instruction, close it. Switch to the Eclipse instance that you started in step 3 of the general introducton (see above).
  2. In the project ATL-example navigate to the file DS2UML.atl, which is located in the project folder /src.
  3. Right click on the DS2UML.atl file and choose Run As > ATL transformation. In the newly opened window enter the following values:
    • DataStructureModel: /ATL-example/model/ml_example.ecore (this is the Ecore representation of the Xcore metamodel of the Data Structure Modeling Language)
    • UML: uri:http://www.eclipse.org/uml2/5.0.0/UML (this represents the current UML metamodel [7])
    • IN: /ATL-example/model/MetamodelInstance.xmi (this a predefined instance of the Xcore metamodel for the Data Structure Modeling Language that reflects the model you created in step (d) in the previous section; if you want to create a new metamodel instance, i.e., a new model, with custom values (i) double click on the project file /ATL-example/model/ml_example.ecore, (ii) in the opened tree right click on Context and hit Create Dynamic Instance..., (iii) after that, follow the guide "Editing Ecore model instances" [6] to create new model elements with custom values)
    • TYPES: /ATL-example/model/UMLPrimitiveTypes.library.uml (this a definition of UML's primitive types, which is needed to create UML PrimitiveType instances)
    • OUT: /ATL-example/output/out.xmi (this is the output file, which contains the UML target instance in the XMI format)
  4. Switch to the "Advanced" tab and activate the checkbox Allow inter-model references.
  5. Hit Run. The transformation will produce a file called out.xmi in the project folder output. It corresponds to the model you created in step (d) of the previous section, but is a UML class diagram instance.

Running the LEMMA Examples

To try out the LEMMA examples, you have to do the following:

  1. Open the project LEMMA-examples which you imported into your workspace in step 3 above.
  2. Within the project you will find different different folders.
    • The domain models folder comprises the domain models Banking.data and Student.data expressed in LEMMA's Domain Data Modeling Language.
    • The microservices folder comprises the service models Banking.services and Student.services expressed in LEMMA's Service Modeling Language.
    • The operation folder comprises the operation model Architecture.operation expressed in LEMMA's Operation Modeling Language.
    • The technology folder comprises the Java technology model (file java.technology) used throughout the lectures. You are invited to explore and play around with it, in case you are curious.
You can double click on each of the mentioned files to open the editor that shows the contained model according to the syntax of the respective modeling language and play around with the models leveraging the editor.

Running the UML examples

To try out the UML examples, you have to do the following:

  1. Start Visual Paradigm which you installed in step 4 (see above).
  2. In the dash panel, click on Project > Open. Select the UML-examples.vpp that you cloned from the repository in step 2 (see above) from the file chooser and open it.

The file contains three different diagrams (class, component, and deployment). You can switch between them in Visual Paradigm via the Project Browser.

References

[1] https://wiki.eclipse.org/EMF
[2] https://wiki.eclipse.org/Xcore
[3] https://www.eclipse.org/Xtext
[4] https://wiki.eclipse.org/Acceleo
[5] https://www.eclipse.org/atl
[6] https://www.ntnu.no/wiki/display/tdt4250/Editing+Ecore+model+instances
[7] https://www.omg.org/spec/UML/2.5/PDF
[8] https://github.com/SeelabFhdo/ddmm
[9] Rademacher, F., Sorgalla, J., Sachweh, S.: Challenges of domain-driven microservice design: A model-driven perspective. IEEE Software 35(3), 36–43 (2018)