Search in sources :

Example 11 with ComponentView

use of com.structurizr.view.ComponentView in project moduliths by moduliths.

the class Documenter method addComponentsToView.

private void addComponentsToView(Supplier<Stream<Module>> modules, ComponentView view, Options options, Consumer<ComponentView> afterCleanup) {
    Styles styles = view.getViewSet().getConfiguration().getStyles();
    Map<Module, Component> components = getComponents(options);
    // 
    modules.get().distinct().filter(// 
    options.getExclusions().negate()).map(// 
    it -> applyBackgroundColor(it, components, options, styles)).filter(// 
    options.getComponentFilter()).forEach(view::add);
    // view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getBackground()
    // Remove filtered dependency types
    // 
    DependencyType.allBut(options.getDependencyTypes()).map(// 
    Object::toString).forEach(it -> view.removeRelationshipsWithTag(it));
    afterCleanup.accept(view);
    // Filter outgoing relationships of target-only modules
    // 
    modules.get().filter(options.getTargetOnly()).forEach(module -> {
        Component component = components.get(module);
        // 
        view.getRelationships().stream().map(// 
        RelationshipView::getRelationship).filter(// 
        it -> it.getSource().equals(component)).forEach(it -> view.remove(it));
    });
    // … as well as all elements left without a relationship
    if (options.hideElementsWithoutRelationships()) {
        view.removeElementsWithNoRelationships();
    }
    afterCleanup.accept(view);
    // Remove default relationships if more qualified ones exist
    // 
    view.getRelationships().stream().map(// 
    RelationshipView::getRelationship).collect(// 
    Collectors.groupingBy(Connection::of)).values().stream().forEach(it -> potentiallyRemoveDefaultRelationship(view, it));
}
Also used : RequiredArgsConstructor(lombok.RequiredArgsConstructor) Diagram(com.structurizr.io.Diagram) C4PlantUMLExporter(com.structurizr.io.plantuml.C4PlantUMLExporter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) SpringBean(org.moduliths.model.SpringBean) JavaClass(com.tngtech.archunit.core.domain.JavaClass) Path(java.nio.file.Path) With(lombok.With) Predicate(java.util.function.Predicate) SoftwareSystem(com.structurizr.model.SoftwareSystem) RelationshipView(com.structurizr.view.RelationshipView) Asciidoctor(org.moduliths.docs.Asciidoctor) Collectors(java.util.stream.Collectors) DependencyDepth(org.moduliths.model.Module.DependencyDepth) Shape(com.structurizr.view.Shape) Tags(com.structurizr.model.Tags) Stream(java.util.stream.Stream) Relationship(com.structurizr.model.Relationship) Writer(java.io.Writer) Entry(java.util.Map.Entry) Styles(com.structurizr.view.Styles) java.util(java.util) Getter(lombok.Getter) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Component(com.structurizr.model.Component) Value(lombok.Value) Modules(org.moduliths.model.Modules) AccessLevel(lombok.AccessLevel) BiConsumer(java.util.function.BiConsumer) View(com.structurizr.view.View) Nullable(org.springframework.lang.Nullable) Model(com.structurizr.model.Model) Container(com.structurizr.model.Container) ComponentView(com.structurizr.view.ComponentView) Files(java.nio.file.Files) StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) MultiValueMap(org.springframework.util.MultiValueMap) IOException(java.io.IOException) File(java.io.File) Workspace(com.structurizr.Workspace) Consumer(java.util.function.Consumer) DependencyType(org.moduliths.model.Module.DependencyType) Module(org.moduliths.model.Module) Paths(java.nio.file.Paths) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter) AllArgsConstructor(lombok.AllArgsConstructor) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Element(com.structurizr.model.Element) Assert(org.springframework.util.Assert) RelationshipView(com.structurizr.view.RelationshipView) Module(org.moduliths.model.Module) Component(com.structurizr.model.Component) Styles(com.structurizr.view.Styles)

Aggregations

ComponentView (com.structurizr.view.ComponentView)11 Container (com.structurizr.model.Container)5 SoftwareSystem (com.structurizr.model.SoftwareSystem)4 ContainerView (com.structurizr.view.ContainerView)4 Workspace (com.structurizr.Workspace)3 Component (com.structurizr.model.Component)3 Model (com.structurizr.model.Model)3 SystemContextView (com.structurizr.view.SystemContextView)3 Element (com.structurizr.model.Element)2 View (com.structurizr.view.View)2 ViewSet (com.structurizr.view.ViewSet)2 File (java.io.File)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)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 Diagram (com.structurizr.export.Diagram)1 StructurizrPlantUMLExporter (com.structurizr.export.plantuml.StructurizrPlantUMLExporter)1