Bug 494009

Summary: Invalid behaviour of CreateInstance for unary composition
Product: [Modeling] Sirius Reporter: Frédéric Madiot <frederic.madiot>
Component: CoreAssignee: Project inbox <sirius.core-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: julien.dupont, laurent.redor
Version: 3.1.0Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:
Attachments:
Description Flags
the metamodel
none
a modeler reproducing the bug
none
a sample model
none
The modified VSM with the proposed solution none

Description Frédéric Madiot CLA 2016-05-19 08:20:13 EDT
Created attachment 261849 [details]
the metamodel

The CreateInstance operation doesn't work on an unary composition that is already set. 

The error message is "Impossible to add a value to the reference <referenceName> of the object".

It seems that Sirius tries to execute a "add" while it should execute a "set".

I have reproduced this case on a simple metamodel (with A containing B) and VSM (a diagram for A which contains nodes for B). A tool performing a CreateInstance works the first time, then fails (when the relation is set).
Comment 1 Frédéric Madiot CLA 2016-05-19 08:20:51 EDT
Created attachment 261850 [details]
a modeler reproducing the bug
Comment 2 Frédéric Madiot CLA 2016-05-19 08:21:17 EDT
Created attachment 261851 [details]
a sample model
Comment 3 Laurent Redor CLA 2016-05-30 10:00:08 EDT
I tried to reproduce your problem, but the test metamodel is missing. Can you attach it?
Comment 4 Laurent Redor CLA 2016-05-30 10:24:35 EDT
Sorry, I don't see that the metamodel is directly attached within the description (and not within a new comment).

So I'm able to reproduce the problem.

In your case, what do you expect for the already existing B instance? It should be automatically delete by Sirius?

I think that your tool must be completed to delete the already existing B before adding a new one.
Comment 5 Laurent Redor CLA 2016-05-30 10:25:25 EDT
Created attachment 262112 [details]
The modified VSM with the proposed solution

Are you OK with the solution?
Comment 6 Laurent Redor CLA 2016-05-30 11:46:43 EDT
After discussion, if you call programatically set() on this kind of reference, EMF replaces the existing B by the new one (the old one is "lost").

Sirius could do the same. Nevertheless, we have currently not planned to work on it in the following releases.

The solution proposed in comment 5 can be used as workaround.