Skip to content

Commit cb57d23

Browse files
structurizr-export: PlantUML exporters - adds order number to relationships in sequence diagrams. Closes #431.
1 parent 837fe69 commit cb57d23

File tree

5 files changed

+30
-37
lines changed

5 files changed

+30
-37
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- structurizr-export: Removes support for deprecated enterprise and location concepts.
2424
- structurizr-export: PlantUML exporters - replaces skinparams with styles.
2525
- structurizr-export: PlantUML exporters - adds support for dark mode exports.
26+
- structurizr-export: PlantUML exporters - adds order number to relationships in sequence diagrams.
2627
- structurizr-export: StructurizrPlantUMLExporter - adds technology to sequence diagrams (https://github.com/structurizr/java/issues/425)
2728
- structurizr-import: Adds support for `plantuml.inline`, `mermaid.inline`, `kroki.inline`, and `image.inline` properties to inline the resulting PNG/SVG file into the workspace.
2829
- structurizr-inspection: Adds a way to disable inspections via a workspace property named `structurizr.inspection` (`false` to disable).

structurizr-export/src/main/java/com/structurizr/export/plantuml/C4PlantUMLExporter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,8 @@ protected void writeRelationship(ModelView view, RelationshipView relationshipVi
611611

612612
String description = "";
613613

614-
if (renderAsSequenceDiagram(view)) {
615-
// do nothing - sequence diagrams don't need the order
616-
} else {
617-
if (!StringUtils.isNullOrEmpty(relationshipView.getOrder())) {
618-
description = relationshipView.getOrder() + ". ";
619-
}
614+
if (!StringUtils.isNullOrEmpty(relationshipView.getOrder())) {
615+
description = relationshipView.getOrder() + ": ";
620616
}
621617

622618
description += (hasValue(relationshipView.getDescription()) ? relationshipView.getDescription() : hasValue(relationshipView.getRelationship().getDescription()) ? relationshipView.getRelationship().getDescription() : "");

structurizr-export/src/main/java/com/structurizr/export/plantuml/StructurizrPlantUMLExporter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,8 @@ protected void writeRelationship(ModelView view, RelationshipView relationshipVi
432432
String description = "";
433433
String technology = relationship.getTechnology();
434434

435-
if (renderAsSequenceDiagram(view)) {
436-
// do nothing - sequence diagrams don't need the order
437-
} else {
438-
if (!StringUtils.isNullOrEmpty(relationshipView.getOrder())) {
439-
description = relationshipView.getOrder() + ". ";
440-
}
435+
if (!StringUtils.isNullOrEmpty(relationshipView.getOrder())) {
436+
description = relationshipView.getOrder() + ": ";
441437
}
442438

443439
description += (hasValue(relationshipView.getDescription()) ? relationshipView.getDescription() : hasValue(relationshipView.getRelationship().getDescription()) ? relationshipView.getRelationship().getDescription() : "");

structurizr-export/src/test/java/com/structurizr/export/plantuml/C4PlantUMLDiagramExporterTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ public void test_BigBankPlcExample() throws Exception {
275275
Container(InternetBankingSystem.SinglePageApplication, "Single-Page Application", $techn="JavaScript and Angular", $descr="Provides all of the Internet banking functionality to customers via their web browser.", $tags="Container,Web Browser", $link="")
276276
ContainerDb(InternetBankingSystem.Database, "Database", $techn="Oracle Database Schema", $descr="Stores user registration information, hashed authentication credentials, access logs, etc.", $tags="Container,Database", $link="")
277277
278-
Rel(InternetBankingSystem.SinglePageApplication, InternetBankingSystem.APIApplication.SignInController, "1. Submits credentials to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
279-
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.APIApplication.SecurityComponent, "2. Validates credentials using", $techn="", $tags="Relationship", $link="")
280-
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.Database, "3. select * from users where username = ?", $techn="SQL/TCP", $tags="Relationship", $link="")
281-
Rel(InternetBankingSystem.Database, InternetBankingSystem.APIApplication.SecurityComponent, "4. Returns user data to", $techn="SQL/TCP", $tags="Relationship", $link="")
282-
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.APIApplication.SignInController, "5. Returns true if the hashed password matches", $techn="", $tags="Relationship", $link="")
283-
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.SinglePageApplication, "6. Sends back an authentication token to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
278+
Rel(InternetBankingSystem.SinglePageApplication, InternetBankingSystem.APIApplication.SignInController, "1: Submits credentials to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
279+
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.APIApplication.SecurityComponent, "2: Validates credentials using", $techn="", $tags="Relationship", $link="")
280+
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.Database, "3: select * from users where username = ?", $techn="SQL/TCP", $tags="Relationship", $link="")
281+
Rel(InternetBankingSystem.Database, InternetBankingSystem.APIApplication.SecurityComponent, "4: Returns user data to", $techn="SQL/TCP", $tags="Relationship", $link="")
282+
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.APIApplication.SignInController, "5: Returns true if the hashed password matches", $techn="", $tags="Relationship", $link="")
283+
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.SinglePageApplication, "6: Sends back an authentication token to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
284284
285285
SHOW_LEGEND(true)
286286
hide stereotypes
@@ -470,12 +470,12 @@ public void test_BigBankPlcExample() throws Exception {
470470
Component(InternetBankingSystem.APIApplication.SecurityComponent, "Security Component", $techn="Spring Bean", $descr="Provides functionality related to signing in, changing passwords, etc.", $tags="Component", $link="")
471471
ContainerDb(InternetBankingSystem.Database, "Database", $techn="Oracle Database Schema", $descr="Stores user registration information, hashed authentication credentials, access logs, etc.", $tags="Container,Database", $link="")
472472
473-
Rel(InternetBankingSystem.SinglePageApplication, InternetBankingSystem.APIApplication.SignInController, "Submits credentials to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
474-
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.APIApplication.SecurityComponent, "Validates credentials using", $techn="", $tags="Relationship", $link="")
475-
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.Database, "select * from users where username = ?", $techn="SQL/TCP", $tags="Relationship", $link="")
476-
Rel(InternetBankingSystem.Database, InternetBankingSystem.APIApplication.SecurityComponent, "Returns user data to", $techn="SQL/TCP", $tags="Relationship", $link="")
477-
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.APIApplication.SignInController, "Returns true if the hashed password matches", $techn="", $tags="Relationship", $link="")
478-
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.SinglePageApplication, "Sends back an authentication token to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
473+
Rel(InternetBankingSystem.SinglePageApplication, InternetBankingSystem.APIApplication.SignInController, "1: Submits credentials to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
474+
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.APIApplication.SecurityComponent, "2: Validates credentials using", $techn="", $tags="Relationship", $link="")
475+
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.Database, "3: select * from users where username = ?", $techn="SQL/TCP", $tags="Relationship", $link="")
476+
Rel(InternetBankingSystem.Database, InternetBankingSystem.APIApplication.SecurityComponent, "4: Returns user data to", $techn="SQL/TCP", $tags="Relationship", $link="")
477+
Rel(InternetBankingSystem.APIApplication.SecurityComponent, InternetBankingSystem.APIApplication.SignInController, "5: Returns true if the hashed password matches", $techn="", $tags="Relationship", $link="")
478+
Rel(InternetBankingSystem.APIApplication.SignInController, InternetBankingSystem.SinglePageApplication, "6: Sends back an authentication token to", $techn="JSON/HTTPS", $tags="Relationship", $link="")
479479
480480
SHOW_LEGEND(true)
481481
hide stereotypes

