Skip to main content



      Home
Home » Modeling » EMF » Persisting a complete model into one file
Persisting a complete model into one file [message #1017691] Tue, 12 March 2013 06:37 Go to next message
Eclipse UserFriend
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 09:14 Go to previous messageGo to next message
Eclipse UserFriend
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 09:42 Go to previous messageGo to next message
Eclipse UserFriend
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 ! :)
Re: Persisting a complete model into one file [message #1018689 is a reply to message #1017760] Thu, 14 March 2013 06:14 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 12:29:18 EDT 2025

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

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

Back to the top