Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with opposites
Problem with opposites [message #629274] Mon, 27 September 2010 16:10 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I have a model with a Role, Person and Allocation objects. Role and
Person both have lists of Allocations and Allocation refers to the
others, and pairs of these references are opposites: Role.allocations is
the opposite of Allocation.role and Person.allocations is the opposite
of Allocation.person.

In my grammar, I have rules for creating Roles, Persons and Allocation,
where only the latter includes grammar fragments for referring to the
others: as follows (slightly simplified):

Role: roleName=EString 'providing' workload=EInt 'units';
Person: 'Person' name=EString 'provides' workload=EInt 'units';
Allocation: person=[Person|EString] 'fills' role=[Role|EString] 'role';

In my test file, I first have all the Roles and Persons. Then the
Allocations follows:

"Hallvard Trætteberg" fills "tdt4250 course responsible" role
"Hallvard Trætteberg" fills "tdt4250 lecturer" role
"Babak Farshchian" fills "tdt4250 lecturer" role

However, I get the following error marker for the first line, and
similiar for each Person/Allocation and Role/Allocation pairt (six in
total):

The opposite features 'person' of AllocationImpl@498b4d
{platform:/resource/rptest/model/h10.rpxt#//@allocations.0}' and
'allocations' of PersonImpl@78bb58
{platform:/resource/rptest/model/h10.rpxt#Hallvard Trætteberg}' do not
refer to each other

I interpret this to mean that the objects that should refer to each
other have inconsistent lists/values. How can this happen?

Hallvard
Re: Problem with opposites [message #629292 is a reply to message #629274] Mon, 27 September 2010 16:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This should not happen but very easily does during development.

Are you sure that you validated your meta-model?

Are you sure you re-genmodelled after changing your meta-model?

Are you sure that you regenerated the editor after re-genmodeling?

Regards

Ed Willink

On 27/09/2010 17:10, Hallvard Trætteberg wrote:
> Hi,
>
> I have a model with a Role, Person and Allocation objects. Role and
> Person both have lists of Allocations and Allocation refers to the
> others, and pairs of these references are opposites: Role.allocations is
> the opposite of Allocation.role and Person.allocations is the opposite
> of Allocation.person.
>
> In my grammar, I have rules for creating Roles, Persons and Allocation,
> where only the latter includes grammar fragments for referring to the
> others: as follows (slightly simplified):
>
> Role: roleName=EString 'providing' workload=EInt 'units';
> Person: 'Person' name=EString 'provides' workload=EInt 'units';
> Allocation: person=[Person|EString] 'fills' role=[Role|EString] 'role';
>
> In my test file, I first have all the Roles and Persons. Then the
> Allocations follows:
>
> "Hallvard Trætteberg" fills "tdt4250 course responsible" role
> "Hallvard Trætteberg" fills "tdt4250 lecturer" role
> "Babak Farshchian" fills "tdt4250 lecturer" role
>
> However, I get the following error marker for the first line, and
> similiar for each Person/Allocation and Role/Allocation pairt (six in
> total):
>
> The opposite features 'person' of AllocationImpl@498b4d
> {platform:/resource/rptest/model/h10.rpxt#//@allocations.0}' and
> 'allocations' of PersonImpl@78bb58
> {platform:/resource/rptest/model/h10.rpxt#Hallvard Trætteberg}' do not
> refer to each other
>
> I interpret this to mean that the objects that should refer to each
> other have inconsistent lists/values. How can this happen?
>
> Hallvard
Re: Problem with opposites [message #629313 is a reply to message #629292] Mon, 27 September 2010 18:45 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 27.09.10 18.38, Ed Willink wrote:
>
> This should not happen but very easily does during development.

I haven't seen this before (I actually thought it shouldn't be
possible). You mean it is due to inconsistencies in the code generated?

The problem marker is EMF's own validator of the data, isn't it?

> Are you sure that you validated your meta-model?
> Are you sure you re-genmodelled after changing your meta-model?

Yes. I took another round before posting.

> Are you sure that you regenerated the editor after re-genmodeling?

Yes. This particular part of the model hasn't changed after I created
the xtext project.

I've tried to trace the accessors (setPerson and getAllocation). The
Person's allocations seems to get set correctly during linking, but when
the validator is executed the Person's allocations list have been cleared.

Hallvard
Re: Problem with opposites [message #629323 is a reply to message #629313] Mon, 27 September 2010 19:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Hallvard

On 27/09/2010 19:45, Hallvard Trætteberg wrote:
> On 27.09.10 18.38, Ed Willink wrote:
>>
>> This should not happen but very easily does during development.
>
> I haven't seen this before (I actually thought it shouldn't be
> possible). You mean it is due to inconsistencies in the code generated?

It is possible to have three inconsistent views of the meta-model
- xx.ecore
- xx*.java
- xx.xmi (the compiled grammar)
and temperamental consequent behaviour

> The problem marker is EMF's own validator of the data, isn't it?
>
>> Are you sure that you validated your meta-model?
> > Are you sure you re-genmodelled after changing your meta-model?
>
> Yes. I took another round before posting.
>
>> Are you sure that you regenerated the editor after re-genmodeling?
>
> Yes. This particular part of the model hasn't changed after I created
> the xtext project.
>
> I've tried to trace the accessors (setPerson and getAllocation). The
> Person's allocations seems to get set correctly during linking, but when
> the validator is executed the Person's allocations list have been cleared.

Mysteriously empty lists can easily occur with Ecore containment lists
since putting an element in one list automatically removes it from another.

Regards

Ed Willink
Re: Problem with opposites (and proxies) [message #629353 is a reply to message #629274] Mon, 27 September 2010 22:05 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
I've tried tracing what happens, and here's what I see (in the debugger):
1) Object creation phase: Person names are set.
2) (Partly) as expected: The Allocation objects are linked to Person
proxies, i.e. different ones than in phase 1. E.g. these do not have
names. After the linking, these Person proxies correctly refer back to
the Allocation objects (the opposite invariant).
3) During the validation phase the Person proxies are resolved, hence,
the Allocation objects are "backpatched" to refer to the correct Person
objects. However, the references from the Person proxies back to
Allocation objects, that are due to the opposite invariant, are not set
as part of resolving the proxy. Hence, the proxy still refers to the
Allocation object, and the real ones do not.

How could this have happened? BTW, I've removed AllocationImpl and
PersonImpl, reloaded the genmodel and regenerated the code.

Hallvard

On 27.09.10 18.10, Hallvard Trætteberg wrote:
>
> I have a model with a Role, Person and Allocation objects. Role and
> Person both have lists of Allocations and Allocation refers to the
> others, and pairs of these references are opposites: Role.allocations is
> the opposite of Allocation.role and Person.allocations is the opposite
> of Allocation.person.
>
> In my grammar, I have rules for creating Roles, Persons and Allocation,
> where only the latter includes grammar fragments for referring to the
> others: as follows (slightly simplified):
>
> Role: roleName=EString 'providing' workload=EInt 'units';
> Person: 'Person' name=EString 'provides' workload=EInt 'units';
> Allocation: person=[Person|EString] 'fills' role=[Role|EString] 'role';
>
> In my test file, I first have all the Roles and Persons. Then the
> Allocations follows:
>
> "Hallvard Trætteberg" fills "tdt4250 course responsible" role
> "Hallvard Trætteberg" fills "tdt4250 lecturer" role
> "Babak Farshchian" fills "tdt4250 lecturer" role
>
> However, I get the following error marker for the first line, and
> similiar for each Person/Allocation and Role/Allocation pairt (six in
> total):
>
> The opposite features 'person' of AllocationImpl@498b4d
> {platform:/resource/rptest/model/h10.rpxt#//@allocations.0}' and
> 'allocations' of PersonImpl@78bb58
> {platform:/resource/rptest/model/h10.rpxt#Hallvard Trætteberg}' do not
> refer to each other
>
> I interpret this to mean that the objects that should refer to each
> other have inconsistent lists/values. How can this happen?
>
> Hallvard
Re: Problem with opposites (and proxies) [message #629356 is a reply to message #629353] Mon, 27 September 2010 22:35 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
I should have googled first:
https://bugs.eclipse.org/bugs/show_bug.cgi?format=multiple&a mp;id=282486
Sorry for the noise.

Setting resolve proxies to false "solved" the problem. Will this be
fixed to work with proxies in the future?

Hallvard

On 28.09.10 00.05, Hallvard Trætteberg wrote:
> I've tried tracing what happens, and here's what I see (in the debugger):
> 1) Object creation phase: Person names are set.
> 2) (Partly) as expected: The Allocation objects are linked to Person
> proxies, i.e. different ones than in phase 1. E.g. these do not have
> names. After the linking, these Person proxies correctly refer back to
> the Allocation objects (the opposite invariant).
> 3) During the validation phase the Person proxies are resolved, hence,
> the Allocation objects are "backpatched" to refer to the correct Person
> objects. However, the references from the Person proxies back to
> Allocation objects, that are due to the opposite invariant, are not set
> as part of resolving the proxy. Hence, the proxy still refers to the
> Allocation object, and the real ones do not.
>
> How could this have happened? BTW, I've removed AllocationImpl and
> PersonImpl, reloaded the genmodel and regenerated the code.
>
> Hallvard
>
> On 27.09.10 18.10, Hallvard Trætteberg wrote:
>>
>> I have a model with a Role, Person and Allocation objects. Role and
>> Person both have lists of Allocations and Allocation refers to the
>> others, and pairs of these references are opposites: Role.allocations is
>> the opposite of Allocation.role and Person.allocations is the opposite
>> of Allocation.person.
>>
>> In my grammar, I have rules for creating Roles, Persons and Allocation,
>> where only the latter includes grammar fragments for referring to the
>> others: as follows (slightly simplified):
>>
>> Role: roleName=EString 'providing' workload=EInt 'units';
>> Person: 'Person' name=EString 'provides' workload=EInt 'units';
>> Allocation: person=[Person|EString] 'fills' role=[Role|EString] 'role';
>>
>> In my test file, I first have all the Roles and Persons. Then the
>> Allocations follows:
>>
>> "Hallvard Trætteberg" fills "tdt4250 course responsible" role
>> "Hallvard Trætteberg" fills "tdt4250 lecturer" role
>> "Babak Farshchian" fills "tdt4250 lecturer" role
>>
>> However, I get the following error marker for the first line, and
>> similiar for each Person/Allocation and Role/Allocation pairt (six in
>> total):
>>
>> The opposite features 'person' of AllocationImpl@498b4d
>> {platform:/resource/rptest/model/h10.rpxt#//@allocations.0}' and
>> 'allocations' of PersonImpl@78bb58
>> {platform:/resource/rptest/model/h10.rpxt#Hallvard Trætteberg}' do not
>> refer to each other
>>
>> I interpret this to mean that the objects that should refer to each
>> other have inconsistent lists/values. How can this happen?
>>
>> Hallvard
>
Previous Topic:Reduce number of affected Resources
Next Topic:Xtext 1.0 compatible with Xtext 1.0.1?
Goto Forum:
  


Current Time: Tue Apr 16 18:34:48 GMT 2024

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

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

Back to the top