structurizr-export/src/test/java/com/structurizr/export/plantuml/StructurizrPlantUMLDiagramExporterTests.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public void dynamicView_CollaborationStyle_NoStyling_Light() {
526526
rectangle "==A\\n<size:16>[Software System]</size>" <<Element-RWxlbWVudA==>> as A
527527
rectangle "==B\\n<size:16>[Software System]</size>" <<Element-RWxlbWVudA==>> as B
528528
529-
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
529+
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
530530
531531
@enduml""", diagram.getDefinition());
532532
}
@@ -590,8 +590,8 @@ public void dynamicView_CollaborationStyle_Frames() {
590590
rectangle "==C\\n<size:16>[Software System]</size>" <<Element-RWxlbWVudA==>> as C
591591
hide C
592592
593-
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
594-
B --> C <<Relationship-UmVsYXRpb25zaGlw>> : "2. Uses"
593+
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
594+
B --> C <<Relationship-UmVsYXRpb25zaGlw>> : "2: Uses"
595595
596596
@enduml""", frames.get(0).getDefinition());
597597

@@ -635,8 +635,8 @@ public void dynamicView_CollaborationStyle_Frames() {
635635
rectangle "==B\\n<size:16>[Software System]</size>" <<Element-RWxlbWVudA==>> as B
636636
rectangle "==C\\n<size:16>[Software System]</size>" <<Element-RWxlbWVudA==>> as C
637637
638-
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
639-
B --> C <<Relationship-UmVsYXRpb25zaGlw>> : "2. Uses"
638+
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
639+
B --> C <<Relationship-UmVsYXRpb25zaGlw>> : "2: Uses"
640640
641641
@enduml""", frames.get(1).getDefinition());
642642
}
@@ -1511,7 +1511,7 @@ public void dynamicView_ExternalContainers() {
15111511
rectangle "==Container 2\\n<size:16>[Container]</size>" <<Element-RWxlbWVudA==>> as SoftwareSystem2.Container2
15121512
}
15131513
1514-
SoftwareSystem1.Container1 --> SoftwareSystem2.Container2 <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
1514+
SoftwareSystem1.Container1 --> SoftwareSystem2.Container2 <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
15151515
15161516
@enduml""", diagram.getDefinition());
15171517
}
@@ -1603,8 +1603,8 @@ public void dynamicView_ExternalComponents() {
16031603
rectangle "==Component 3\\n<size:16>[Component]</size>" <<Element-RWxlbWVudA==>> as SoftwareSystem2.Container2.Component3
16041604
}
16051605
1606-
SoftwareSystem1.Container1.Component1 --> SoftwareSystem1.Container1.Component2 <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
1607-
SoftwareSystem1.Container1.Component2 --> SoftwareSystem2.Container2.Component3 <<Relationship-UmVsYXRpb25zaGlw>> : "2. Uses"
1606+
SoftwareSystem1.Container1.Component1 --> SoftwareSystem1.Container1.Component2 <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
1607+
SoftwareSystem1.Container1.Component2 --> SoftwareSystem2.Container2.Component3 <<Relationship-UmVsYXRpb25zaGlw>> : "2: Uses"
16081608
16091609
@enduml""", diagram.getDefinition());
16101610
}
@@ -1725,8 +1725,8 @@ public void dynamicView_ExternalComponentsAndSoftwareSystemBoundariesIncluded()
17251725
17261726
}
17271727
1728-
SoftwareSystem1.Container1.Component1 --> SoftwareSystem1.Container1.Component2 <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
1729-
SoftwareSystem1.Container1.Component2 --> SoftwareSystem2.Container2.Component3 <<Relationship-UmVsYXRpb25zaGlw>> : "2. Uses"
1728+
SoftwareSystem1.Container1.Component1 --> SoftwareSystem1.Container1.Component2 <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
1729+
SoftwareSystem1.Container1.Component2 --> SoftwareSystem2.Container2.Component3 <<Relationship-UmVsYXRpb25zaGlw>> : "2: Uses"
17301730
17311731
@enduml""", diagram.getDefinition());
17321732
}
@@ -2018,7 +2018,7 @@ public void dynamicView_UnscopedWithGroups() {
20182018
}
20192019
20202020
2021-
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
2021+
A --> B <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
20222022
20232023
@enduml""", diagram.getDefinition());
20242024
}
@@ -2132,7 +2132,7 @@ public void dynamicView_SoftwareSystemScopedWithGroups() {
21322132
21332133
}
21342134
2135-
A.A --> B.B <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
2135+
A.A --> B.B <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
21362136
21372137
@enduml""", diagram.getDefinition());
21382138
}
@@ -2248,7 +2248,7 @@ public void dynamicView_ContainerScopedWithGroups() {
22482248
22492249
}
22502250
2251-
A.A.A --> B.B.B <<Relationship-UmVsYXRpb25zaGlw>> : "1. Uses"
2251+
A.A.A --> B.B.B <<Relationship-UmVsYXRpb25zaGlw>> : "1: Uses"
22522252
22532253
@enduml""", diagram.getDefinition());
22542254
}

0 commit comments

Comments
 (0)