File tree Expand file tree Collapse file tree 3 files changed +54
-3
lines changed
main/java/com/structurizr/export/ilograph
test/java/com/structurizr/export/ilograph Expand file tree Collapse file tree 3 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 12
12
- structurizr-dsl: Adds a ` !relationships ` keyword that can be used to find a set of relationships via an expression.
13
13
- structurizr-dsl: Adds a DSL wrapper around the ` structurizr-component ` component finder.
14
14
- structurizr-dsl: Adds support for local theme files to be specified via ` theme ` (https://github.com/structurizr/java/issues/331 ).
15
- - structurizr-export: Adds support for icons to the Ilograph exporter.
15
+ - structurizr-export: Adds support for icons to the Ilograph exporter (https://github.com/structurizr/java/issues/332 ).
16
+ - structurizr-export: Adds support for imports to the Ilograph exporter (https://github.com/structurizr/java/issues/332 ).
16
17
17
18
## 2.2.0 (2nd July 2024)
18
19
Original file line number Diff line number Diff line change 16
16
*/
17
17
public class IlographExporter extends AbstractWorkspaceExporter {
18
18
19
+ public static final String ILOGRAPH_IMPORTS = "ilograph.imports" ;
19
20
public static final String ILOGRAPH_ICON = "ilograph.icon" ;
20
21
21
22
public WorkspaceExport export (Workspace workspace ) {
22
23
IndentingWriter writer = new IndentingWriter ();
24
+
25
+ // Ilograph imports can be specified in the form:
26
+ //
27
+ // AWS:ilograph/aws
28
+ //
29
+ // Which gets exported as:
30
+ //
31
+ // imports:
32
+ // - from: ilograph/aws
33
+ // namespace: AWS
34
+ String commaSeparatedListOfImports = workspace .getProperties ().get (ILOGRAPH_IMPORTS );
35
+ if (!StringUtils .isNullOrEmpty (commaSeparatedListOfImports )) {
36
+ writer .writeLine ("imports:" );
37
+
38
+ String [] ilographImports = commaSeparatedListOfImports .split ("," );
39
+ for (String ilographImport : ilographImports ) {
40
+ String [] parts = ilographImport .split (":" );
41
+ if (parts .length == 2 ) {
42
+ String namespace = parts [0 ];
43
+ String from = parts [1 ];
44
+
45
+ writer .writeLine ("- from: " + from );
46
+ writer .indent ();
47
+ writer .writeLine ("namespace: " + namespace );
48
+ writer .outdent ();
49
+ }
50
+ }
51
+ writer .writeLine ();
52
+ }
53
+
23
54
writer .writeLine ("resources:" );
24
55
writer .indent ();
25
56
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public void test_BigBankPlcExample() throws Exception {
26
26
}
27
27
28
28
@ Test
29
- public void test_AmazonWebServicesExample () throws Exception {
29
+ void test_AmazonWebServicesExample () throws Exception {
30
30
Workspace workspace = WorkspaceUtils .loadWorkspaceFromJson (new File ("./src/test/resources/structurizr-54915-workspace.json" ));
31
31
workspace .getViews ().getConfiguration ().getStyles ().addElementStyle ("Amazon Web Services - Route 53" ).addProperty (IlographExporter .ILOGRAPH_ICON , "AWS/Networking/Route-53.svg" );
32
32
@@ -39,7 +39,7 @@ public void test_AmazonWebServicesExample() throws Exception {
39
39
}
40
40
41
41
@ Test
42
- public void test_renderCustomElements () throws Exception {
42
+ void test_renderCustomElements () {
43
43
Workspace workspace = new Workspace ("Name" , "Description" );
44
44
Model model = workspace .getModel ();
45
45
@@ -71,4 +71,23 @@ public void test_renderCustomElements() throws Exception {
71
71
" color: \" #707070\" \n " , export .getDefinition ());
72
72
}
73
73
74
+ @ Test
75
+ void test_imports () {
76
+ Workspace workspace = new Workspace ("Name" , "Description" );
77
+ workspace .addProperty (IlographExporter .ILOGRAPH_IMPORTS , "NAMESPACE1:path1,NAMESPACE2:path2" );
78
+
79
+ WorkspaceExport export = new IlographExporter ().export (workspace );
80
+ assertEquals ("""
81
+ imports:
82
+ - from: path1
83
+ namespace: NAMESPACE1
84
+ - from: path2
85
+ namespace: NAMESPACE2
86
+
87
+ resources:
88
+ perspectives:
89
+ - name: Static Structure
90
+ relations:""" , export .getDefinition ());
91
+ }
92
+
74
93
}
You can’t perform that action at this time.
0 commit comments