com.structurizr.model.SoftwareSystem Java Examples

The following examples show how to use com.structurizr.model.SoftwareSystem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilteredViewTests.java    From java with Apache License 2.0 6 votes vote down vote up
@Test
public void test_construction() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
    SystemContextView systemContextView = views.createSystemContextView(softwareSystem, "SystemContext", "Description");
    FilteredView filteredView = views.createFilteredView(
            systemContextView,
            "CurrentStateSystemContext",
            "The system context as-is.",
            FilterMode.Exclude,
            "v2", "v3"
    );

    assertEquals("CurrentStateSystemContext", filteredView.getKey());
    assertEquals("SystemContext", filteredView.getBaseViewKey());
    assertSame(systemContextView, filteredView.getView());
    assertEquals("The system context as-is.", filteredView.getDescription());
    assertEquals(FilterMode.Exclude, filteredView.getMode());
    assertEquals(2, filteredView.getTags().size());
    assertTrue(filteredView.getTags().contains("v2"));
    assertTrue(filteredView.getTags().contains("v3"));
}
 
Example #2
Source File: StructurizrSimple.java    From tutorials with MIT License 6 votes vote down vote up
private static void addContainers(Workspace workspace) {
    Model model = workspace.getModel();

    SoftwareSystem paymentTerminal = model.getSoftwareSystemWithName(PAYMENT_TERMINAL);
    Container f5 = paymentTerminal.addContainer("Payment Load Balancer", "Payment Load Balancer", "F5");
    Container jvm1 = paymentTerminal.addContainer("JVM-1", "JVM-1", "Java Virtual Machine");
    Container jvm2 = paymentTerminal.addContainer("JVM-2", "JVM-2", "Java Virtual Machine");
    Container jvm3 = paymentTerminal.addContainer("JVM-3", "JVM-3", "Java Virtual Machine");
    Container oracle = paymentTerminal.addContainer("oracleDB", "Oracle Database", "RDBMS");

    f5.uses(jvm1, "route");
    f5.uses(jvm2, "route");
    f5.uses(jvm3, "route");

    jvm1.uses(oracle, "storage");
    jvm2.uses(oracle, "storage");
    jvm3.uses(oracle, "storage");

    ContainerView view = workspace.getViews().createContainerView(paymentTerminal, CONTAINER_VIEW, "Container View");
    view.addAllContainers();
}
 
Example #3
Source File: StructurizrClientIntegrationTests.java    From java with Apache License 2.0 6 votes vote down vote up
@Test
public void test_putAndGetWorkspace_WithEncryption() throws Exception {
    structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password"));
    Workspace workspace = new Workspace("Structurizr client library tests - with encryption", "A test workspace for the Structurizr client library");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
    Person person = workspace.getModel().addPerson("Person", "Description");
    person.uses(softwareSystem, "Uses");
    SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description");
    systemContextView.addAllElements();

    structurizrClient.putWorkspace(20081, workspace);

    workspace = structurizrClient.getWorkspace(20081);
    assertNotNull(workspace.getModel().getSoftwareSystemWithName("Software System"));
    assertNotNull(workspace.getModel().getPersonWithName("Person"));
    assertEquals(1, workspace.getModel().getRelationships().size());
    assertEquals(1, workspace.getViews().getSystemContextViews().size());

    // and check the archive version is readable
    EncryptedWorkspace archivedWorkspace = new EncryptedJsonReader().read(new FileReader(getArchivedWorkspace()));
    assertEquals(20081, archivedWorkspace.getId());
    assertEquals("Structurizr client library tests - with encryption", archivedWorkspace.getName());
    assertTrue(archivedWorkspace.getEncryptionStrategy() instanceof AesEncryptionStrategy);

    assertEquals(1, workspaceArchiveLocation.listFiles().length);
}
 
