Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Opposite reference unset after resolve
Opposite reference unset after resolve [message #644144] Thu, 09 December 2010 16:49 Go to next message
Julien Bigot is currently offline Julien BigotFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I'm loading a model instance from files, partially XMI, partially using a DSL with xtext.

In this model, I have two classes (A and B) referencing each other though a bidirectional relation (with EOpposite reference set) through ref r1 & r2.

A.r1<---->r2.B

When parsing the model, an object "a" of the class "A" is read from one resource and an object "b" of class "B" from another resource.
In this resource, b.r1 is set to reference a. At this time, this is however only a proxy.

Res1:
A: a (r1=null)

Res2
B: b (r2=aProxy)
AProxy: aProxy (r1=b)

Then proxy are resolved with a call to EcoreUtil.resolveAll and the proxy "aProxy" is replaced by the actual object "a". However this processes doesn't ensure the opposite relation.

Res1:
A: a (r1=null)

Res2:
B: b (r2=a)

Is there a way I can ensure the opposite relationship ?
Tanks in advance.

Regard,
Julien
Re: Opposite reference unset after resolve [message #644165 is a reply to message #644144] Thu, 09 December 2010 17:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Julien,

Comments below.

Julien Bigot wrote:
> Hi,
>
> I'm loading a model instance from files, partially XMI, partially
> using a DSL with xtext.
>
> In this model, I have two classes (A and B) referencing each other
> though a bidirectional relation (with EOpposite reference set) through
> ref r1 & r2.
>
> A.r1<---->r2.B
>
> When parsing the model, an object "a" of the class "A" is read from
> one resource and an object "b" of class "B" from another resource.
> In this resource, b.r1 is set to reference a. At this time, this is
> however only a proxy.
There must be proxies on both ends. Resolving a proxy has no effect on
the opposite; it's assumed to hold a proxy that resolves independently.
>
> Res1:
> A: a (r1=null)
>
> Res2
> B: b (r2=aProxy)
> AProxy: aProxy (r1=b)
>
> Then proxy are resolved with a call to EcoreUtil.resolveAll and the
> proxy "aProxy" is replaced by the actual object "a". However this
> processes doesn't ensure the opposite relation.
Indeed. That's why we constrain opposites that are proxy resolving to
both be non-transient. I.e., both ends must serialize proxies.
>
> Res1:
> A: a (r1=null)
>
> Res2:
> B: b (r2=a)
>
> Is there a way I can ensure the opposite relationship ?
Ensure that the relationship is explicit in both resources. If you
can't do that, you really shouldn't have bidirectional references. You
might argue, but I really want them. In fact, many a time folks have
asked "why doesn't EClass.eSuperTypes have an opposite?" "It would be
so useful to know all derived classes. Indeed it would, but given a
class, it's impossible to know all derived classes, because a class
doesn't store references to all derived classes and it wouldn't make for
very predictable behavior if the set of derived classes just grew
whenever a new class shows up and resolves its eSuperType proxy...
> Tanks in advance.
>
> Regard,
> Julien


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Opposite reference unset after resolve [message #644288 is a reply to message #644165] Fri, 10 December 2010 12:10 Go to previous message
Julien Bigot is currently offline Julien BigotFriend
Messages: 26
Registered: July 2009
Junior Member
Thank you very much for your very helpful reply.

Regards,
Julien
Previous Topic:Dynamic Feature Delegation - wrapping features that have multiplicity (How?)
Next Topic:accessing a genmodel programmatically
Goto Forum:
  


Current Time: Sat Apr 27 03:56:38 GMT 2024

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

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

Back to the top