Closed MTomBosch closed 2 years ago
Probably the easiest way to do that is to use the scripting support in conjunction with the removeRelationshipsNotConnectedToElement method.
Are the scripts also supported when using the cli and the export command?
It worked, thank you. But I first thought I have to add the groovy code within the view block that I want to change. But there nothing happened. Only after adding it to the end of the dsl file it worked.
Nevertheless I personally feel that this feature would be really nice to have out of the box and not with a custom script, using the above mentioned but not supported expression:
exclude relationship!=systemInContext->*
exclude relationship!=*->systemInContext
In words: Remove all relations that are not linked to the system in context.
Thanks, that's great. You can also do something like this:
workspace {
model {
a = softwareSystem "A"
b = softwareSystem "B"
c = softwareSystem "C"
a -> b
a -> c
b -> c
}
views {
systemContext b {
include *
exclude *->*
include *->b
include b->*
autolayout
}
}
}
Does it mean that the includes and excludes are executed in the order of their appearance in the view block? And what remains after executing the includes and excludes will be shown.
If that is the case it would be a good to mention this include/exclude behaviour explicitly in the user doc. Because I thought that the includes and excludes are kind of aggregated (independent of the sequence in the block) and then the excludes are removed from the includes.
To share the script that I used:
# Remove all relations not linked to system in context for all system context views!
# Otherwise the diagram is too much cluttered
# Custom script based fix for https://github.com/structurizr/dsl/issues/97
!script groovy {
workspace.views.systemContextViews.each{ v ->
element = v.getSoftwareSystem();
v.removeRelationshipsNotConnectedToElement(element);
};
}
Does it mean that the includes and excludes are executed in the order of their appearance in the view block?
Yes, all lines are executed in order; see https://github.com/structurizr/dsl/blob/master/docs/language-reference.md#general-rules
Ok. That short sentence is proof ;)
Lines are processed in order.
Maybe adding a hint especially for the include/exclude scenario would help.
Anyway thank you, will close the issue now.
I am trying to get a system context diagram where only the relations are visible that are linked with the system in context. Otherwise the diagram that I get is so cluttered with relations that it can no more read easily.
I tried different approach but it did not work out. E.g. I took the big bank example and adapted it to have a relation between the email and mainframe system. Then I played around with the include and exclude expressions but it did not work out. My expection would be to be able to ignore the relation between the mainframe and email system and between the email and the person.
I finally tried also such an expression: include relationship!=systemInContext->* but the dsl does not understand that sort of expression unfortunately.
For reference here the complete big bank dsl that I adapted: