Last active
September 20, 2024 04:11
-
-
Save jbsarrodie/9bcab008be7f7e75b737e43bfab43048 to your computer and use it in GitHub Desktop.
#jArchi script to add all possible relationships to a view
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
// Find DiagramComponents for a given element in a given view | |
var getDiagramComponents = function(v, e) { | |
return $(v).find("concept").filter(function(o) { | |
return o.concept.id == e.id; | |
}); | |
} | |
// Checks if a view contains a visual connection from src and tgt visual objects | |
var contains = function(r, src, tgt) { | |
found = false; | |
$(r).objectRefs().each(function(o) { | |
if (o.source.id == src.id && o.target.id == tgt.id) { | |
found = true; | |
} | |
}); | |
return found;; | |
} | |
// Iterate through selected views to add relationships which exist in the model but not in the view | |
$(selection).filter("archimate-diagram-model").each(function(v) { | |
$(v).find("element").each(function(e) { | |
$(e.concept).rels().each(function(r) { | |
getDiagramComponents(v,r.source).each(function(src) { | |
getDiagramComponents(v,r.target).each(function(tgt) { | |
if (! contains(r, src, tgt)) { | |
v.add(r, src, tgt); | |
} | |
}); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
This can happen if you have some notes or visual groups (ie. non ArchiMate concepts). I did fix this some time ago but have never updated this gist, this is now done (one of the first call to "find" now filter on concepts).
Does this fix your issue ?