use of com.structurizr.view.SystemContextView in project dsl by structurizr.
the class SystemContextViewParser method parse.
SystemContextView parse(DslContext context, Tokens tokens) {
// systemContext <software system identifier> [key] [description] {
Workspace workspace = context.getWorkspace();
SoftwareSystem softwareSystem;
String key = "";
String description = "";
if (tokens.hasMoreThan(DESCRIPTION_INDEX)) {
throw new RuntimeException("Too many tokens, expected: " + GRAMMAR);
}
if (!tokens.includes(SOFTWARE_SYSTEM_IDENTIFIER_INDEX)) {
throw new RuntimeException("Expected: " + GRAMMAR);
}
String softwareSystemIdentifier = tokens.get(SOFTWARE_SYSTEM_IDENTIFIER_INDEX);
Element element = context.getElement(softwareSystemIdentifier);
if (element == null) {
throw new RuntimeException("The software system \"" + softwareSystemIdentifier + "\" does not exist");
}
if (element instanceof SoftwareSystem) {
softwareSystem = (SoftwareSystem) element;
} else {
throw new RuntimeException("The element \"" + softwareSystemIdentifier + "\" is not a software system");
}
if (tokens.includes(KEY_INDEX)) {
key = tokens.get(KEY_INDEX);
} else {
key = removeNonWordCharacters(softwareSystem.getName()) + "-" + VIEW_TYPE;
}
validateViewKey(key);
if (tokens.includes(DESCRIPTION_INDEX)) {
description = tokens.get(DESCRIPTION_INDEX);
}
SystemContextView view = workspace.getViews().createSystemContextView(softwareSystem, key, description);
view.setEnterpriseBoundaryVisible(true);
return view;
}
use of com.structurizr.view.SystemContextView in project dsl by structurizr.
the class StaticViewContentParserTests method test_parseInclude_AddsTheSpecifiedPeopleAndSoftwareSystemsToASystemContextView.
@Test
void test_parseInclude_AddsTheSpecifiedPeopleAndSoftwareSystemsToASystemContextView() {
Person user = model.addPerson("User", "Description");
SoftwareSystem softwareSystem1 = model.addSoftwareSystem("Software System 1", "Description");
SoftwareSystem softwareSystem2 = model.addSoftwareSystem("Software System 2", "Description");
user.uses(softwareSystem1, "Uses");
softwareSystem1.uses(softwareSystem2, "Uses");
SystemContextView view = views.createSystemContextView(softwareSystem1, "key", "Description");
SystemContextViewDslContext context = new SystemContextViewDslContext(view);
context.setWorkspace(workspace);
IdentifiersRegister elements = new IdentifiersRegister();
elements.register("user", user);
elements.register("softwaresystem1", softwareSystem1);
elements.register("softwaresystem2", softwareSystem2);
context.setIdentifierRegister(elements);
parser.parseInclude(context, tokens("include", "user"));
assertEquals(2, view.getElements().size());
assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(user)));
assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(softwareSystem1)));
assertTrue(view.getElements().stream().noneMatch(ev -> ev.getElement().equals(softwareSystem2)));
assertEquals(1, view.getRelationships().size());
}
use of com.structurizr.view.SystemContextView in project dsl by structurizr.
the class StaticViewContentParserTests method test_parseInclude_AddsNearestNeighboursToASystemContextView_WhenTheWildcardIsSpecified.
@Test
void test_parseInclude_AddsNearestNeighboursToASystemContextView_WhenTheWildcardIsSpecified() {
Person user = model.addPerson("User", "Description");
SoftwareSystem softwareSystem1 = model.addSoftwareSystem("Software System 1", "Description");
softwareSystem1.addContainer("Container 1", "Description", "Technology");
SoftwareSystem softwareSystem2 = model.addSoftwareSystem("Software System 2", "Description");
user.uses(softwareSystem1, "Uses");
softwareSystem1.uses(softwareSystem2, "Uses");
SystemContextView view = views.createSystemContextView(softwareSystem1, "key", "Description");
SystemContextViewDslContext context = new SystemContextViewDslContext(view);
context.setWorkspace(workspace);
parser.parseInclude(context, tokens("include", "*"));
assertEquals(3, view.getElements().size());
assertEquals(2, view.getRelationships().size());
}
use of com.structurizr.view.SystemContextView in project dsl by structurizr.
the class StaticViewContentParserTests method test_parseInclude_ThrowsAnException_WhenTryingToAddAContainerToASystemContextView.
@Test
void test_parseInclude_ThrowsAnException_WhenTryingToAddAContainerToASystemContextView() {
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
Container container = softwareSystem.addContainer("Container", "Description", "Technology");
SystemContextView view = views.createSystemContextView(softwareSystem, "key", "Description");
SystemContextViewDslContext context = new SystemContextViewDslContext(view);
context.setWorkspace(workspace);
IdentifiersRegister elements = new IdentifiersRegister();
elements.register("container", container);
context.setIdentifierRegister(elements);
try {
parser.parseInclude(context, tokens("include", "container"));
fail();
} catch (RuntimeException iae) {
assertEquals("The element \"container\" can not be added to this type of view", iae.getMessage());
}
}
use of com.structurizr.view.SystemContextView in project agile-architecture-documentation-system by Riduidel.
the class ViewsGenerator method endVisit.
@Override
public void endVisit(Workspace workspace, OutputBuilder builder) {
ViewSet views = workspace.getViews();
SoftwareSystem agileArchitecture = workspace.getModel().getSoftwareSystemWithName(Architecture.AGILE_ARCHITECTURE_DOCUMENTATION);
SystemContextView contextView = views.createSystemContextView(agileArchitecture, "SystemContext", "Illustration of agile-architecture-documentation usage");
contextView.addAllSoftwareSystems();
contextView.addAllPeople();
ContainerView agileArchitectureContainers = views.createContainerView(agileArchitecture, "agile.architecture.containers", "Agile architecture containers");
agileArchitectureContainers.addAllContainersAndInfluencers();
ComponentView agileArchitectureBaseComponents = views.createComponentView(agileArchitecture.getContainerWithName(Architecture.CONTAINERS_BASE), "agile.architecture.base.components", "Agile architecture base components view");
agileArchitectureBaseComponents.addAllComponents();
// Styles styles = views.getConfiguration().getStyles();
// styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff");
// styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person);
}
Aggregations