Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [ETL] why is edge created as child node?
[ETL] why is edge created as child node? [message #1698270] Fri, 12 June 2015 17:03 Go to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
I'm exploring ETL through transforming eclipse UML2 models into the Graph metamodel provided in the epsilon samples. The goal is:

- For each Class, generate a Node;
- For each Association, generate an Edge.

ETL as follows:

rule UMLClass2Node 
	transform c : TUML!Class
	to n : Graph!Node {
	
	n.name = c.name;
}

rule UMLAssociation2Edge
	transform a: TUML!Association
	to e: Graph!Edge {
	
	e.label = a.name;
	
	e.source ::= a.ownedEnd.first().type;
	e.target ::= a.ownedEnd.last().type;
}


This works - almost. A UML model comprising 2 classes ("Dog" and "Person") plus one Association linking them ("Ownership") results in:

<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:Graph="Graph">
  <Graph:Node name="Dog" incoming="/1/@outgoing.0"/>
  <Graph:Node name="Person">
    <outgoing target="/0" label="Ownership"/>
  </Graph:Node>
</xmi:XMI>


I would have expected 'Ownership' to translate into a 'Graph:Edge' element at the root level - not child attributes of the "Node" entries.

This might just be down to how ecore serialises models. However I'm looking to do a follow on EGL transformation that will generate graphviz DOT files. It would seem more straightforward to do that if the edge was a first class entity.

Just want to make sure I'm not missing something. Would appreciate any explanation/suggestion.

Thanks.
Re: [ETL] why is edge created as child node? [message #1698274 is a reply to message #1698270] Fri, 12 June 2015 17:49 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Scott,

This happens because "outgoing" is a containment reference. To achieve the desired serialisation, you should change the metamodel as follows:

class Graph {
   val Node[*] nodes;
   val Edge[*] edges; // Edges need to be contained somewhere
}

class Node {
   attr String name;
   ref Edge[*]#source outgoing; // ref instead of val
   ref Edge[*]#target incoming;
}


Cheers,
Dimitris
Re: [ETL] why is edge created as child node? [message #1698278 is a reply to message #1698274] Fri, 12 June 2015 18:17 Go to previous message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
Quote:
This happens because "outgoing" is a containment reference.


Of course - should have thought about that. Thanks Dimitris.
Previous Topic:Printing Epsilon and Model-Metamodel File Names
Next Topic:[ETL] List References and Model Element Deletion
Goto Forum:
  


Current Time: Fri Apr 26 12:41:05 GMT 2024

Powered by FUDForum. Page generated in 0.02695 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top