Skip to content

Instantly share code, notes, and snippets.

@adgerrits
Last active April 10, 2021 19:16
Show Gist options
  • Save adgerrits/32ae02b61c273ddaae0163b402d7c120 to your computer and use it in GitHub Desktop.
Save adgerrits/32ae02b61c273ddaae0163b402d7c120 to your computer and use it in GitHub Desktop.
#jArchi script to compare two views and show mutual missing Archimate elements
/*
* 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');
}
@vnevzorov
Copy link

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?

@adgerrits
Copy link
Author

@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.

@vnevzorov
Copy link

vnevzorov commented Mar 12, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment