-
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.
bump structurizr version 2.1.2 and fix removed or deprecated features
- Loading branch information
Showing
22 changed files
with
259 additions
and
123 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
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
77 changes: 77 additions & 0 deletions
77
...n/kotlin/com/github/chriskn/structurizrextension/export/exporter/LandscapeViewExporter.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,77 @@ | ||
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.github.chriskn.structurizrextension.model.c4Location | ||
import com.structurizr.export.Diagram | ||
import com.structurizr.export.IndentingWriter | ||
import com.structurizr.model.Element | ||
import com.structurizr.model.Location | ||
import com.structurizr.model.Person | ||
import com.structurizr.model.SoftwareSystem | ||
import com.structurizr.view.ModelView | ||
import com.structurizr.view.SystemLandscapeView | ||
import com.structurizr.view.showEnterpriseBoundary | ||
|
||
class LandscapeViewExporter( | ||
private val boundaryWriter: BoundaryWriter, | ||
private val footerWriter: FooterWriter, | ||
private val headerWriter: HeaderWriter, | ||
private val elementWriter: ElementWriter, | ||
private val relationshipWriter: RelationshipWriter | ||
) { | ||
|
||
internal fun exportLandscapeView(view: SystemLandscapeView): Diagram { | ||
val writer = IndentingWriter() | ||
headerWriter.writeHeader(view, writer) | ||
|
||
val sortedElements = view.elements.sortedBy { it.id } | ||
val systemsInEnterprise = systemsInEnterprise(view) | ||
for (systemInEnterprise in systemsInEnterprise) { | ||
val showEnterpriseBoundary = view.showEnterpriseBoundary | ||
if (showEnterpriseBoundary) { | ||
val enterpriseName = view.elements.map { it.element }.first().model.enterprise.name | ||
boundaryWriter.startEnterpriseBoundary(enterpriseName, writer, view) | ||
} | ||
for (elementView in sortedElements) { | ||
if (elementView.element === systemInEnterprise) { | ||
elementWriter.writeElement(view, elementView.element, writer) | ||
} | ||
} | ||
if (showEnterpriseBoundary) { | ||
boundaryWriter.endEnterpriseBoundary(writer, view) | ||
} else { | ||
writer.writeLine() | ||
} | ||
} | ||
|
||
var elementsWritten = false | ||
|
||
for (elementView in sortedElements) { | ||
elementWriter.writeElement(view, elementView.element, writer) | ||
elementsWritten = true | ||
} | ||
if (elementsWritten) { | ||
writer.writeLine() | ||
} | ||
|
||
relationshipWriter.writeRelationships(view, writer) | ||
|
||
footerWriter.writeFooter(view, writer) | ||
|
||
return createC4Diagram(view, writer.toString()) | ||
} | ||
|
||
private fun systemsInEnterprise(view: ModelView): List<Element> = | ||
view.elements | ||
.map { it.element } | ||
.filter { | ||
(it is SoftwareSystem && it.c4Location == Location.Internal) || (it is Person && it.c4Location == Location.Internal) | ||
} | ||
.toSet() | ||
.sortedBy { it.id } | ||
} |
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
23 changes: 0 additions & 23 deletions
23
src/main/kotlin/com/github/chriskn/structurizrextension/model/Component.kt
This file was deleted.
Oops, something went wrong.
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
47 changes: 47 additions & 0 deletions
47
src/main/kotlin/com/github/chriskn/structurizrextension/model/LocationExtension.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,47 @@ | ||
package com.github.chriskn.structurizrextension.model | ||
|
||
import com.structurizr.model.Container | ||
import com.structurizr.model.Location | ||
import com.structurizr.model.Person | ||
import com.structurizr.model.SoftwareSystem | ||
|
||
private const val LOCATION_PROPERTY = "c4location" | ||
|
||
var SoftwareSystem.c4Location: Location | ||
/** | ||
* Returns the [Location] of the SoftwareSystem. | ||
*/ | ||
get() = Location.valueOf(this.properties.getValue(LOCATION_PROPERTY)) | ||
|
||
/** | ||
* Sets the [Location] of the SoftwareSystem. | ||
*/ | ||
set(location) { | ||
this.addProperty(LOCATION_PROPERTY, location.name) | ||
} | ||
|
||
var Container.c4Location: Location | ||
/** | ||
* Returns the [Location] of the container. | ||
*/ | ||
get() = Location.valueOf(this.properties.getValue(LOCATION_PROPERTY)) | ||
|
||
/** | ||
* Sets the [Location] of the container. | ||
*/ | ||
set(location) { | ||
this.addProperty(LOCATION_PROPERTY, location.name) | ||
} | ||
|
||
var Person.c4Location: Location | ||
/** | ||
* Returns the [Location] of the Component. | ||
*/ | ||
get() = Location.valueOf(this.properties.getValue(LOCATION_PROPERTY)) | ||
|
||
/** | ||
* Sets the [Location] of the Component. | ||
*/ | ||
set(location) { | ||
this.addProperty(LOCATION_PROPERTY, location.name) | ||
} |
Oops, something went wrong.