Bug 540395 - EmfModel getAllContents loads elements from ALL resources in the ResourceSet
Summary: EmfModel getAllContents loads elements from ALL resources in the ResourceSet
Status: NEW
Alias: None
Product: Epsilon
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Dimitris Kolovos CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-23 07:04 EDT by Horacio Hoyos CLA
Modified: 2020-04-18 03:50 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Horacio Hoyos CLA 2018-10-23 07:04:32 EDT
The allContentsFromModel method uses the getResources method to find all resources from which elements should be retrieved. The reason for this is so that the expand flag is respected -> comments suggest we are looking for parent resources of the current EMF model.

However, the selection logic is flawed because the { rootContainer == null } condition is not enough. When using an InMemoryEmfModel there might be multiple resources loaded into the resource set, and for unrelated resources the rootContainer will also be null. As a result, methods that depend on getAllContents/allContentsFromModel are returning elements that are not contained in the model (nor its container). 

Antonio, according to git you are the author of this particular section. Can you tell us more about the logic and how we could improve it?
Comment 1 Sina Madani CLA 2020-04-12 08:47:41 EDT
Given this is marked as a "blocker" (is this really that critical?), we should ideally fix this before next release. The lack of attention this has received suggests it is not a "blocker".
Comment 2 Sina Madani CLA 2020-04-12 08:49:52 EDT
I realised Antonio was not CC'd, hence no reply.
Comment 3 Antonio Garcia-Dominguez CLA 2020-04-13 12:23:17 EDT
This is done to support models that use cross-file containment. A single "model" may be split across many .xmi files, which means we have to find the "root" resources inside that resource set.

I am not sure how we would distinguish the cross-file containment case from the "unrelated models in the same set" case. Perhaps InMemoryEmfModel should be tweaked to support the idea of a "main" resource, or have its allContentsFromModel() method appropriately changed.
Comment 4 Horacio Hoyos CLA 2020-04-13 12:52:07 EDT
I guess another valid solution would be to improve the documentation/ui information on allContentsFromModel method. Most of this "bugs" come from using Epsilon in standalone applications, where the ResourceSet is under control of the user and not Eclipse/EMF. 

That is, if some one warns me that A.all() will go over the complete ResourceSet then I could be "smarter" and use separate ResourceSets for un-related models or when I want to limit the reach of the the all() semantics.
Comment 5 Antonio Garcia-Dominguez CLA 2020-04-18 03:50:57 EDT
+1 for doing it through documentation. Particularly, I'd suggest tweaking any articles we may have about this in the website, and also extending the InMemoryEmfModel talking about this resource set issue.