Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Deletion of contained objects(How do i get referenced objects deleted if it's an contained object within the same model?)
Deletion of contained objects [message #487629] Wed, 23 September 2009 19:54 Go to next message
Babloo is currently offline BablooFriend
Messages: 12
Registered: September 2009
Junior Member
Hi,

I am using EMF 2.4.
I have a EClass (say ClassA) that contains a reference object (say ref1) -- which is contained.
This same EClass has another contained object (say ref2) , which has a eref to ref1 (which is non-contained from ref2).
When I try remove ref1 from ClassA, it still remains in ref2. How do I get this to go away as well?

I have this same pattern in several different objects as well. Hence, I would not want to write some kind of Adapter to deal with this situation.

Please advice on how do i handle this situation.

Thanks,
Babs
Re: Deletion of contained objects [message #487687 is a reply to message #487629] Thu, 24 September 2009 07:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
Babs,

Comments below.

babloo80@gmail.com wrote:
> Hi,
>
> I am using EMF 2.4.
> I have a EClass (say ClassA) that contains a reference object (say
> ref1) -- which is contained.
> This same EClass has another contained object (say ref2) , which has a
> eref to ref1 (which is non-contained from ref2). When I try remove
> ref1 from ClassA, it still remains in ref2. How do I get this to go
> away as well?
You could try EcoreUtil.delete, it removes the object from its container
and removes all references to it. It can also recursively act on all
contained children of the deleted object.
>
> I have this same pattern in several different objects as well. Hence,
> I would not want to write some kind of Adapter to deal with this
> situation.
>
> Please advice on how do i handle this situation.
>
> Thanks,
> Babs


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Deletion of contained objects [message #488148 is a reply to message #487687] Fri, 25 September 2009 17:00 Go to previous messageGo to next message
Babloo is currently offline BablooFriend
Messages: 12
Registered: September 2009
Junior Member
Hello Ed,

I forgot to mention, I am using this (Ecoreutil.delete()) as a workaround.
Wondering to see, if there is an OOTB annotation in EMF that I could use to achieve this in the generated code?
Or, may be, I have to write a custom annotation for this? If yes, is there a sample that i could look at?

Ed - Thank you for looking into this!

Thanks,
Babs
Re: Deletion of contained objects [message #488163 is a reply to message #488148] Fri, 25 September 2009 17:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33147
Registered: July 2009
Senior Member
Babs,

Something like this needs to be done using reflection because you can't
generally know all possible references to the object from just the model
information available to the generated model. So no, expect the
generated model to support only finer grained operations...


babloo80@gmail.com wrote:
> Hello Ed,
>
> I forgot to mention, I am using this (Ecoreutil.delete()) as a
> workaround. Wondering to see, if there is an OOTB annotation in EMF
> that I could use to achieve this in the generated code?
> Or, may be, I have to write a custom annotation for this? If yes, is
> there a sample that i could look at?
>
> Ed - Thank you for looking into this!
>
> Thanks,
> Babs


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Re: How can I put together TransactionalEditingDomain and a monitored CommandStack
Next Topic:How to model an exception with MagicDraw
Goto Forum:
  


Current Time: Sun May 12 18:04:10 GMT 2024

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

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

Back to the top