Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Removing element from a list with in an operation
Removing element from a list with in an operation [message #1666209] Wed, 11 March 2015 15:39 Go to next message
Martin Schreiber is currently offline Martin SchreiberFriend
Messages: 10
Registered: March 2015
Junior Member

I do have 2 domain objects

"Input" and "Output". Input does have a feature called "connectedTo" with type "Output", the "Output" does have a feature called "referencedBy" which is a 0..n relation to "Input".

I do have a Delete operation on an "Relation based edge".
Within the "Change Context" of this operation I do unset the "connectedTo" feature of the "Input" element which works fine. But I also need to remove the element from the referencedBy list.

I tried it with:
ChangeContext: "Browse Expression": self.connectedTo
Set: feature: "referencedBy"; Value Expression: "[self.referencedBy->excluding(element)" /]

It looks like that the "set" operation does try to call a setter method for the feature but since EMF does not generate a setter for a 0..n relations, the above stuff does not work. The ChangeContext stuff must be correct, because if I am setting another feature:
Set: feature: "name"; Value Expression: "[self.referencedBy->excluding(element)->toString()" /]
it works.

How can I remove the an element from a collection?

thanks
martin
Re: Removing element from a list with in an operation [message #1666281 is a reply to message #1666209] Wed, 11 March 2015 16:18 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

I think that the easiest way is to update your metamodel to have the
Input "connectedTo" reference to be an "eOpposite" of the Output
"referenceBy" reference. This way when you add/remove a referenced
element to one of these references, the other one will be updated
accordingly. Therefore, in your tool you will only need the (already
working) Set task.

Regards,
Steve

Le 11/03/2015 16:39, Martin Schreiber a écrit :
>
> I do have 2 domain objects
> "Input" and "Output". Input does have a feature called "connectedTo"
> with type "Output", the "Output" does have a feature called
> "referencedBy" which is a 0..n relation to "Input".
>
> I do have a Delete operation on an "Relation based edge". Within the
> "Change Context" of this operation I do unset the "connectedTo" feature
> of the "Input" element which works fine. But I also need to remove the
> element from the referencedBy list.
> I tried it with:
> ChangeContext: "Browse Expression": self.connectedTo
> Set: feature: "referencedBy"; Value Expression:
> "[self.referencedBy->excluding(element)" /]
>
> It looks like that the "set" operation does try to call a setter method
> for the feature but since EMF does not generate a setter for a 0..n
> relations, the above stuff does not work. The ChangeContext stuff must
> be correct, because if I am setting another feature:
> Set: feature: "name"; Value Expression:
> "[self.referencedBy->excluding(element)->toString()" /]
> it works.
>
> How can I remove the an element from a collection?
>
> thanks
> martin
>


--
Steve Monnier - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Removing element from a list with in an operation [message #1667683 is a reply to message #1666281] Thu, 12 March 2015 06:29 Go to previous message
Martin Schreiber is currently offline Martin SchreiberFriend
Messages: 10
Registered: March 2015
Junior Member
Steve,

Oh, it's that easy, I thought with the "eOpposite" you are also deleting the "oposite" when the item gets deleted and I do not want that, but that's not the case, for deleting the "Containment" has to be true.
So with the "eOposite" everything works fine, thank you very much Steve!
Previous Topic:Petri-Net Editor Edge Contraints
Next Topic:Sirius post-condition expression?
Goto Forum:
  


Current Time: Thu Apr 25 11:04:06 GMT 2024

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

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

Back to the top