Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Cross-Document References Loading/Saving.
Cross-Document References Loading/Saving. [message #387054] Mon, 16 August 2004 05:25 Go to next message
Eclipse UserFriend
Originally posted by: scottwarren.myself.com

Here's a situation where I could use some advice:

I'm modeling a process flow and my original design of the EMF model had a
single top-level object that was the containment root for all objects in the
model. This worked fine. I could load/save without any problems. Now, I
have the requirement to make certain parts of the model "shareable". For
example, a user designs a sub-process that he/she wants to use across
multiple model instances. In an effort to accomplish this, I've changed
almost all references to non-containment references so that the component
parts can be written to separate files. Now, rather than one single file,
I've got quite a few (30+ in my unit test). So, it seems to save fine. I
load the "root" (top-level) document and load appears to work fine until I
go to save the model again. If I load the root document and immediately try
to save again (like a "Save As"), it appears that the other referenced
objects never get completely loaded. I find that if I write code that walks
the object tree after the load, everything gets demand loaded and the save
works correctly. Shouldn't the reference to each object by the EMF
serialization code cause the resources to be loaded?
If I'm going about this the wrong way, please let me know.
Thanks,

Scott
Re: Cross-Document References Loading/Saving. [message #387063 is a reply to message #387054] Mon, 16 August 2004 14:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Scott,

When a document with cross document references is read in, proxies are
created to refer to objects in other documents. Those proxies are
resolved on demand as you access them. But when the serializer accesses
the instance, it's careful to do so in a way that does not cause any
proxies to resolve. So what you are describing is what I would expect...


Scott Warren wrote:

>Here's a situation where I could use some advice:
>
>I'm modeling a process flow and my original design of the EMF model had a
>single top-level object that was the containment root for all objects in the
>model. This worked fine. I could load/save without any problems. Now, I
>have the requirement to make certain parts of the model "shareable". For
>example, a user designs a sub-process that he/she wants to use across
>multiple model instances. In an effort to accomplish this, I've changed
>almost all references to non-containment references so that the component
>parts can be written to separate files. Now, rather than one single file,
>I've got quite a few (30+ in my unit test). So, it seems to save fine. I
>load the "root" (top-level) document and load appears to work fine until I
>go to save the model again. If I load the root document and immediately try
>to save again (like a "Save As"), it appears that the other referenced
>objects never get completely loaded. I find that if I write code that walks
>the object tree after the load, everything gets demand loaded and the save
>works correctly. Shouldn't the reference to each object by the EMF
>serialization code cause the resources to be loaded?
>If I'm going about this the wrong way, please let me know.
>Thanks,
>
>Scott
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Cross-Document References Loading/Saving. [message #387072 is a reply to message #387063] Mon, 16 August 2004 15:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: scottwarren.myself.com

Thanks Ed.

How would you suggest I handle this? I really don't want to walk the entire
model to get everything loaded and I REALLY don't want a half-cooked model
serialized. I've got a separate "manifest" that tells me all the files that
make up the model. Should I just do a resourceSet.getResource(uri, true)
for each file? My first take would be that the LoadOnDemand parameter would
be false, but I get a null back when I try that. Any suggestions?

Thanks,
-Scott

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:cfqfi5$unf$1@eclipse.org...
> Scott,
>
> When a document with cross document references is read in, proxies are
> created to refer to objects in other documents. Those proxies are
> resolved on demand as you access them. But when the serializer accesses
> the instance, it's careful to do so in a way that does not cause any
> proxies to resolve. So what you are describing is what I would expect...
>
>
> Scott Warren wrote:
>
> >Here's a situation where I could use some advice:
> >
> >I'm modeling a process flow and my original design of the EMF model had a
> >single top-level object that was the containment root for all objects in
the
> >model. This worked fine. I could load/save without any problems. Now,
I
> >have the requirement to make certain parts of the model "shareable". For
> >example, a user designs a sub-process that he/she wants to use across
> >multiple model instances. In an effort to accomplish this, I've changed
> >almost all references to non-containment references so that the component
> >parts can be written to separate files. Now, rather than one single
file,
> >I've got quite a few (30+ in my unit test). So, it seems to save fine.
I
> >load the "root" (top-level) document and load appears to work fine until
I
> >go to save the model again. If I load the root document and immediately
try
> >to save again (like a "Save As"), it appears that the other referenced
> >objects never get completely loaded. I find that if I write code that
walks
> >the object tree after the load, everything gets demand loaded and the
save
> >works correctly. Shouldn't the reference to each object by the EMF
> >serialization code cause the resources to be loaded?
> >If I'm going about this the wrong way, please let me know.
> >Thanks,
> >
> >Scott
> >
> >
> >
> >
Re: Cross-Document References Loading/Saving. [message #387086 is a reply to message #387072] Mon, 16 August 2004 17:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020307020408060003050202
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Scott,

You haven't actually described anything that sounds like a problem.
What do you see as the problem?

One way to force all proxies to be resolved is to iterate over
ResourceSet.getAllContents and for each EObject, iterate over
eCrossReferences...



Scott Warren wrote:

>Thanks Ed.
>
>How would you suggest I handle this? I really don't want to walk the entire
>model to get everything loaded and I REALLY don't want a half-cooked model
>serialized. I've got a separate "manifest" that tells me all the files that
>make up the model. Should I just do a resourceSet.getResource(uri, true)
>for each file? My first take would be that the LoadOnDemand parameter would
>be false, but I get a null back when I try that. Any suggestions?
>
>Thanks,
>-Scott
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:cfqfi5$unf$1@eclipse.org...
>
>
>>Scott,
>>
>>When a document with cross document references is read in, proxies are
>>created to refer to objects in other documents. Those proxies are
>>resolved on demand as you access them. But when the serializer accesses
>>the instance, it's careful to do so in a way that does not cause any
>>proxies to resolve. So what you are describing is what I would expect...
>>
>>
>>Scott Warren wrote:
>>
>>
>>
>>>Here's a situation where I could use some advice:
>>>
>>>I'm modeling a process flow and my original design of the EMF model had a
>>>single top-level object that was the containment root for all objects in
>>>
>>>
>the
>
>
>>>model. This worked fine. I could load/save without any problems. Now,
>>>
>>>
>I
>
>
>>>have the requirement to make certain parts of the model "shareable". For
>>>example, a user designs a sub-process that he/she wants to use across
>>>multiple model instances. In an effort to accomplish this, I've changed
>>>almost all references to non-containment references so that the component
>>>parts can be written to separate files. Now, rather than one single
>>>
>>>
>file,
>
>
>>>I've got quite a few (30+ in my unit test). So, it seems to save fine.
>>>
>>>
>I
>
>
>>>load the "root" (top-level) document and load appears to work fine until
>>>
>>>
>I
>
>
>>>go to save the model again. If I load the root document and immediately
>>>
>>>
>try
>
>
>>>to save again (like a "Save As"), it appears that the other referenced
>>>objects never get completely loaded. I find that if I write code that
>>>
>>>
>walks
>
>
>>>the object tree after the load, everything gets demand loaded and the
>>>
>>>
>save
>
>
>>>works correctly. Shouldn't the reference to each object by the EMF
>>>serialization code cause the resources to be loaded?
>>>If I'm going about this the wrong way, please let me know.
>>>Thanks,
>>>
>>>Scott
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>


--------------020307020408060003050202
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Scott,<br>
<br>
You haven't actually described anything that sounds like a problem.&nbsp;
What do you see as the problem?&nbsp;&nbsp; <br>
<br>
One way to force all proxies to be resolved is to iterate over
ResourceSet.getAllContents and for each EObject, iterate over
eCrossReferences...<br>
<br>
<br>
<br>
Scott Warren wrote:<br>
<blockquote cite="midcfqk9v$8nj$1@eclipse.org" type="cite">
<pre wrap="">Thanks Ed.

How would you suggest I handle this? I really don't want to walk the entire
model to get everything loaded and I REALLY don't want a half-cooked model
serialized. I've got a separate "manifest" that tells me all the files that
make up the model. Should I just do a resourceSet.getResource(uri, true)
for each file? My first take would be that the LoadOnDemand parameter would
be false, but I get a null back when I try that. Any suggestions?

Thanks,
-Scott

"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:cfqfi5$unf$1@eclipse.org">news:cfqfi5$unf$1@eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Scott,

When a document with cross document references is read in, proxies are
created to refer to objects in other documents. Those proxies are
resolved on demand as you access them. But when the serializer accesses
the instance, it's careful to do so in a way that does not cause any
proxies to resolve. So what you are describing is what I would expect...


Scott Warren wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Here's a situation where I could use some advice:

I'm modeling a process flow and my original design of the EMF model had a
single top-level object that was the containment root for all objects in
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->the
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">model. This worked fine. I could load/save without any problems. Now,
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->I
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">have the requirement to make certain parts of the model "shareable". For
example, a user designs a sub-process that he/she wants to use across
multiple model instances. In an effort to accomplish this, I've changed
almost all references to non-containment references so that the component
parts can be written to separate files. Now, rather than one single
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->file,
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">I've got quite a few (30+ in my unit test). So, it seems to save fine.
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->I
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">load the "root" (top-level) document and load appears to work fine until
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->I
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">go to save the model again. If I load the root document and immediately
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->try
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">to save again (like a "Save As"), it appears that the other referenced
objects never get completely loaded. I find that if I write code that
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->walks
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">the object tree after the load, everything gets demand loaded and the
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->save
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">works correctly. Shouldn't the reference to each object by the EMF
serialization code cause the resources to be loaded?
If I'm going about this the wrong way, please let me know.
Thanks,

Scott




</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------020307020408060003050202--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Cross-Document References Loading/Saving. [message #387547 is a reply to message #387086] Tue, 07 September 2004 20:05 Go to previous messageGo to next message
Phong Nguyen Le is currently offline Phong Nguyen LeFriend
Messages: 1
Registered: July 2009
Junior Member
Is it possible to save a containment reference of a object as a
cross-document reference? In other words, I'd like to save the parent
and child in separate files.

Thanks,
Phong.

Ed Merks wrote:

> Scott,
>
> You haven't actually described anything that sounds like a problem.
> What do you see as the problem?
>
> One way to force all proxies to be resolved is to iterate over
> ResourceSet.getAllContents and for each EObject, iterate over
> eCrossReferences...
>
>
>
> Scott Warren wrote:
>
>>Thanks Ed.
>>
>>How would you suggest I handle this? I really don't want to walk the entire
>>model to get everything loaded and I REALLY don't want a half-cooked model
>>serialized. I've got a separate "manifest" that tells me all the files that
>>make up the model. Should I just do a resourceSet.getResource(uri, true)
>>for each file? My first take would be that the LoadOnDemand parameter would
>>be false, but I get a null back when I try that. Any suggestions?
>>
>>Thanks,
>>-Scott
>>
>>"Ed Merks" <merks@ca.ibm.com> wrote in message
>>news:cfqfi5$unf$1@eclipse.org...
>>
>>
>>>Scott,
>>>
>>>When a document with cross document references is read in, proxies are
>>>created to refer to objects in other documents. Those proxies are
>>>resolved on demand as you access them. But when the serializer accesses
>>>the instance, it's careful to do so in a way that does not cause any
>>>proxies to resolve. So what you are describing is what I would expect...
>>>
>>>
>>>Scott Warren wrote:
>>>
>>>
>>>
>>>>Here's a situation where I could use some advice:
>>>>
>>>>I'm modeling a process flow and my original design of the EMF model had a
>>>>single top-level object that was the containment root for all objects in
>>>>
>>>>
>>the
>>
>>
>>>>model. This worked fine. I could load/save without any problems. Now,
>>>>
>>>>
>>I
>>
>>
>>>>have the requirement to make certain parts of the model "shareable". For
>>>>example, a user designs a sub-process that he/she wants to use across
>>>>multiple model instances. In an effort to accomplish this, I've changed
>>>>almost all references to non-containment references so that the component
>>>>parts can be written to separate files. Now, rather than one single
>>>>
>>>>
>>file,
>>
>>
>>>>I've got quite a few (30+ in my unit test). So, it seems to save fine.
>>>>
>>>>
>>I
>>
>>
>>>>load the "root" (top-level) document and load appears to work fine until
>>>>
>>>>
>>I
>>
>>
>>>>go to save the model again. If I load the root document and immediately
>>>>
>>>>
>>try
>>
>>
>>>>to save again (like a "Save As"), it appears that the other referenced
>>>>objects never get completely loaded. I find that if I write code that
>>>>
>>>>
>>walks
>>
>>
>>>>the object tree after the load, everything gets demand loaded and the
>>>>
>>>>
>>save
>>
>>
>>>>works correctly. Shouldn't the reference to each object by the EMF
>>>>serialization code cause the resources to be loaded?
>>>>If I'm going about this the wrong way, please let me know.
>>>>Thanks,
>>>>
>>>>Scott
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
>
Re: Cross-Document References Loading/Saving. [message #387551 is a reply to message #387547] Wed, 08 September 2004 00:27 Go to previous message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Phong Nguyen Le wrote:
> Is it possible to save a containment reference of a object as a
> cross-document reference? In other words, I'd like to save the parent
> and child in separate files.

Hi Phong,

In order to be able to enforce reasonable containment semantics, EMF
does not allow cross-document containment references. You'll need to
make the reference non-containment if you want it to associate objects
in separate files.

Cheers,
Dave
Previous Topic:Loading a remote URI resource
Next Topic:how do i use ecore.sdo to support other data source
Goto Forum:
  


Current Time: Sat Apr 27 00:07:08 GMT 2024

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

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

Back to the top