Search in sources :

Example 1 with SystemContextView

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;
}
Also used : SystemContextView(com.structurizr.view.SystemContextView) Element(com.structurizr.model.Element) SoftwareSystem(com.structurizr.model.SoftwareSystem) Workspace(com.structurizr.Workspace)

Example 2 with SystemContextView

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());
}
Also used : com.structurizr.model(com.structurizr.model) Test(org.junit.jupiter.api.Test) ComponentView(com.structurizr.view.ComponentView) Assertions(org.junit.jupiter.api.Assertions) SystemContextView(com.structurizr.view.SystemContextView) SystemLandscapeView(com.structurizr.view.SystemLandscapeView) SystemContextView(com.structurizr.view.SystemContextView) Test(org.junit.jupiter.api.Test)

Example 3 with SystemContextView

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());
}
Also used : SystemContextView(com.structurizr.view.SystemContextView) Test(org.junit.jupiter.api.Test)

Example 4 with SystemContextView

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());
    }
}
Also used : SystemContextView(com.structurizr.view.SystemContextView) Test(org.junit.jupiter.api.Test)

Example 5 with SystemContextView

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);
}
Also used : ComponentView(com.structurizr.view.ComponentView) ViewSet(com.structurizr.view.ViewSet) SystemContextView(com.structurizr.view.SystemContextView) SoftwareSystem(com.structurizr.model.SoftwareSystem) ContainerView(com.structurizr.view.ContainerView)

Aggregations

SystemContextView (com.structurizr.view.SystemContextView)11 SoftwareSystem (com.structurizr.model.SoftwareSystem)6 Workspace (com.structurizr.Workspace)5 Person (com.structurizr.model.Person)4 ComponentView (com.structurizr.view.ComponentView)4 Test (org.junit.jupiter.api.Test)4 ContainerView (com.structurizr.view.ContainerView)3 ViewSet (com.structurizr.view.ViewSet)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2 EncryptedJsonReader (com.structurizr.io.json.EncryptedJsonReader)2 Model (com.structurizr.model.Model)2 SystemLandscapeView (com.structurizr.view.SystemLandscapeView)2 FileReader (java.io.FileReader)2 Test (org.junit.Test)2 ComponentFinder (com.structurizr.analysis.ComponentFinder)1 StructurizrAnnotationsComponentFinderStrategy (com.structurizr.analysis.StructurizrAnnotationsComponentFinderStrategy)1 StructurizrDslParser (com.structurizr.dsl.StructurizrDslParser)1 StructurizrDslParserException (com.structurizr.dsl.StructurizrDslParserException)1 AesEncryptionStrategy (com.structurizr.encryption.AesEncryptionStrategy)1 Diagram (com.structurizr.export.Diagram)1