/** * Adds all containers within the software system in scope to this view. */ public void addAllContainers() { getSoftwareSystem().getContainers().forEach(this::add); }
@Test public void test_construction() { assertEquals("The System - Containers", view.getName()); assertEquals("Description", view.getDescription()); assertEquals(0, view.getElements().size()); assertSame(softwareSystem, view.getSoftwareSystem()); assertEquals(softwareSystem.getId(), view.getSoftwareSystemId()); assertSame(model, view.getModel()); }
/** * Gets the (computed) name of this view. * * @return the name, as a String */ @Override public String getName() { return getSoftwareSystem().getName() + " - Containers"; }
public final void addDependentSoftwareSystems() { getModel().getSoftwareSystems().stream() .filter(softwareSystem -> softwareSystem.hasEfferentRelationshipWith(this.getSoftwareSystem())) .forEach(this::add); }
/** * Adds a software system to this view. Please note that you cannot add the software system * that is the scope of this view. * * @param softwareSystem the SoftwareSystem to add * @param addRelationships whether to add relationships to/from the software system */ @Override public void add(@Nonnull SoftwareSystem softwareSystem, boolean addRelationships) { if (softwareSystem != null && !softwareSystem.equals(getSoftwareSystem())) { addElement(softwareSystem, addRelationships); } }
/** * <p>Adds all {@link com.structurizr.model.Container}s of the given {@link ContainerView} as well as all external influencers, that is all * persons and all other software systems with incoming or outgoing dependencies.</p> * <p>Additionally, all relationships of external dependencies are omitted to keep the diagram clean</p> */ public final void addAllInfluencers() { // add all software systems with incoming or outgoing dependencies getModel().getSoftwareSystems() .stream() .filter(softwareSystem -> softwareSystem.hasEfferentRelationshipWith(getSoftwareSystem()) || getSoftwareSystem().hasEfferentRelationshipWith(softwareSystem)) .forEach(this::add); // then add all people with incoming or outgoing dependencies getModel().getPeople() .stream() .filter(person -> person.hasEfferentRelationshipWith(getSoftwareSystem()) || getSoftwareSystem().hasEfferentRelationshipWith(person)) .forEach(this::add); // then remove all relationships of external elements to keep the container view clean getRelationships() .stream() .map(view -> view.getRelationship()) .filter(relationship -> !isPartOf(relationship.getDestination(), getSoftwareSystem()) && !isPartOf(relationship.getSource(), getSoftwareSystem())) .forEach(this::remove); }
protected void write(ContainerView view, Writer writer) { try { writeHeader(view, writer); view.getElements().stream() .filter(ev -> !(ev.getElement() instanceof Container)) .map(ElementView::getElement) .sorted((e1, e2) -> e1.getName().compareTo(e2.getName())) .forEach(e -> write(view, e, writer, false)); writer.write("package \"" + view.getSoftwareSystem().getName() + "\" <<" + typeOf(view.getSoftwareSystem()) + ">> {"); writer.write(System.lineSeparator()); view.getElements().stream() .filter(ev -> ev.getElement() instanceof Container) .map(ElementView::getElement) .sorted((e1, e2) -> e1.getName().compareTo(e2.getName())) .forEach(e -> write(view, e, writer, true)); writer.write("}"); writer.write(System.lineSeparator()); writeRelationships(view, writer); writeFooter(writer); } catch (IOException e) { e.printStackTrace(); } }
/** * Writes the views in the given workspace as DOT notation, to the specified Writer. * * @param workspace the workspace containing the views to be written * @param writer the Writer to write to */ public void write(Workspace workspace, Writer writer) { workspace.getViews().getSystemContextViews().forEach(v -> write(v, null, writer)); workspace.getViews().getContainerViews().forEach(v -> write(v, v.getSoftwareSystem(), writer)); workspace.getViews().getComponentViews().forEach(v -> write(v, v.getContainer(), writer)); }
@Test public void test_createContainerView() { Workspace workspace = new Workspace("Name", "Description"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); ContainerView containerView = workspace.getViews().createContainerView(softwareSystem, "key", "Description"); assertEquals("key", containerView.getKey()); assertEquals("Description", containerView.getDescription()); assertSame(softwareSystem, containerView.getSoftwareSystem()); }
assertSame(softwareSystem, containerView.getSoftwareSystem()); assertSame(container, containerView.getElementView(container).getElement());