Example #4
Source File: StructurizrSimple.java    From tutorials with MIT License 6 votes vote down vote up
private static void addComponents(Workspace workspace) {
    Model model = workspace.getModel();

    SoftwareSystem paymentTerminal = model.getSoftwareSystemWithName(PAYMENT_TERMINAL);
    Container jvm1 = paymentTerminal.getContainerWithName("JVM-1");

    Component jaxrs = jvm1.addComponent("jaxrs-jersey", "restful webservice implementation", "rest");
    Component gemfire = jvm1.addComponent("gemfire", "Clustered Cache Gemfire", "cache");
    Component hibernate = jvm1.addComponent("hibernate", "Data Access Layer", "jpa");

    jaxrs.uses(gemfire, "");
    gemfire.uses(hibernate, "");

    ComponentView componentView = workspace.getViews().createComponentView(jvm1, COMPONENT_VIEW, "JVM Components");
    componentView.addAllComponents();
}
 
Example #5
Source File: DocumentationTests.java    From java with Apache License 2.0 6 votes vote down vote up
@Test
public void test_hydrate() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");

    Section section = new Section();
    section.setElementId(softwareSystem.getId());
    section.setTitle("Title");
    documentation.setSections(Collections.singleton(section));

    Decision decision = new Decision();
    decision.setElementId(softwareSystem.getId());
    documentation.setDecisions(Collections.singleton(decision));

    documentation.hydrate(model);

    assertSame(softwareSystem, section.getElement());
    assertSame(softwareSystem, decision.getElement());
}
 
Example #6
Source File: StyleTests.java    From java with Apache License 2.0 6 votes vote down vote up
@Test
public void test_findElementStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined() {
    SoftwareSystem element = model.addSoftwareSystem("Name", "Description");
    element.addTags("Some Tag");

    styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000").color("#ffffff");
    styles.addElementStyle("Some Tag").color("#0000ff").stroke("#00ff00").shape(Shape.RoundedBox).width(123).height(456);

    ElementStyle style = styles.findElementStyle(element);
    assertEquals("#ff0000", style.getBackground());
    assertEquals("#0000ff", style.getColor());
    assertEquals("#00ff00", style.getStroke());
    assertEquals(Shape.RoundedBox, style.getShape());
    assertEquals(new Integer(123), style.getWidth());
    assertEquals(new Integer(456), style.getHeight());
}
 
Example #7
Source File: GettingStarted.java    From java with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // all software architecture models belong to a workspace
    Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
    Model model = workspace.getModel();

    // create a model to describe a user using a software system
    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    // create a system context diagram showing people and software systems
    ViewSet views = workspace.getViews();
    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    // add some styling to the diagram elements
    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);

    // upload to structurizr.com (you'll need your own workspace ID, API key and API secret)
    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #8
Source File: AutomaticDocumentationTemplateExample.java    From java with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Documentation - Automatic", "An empty software architecture document using the Structurizr template.");
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();

    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    Styles styles = views.getConfiguration().getStyles();
    styles.addElementStyle(Tags.PERSON).shape(Shape.Person);

    // this directory includes a mix of Markdown and AsciiDoc files
    File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/automatic");

    AutomaticDocumentationTemplate template = new AutomaticDocumentationTemplate(workspace);
    template.addSections(softwareSystem, documentationRoot);

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #9
Source File: ClientSideEncryption.java    From java with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Client-side encrypted workspace", "This is a client-side encrypted workspace. The passphrase is 'password'.");
    Model model = workspace.getModel();

    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    ViewSet views = workspace.getViews();
    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    Styles styles = views.getConfiguration().getStyles();
    styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#d34407").color("#ffffff");
    styles.addElementStyle(Tags.PERSON).background("#f86628").color("#ffffff").shape(Shape.Person);

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password"));
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #10
Source File: Theme.java    From java with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Theme", "This is a model of my software system.");
    Model model = workspace.getModel();

    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    ViewSet views = workspace.getViews();
    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    // add a theme
    views.getConfiguration().setTheme("https://raw.githubusercontent.com/structurizr/java/master/structurizr-examples/src/com/structurizr/example/theme/theme.json");

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #11
Source File: CorporateBranding.java    From java with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system.");
    Model model = workspace.getModel();

    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    ViewSet views = workspace.getViews();
    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    Styles styles = views.getConfiguration().getStyles();
    styles.addElementStyle(Tags.PERSON).shape(Shape.Person);

    StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);
    template.addContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n\n![](embed:SystemContext)");

    Branding branding = views.getConfiguration().getBranding();
    branding.setLogo(ImageUtils.getImageAsDataUri(new File("./docs/images/structurizr-logo.png")));

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example #12
Source File: Structurizr.java    From architecture-guild with Apache License 2.0 5 votes vote down vote up
private static void createWorkspace() throws Exception {
    Workspace workspace = new Workspace("Main workspace", "Main workspace");
    Model model = workspace.getModel();
    SoftwareSystem carShare = model.addSoftwareSystem("Car sharing system", "Car sharing system");
    ExternalSystems externalSystems = CarShareContextDiagram.create(workspace, model, carShare);
    InternalContainers internalContainers = CarShareContainersDiagram.create(workspace, carShare, externalSystems);
    CarShareComponents.create(workspace, internalContainers, externalSystems);
    uploadWorkspaceToStructurizr(workspace);
}
 
