Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Incorrect Set Value operation on collection?(Append i.s.o. assign)
Incorrect Set Value operation on collection? [message #1229477] Thu, 09 January 2014 14:24 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 99
Registered: June 2010
Member
Hi,

I created a simple meta model consisting of a Container and Nodes. The Container holds Nodes using two composition references: rightnodes and leftnodes. Furthermore, the container maintains a reference to all nodes via (a non containment feature) allnodes.

Based on that model I created an editor that provides the ability to create 'leftnodes' and 'rightnodes'. Upon invocation of such tool, a new Node instance is created and added to the corresponding Container feature(leftnodes or rightnodes).

However I also need to update the 'allnodes' feature. Therefore, my addLeftNode tool definition looks like:

Create Instance Node (reference name = leftnodes, variable name is instance)
- Set Value side 
- Set Value name
- Change context var:container
-- Set Value allnodes


Obviously the purpose of the Set Value allnodes action is to add the newly added node to the allnodes feature.

By mistake I set the value of allnodes to [ Set{instance} /] To my opinion, this expression assign a new collection holding only the new instance to the allnodes feature.

However, I was surprised to discover that each newly added Node got added to the allnodes feature. So instead of assigning a new Set to the allnodes feature, a new entitiy is added upon each tool invocation.

Am I doing something wrong or is this a bug? In case of the former, please explain to me what is going on?

Greetings,
Wilbert.

Re: Incorrect Set Value operation on collection? [message #1229514 is a reply to message #1229477] Thu, 09 January 2014 15:58 Go to previous messageGo to next message
Alex Lagarde is currently offline Alex LagardeFriend
Messages: 185
Registered: May 2010
Senior Member

Hi Wilbert,

this is a known and a wanted behavior (because most of the time you want
to add elements not replace your list content). Notice that this allows
to use the same syntax for mono-valued and multi-valued references.

If you want to set the whole list, first do an Unset and then call your
Set {instance}.

Notice that this is similaire to what you would do with the EMF API :
myList.clear();
myList.add(myElement);

Best regards,
Alex
Re: Incorrect Set Value operation on collection? [message #1229789 is a reply to message #1229514] Fri, 10 January 2014 08:15 Go to previous messageGo to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 99
Registered: June 2010
Member
Hi Alex,

That sounds reasonable though it goes against my intuition. Setting a value is something different from extending a collection.

However, in that case it might be wise to update the documentation for the Set Value operation as it clearly states that it sets the value of a feature.

Does it help if I file a bug against this (to update the documentation, not necessarily to update the behavior)? Note that the documentation of the model operation has some other areas that might deserve some attention. (Especially "Go To" seems to be renamed to "Change context" which is a much more sensible name in my opinion.

Greetings,
Wilbert.

Re: Incorrect Set Value operation on collection? [message #1229799 is a reply to message #1229789] Fri, 10 January 2014 08:37 Go to previous message
Alex Lagarde is currently offline Alex LagardeFriend
Messages: 185
Registered: May 2010
Senior Member

Hi Wilbert,

we would indeed appreciate if you raised a bugzilla issue to update the
Set instruction documentation. Could you also include the 2 updates you
mentionned in your latest posts:
- Make sure that we are consistent with the use of "Go To"/"Change Context"
- Update the CreateInstance (and general Model operations) documentation
to detail the variables Scope

Thanks a lot for your feedbacks,
Alex

Le 10/01/2014 09:15, Wilbert Alberts a écrit :
> Hi Alex,
>
> That sounds reasonable though it goes against my intuition. Setting a
> value is something different from extending a collection.
>
> However, in that case it might be wise to update the documentation for
> the Set Value operation as it clearly states that it sets the value of a
> feature.
>
> Does it help if I file a bug against this (to update the documentation,
> not necessarily to update the behavior)? Note that the documentation of
> the model operation has some other areas that might deserve some
> attention. (Especially "Go To" seems to be renamed to "Change context"
> which is a much more sensible name in my opinion.
>
> Greetings,
> Wilbert.
>
>
Previous Topic:Visibility of variabe
Next Topic:Unable to show derived values in table colum
Goto Forum:
  


Current Time: Sat Dec 20 16:04:33 GMT 2014

Powered by FUDForum. Page generated in 0.02448 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software