Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Saving EMF Resources(Nested contained data writes out incorrectly)
Saving EMF Resources [message #1049203] Thu, 25 April 2013 13:58 Go to next message
Nick Staudt is currently offline Nick StaudtFriend
Messages: 2
Registered: April 2013
Junior Member
I am trying to save a model using the EMF Resource tools. The root node essentially writes out the data correctly, but within there is an underlying containment to two other "reference" objects. These objects share the same eResource as it's parent, and the containment is true. After saving i viewed the xml file, expecting to see the data written out from each of these "references". but instead they both look similar to this:

<reference href="Model550.xml#Reference~Some-Data 1"/>
<reference href="Model550.xml#Reference~Some-Data 2"/>

Not sure what this could be. Any ideas? Thanks in advance.

Nick
Re: Saving EMF Resources [message #1049365 is a reply to message #1049203] Thu, 25 April 2013 19:06 Go to previous messageGo to next message
Nick Staudt is currently offline Nick StaudtFriend
Messages: 2
Registered: April 2013
Junior Member
Just a note, I did figure out the problem. When saving, the inner References had an eResource different than the container. But even if they were the same, it would still save out incorrectly. So what i did was i cleared the eResource for each of the inner contained references. This then allowed the parent container to write out the data contained in each of the references. It seems to me like if it has an eResource, that it writes out to that, rather than being written with it's parent when saved. I am probably wrong, but that's what my observation was. Thanks though! This was my first post. Maybe it will help someone else

Nick
Re: Saving EMF Resources [message #1049784 is a reply to message #1049365] Fri, 26 April 2013 09:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Nick,

There is support for cross resource containment so indeed, if a
contained object is directly contained in some other resource or even
the same resource, it will be serialized much like a cross reference,
i.e., by referencing the object where it is contained as the root object
of some resource.


On 25/04/2013 9:06 PM, Nick Staudt wrote:
> Just a note, I did figure out the problem. When saving, the inner
> References had an eResource different than the container. But even if
> they were the same, it would still save out incorrectly. So what i did
> was i cleared the eResource for each of the inner contained
> references. This then allowed the parent container to write out the
> data contained in each of the references. It seems to me like if it
> has an eResource, that it writes out to that, rather than being
> written with it's parent when saved. I am probably wrong, but that's
> what my observation was. Thanks though! This was my first post. Maybe
> it will help someone else
>
> Nick


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Saving EMF Resources [message #1052832 is a reply to message #1049784] Tue, 30 April 2013 16:03 Go to previous messageGo to next message
Ian Price is currently offline Ian PriceFriend
Messages: 1
Registered: April 2013
Junior Member
Ed,

Is there a way to force proxies to be resolved upon serializing out a Resource? Nick's approach, though it works, seems like it's going about it the wrong way.

For example, we have a usecase where we have to load a model from a database (Model A), attach it to another model (Model B), and save it to a server from which a third party can reload it. Upon reload, we don't care if Model A and Model B are contained by the same Resource.

V/r,
-Ian
Re: Saving EMF Resources [message #1052949 is a reply to message #1052832] Wed, 01 May 2013 14:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ian,

Comments below.


On 01/05/2013 2:44 PM, Ian Price wrote:
> Ed,
>
> Is there a way to force proxies to be resolved upon serializing out a
> Resource?
I'm not sure what you mean... It's never necessary to resolve proxy as
part of serialization, so what's gained from that? EcoreUtil.resolveAll
can be used to force proxies to resolve in general...
> Nick's approach, though it works, seems like it's going about it the
> wrong way.
>
> For example, we have a usecase where we have to load a model from a
> database (Model A), attach it to another model (Model B), and save it
> to a server from which a third party can reload it. Upon reload, we
> don't care if Model A and Model B are contained by the same Resource.
Having models that span resources is common. That's what proxies are
for. Normally proxies are resolved as you traverse them, so it's all
transparent. So I'm not sure what problem you're trying to solve. In
any case, EcoreUtil.resolveAll is a brute force way to resolve all
proxies up front, i.e., you can apply it to a resource set and be
assured that the resource set contains all reachable resources and any
proxy that can be resolved, has been resolved.
> V/r,
> -Ian


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:3 or 4 layers
Next Topic:[XCore] default value
Goto Forum:
  


Current Time: Fri Apr 19 21:15:39 GMT 2024

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

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

Back to the top