-
-
Save jbsarrodie/9bcab008be7f7e75b737e43bfab43048 to your computer and use it in GitHub Desktop.
// 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); | |
} | |
}); | |
}); | |
}); | |
}); | |
}); |
Hi, I've just tried using this and it doesn't show the relationships where there is a decision point. Not sure if I'm missing something here, but I would expect that such relationships would be shown. I copied the decision point, so all required nodes are in the diagram, but no joy.
Good catch, I'll try to reproduce and update my script.
I've just tried and it works as expected: if you have all needed elements (including junctions) then relationships will be added, but if you only have source and target without intermediary junction, then this script will not add them. That might be some additional feature at some point...
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 ?
Works fine now. Thank you!
Hi, I've just tried using this and it doesn't show the relationships where there is a decision point. Not sure if I'm missing something here, but I would expect that such relationships would be shown. I copied the decision point, so all required nodes are in the diagram, but no joy.