Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] resolve of a reference
[EMF] resolve of a reference [message #705154] Fri, 29 July 2011 13:59 Go to next message
Rimvydas is currently offline RimvydasFriend
Messages: 47
Registered: July 2009
Member
Hi,

I have model:

EClass Folder
EReference subfolders (type: Folder, containment = true, eOpposite = parent)
EReference parent (type: Folder, eOpposite = subfolders)

Object folderA of type Folder is added into XMIResource resourceA
contents. Object folderB of type Folder is added into XMIResource
resourceB contents. folderA.eContents().contains(folderB).
Both resources are saved.

Case 1:

resourceB.unload();
remove parent reference from the resource file (file modification)
folderA.eContents().get(0).eContainer(); // returns folderA

Case 2:

resourceA.unload();
remove subfolders reference from the resource file (file modification)
folderB.eContainer().eContents().contains(folderB) - returns false


Question: Why resolving of contents fixes the container but resolving of
container does not add the object into contents of container ?

Thanks in advance for an answer.

Regards,
Rimvydas Vaidelis
Re: [EMF] resolve of a reference [message #705224 is a reply to message #705154] Fri, 29 July 2011 15:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33217
Registered: July 2009
Senior Member
Comments below.

On 29/07/2011 6:59 AM, Rimvydas Vaidelis wrote:
> Hi,
>
> I have model:
>
> EClass Folder
> EReference subfolders (type: Folder, containment = true, eOpposite =
> parent)
> EReference parent (type: Folder, eOpposite = subfolders)
>
> Object folderA of type Folder is added into XMIResource resourceA
> contents. Object folderB of type Folder is added into XMIResource
> resourceB contents. folderA.eContents().contains(folderB).
So I assume you have proxy resolving containment here. Not sure if
parent is transient or not...
> Both resources are saved.
>
> Case 1:
>
> resourceB.unload();
> remove parent reference from the resource file (file modification)
> folderA.eContents().get(0).eContainer(); // returns folderA
>
> Case 2:
>
> resourceA.unload();
> remove subfolders reference from the resource file (file modification)
> folderB.eContainer().eContents().contains(folderB) - returns false
>
>
> Question: Why resolving of contents fixes the container but resolving
> of container does not add the object into contents of container ?
Because container features are not necessarily (and often aren't)
serialized. For other types of bidirectional reference, both ends need
to be serialized (if they can span documents), and proxy resolution only
affects one side. We didn't impose that restriction on containment
references to make them a little more flexible, which is possible in
this case because the reference must refer to the root object of a resource.
>
> Thanks in advance for an answer.
>
> Regards,
> Rimvydas Vaidelis
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Schema location attribute in serialized model causes validation problems
Next Topic:how to make AND operation between two conditions in EmfFacet
Goto Forum:
  


Current Time: Mon Sep 23 23:49:12 GMT 2024

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

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

Back to the top