Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315500 - Setting owning association of endpoint of an association between different models causes another end to be added to that association
Summary: Setting owning association of endpoint of an association between different mo...
Status: NEW
Alias: None
Product: MDT.UML2
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: UML2 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-02 17:25 EDT by liannes CLA
Modified: 2010-06-16 14:21 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description liannes CLA 2010-06-02 17:25:16 EDT
Build Identifier: 201004131618

I have an Association whose ends are Classes in two different models. Originally, the ends were owned by the Classes. While removing the navigability of one of the ends, I tried to set the owning association of that end to the Association. This caused another end (a duplicate of the end whose owning association I was trying to set) to be added to the Association's member end list.

The problem seems to be in PropertyImpl method basicSetOwningAssociation(association) (which is called from setOwningAssociation(association)) because the 'association' attribute of the end is a proxy that has not been resolved and does not equal 'newOwningAssociation' which is the Association. 

**The setOwningAssociation(association) method should resolve the proxy before basicSetOwningAssociation(association) is called. This way the resolved 'association' attribute will be compared to itself ('newOwningAssociation') and the if-statement shown in step 4 of "Steps to Reproduce" will not be executed.**

The workaround was to call getAssociation() on the end to force the proxy to be resolved before calling setOwningAssociation(association).

Reproducible: Always

Steps to Reproduce:
1. Make an association whose XMI serialization that looks something like:

  <packagedElement xmi:type="uml:Association" xmi:id="_Cc0ZkGUREd-E7rte44yLZQ">
    <memberEnd href="#_CdaPcGUREd-E7rte44yLZQ?M1/F1/C1/c2?"/>
    <memberEnd href="platform:/resource/P2/F2.efx#_Cd27YmUREd-E7rte44yLZQ?M2  /F2/C2/c1?"/>
  </packagedElement>

So that one of the member ends is actually a reference to property of a class in another model.

2. Call setOwningAssociation(association) on the C1 end (the end in same model as the association).
3. In setOwningAssociation(association), basicSetOwningAssociation(association) gets called. However, the 'association' attribute of the end is still a proxy. 
4. So we fall into this if-statement in basicSetOwningAssociation(association):

   if (newOwningAssociation != association) {
	setAssociation(newOwningAssociation);
   }

5. setAssociation(association) is called which adds another end to the association's member end list.
Comment 1 Kenn Hussey CLA 2010-06-02 23:51:32 EDT
The current logic is generated by the UML2 code generator and it's too risky to change it at this stage of the release. :(

Have you tried using the Property#setIsNavigable(boolean) method to change the navigability? I suspect that the problem will not occur if/when this method is used...
Comment 2 liannes CLA 2010-06-16 14:21:12 EDT
Thanks, that method works :)