Example #13
Source File: StaticViewTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_addAnimationStep_IgnoresElementsThatDoNotExistInTheView() {
    SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", "");
    SoftwareSystem element2 = model.addSoftwareSystem("Software System 2", "");

    SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
    view.add(element1);
    view.addAnimation(element1, element2);

    Animation step1 = view.getAnimations().stream().filter(step -> step.getOrder() == 1).findFirst().get();
    assertEquals(1, step1.getElements().size());
    assertTrue(step1.getElements().contains(element1.getId()));
}
 
Example #14
Source File: View.java    From java with Apache License 2.0 5 votes vote down vote up
View(SoftwareSystem softwareSystem, String key, String description) {
    this.softwareSystem = softwareSystem;
    if (!StringUtils.isNullOrEmpty(key)) {
        setKey(key);
    } else {
        throw new IllegalArgumentException("A key must be specified.");
    }
    setDescription(description);
}
 
Example #15
Source File: ContainerView.java    From java with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the default set of elements to this view.
 */
@Override
public void addDefaultElements() {
    for (Container container : getSoftwareSystem().getContainers()) {
        add(container);
        addNearestNeighbours(container, Person.class);
        addNearestNeighbours(container, SoftwareSystem.class);
    }
}
 
Example #16
Source File: DocumentationTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_addSection_ThrowsAnException_WhenASectionExistsWithTheSameTitleForAnElement() {
    try {
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
        documentation.addSection(softwareSystem, "Title", Format.Markdown, "Content");
        documentation.addSection(softwareSystem, "Title", Format.Markdown, "Content");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A section with a title of Title already exists for the element named Software System.", iae.getMessage());
    }
}
 
Example #17
Source File: StylingRelationships.java    From java with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
        Workspace workspace = new Workspace("Styling Relationships", "This is a model of my software system.");
        Model model = workspace.getModel();

        Person user = model.addPerson("User", "A user of my software system.");
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
        Container webApplication = softwareSystem.addContainer("Web Application", "My web application.", "Java and Spring MVC");
        Container database = softwareSystem.addContainer("Database", "My database.", "Relational database schema");
        user.uses(webApplication, "Uses", "HTTPS");
        webApplication.uses(database, "Reads from and writes to", "JDBC");

        ViewSet views = workspace.getViews();
        ContainerView containerView = views.createContainerView(softwareSystem, "containers", "An example of a container diagram.");
        containerView.addAllElements();

        Styles styles = workspace.getViews().getConfiguration().getStyles();

        // example 1
//        styles.addRelationshipStyle(Tags.RELATIONSHIP).color("#ff0000");

        // example 2
//        model.getRelationships().stream().filter(r -> "HTTPS".equals(r.getTechnology())).forEach(r -> r.addTags("HTTPS"));
//        model.getRelationships().stream().filter(r -> "JDBC".equals(r.getTechnology())).forEach(r -> r.addTags("JDBC"));
//        styles.addRelationshipStyle("HTTPS").color("#ff0000");
//        styles.addRelationshipStyle("JDBC").color("#0000ff");

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example #18
Source File: StyleTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_findElementStyle_ReturnsTheDefaultStyle_WhenNoStylesAreDefined() {
    SoftwareSystem element = model.addSoftwareSystem("Name", "Description");
    ElementStyle style = styles.findElementStyle(element);
    assertEquals("#dddddd", style.getBackground());
    assertEquals("#000000", style.getColor());
    assertEquals(Shape.Box, style.getShape());
    assertEquals(new Integer(450), style.getWidth());
    assertEquals(new Integer(300), style.getHeight());
}
 
