Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Processing an Ecore-Based Model as a Graph
Processing an Ecore-Based Model as a Graph [message #1415196] Tue, 02 September 2014 09:41 Go to next message
Tom Richardson is currently offline Tom RichardsonFriend
Messages: 3
Registered: August 2014
Junior Member
Hello,

I currently have a graphml model/muddle and an EOL program which processes this model. However, I would like to (minimally) modify my EOL program to process an Ecore-based version of my model. I am therefore looking to replace the code below with something that would perform the equivalent function but with an Ecore-based model:

var elements = myModel.muddle.elements;
var nodes = elements.select(e|e.type.eClass().name = "MuddleElementType");
var edges = elements.select(e|e.type.eClass().name = "LinkElementType");

for(e in edges)
{
if(e.Target = self && e.Source = x)
{
}
}

for (n in nodes
{
//process
}

Having looked at the Javadoc for EmfModel, I noticed the methods
getAllOfType, getAllOfKind, and allContents. I tried:

var elements = myModel.getAllOfKind("EObject");
var elements = myModel.allContents();

These lines of code only returned the "nodes", that is, the EReferences (edges) were not returned. Furthermore, var edges = myModel.getAllOfKind("EReference") returned zero elements.

Does anyone have any suggestions?

Even if it is possible to obtain a list of all EReferences in a model, is it then possible to obtain the source and target EObjects given an EReference (as shown in the code above)? It would appear to me that it is only possible to determine the target of an EReference from a given source EObject.

Thanks,
Tom
Re: Processing an Ecore-Based Model as a Graph [message #1415393 is a reply to message #1415196] Tue, 02 September 2014 17:27 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 Tom,

When querying a model that conforms to an Ecore metamodel X, you can only use names of EClasses in X as parametes of getAllOf*(). The "EReference" EClass belongs to Ecore.ecore itself (your model -- conforms to --> X.ecore -- conforms to --> Ecore.ecore), so it's two meta-levels up and has no instances in your model. Does this help?

Cheers,
Dimitris
Re: Processing an Ecore-Based Model as a Graph [message #1415687 is a reply to message #1415393] Wed, 03 September 2014 11:03 Go to previous messageGo to next message
Tom Richardson is currently offline Tom RichardsonFriend
Messages: 3
Registered: August 2014
Junior Member
Thanks for the explanation. Is the implication of this then that it is not possible to generate a list\collection of all of the references/edges in my model? So, as an example, if I have an ecore model with 10,000 model elements (nodes) and only two references\links (edges), to find the target element of those two links I would need to iterate through the list of 10,000 model elements calling eCrossReferences() on each node? Clearly, if possible, it would be far more efficient in this case to be able to obtain all edges (2) and iterate through them to find the target nodes.

Thanks,
Tom
Re: Processing an Ecore-Based Model as a Graph [message #1415701 is a reply to message #1415687] Wed, 03 September 2014 11:53 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 Tom,

In EMF, references are not first-class objects. For example, in [1] it is not possible to directly get all the "author" references, but you could get hold of the author of a particular book "b" (b.author), all Writers in the model (Writer.all), or all authors of all books (Book.all.author).

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/reflective-emf-tutorial/

[Updated on: Fri, 05 September 2014 10:24]

Report message to a moderator

Re: Processing an Ecore-Based Model as a Graph [message #1415861 is a reply to message #1415701] Wed, 03 September 2014 21:12 Go to previous message
Tom Richardson is currently offline Tom RichardsonFriend
Messages: 3
Registered: August 2014
Junior Member
I understand,thanks Dimitris!

Tom
Previous Topic:Model visibility in ETL-guard
Next Topic:[ECL] Problems with recursive permutation of items in collections acc. to Fike algorithm
Goto Forum:
  


Current Time: Fri Apr 26 05:27:25 GMT 2024

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

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

Back to the top