Bug 494009 - Invalid behaviour of CreateInstance for unary composition
Summary: Invalid behaviour of CreateInstance for unary composition
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.1.0   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-05-19 08:20 EDT by Frédéric Madiot CLA
Modified: 2016-05-30 11:46 EDT (History)
2 users (show)

See Also:


Attachments
the metamodel (127.12 KB, application/x-zip-compressed)
2016-05-19 08:20 EDT, Frédéric Madiot CLA
no flags Details
a modeler reproducing the bug (4.36 KB, application/x-zip-compressed)
2016-05-19 08:20 EDT, Frédéric Madiot CLA
no flags Details
a sample model (1.81 KB, application/x-zip-compressed)
2016-05-19 08:21 EDT, Frédéric Madiot CLA
no flags Details
The modified VSM with the proposed solution (2.31 KB, application/octet-stream)
2016-05-30 10:25 EDT, Laurent Redor CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.