Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » API way to determine the subset(s) of a given EReference
API way to determine the subset(s) of a given EReference [message #989493] Thu, 06 December 2012 13:32 Go to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Hi,

I am working on the UML-specific support for model comparison through EMF Compare. I am running into a lot of issues for the merging of detected differences because of values that end up duplicated.

For example, Association#memberEnds is a superset of Association#ownedEnds which in turn is a superset of Association#navigableOwnedEnds.

If a user adds a value to "ownedEnds", it will automatically be added to "memberEnds" but not to "navigableOwnedEnds". EMF Compare will detect two differences :
- 'value has been added to ownedEnds' and
- 'value has been added to memberEnds'.

We need to ignore the diff on memberEnds, but not the one on ownedEnds (otherwise, and since these are not simple equivalences, the value would be added twice to memberEnds, and once in ownedEnds).

Likewise, if we add a value to navigableOwnedEnds, we must still ignore the diff on memberEnds, but this time and for that value we also need to ignore the diff on ownedEnds, lest we end up post-merge with three identical values in memberEnds, two in ownedEnds and one in navigableOwnedEnds.

Note that we are using EList#addUnique during the merge, which is probably why we observe this behavior. It did allow us to understand that we were doing too much work to merge differences. I'd rather not resort to switching back to EList#add though.

What I would like to know is : when I have a given EReference (for example, UMLPackage.Literals.ASSOCIATION__MEMBER_END), do I have any way to determine what reference(s) are its subsets, if any?

For now, I had to resort to retrieving the reference's value through eGet, casting the reference's value to "SubsetSupersetEObjectEList" and reflexively access its "subsetFeatureIDs" protected field. This is really not a good thing to do, even less since what this field holds are feature ids, which I then need to "sanitize" to find the proper EReference(s).

Laurent Goubet
Obeo
Re: API way to determine the subset(s) of a given EReference [message #989521 is a reply to message #989493] Thu, 06 December 2012 15:28 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. Damus
Messages: 789
Registered: July 2009
Senior Member
Hi, Laurent,

Superset EStructuralFeatures have an annotation with source "subsets"
that references the subset EStructuralFeatures.

BTW, I'm not sure that you can ignore differences in the memberEnd
reference. It's a mutable superset, not a derived union. Properties
can be added to an association's memberEnd list without adding them to
any subset such as ownedEnd.

HTH,

Christian


On 2012-12-06 13:32:57 +0000, Laurent Goubet said:

> Hi,
>
> I am working on the UML-specific support for model comparison through
> EMF Compare. I am running into a lot of issues for the merging of
> detected differences because of values that end up duplicated.
>
> For example, Association#memberEnds is a superset of
> Association#ownedEnds which in turn is a superset of
> Association#navigableOwnedEnds.
>
> If a user adds a value to "ownedEnds", it will automatically be added
> to "memberEnds" but not to "navigableOwnedEnds". EMF Compare will
> detect two differences :
> - 'value has been added to ownedEnds' and
> - 'value has been added to memberEnds'.
>
> We need to ignore the diff on memberEnds, but not the one on ownedEnds
> (otherwise, and since these are not simple equivalences, the value
> would be added twice to memberEnds, and once in ownedEnds).
>
> Likewise, if we add a value to navigableOwnedEnds, we must still ignore
> the diff on memberEnds, but this time and for that value we also need
> to ignore the diff on ownedEnds, lest we end up post-merge with three
> identical values in memberEnds, two in ownedEnds and one in
> navigableOwnedEnds.
>
> Note that we are using EList#addUnique during the merge, which is
> probably why we observe this behavior. It did allow us to understand
> that we were doing too much work to merge differences. I'd rather not
> resort to switching back to EList#add though.
>
> What I would like to know is : when I have a given EReference (for
> example, UMLPackage.Literals.ASSOCIATION__MEMBER_END), do I have any
> way to determine what reference(s) are its subsets, if any?
>
> For now, I had to resort to retrieving the reference's value through
> eGet, casting the reference's value to "SubsetSupersetEObjectEList" and
> reflexively access its "subsetFeatureIDs" protected field. This is
> really not a good thing to do, even less since what this field holds
> are feature ids, which I then need to "sanitize" to find the proper
> EReference(s).
>
> Laurent Goubet
> Obeo
Re: API way to determine the subset(s) of a given EReference [message #989953 is a reply to message #989521] Mon, 10 December 2012 08:53 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Hi,

Christian W. Damus wrote on Thu, 06 December 2012 10:28

Superset EStructuralFeatures have an annotation with source "subsets"
that references the subset EStructuralFeatures.


That annotation did not seem to hold the information I was hoping for, as it seems like the only problematic relations are those that are implemented with an instance of the SubsetSupersetEObjectEList. I think I'll have to look into the generation rules :s.

Thanks for the answer though : I asked before searching in more details and don't think I had the right question (or rather, I don't think there's an easy answer to my "compare & merge" problems for these references).

Christian W. Damus wrote on Thu, 06 December 2012 10:28

BTW, I'm not sure that you can ignore differences in the memberEnd
reference. It's a mutable superset, not a derived union. Properties
can be added to an association's memberEnd list without adding them to
any subset such as ownedEnd.


Whether it has been updated through one of its subset or by its opposites, we'll have another diff for memberEnds (when we set the association reference of a property for example). In such a case, we define both differences to be "equivalent" : whether I merge one or the other does not matter, the end result will be the same. Thus I can safely ignore the other once I've merged one of the two.

This is not the case for the couple "p1 added to memberEnds" (first) <-> "p1 added to ownedEnds" (second) though : If I merge the second, it will indeed properly merge the first. However, If I merge the first, it will not add "p1" to ownedEnds along with it, so that's not a proper equivalence. (Let's not talk about the triplet "p1 added to memberEnds" <-> "p1 added to ownedEnds" <-> "p1 added to navigableOwnedEnds" where the only "real" difference is the addition in navigableOwnedEnds.)

The end result is the same though : whatever the "real" change, a diff on memberEnds can be safely ignored as it will be merged along with another... as long as we detect another related diff (or I've missed a problematic use case).

Laurent Goubet
Obeo
Previous Topic:Using UML2 Java Code in Eclipse
Next Topic:State Machine - UML Editor & Programmatic
Goto Forum:
  


Current Time: Fri Sep 19 07:54:44 GMT 2014

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

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