Processing an Ecore-Based Model as a Graph [message #1415196] |
Tue, 02 September 2014 09:41 |
Tom Richardson 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 |
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03635 seconds