Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Ecore] deep copying properties of Ecore elements without subcontents
[Ecore] deep copying properties of Ecore elements without subcontents [message #660277] Thu, 17 March 2011 12:15 Go to next message
leonard.krpan is currently offline leonard.krpan
Messages: 20
Registered: March 2011
Junior Member
I'm processing an Ecore model where the resulting model is a subset of the original one, but should be an independet model without any references to the original one.

I'm using a TreeIterator to process model elements one at a time. If an element (EPackage, EClass, EAttribute or EReference) should be a part of the resulting model, I create a new appropriate Ecore class and then I need to set all the properties as in the original element. However, I do not want to set references such as subpackages, since at the moment that I'm processing this package I don't know which of it's subpackages will fulfill the processing conditions to be taken into the resulting model. So,

I just tried using EcoreUtil.copy and EcoreUtil.Copier.copy but they both have the effect of copying everything the package contains, which I don't want - I need the package alone, cut off from it's super and subpackages...

Is there a way to this other than stripping the copied package contents manually?
Re: [Ecore] deep copying properties of Ecore elements without subcontents [message #660291 is a reply to message #660277] Thu, 17 March 2011 12:37 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
You could specialize copyContainment to ignore certain containment
references.

lk_muc wrote:
> I'm processing an Ecore model where the resulting model is a subset of
> the original one, but should be an independet model without any
> references to the original one.
>
> I'm using a TreeIterator to process model elements one at a time. If
> an element (EPackage, EClass, EAttribute or EReference) should be a
> part of the resulting model, I create a new appropriate Ecore class
> and then I need to set all the properties as in the original element.
> However, I do not want to set references such as subpackages, since at
> the moment that I'm processing this package I don't know which of it's
> subpackages will fulfill the processing conditions to be taken into
> the resulting model. So,
> I just tried using EcoreUtil.copy and EcoreUtil.Copier.copy but they
> both have the effect of copying everything the package contains, which
> I don't want - I need the package alone, cut off from it's super and
> subpackages...
>
> Is there a way to this other than stripping the copied package
> contents manually?
Previous Topic:Loading a resource with invalid non contained reference
Next Topic:[Ecore] Check class reference consistency in model
Goto Forum:
  


Current Time: Wed Jul 30 13:21:09 EDT 2014

Powered by FUDForum. Page generated in 0.11284 seconds