Bug 419450 - An AbstractNodeMapping with empty semantic candidate expression ignores the Resource roots
Summary: An AbstractNodeMapping with empty semantic candidate expression ignores the R...
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2013-10-15 09:02 EDT by Cedric Brun CLA
Modified: 2014-09-17 09:16 EDT (History)
4 users (show)

See Also:


Attachments
Reproduction use case. (3.22 KB, application/x-zip-compressed)
2013-12-24 11:25 EST, Maxime Porhel CLA
no flags Details
Reproduction use case with modeling project. (3.39 KB, application/x-zip-compressed)
2014-01-09 08:45 EST, Maxime Porhel CLA
no flags Details
Reproduction use case with modeling project. (3.39 KB, application/x-zip-compressed)
2014-01-09 08:46 EST, Maxime Porhel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Brun CLA 2013-10-15 09:02:51 EDT
When one don't use the semantic candidate expression the expectation is that means : any EObject of the right type in the Session.

Let's say you define a diagram attached to EPackage, and then add a ContainerMapping with domainClass="EPackage" and semanticCandidateExpression=""

You'll be suprised to see that only subEPackages will be displayed, and not the ones which are roots of a Resource

Of course this can be quite easily worked around by writing a dedicated java service.

Looking at the code, it simply ignores the roots when retrievient the semantic candidates, see the following patch fixing the pb:

--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/experimental/sync/AbstractSynchronizerHelper.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/experimental/sync/AbstractSynchronizerHelper.java
@@ -140,6 +140,9 @@ public abstract class AbstractSynchronizerHelper {
             } else {
                 for (final Resource resource : session.getSemanticResources()) {
                     for (final EObject root : resource.getContents()) {
+                       if (this.accessor.eInstanceOf(root, domainClass.get())) {
+                               semantics.add(root);
+                       }
                         semantics.addAll(this.accessor.eAllContents(root, domainClass.get()));
                     }
                 }



The thing is, it's been around for quite a long time and even our tests might rely on this behavior. We need to have a close look at them when integrating this change.
Comment 1 Laurent Redor CLA 2013-12-23 08:48:22 EST
Cédric, can you attach a reproduction use case to simplify the analysis please?
Comment 2 Maxime Porhel CLA 2013-12-24 11:25:04 EST
Created attachment 238555 [details]
Reproduction use case.

Laurent, Cédric, I attached a use case.
Comment 3 Maxime Porhel CLA 2014-01-09 08:45:45 EST
Created attachment 238820 [details]
Reproduction use case with modeling project.
Comment 4 Maxime Porhel CLA 2014-01-09 08:46:12 EST
Created attachment 238821 [details]
Reproduction use case with modeling project.
Comment 5 Maxime Porhel CLA 2014-01-09 08:51:12 EST
Steps to reproduce:
 . Import the modeling project from the attached use case.
 . Open the 'new 419450' diagram.
 . There are only 3 diagram elements displayed (1 node, 1 edge and 1 container with childPackage as semantic element): KO

We should have 6 diagram elements: 1 node, 1 edge and 1 container for childPackage and the same constructions for the packaged named 'root' which is the root of the semantic resource.
Comment 6 Matthieu Helleboid CLA 2014-01-09 11:13:38 EST
Stéphane Bonnet has committed Cedric's patch which seems to fix this issue. Do you want me to also add the test?
Comment 7 Pierre-Charles David CLA 2014-04-22 08:58:51 EDT
See https://git.eclipse.org/r/#/c/20445