-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicit boundaries for static views (#210)
Explicit boundaries for static views show container boundaries in component diagrams only when componentView.showExternalContainerBoundaries = true show system boundaries in container diagrams only when containerView.showExternalSoftwareSystemBoundaries = true
- Loading branch information
Showing
14 changed files
with
454 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...n/kotlin/com/github/chriskn/structurizrextension/export/exporter/ComponentViewExporter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.github.chriskn.structurizrextension.export.exporter | ||
|
||
import com.github.chriskn.structurizrextension.export.createC4Diagram | ||
import com.github.chriskn.structurizrextension.export.writer.BoundaryWriter | ||
import com.github.chriskn.structurizrextension.export.writer.ElementWriter | ||
import com.github.chriskn.structurizrextension.export.writer.FooterWriter | ||
import com.github.chriskn.structurizrextension.export.writer.HeaderWriter | ||
import com.github.chriskn.structurizrextension.export.writer.RelationshipWriter | ||
import com.structurizr.export.Diagram | ||
import com.structurizr.export.IndentingWriter | ||
import com.structurizr.model.Component | ||
import com.structurizr.model.Container | ||
import com.structurizr.view.ComponentView | ||
import com.structurizr.view.ElementView | ||
import com.structurizr.view.ModelView | ||
|
||
class ComponentViewExporter( | ||
private val boundaryWriter: BoundaryWriter, | ||
private val footerWriter: FooterWriter, | ||
private val headerWriter: HeaderWriter, | ||
private val elementWriter: ElementWriter, | ||
private val relationshipWriter: RelationshipWriter | ||
) { | ||
|
||
internal fun exportComponentView(view: ComponentView): Diagram { | ||
val writer = IndentingWriter() | ||
headerWriter.writeHeader(view, writer) | ||
|
||
var elementsWritten = false | ||
for (elementView in view.elements) { | ||
if (elementView.element !is Component) { | ||
elementWriter.writeElement(view, elementView.element, writer) | ||
elementsWritten = true | ||
} | ||
} | ||
if (elementsWritten) { | ||
writer.writeLine() | ||
} | ||
|
||
val containers: List<Container> = getBoundaryContainer(view) | ||
for (container in containers) { | ||
val showContainerBoundary = view.externalContainerBoundariesVisible | ||
if (showContainerBoundary) { | ||
boundaryWriter.startContainerBoundary(container, writer, view) | ||
} | ||
for (elementView in view.elements) { | ||
if (elementView.element.parent === container) { | ||
elementWriter.writeElement(view, elementView.element, writer) | ||
} | ||
} | ||
if (showContainerBoundary) { | ||
boundaryWriter.endContainerBoundary(writer, view) | ||
} else { | ||
writer.writeLine() | ||
} | ||
} | ||
|
||
relationshipWriter.writeRelationships(view, writer) | ||
|
||
footerWriter.writeFooter(view, writer) | ||
|
||
return createC4Diagram(view, writer.toString()) | ||
} | ||
|
||
private fun getBoundaryContainer(view: ModelView): List<Container> = | ||
view.elements | ||
.asSequence() | ||
.map { obj: ElementView -> obj.element } | ||
.filterIsInstance<Component>() | ||
.map { it.container } | ||
.toSet() | ||
.toList() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.