Copy/paste between projects may break cross-references
Steps to reproduce (see attached model!):
- Create source model in a new project Source
- Create Component Architecture CA with one Component C
- Create Platform Architecture PA with one Execution Unit E
- Create Deployment D that maps C to E
- Create an empty Target project
- Save all projects
- Perform non-atomic copy operation
- Copy CA from Source to Target
- Copy PA from Source to Target
- Copy D from from Source to Target
- Observe (e.g., by opening Target model in a text editor), that the
ComponentAllocation
in the deployment contained in Target erroneously references C and E contained in Source (Source.af3_23#10
in below example!)
<rootElements xsi:type="org-fortiss-af3-deployment:Deployment" xmi:id="24" id="24" name="Deployment">
<componentArchitectureReference/>
<platformArchitectureReference/>
<componentAllocations xmi:id="25" id="25">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/>
<component href="Source.af3_23#10"/>
<executionUnit href="Source.af3_23#20"/>
</componentAllocations>
Analysis:
- If all three artifacts (CA, PA and Deployment) are copied atomically at once, the resulting Deployment in Target is valid (i.e., it does not reference an model element in Source
- The current logic (presumably the deployment’s compositors) prevents to copy the deployment to Target in case it does not contain both a Component Architecture and Platform Architecture. However, it does not check if the the CA and/or the PA contained in the target match the Deployment to be copied (which would be very difficult if not impossible to implement)
- #877 first introduced cross-project copy-and-paste
Proposed fix:
- If a top-level element to be copied contains references (here: Deployment) to model elements contained in other top-level elements (here: CA, PA), enable the copy operation only if the top-level elements containing all referenced model elements are copied in the same copy operation
Work-around:
- Copy all top-level elements that you indent to copy from one model to another in one operation. This will ensure that cross-references in the copy point to model elements in the copy (as expected).
(from redmine: issue id 2845, created on 2017-02-17, closed on 2018-06-12)
- Relations:
- relates #2981 (closed)
- relates #2874 (closed)
- Uploads:
- Source.af3_23 Source model from "steps-to-reproduce"