Example #19
Source File: DocumentationTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_addSection_IncrementsTheSectionOrderNumber() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Section section1 = documentation.addSection(softwareSystem, "Section 1", Format.Markdown, "Content");
    Section section2 = documentation.addSection(softwareSystem, "Section 2", Format.Markdown, "Content");
    Section section3 = documentation.addSection(softwareSystem, "Section 3", Format.Markdown, "Content");

    assertEquals(1, section1.getOrder());
    assertEquals(2, section2.getOrder());
    assertEquals(3, section3.getOrder());
}
 
Example #20
Source File: DocumentationTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_addSection_ThrowsAnException_WhenTheRelatedElementIsNotPresentInTheAssociatedModel() {
    try {
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
        new Workspace("", "").getDocumentation().addSection(softwareSystem, "Title", Format.Markdown, "Content");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("The element named Software System does not exist in the model associated with this documentation.", iae.getMessage());
    }
}
 
Example #21
Source File: StyleTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_findElementStyle_ReturnsTheDefaultElementSize_WhenTheShapeIsAPerson() {
    SoftwareSystem element = model.addSoftwareSystem("Name", "Description");
    element.addTags("Some Tag");

    styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000").color("#ffffff");
    styles.addElementStyle("Some Tag").shape(Shape.Person);

    ElementStyle style = styles.findElementStyle(element);
    assertEquals(Shape.Person, style.getShape());
    assertEquals(new Integer(400), style.getWidth());
    assertEquals(new Integer(400), style.getHeight());
}
 
Example #22
Source File: StaticViewTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_addAnimationStep_ThrowsAnException_WhenElementsAreSpecifiedButNoneOfThemExistInTheView() {
    try {
        SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", "");

        SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
        view.addAnimation(element1);
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("None of the specified elements exist in this view.", iae.getMessage());
    }
}
 
Example #23
Source File: StaticViewTests.java    From java with Apache License 2.0 5 votes vote down vote up
@Test
public void test_addAnimationStep() {
    SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", "");
    SoftwareSystem element2 = model.addSoftwareSystem("Software System 2", "");
    SoftwareSystem element3 = model.addSoftwareSystem("Software System 3", "");

    Relationship relationship1_2 = element1.uses(element2, "uses");
    Relationship relationship2_3 = element2.uses(element3, "uses");

    SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
    view.addAllElements();

    view.addAnimation(element1);
    view.addAnimation(element2);
    view.addAnimation(element3);

    Animation step1 = view.getAnimations().stream().filter(step -> step.getOrder() == 1).findFirst().get();
    assertEquals(1, step1.getElements().size());
    assertTrue(step1.getElements().contains(element1.getId()));
    assertEquals(0, step1.getRelationships().size());

    Animation step2 = view.getAnimations().stream().filter(step -> step.getOrder() == 2).findFirst().get();
    assertEquals(1, step2.getElements().size());
    assertTrue(step2.getElements().contains(element2.getId()));
    assertEquals(1, step2.getRelationships().size());
    assertTrue(step2.getRelationships().contains(relationship1_2.getId()));

    Animation step3 = view.getAnimations().stream().filter(step -> step.getOrder() == 3).findFirst().get();
    assertEquals(1, step3.getElements().size());
    assertTrue(step3.getElements().contains(element3.getId()));
    assertEquals(1, step3.getRelationships().size());
    assertTrue(step3.getRelationships().contains(relationship2_3.getId()));
}
 
Example #24
Source File: CarShareContextDiagram.java    From architecture-guild with Apache License 2.0 5 votes vote down vote up
private static void setupContextView(Workspace workspace, SoftwareSystem eMobility) {
    Function<ViewSet, StaticView> contextViewCrator = views ->
            views.createSystemContextView(
                    eMobility,
                    "context diagram",
                    "context view");
    ViewCreator.setupView(workspace, contextViewCrator, PaperSize.A5_Landscape);
}
 
