[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Question re href and @children

Alan,

Comments below.

Alan wrote:
Hello,

I am having a strange issue with hrefs.
I have 2 resources.
In the first I have a number of Object As which contains a collection of Object Bs (containment = true)
(I also have something things above A but we'll focus on A and B for example)
In the second I have a reference to a collection of Object Bs (containment = false)


The href for one of the Object Bs in the second resource reads like this:
href="resource1.config#//@children.2/@children.3/@myobjectBs.0

The issue arises when I delete an Object A.
In the first resource it is now found at @children.2/@children.2
instead of at @children.2/@children.3
Yes, that's expected.
This only occurs if I delete an Object A that was not the last created one.
In other words it seems as if that format is like an index.
Yes, exactly.
So when I delete one Object A any ObjectAs created after it have their "indexes" updated.
Indeed the format it fragile with respect to reordering.
However the second resource does not update to reflect this.
It makes a difference whether the proxy is resolved or not. If it's not resolved yet, it will end up keeping the same proxy URI and will point to a different object.
So when I try to restart the application the collection of ObjectBs from resource 2 does not find an object.

I confirmed that this was what was happening by changing the reference manually in the xml file of the second resource
So If I change index to reflect resource 1 it works fine.


I tried making sure that resource1 was saved first and then resource2 but it made no difference.
Whether proxies have been resolved makes a difference. EcoreUtil.resolveAll can be used to force all proxies to be resolve.
Has anyone any ideas as to why this is happening an how I might fix it ?
If possible take advantage of EReference.eKeys. I.e., identify an attribute or combination of attributes in A that make it unique with respect to the containment reference. The serialization will then look like @children[key='value'] and will be resilient with respect to reordering.
thanks,
Alan.