Last active
April 10, 2021 19:16
-
-
Save adgerrits/32ae02b61c273ddaae0163b402d7c120 to your computer and use it in GitHub Desktop.
#jArchi script to compare two views and show mutual missing Archimate elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Comparison of two views to see which Archimate elements are missing | |
* 2018, Ad Gerrits | |
*/ | |
console.clear(); | |
function checkViews (v1, v2) { | |
var v2elements = []; | |
$(v2).find('element').each(function (e) { | |
v2elements.push(e.concept.id); | |
}) | |
var lastconceptid = -1; | |
console.log('Present in view "' + v1.name + '" but missing in view "' + v2.name + '":'); | |
$(v1).find('element').each(function (e) { | |
if (e.concept.id !== lastconceptid) { | |
if (v2elements.indexOf(e.concept.id) === -1) { | |
console.log(e.name + ' (' + e.type + ')'); | |
} | |
lastconceptid = e.concept.id; | |
} | |
}) | |
} | |
if (selection.size() === 2 && ($(selection.get(0)).is('archimate-diagram-model') && $(selection.get(1)).is('archimate-diagram-model'))) { | |
var v1 = selection.get(0); | |
var v2 = selection.get(1); | |
console.log('Compare views: "' + v1.name + '" and "' + v2.name + '"\n'); | |
checkViews(v1, v2); | |
console.log('\n'); | |
checkViews(v2, v1); | |
} else { | |
window.alert('Select 2 views to compare'); | |
} |
A stupid question, though... How one can select two views in Archi tool? I have tried doing that in the Model Tree view, but it always selects all views between those I need. Any advice?
@vnevzorov: After the first selected view, press the Ctrl-key and select the second view. Just like when you want to select multiple elements in the model tree at other times.
Thank you! Much appreciated.
…On Thu, Mar 12, 2020 at 4:35 AM Ad Gerrits ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
@vnevzorov <https://github.com/vnevzorov>: After the first selected view,
press the Ctrl-key and select the second view. Just like when you want to
select multiple elements in the model tree at other times.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/32ae02b61c273ddaae0163b402d7c120#gistcomment-3209298>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQXHU32NWGTNSFDAKETD23RHCUH5ANCNFSM4KUDR53A>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good point !
So we have to create a collection of elements from a collection of visual objects:
In fact what we need is a map operator, but this is not implemented (yet) on collections (which are not JS arrays even if very similar).