Phillipus/archi — pull request #70 by mbd (2014-04-24 11:07:15+00:00)
Title: RFC: Merge feature

This is *not* a pull request at this moment.

This is more of a "please comment/review". (If reception in genereal is favorable, I will clean the code up, create docs, suitable tests, (icons?) etc, for a "proper" pull request.). It is related to feature request https://github.com/Phillipus/archi/issues/60

What this branch/request does: It puts a new version of "paste" on the diagram contexts menus, called "merge". Merge works like this: for each element in the selection, it tries to figure out if the associated archimate element is already present in the diagram beeing pasted into. If it is, this will be used as a reference instead of pasting a new element. The usecase is "updates" and the like, where a diagram (view) for e.g. a host gets updated with e.g. a new infrastructure service or the like, and you want this change to be reflected in other views where the diagram is used. Another usecase is when you want to combine the elements from two or more views into one.

For my use, it works quite well, but there is some loose ends regarding the merging of duplacates, especially duplicate containers and/or groups. This is mostly some choice about what makes most sense: Currently duplicate elements in the selection are beeing silently merged, whereas relations between duplicate elements in the target gets "exploded" (all permuations).

There is some discussion of the approach on this wiki page: https://github.com/Phillipus/archi/wiki/Selecting,-Copying,-Duplicating-and-Merging .

The code is mostly additions to CopySnapshot, and the needed "glue" to get a new Merge entry. Because I needed to understand the code, there is quite a lot of unittests added to needsCopiedArchimateElements - which I ended up not using, btw - which may go in a final pull request. I also added a lot of JSDOC comments - I obviously hope they are relevant/useful, although I know I do tend to overcomment code.