Example #25
Source File: SystemContextView.java    From java with Apache License 2.0 4 votes vote down vote up
SystemContextView(SoftwareSystem softwareSystem, String key, String description) {
    super(softwareSystem, key, description);

    addElement(softwareSystem, true);
}
 
Example #26
Source File: SystemContextView.java    From java with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the default set of elements to this view.
 */
@Override
public void addDefaultElements() {
    addNearestNeighbours(getSoftwareSystem(), Person.class);
    addNearestNeighbours(getSoftwareSystem(), SoftwareSystem.class);
}
 
Example #27
Source File: CarShareContextDiagram.java    From architecture-guild with Apache License 2.0 4 votes vote down vote up
static ExternalSystems create(Workspace workspace, Model model, SoftwareSystem carShare) {
    ExternalSystems externalSystems = new ExternalSystems(model);
    externalSystems.createUsages(carShare);
    setupContextView(workspace, carShare);
    return externalSystems;
}
 
Example #28
Source File: Sap.java    From structurizr-extensions with Apache License 2.0 4 votes vote down vote up
public SoftwareSystem getSap() {
    return sap;
}
 
Example #29
Source File: StructurizrDocumentationExample.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
        Workspace workspace = new Workspace("Documentation - Structurizr", "An empty software architecture document using the Structurizr template.");
        Model model = workspace.getModel();
        ViewSet views = workspace.getViews();

        Person user = model.addPerson("User", "A user of my software system.");
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
        user.uses(softwareSystem, "Uses");

        SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
        contextView.addAllSoftwareSystems();
        contextView.addAllPeople();

        Styles styles = views.getConfiguration().getStyles();
        styles.addElementStyle(Tags.PERSON).shape(Shape.Person);

        StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);

        // this is the Markdown version
        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/structurizr/markdown");
        template.addContextSection(softwareSystem, new File(documentationRoot, "01-context.md"));
        template.addFunctionalOverviewSection(softwareSystem, new File(documentationRoot, "02-functional-overview.md"));
        template.addQualityAttributesSection(softwareSystem, new File(documentationRoot, "03-quality-attributes.md"));
        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "04-constraints.md"));
        template.addPrinciplesSection(softwareSystem, new File(documentationRoot, "05-principles.md"));
        template.addSoftwareArchitectureSection(softwareSystem, new File(documentationRoot, "06-software-architecture.md"));
        template.addDataSection(softwareSystem, new File(documentationRoot, "07-data.md"));
        template.addInfrastructureArchitectureSection(softwareSystem, new File(documentationRoot, "08-infrastructure-architecture.md"));
        template.addDeploymentSection(softwareSystem, new File(documentationRoot, "09-deployment.md"));
        template.addDevelopmentEnvironmentSection(softwareSystem, new File(documentationRoot, "10-development-environment.md"));
        template.addOperationAndSupportSection(softwareSystem, new File(documentationRoot, "11-operation-and-support.md"));
        template.addDecisionLogSection(softwareSystem, new File(documentationRoot, "12-decision-log.md"));

        // this is the AsciiDoc version
