Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Persisting a complete model into one file
Persisting a complete model into one file [message #1017691] Tue, 12 March 2013 10:37 Go to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 16
Registered: July 2012
Junior Member
Hi all,

I'm a bit new to EMF, so may be the question can seem a basic one, but I haven't found an esay answer yet Sad

I have an eCore model with containment/proxies reference (let's say object A has a list containing multiple B references). Each B object is stored in its own XMI file, and object A has just a proxy reference to it. That works fine Smile

than the use case is that I would like to use multiple files in a sort of "development mode", but when everything is well defined and won't change very often, it's easier for me to have everything in one file.

So I would like to be able to store A with all B objects in one XMI file (so without any proxy reference to other files).

How can I do that, how can I go from a multi-resources model to a one-resource one ?

Thanks ! Smile
Re: Persisting a complete model into one file [message #1017740 is a reply to message #1017691] Tue, 12 March 2013 13:14 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

You could iterate your model with eAllContents() and, for every EObject
that has an eDirectResource(), remove it from the eDirectResource()'s
getContents() list.

Just be careful not to remove the root element(s) of your model from
their resource, otherwise you'll end up with an empty file. :-)

HTH,

Christian


On 2013-03-12 10:37:59 +0000, Vince Cadmus said:

> Hi all,
>
> I'm a bit new to EMF, so may be the question can seem a basic one, but
> I haven't found an esay answer yet :(
>
> I have an eCore model with containment/proxies reference (let's say
> object A has a list containing multiple B references). Each B object is
> stored in its own XMI file, and object A has just a proxy reference to
> it. That works fine :)
>
> than the use case is that I would like to use multiple files in a sort
> of "development mode", but when everything is well defined and won't
> change very often, it's easier for me to have everything in one file.
>
> So I would like to be able to store A with all B objects in one XMI
> file (so without any proxy reference to other files).
> How can I do that, how can I go from a multi-resources model to a
> one-resource one ?
>
> Thanks ! :)
Re: Persisting a complete model into one file [message #1017760 is a reply to message #1017691] Tue, 12 March 2013 13:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Vince,

Comments below.

On 12/03/2013 11:37 AM, Vince Cadmus wrote:
> Hi all,
>
> I'm a bit new to EMF, so may be the question can seem a basic one, but
> I haven't found an esay answer yet :(
>
> I have an eCore model with containment/proxies reference (let's say
> object A has a list containing multiple B references). Each B object
> is stored in its own XMI file, and object A has just a proxy reference
> to it. That works fine :)
>
> than the use case is that I would like to use multiple files in a sort
> of "development mode", but when everything is well defined and won't
> change very often, it's easier for me to have everything in one file.
>
> So I would like to be able to store A with all B objects in one XMI
> file (so without any proxy reference to other files).
> How can I do that, how can I go from a multi-resources model to a
> one-resource one ?
Simply remove each B from its resource's getContents(). E.g., you could
write something like this

for (B b : a.getBs())
{
b.eResource().getContents().remove(b);
}

>
> Thanks ! :)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Persisting a complete model into one file [message #1018689 is a reply to message #1017760] Thu, 14 March 2013 10:14 Go to previous message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 16
Registered: July 2012
Junior Member
Many thanks guys, very clear and useful answer, it works ! Smile
Previous Topic:XSD->Ecore Mapping for unbounded sequences
Next Topic:[CDO] [HibernateStore]
Goto Forum:
  


Current Time: Thu Apr 18 14:34:01 GMT 2024

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

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

Back to the top