diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/api/model/Model.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/api/model/Model.kt index 8c75861..7f26abc 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/api/model/Model.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/api/model/Model.kt @@ -8,14 +8,17 @@ import com.structurizr.model.Model import com.structurizr.model.Person import com.structurizr.model.SoftwareSystem import com.structurizr.model.StaticStructureElement -import com.structurizr.model.enterpriseNameProperty + +private const val ENTERPRISE_NAME_PROPERTY = "enterprise:name" /** * Stores the name of the enterprise this model belongs to if set */ var Model.enterpriseName: String? - set(name) { this.enterpriseNameProperty = name } - get() = this.enterpriseNameProperty + set(name) { + this.addProperty(ENTERPRISE_NAME_PROPERTY, name) + } + get() = this.properties[ENTERPRISE_NAME_PROPERTY] /** * Adds a person. diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ExternalBoundariesExtensions.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ExternalBoundariesExtensions.kt index 1f14e95..d03cb4d 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ExternalBoundariesExtensions.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ExternalBoundariesExtensions.kt @@ -5,37 +5,35 @@ import com.structurizr.view.ContainerView import com.structurizr.view.DynamicView import com.structurizr.view.SystemContextView import com.structurizr.view.SystemLandscapeView -import com.structurizr.view.showEnterpriseBoundaryInternal -import com.structurizr.view.showExternalBoundariesInternal -import com.structurizr.view.showExternalContainerBoundariesInternal -import com.structurizr.view.showExternalSoftwareSystemBoundariesInternal + +private const val SHOW_BOUNDARY_PROPERTY = "SHOW_BOUNDARY" var DynamicView.showExternalBoundaries: Boolean - get() = this.showExternalBoundariesInternal + get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean() set(value) { - this.showExternalBoundariesInternal = value + this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString()) } var ContainerView.showExternalSoftwareSystemBoundaries: Boolean - get() = this.showExternalSoftwareSystemBoundariesInternal + get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean() set(value) { - this.showExternalSoftwareSystemBoundariesInternal = value + this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString()) } var ComponentView.showExternalContainerBoundaries: Boolean - get() = this.showExternalContainerBoundariesInternal + get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean() set(value) { - this.showExternalContainerBoundariesInternal = value + this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString()) } var SystemLandscapeView.showEnterpriseBoundary: Boolean - get() = this.showEnterpriseBoundaryInternal + get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean() set(value) { - this.showEnterpriseBoundaryInternal = value + this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString()) } var SystemContextView.showEnterpriseBoundary: Boolean - get() = this.showEnterpriseBoundaryInternal + get() = this.properties[SHOW_BOUNDARY_PROPERTY].toBoolean() set(value) { - this.showEnterpriseBoundaryInternal = value + this.addProperty(SHOW_BOUNDARY_PROPERTY, value.toString()) } diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ViewSet.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ViewSetExtension.kt similarity index 100% rename from src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ViewSet.kt rename to src/main/kotlin/com/github/chriskn/structurizrextension/api/view/ViewSetExtension.kt diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/DynamicView.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/dynamic/DynamicView.kt similarity index 84% rename from src/main/kotlin/com/github/chriskn/structurizrextension/api/view/DynamicView.kt rename to src/main/kotlin/com/github/chriskn/structurizrextension/api/view/dynamic/DynamicView.kt index 530504e..db0badf 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/DynamicView.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/dynamic/DynamicView.kt @@ -1,9 +1,9 @@ -package com.github.chriskn.structurizrextension.api.view +package com.github.chriskn.structurizrextension.api.view.dynamic import com.structurizr.model.StaticStructureElement import com.structurizr.view.DynamicView import com.structurizr.view.RelationshipView -import com.structurizr.view.nestedParallelSequenceOrder +import com.structurizr.view.orderInternal private const val NUMBER_OF_ENDED_PARALLEL_FLOWS = "NUMBER_OF_PARALLEL_ROOT_SEQUENCES" private const val AS_SEQUENCE_DIAGRAM = "plantuml.sequenceDiagram" @@ -27,7 +27,7 @@ fun DynamicView.add( technology: String? = null, ): RelationshipView { val relationshipView = this.add(source, description, technology, destination) - relationshipView.nestedParallelSequenceOrder = (relationshipView.order.toInt() + this.numberOfEndedParallelFlows).toString() + relationshipView.orderInternal = (relationshipView.order.toInt() + this.numberOfEndedParallelFlows).toString() return relationshipView } @@ -46,10 +46,10 @@ fun DynamicView.startNestedParallelSequence(): NestedParallelSequenceContext { var DynamicView.numberOfEndedParallelFlows: Int get() { - return this.properties.getOrDefault(NUMBER_OF_ENDED_PARALLEL_FLOWS, "0").toInt() + return properties.getOrDefault(NUMBER_OF_ENDED_PARALLEL_FLOWS, "0").toInt() } set(value) { - this.addProperty(NUMBER_OF_ENDED_PARALLEL_FLOWS, value.toString()) + addProperty(NUMBER_OF_ENDED_PARALLEL_FLOWS, value.toString()) } var DynamicView.renderAsSequenceDiagram: Boolean diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/NestedParallelSequenceContext.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/dynamic/NestedParallelSequenceContext.kt similarity index 92% rename from src/main/kotlin/com/github/chriskn/structurizrextension/api/view/NestedParallelSequenceContext.kt rename to src/main/kotlin/com/github/chriskn/structurizrextension/api/view/dynamic/NestedParallelSequenceContext.kt index 05f4897..b77c19b 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/NestedParallelSequenceContext.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/dynamic/NestedParallelSequenceContext.kt @@ -1,9 +1,9 @@ -package com.github.chriskn.structurizrextension.api.view +package com.github.chriskn.structurizrextension.api.view.dynamic import com.structurizr.model.StaticStructureElement import com.structurizr.view.DynamicView import com.structurizr.view.RelationshipView -import com.structurizr.view.nestedParallelSequenceOrder +import com.structurizr.view.orderInternal /** * Wrapper around [DynamicView] to manage nested numbering for parallel sequences. @@ -45,7 +45,7 @@ data class NestedParallelSequenceContext( description = description, technology = technology ) - view.nestedParallelSequenceOrder = getNextOrder() + view.orderInternal = getNextOrder() return view } diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/layout/C4PlantUmlLayout.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/layout/C4PlantUmlLayout.kt index 82b471c..76b8699 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/layout/C4PlantUmlLayout.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/api/view/layout/C4PlantUmlLayout.kt @@ -1,25 +1,35 @@ package com.github.chriskn.structurizrextension.api.view.layout -import com.github.chriskn.structurizrextension.api.view.layout.Direction.Down -import com.github.chriskn.structurizrextension.api.view.layout.Direction.Left -import com.github.chriskn.structurizrextension.api.view.layout.Direction.Right -import com.github.chriskn.structurizrextension.api.view.layout.Direction.Up -import com.github.chriskn.structurizrextension.api.view.layout.Layout.Landscape -import com.github.chriskn.structurizrextension.api.view.layout.Layout.LeftToRight import com.github.chriskn.structurizrextension.api.view.layout.Layout.TopDown import com.github.chriskn.structurizrextension.api.view.layout.Legend.None -import com.github.chriskn.structurizrextension.api.view.layout.Legend.ShowFloatingLegend import com.github.chriskn.structurizrextension.api.view.layout.Legend.ShowLegend -import com.github.chriskn.structurizrextension.api.view.layout.Legend.ShowStaticLegend -import com.github.chriskn.structurizrextension.api.view.layout.LineType.Ortho -import com.github.chriskn.structurizrextension.api.view.layout.LineType.Polyline -import com.github.chriskn.structurizrextension.api.view.layout.Mode.Back -import com.github.chriskn.structurizrextension.api.view.layout.Mode.BackNeighbor -import com.github.chriskn.structurizrextension.api.view.layout.Mode.Neighbor -import com.github.chriskn.structurizrextension.api.view.layout.Mode.Rel -import com.github.chriskn.structurizrextension.api.view.layout.Mode.RelIndex import com.structurizr.model.Relationship +/** + * Allows the configuration of the layout for generated C4-PlantUML diagram. + * + * @param nodeSep the PlantUML nodesep skinparam in order to control the distance between nodes + * @param rankSep the PlantUML ranksep skinparam in order to control the distance between ranks + * @param lineType the PlantUML [LineType] skinparam + * @param layout the C4PlantUML [Layout]. [TopDown] is default + * @param layout the C4PlantUML [Legend]. [ShowLegend] is default + * @param showPersonOutline activates person outline instead of a rectangle (default is true) + * @param hideStereotypes hides stereotypes when rendering elements (default is true) + * @param dependencyConfigurations list of [DependencyConfiguration] + */ +data class C4PlantUmlLayout( + val nodeSep: Int? = null, + val rankSep: Int? = null, + val lineType: LineType? = null, + val layout: Layout = TopDown, + val legend: Legend = ShowLegend, + val showPersonOutline: Boolean = true, + val hideStereotypes: Boolean = true, + val dependencyConfigurations: List = listOf() +) { + internal fun hasPostamble(): Boolean = nodeSep != null || rankSep != null || lineType != null || legend != None +} + /** * Options for the PlanUML skinparam linetype. * @@ -112,28 +122,3 @@ data class DependencyConfiguration( val mode: Mode? = null, val direction: Direction? = null ) - -/** - * Allows the configuration of the layout for generated C4-PlantUML diagram. - * - * @param nodeSep the PlantUML nodesep skinparam in order to control the distance between nodes - * @param rankSep the PlantUML ranksep skinparam in order to control the distance between ranks - * @param lineType the PlantUML [LineType] skinparam - * @param layout the C4PlantUML [Layout]. [TopDown] is default - * @param layout the C4PlantUML [Legend]. [ShowLegend] is default - * @param showPersonOutline activates person outline instead of a rectangle (default is true) - * @param hideStereotypes hides stereotypes when rendering elements (default is true) - * @param dependencyConfigurations list of [DependencyConfiguration] - */ -data class C4PlantUmlLayout( - val nodeSep: Int? = null, - val rankSep: Int? = null, - val lineType: LineType? = null, - val layout: Layout = TopDown, - val legend: Legend = ShowLegend, - val showPersonOutline: Boolean = true, - val hideStereotypes: Boolean = true, - val dependencyConfigurations: List = listOf() -) { - fun hasPostamble(): Boolean = nodeSep != null || rankSep != null || lineType != null || legend != None -} diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/BoundaryWriter.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/BoundaryWriter.kt index d81e652..bc1090a 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/BoundaryWriter.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/BoundaryWriter.kt @@ -2,7 +2,7 @@ package com.github.chriskn.structurizrextension.internal.export.writer import com.github.chriskn.structurizrextension.api.model.icon import com.github.chriskn.structurizrextension.api.model.link -import com.github.chriskn.structurizrextension.api.view.renderAsSequenceDiagram +import com.github.chriskn.structurizrextension.api.view.dynamic.renderAsSequenceDiagram import com.github.chriskn.structurizrextension.internal.export.idOf import com.github.chriskn.structurizrextension.internal.icons.IconRegistry import com.structurizr.export.IndentingWriter diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/HeaderWriter.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/HeaderWriter.kt index 477c5b6..95aa745 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/HeaderWriter.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/HeaderWriter.kt @@ -1,8 +1,8 @@ package com.github.chriskn.structurizrextension.internal.export.writer import com.github.chriskn.structurizrextension.api.model.icon +import com.github.chriskn.structurizrextension.api.view.dynamic.renderAsSequenceDiagram import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry -import com.github.chriskn.structurizrextension.api.view.renderAsSequenceDiagram import com.github.chriskn.structurizrextension.internal.icons.AWS_ICON_COMMONS import com.github.chriskn.structurizrextension.internal.icons.AWS_ICON_URL import com.github.chriskn.structurizrextension.internal.icons.IconRegistry diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/RelationshipWriter.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/RelationshipWriter.kt index 233d8ab..f4c01ba 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/RelationshipWriter.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/internal/export/writer/RelationshipWriter.kt @@ -2,11 +2,11 @@ package com.github.chriskn.structurizrextension.internal.export.writer import com.github.chriskn.structurizrextension.api.model.icon import com.github.chriskn.structurizrextension.api.model.link +import com.github.chriskn.structurizrextension.api.view.dynamic.renderAsSequenceDiagram import com.github.chriskn.structurizrextension.api.view.layout.DependencyConfiguration import com.github.chriskn.structurizrextension.api.view.layout.Direction import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry import com.github.chriskn.structurizrextension.api.view.layout.Mode -import com.github.chriskn.structurizrextension.api.view.renderAsSequenceDiagram import com.github.chriskn.structurizrextension.internal.export.idOf import com.github.chriskn.structurizrextension.internal.icons.IconRegistry import com.structurizr.export.IndentingWriter diff --git a/src/main/kotlin/com/structurizr/model/EnterpriseExtension.kt b/src/main/kotlin/com/structurizr/model/EnterpriseExtension.kt deleted file mode 100644 index ad2a49c..0000000 --- a/src/main/kotlin/com/structurizr/model/EnterpriseExtension.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.structurizr.model - -private const val ENTERPRISE_NAME_PROPERTY = "enterpriseName" - -internal var Model.enterpriseNameProperty: String? - set(name) { - val propertiesWithEnterpriseName = this.properties - propertiesWithEnterpriseName[ENTERPRISE_NAME_PROPERTY] = name - this.properties = propertiesWithEnterpriseName - } - get() = this.properties[ENTERPRISE_NAME_PROPERTY] diff --git a/src/main/kotlin/com/structurizr/view/InternalBoundariesExtensions.kt b/src/main/kotlin/com/structurizr/view/InternalBoundariesExtensions.kt deleted file mode 100644 index 814b606..0000000 --- a/src/main/kotlin/com/structurizr/view/InternalBoundariesExtensions.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.structurizr.view - -@Suppress("DEPRECATION") -internal var DynamicView.showExternalBoundariesInternal: Boolean - get() = this.externalBoundariesVisible - set(value) { - this.externalBoundariesVisible = value - } - -@Suppress("DEPRECATION") -internal var ContainerView.showExternalSoftwareSystemBoundariesInternal: Boolean - get() = this.externalSoftwareSystemBoundariesVisible - set(value) { - this.externalSoftwareSystemBoundariesVisible = value - } - -@Suppress("DEPRECATION") -internal var ComponentView.showExternalContainerBoundariesInternal: Boolean - get() = this.externalContainerBoundariesVisible - set(value) { - this.setExternalSoftwareSystemBoundariesVisible(value) - } - -@Suppress("DEPRECATION") -internal var SystemLandscapeView.showEnterpriseBoundaryInternal: Boolean - get() = this.isEnterpriseBoundaryVisible - set(value) { - this.isEnterpriseBoundaryVisible = value - } - -@Suppress("DEPRECATION") -internal var SystemContextView.showEnterpriseBoundaryInternal: Boolean - get() = this.isEnterpriseBoundaryVisible - set(value) { - this.isEnterpriseBoundaryVisible = value - } diff --git a/src/main/kotlin/com/structurizr/view/RelationshipViewExtension.kt b/src/main/kotlin/com/structurizr/view/RelationshipViewExtension.kt index fc1e38d..665e377 100644 --- a/src/main/kotlin/com/structurizr/view/RelationshipViewExtension.kt +++ b/src/main/kotlin/com/structurizr/view/RelationshipViewExtension.kt @@ -1,5 +1,5 @@ package com.structurizr.view -internal var RelationshipView.nestedParallelSequenceOrder: String +internal var RelationshipView.orderInternal: String get() = this.order set(order) { this.order = order } diff --git a/src/test/kotlin/com/github/chriskn/structurizrextension/view/DynamicViewTest.kt b/src/test/kotlin/com/github/chriskn/structurizrextension/view/DynamicViewTest.kt index 4803104..a5d0056 100644 --- a/src/test/kotlin/com/github/chriskn/structurizrextension/view/DynamicViewTest.kt +++ b/src/test/kotlin/com/github/chriskn/structurizrextension/view/DynamicViewTest.kt @@ -7,16 +7,16 @@ import com.github.chriskn.structurizrextension.api.model.component import com.github.chriskn.structurizrextension.api.model.container import com.github.chriskn.structurizrextension.api.model.person import com.github.chriskn.structurizrextension.api.model.softwareSystem -import com.github.chriskn.structurizrextension.api.view.add +import com.github.chriskn.structurizrextension.api.view.dynamic.add +import com.github.chriskn.structurizrextension.api.view.dynamic.renderAsSequenceDiagram +import com.github.chriskn.structurizrextension.api.view.dynamic.startNestedParallelSequence import com.github.chriskn.structurizrextension.api.view.dynamicView import com.github.chriskn.structurizrextension.api.view.layout.C4PlantUmlLayout import com.github.chriskn.structurizrextension.api.view.layout.DependencyConfiguration import com.github.chriskn.structurizrextension.api.view.layout.Direction.Left import com.github.chriskn.structurizrextension.api.view.layout.Direction.Right import com.github.chriskn.structurizrextension.api.view.layout.Mode.Neighbor -import com.github.chriskn.structurizrextension.api.view.renderAsSequenceDiagram import com.github.chriskn.structurizrextension.api.view.showExternalBoundaries -import com.github.chriskn.structurizrextension.api.view.startNestedParallelSequence import com.github.chriskn.structurizrextension.api.writeDiagrams import com.github.chriskn.structurizrextension.assertExpectedDiagramWasWrittenForView import com.structurizr.Workspace