//        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/structurizr/asciidoc");
//        template.addContextSection(softwareSystem, new File(documentationRoot, "01-context.adoc"));
//        template.addFunctionalOverviewSection(softwareSystem, new File(documentationRoot, "02-functional-overview.adoc"));
//        template.addQualityAttributesSection(softwareSystem, new File(documentationRoot, "03-quality-attributes.adoc"));
//        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "04-constraints.adoc"));
//        template.addPrinciplesSection(softwareSystem, new File(documentationRoot, "05-principles.adoc"));
//        template.addSoftwareArchitectureSection(softwareSystem, new File(documentationRoot, "06-software-architecture.adoc"));
//        template.addDataSection(softwareSystem, new File(documentationRoot, "07-data.adoc"));
//        template.addInfrastructureArchitectureSection(softwareSystem, new File(documentationRoot, "08-infrastructure-architecture.adoc"));
//        template.addDeploymentSection(softwareSystem, new File(documentationRoot, "09-deployment.adoc"));
//        template.addDevelopmentEnvironmentSection(softwareSystem, new File(documentationRoot, "10-development-environment.adoc"));
//        template.addOperationAndSupportSection(softwareSystem, new File(documentationRoot, "11-operation-and-support.adoc"));
//        template.addDecisionLogSection(softwareSystem, new File(documentationRoot, "12-decision-log.adoc"));

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example #30
Source File: Arc42DocumentationExample.java    From java with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
        Workspace workspace = new Workspace("Documentation - arc42", "An empty software architecture document using the arc42 template.");
        Model model = workspace.getModel();
        ViewSet views = workspace.getViews();

        Person user = model.addPerson("User", "A user of my software system.");
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
        user.uses(softwareSystem, "Uses");

        SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
        contextView.addAllSoftwareSystems();
        contextView.addAllPeople();

        Styles styles = views.getConfiguration().getStyles();
        styles.addElementStyle(Tags.PERSON).shape(Shape.Person);

        Arc42DocumentationTemplate template = new Arc42DocumentationTemplate(workspace);

        // this is the Markdown version
        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/arc42/markdown");
        template.addIntroductionAndGoalsSection(softwareSystem, new File(documentationRoot, "01-introduction-and-goals.md"));
        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "02-architecture-constraints.md"));
        template.addContextAndScopeSection(softwareSystem, new File(documentationRoot, "03-system-scope-and-context.md"));
        template.addSolutionStrategySection(softwareSystem, new File(documentationRoot, "04-solution-strategy.md"));
        template.addBuildingBlockViewSection(softwareSystem, new File(documentationRoot, "05-building-block-view.md"));
        template.addRuntimeViewSection(softwareSystem, new File(documentationRoot, "06-runtime-view.md"));
        template.addDeploymentViewSection(softwareSystem, new File(documentationRoot, "07-deployment-view.md"));
        template.addCrosscuttingConceptsSection(softwareSystem, new File(documentationRoot, "08-crosscutting-concepts.md"));
        template.addArchitecturalDecisionsSection(softwareSystem, new File(documentationRoot, "09-architecture-decisions.md"));
        template.addRisksAndTechnicalDebtSection(softwareSystem, new File(documentationRoot, "10-quality-requirements.md"));
        template.addQualityRequirementsSection(softwareSystem, new File(documentationRoot, "11-risks-and-technical-debt.md"));
        template.addGlossarySection(softwareSystem, new File(documentationRoot, "12-glossary.md"));

        // this is the AsciiDoc version
//        File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/arc42/asciidoc");
//        template.addIntroductionAndGoalsSection(softwareSystem, new File(documentationRoot, "01-introduction-and-goals.adoc"));
//        template.addConstraintsSection(softwareSystem, new File(documentationRoot, "02-architecture-constraints.adoc"));
//        template.addContextAndScopeSection(softwareSystem, new File(documentationRoot, "03-system-scope-and-context.adoc"));
//        template.addSolutionStrategySection(softwareSystem, new File(documentationRoot, "04-solution-strategy.adoc"));
//        template.addBuildingBlockViewSection(softwareSystem, new File(documentationRoot, "05-building-block-view.adoc"));
//        template.addRuntimeViewSection(softwareSystem, new File(documentationRoot, "06-runtime-view.adoc"));
//        template.addDeploymentViewSection(softwareSystem, new File(documentationRoot, "07-deployment-view.adoc"));
//        template.addCrosscuttingConceptsSection(softwareSystem, new File(documentationRoot, "08-crosscutting-concepts.adoc"));
//        template.addArchitecturalDecisionsSection(softwareSystem, new File(documentationRoot, "09-architecture-decisions.adoc"));
//        template.addRisksAndTechnicalDebtSection(softwareSystem, new File(documentationRoot, "10-quality-requirements.adoc"));
//        template.addQualityRequirementsSection(softwareSystem, new File(documentationRoot, "11-risks-and-technical-debt.adoc"));
//        template.addGlossarySection(softwareSystem, new File(documentationRoot, "12-glossary.adoc"));

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }