-
Notifications
You must be signed in to change notification settings - Fork 6
/
domainStory.puml
422 lines (362 loc) · 12 KB
/
domainStory.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
' DomainStory-PlantUML, version 0.3.1
' https://github.com/johthor/DomainStory-PlantUML
' Version
' ##################################
!function DomainStoryVersion()
' This is method is directly copied from C4-PlantUML and only slightly adjusted
' 2 spaces are used as a unique marker, that the release script makes the correct version update
!global $DomainStoryVersion = "0.3.1"
!return $DomainStoryVersion
!end function
' Default Styling
' ##################################
!$storyLayout ?= "left-to-right"
!$textColor ?= "#0b0c10"
!$actorStyle ?= "default"
!$actorScale ?= 1
!$actorColor ?= "#1f2833"
!$objectStyle ?= "default"
!$objectScale ?= 0.8
!$objectColor ?= "#1f2833"
!$boundaryColor ?= "#1f2833"
!$activityColor ?= "#c5c6c7"
!$stepColor ?= "#66fcf1"
!$stepFontSize ?= 16
!$stepFontColor ?= $textColor
!$noteColor ?= "#c5c6c7"
!$noteBorder ?= "#1f2833"
hide stereotypes
skinparam Shadowing false
skinparam DefaultTextAlignment center
skinparam Padding 5
' agent nodes are used for the actors
skinparam agent {
FontColor $textColor
BackgroundColor none
BorderColor none
}
' card nodes are used for the work objects
skinparam card {
FontColor $textColor
BackgroundColor none
BorderColor none
}
skinparam rectangle<<boundary>> {
FontColor $textColor
BackgroundColor none
BorderColor $boundaryColor
BorderStyle dashed
RoundCorner 15
}
skinparam Arrow {
FontColor $textColor
Color $activityColor
}
skinparam note {
FontColor $textColor
BackgroundColor $noteColor
BorderColor $noteBorder
}
' Layout
' ##################################
' in journeys with multiple stories the default top-to-bottom direction
' usually gives better results
!if $storyLayout == "left-to-right"
left to right direction
!else
top to bottom direction
!endif
' Actors
' ##################################
!unquoted procedure Actor($kind, $sprite, $name, $label = "", $color = "", $scale = "", $note = "")
!if $label == ""
!$label = $name
!endif
!if $color == ""
!$color = $actorColor
!endif
!if $scale == ""
!$scale = $actorScale
!endif
agent "<color:$color><$sprite{scale=$scale}></color>\r $label" as $name <<$kind>>
$addNote($name, $note)
!endprocedure
!if %not(%variable_exists("$personSprite"))
!if $actorStyle == "default"
!include <material/account_outline>
!global $personSprite = "$ma_account_outline"
!else
!include <material/account>
!global $personSprite = "$ma_account"
!endif
!endif
!unquoted procedure Person($name, $label = "", $color = "", $scale = "", $note = "")
Actor("Person", "$personSprite", $name, $label, $color, $scale, $note)
!endprocedure
!if %not(%variable_exists("$groupSprite"))
!if $actorStyle == "default"
!include <material/account_multiple_outline>
!global $groupSprite = "$ma_account_multiple_outline"
!else
!include <material/account_multiple>
!global $groupSprite = "$ma_account_multiple"
!endif
!endif
!unquoted procedure Group($name, $label = "", $color = "", $scale = "", $note = "")
Actor("Group", "$groupSprite", $name, $label, $color, $scale, $note)
!endprocedure
!include <material/laptop>
!unquoted procedure System($name, $label = "", $color = "", $scale = "", $note = "")
Actor("System", "$ma_laptop", $name, $label, $color, $scale, $note)
!endprocedure
' Work objects
' ##################################
!unquoted procedure Object($kind, $sprite, $name, $label = "", $color = "", $scale = "", $note = "")
!if $label == ""
!$label = $name
!endif
!if $color == ""
!$color = $objectColor
!endif
!if $scale == ""
!$scale = $objectScale
!endif
card "<color:$color><$sprite{scale=$scale}></color>\r $label" as $name <<$kind>>
$addNote($name, $note)
!endprocedure
!if %not(%variable_exists("$documentSprite"))
!if $objectStyle == "default"
!include <material/file_document>
!global $documentSprite = "$ma_file_document"
!else
!include <material/document>
!global $documentSprite = "$ma_document"
!endif
!endif
!unquoted procedure Document($name, $label = "", $color = "", $scale = "", $note = "")
Object("Document", "$documentSprite", $name, $label, $color, $scale, $note)
!endprocedure
!if %not(%variable_exists("$folderSprite"))
!if $objectStyle == "default"
!include <material/folder_outline>
!global $folderSprite = "$ma_folder_outline"
!else
!include <material/folder>
!global $folderSprite = "$ma_folder"
!endif
!endif
!unquoted procedure Folder($name, $label = "", $color = "", $scale = "", $note = "")
Object("Folder", "$folderSprite", $name, $label, $color, $scale, $note)
!endprocedure
!include <material/phone>
!unquoted procedure Call($name, $label = "", $color = "", $scale = "", $note = "")
Object("Call", "$ma_phone", $name, $label, $color, $scale, $note)
!endprocedure
!if %not(%variable_exists("$emailSprite"))
!if $objectStyle == "default"
!include <material/at>
!global $emailSprite = "$ma_at"
!else
!include <material/email>
!global $emailSprite = "$ma_email"
!endif
!endif
!unquoted procedure Email($name, $label = "", $color = "", $scale = "", $note = "")
Object("Email", "$emailSprite", $name, $label, $color, $scale, $note)
!endprocedure
!if %not(%variable_exists("$conversationSprite"))
!if $objectStyle == "default"
!include <material/message_outline>
!global $conversationSprite = "$ma_message_outline"
!else
!include <material/message>
!global $conversationSprite = "$ma_message"
!endif
!endif
!unquoted procedure Conversation($name, $label = "", $color = "", $scale = "", $note = "")
Object("Conversation", "$conversationSprite", $name, $label, $color, $scale, $note)
!endprocedure
!if %not(%variable_exists("$infoSprite"))
!if $objectStyle == "default"
!include <material/information_outline>
!global $infoSprite = "$ma_information_outline"
!else
!include <material/information>
!global $infoSprite = "$ma_information"
!endif
!endif
!unquoted procedure Info($name, $label = "", $color = "", $scale = "", $note = "")
Object("Info", "$infoSprite", $name, $label, $color, $scale, $note)
!endprocedure
' Boundaries
' ##################################
!unquoted procedure Boundary($name, $label = "", $note = "")
!if $label == ""
!$label = $name
!endif
!if $note != ""
rectangle $name
$addBoundaryNote($name, $note)
!endif
rectangle "==$label" <<Boundary>> as $name
!endprocedure
' Activities
' ##################################
!global $stepCounter = 0
!global $objectCounter = 0
!unquoted procedure activity($step, $subject, $predicate, $object, $post = "", $target = "", $objectArr = "", $targetArr = "", $color = "", $scale = "", $note = "")
' activity direction
!if $objectArr == "" && $targetArr == ""
!$vPosition = %strpos($step, "v")
!$ltPosition = %strpos($step, "<")
!$caretPosition = %strpos($step, "^")
!$gtPosition = %strpos($step, ">")
!if $gtPosition > -1
!$step = %substr($step, 0, $gtPosition)
!if $storyLayout == "left-to-right"
!$objectArr = "-->"
!else
!$objectArr = "->"
!endif
!elseif $ltPosition > -1
!$step = %substr($step, 0, $ltPosition)
!if $storyLayout == "left-to-right"
!$objectArr = "<--"
!else
!$objectArr = "<-"
!endif
!elseif $vPosition > -1
!$step = %substr($step, 0, $vPosition)
!if $storyLayout == "left-to-right"
!$objectArr = "->"
!else
!$objectArr = "-->"
!endif
!elseif $caretPosition > -1
!$step = %substr($step, 0, $caretPosition)
!if $storyLayout == "left-to-right"
!$objectArr = "<-"
!else
!$objectArr = "<--"
!endif
!endif
!endif
!if $objectArr == ""
!$objectArr = "-->"
!endif
!if $targetArr == ""
!$targetArr = $objectArr
!endif
' ensure the object exists / create one dynamically
!$object = $ensureObjectExists($object, $color, $scale)
' create connecting arrows
$arrow($subject, $object, $objectArr) : $stepLabel($step) $predicate
' Handle possible second arrow between object and target
' ensure the target exists / create one dynamically
!$target = $ensureObjectExists($target, $color, $scale)
!if $post != "" && $post != "_"
!if $target != "" && $target != "_"
$arrow($object, $target, $targetArr) : $post
!else
$arrow($object, $post, $targetArr)
!endif
!endif
$addNote($object, $note)
!endprocedure
' Helper
' ##################################
!procedure $addNote($target, $note)
!if $note != ""
!$noteDir = %substr($note, 0, 1)
!if $noteDir == "v"
note bottom of $target : %substr($note, 1)
!elseif $noteDir == "<"
note left of $target : %substr($note, 1)
!elseif $noteDir == "^"
note top of $target : %substr($note, 1)
!elseif $noteDir == ">"
note right of $target : %substr($note, 1)
!else
!if $storyLayout == "left-to-right"
note right of $target : $note
!else
note bottom of $target : $note
!endif
!endif
!endif
!endprocedure
!procedure $addBoundaryNote($boundary, $note)
!if $note != ""
!$noteDir = %substr($note, 0, 1)
!if $noteDir == "v"
!if $storyLayout == "left-to-right"
note top of $boundary : %substr($note, 1)
!else
note bottom of $boundary : %substr($note, 1)
!endif
!elseif $noteDir == "<"
note left of $boundary : %substr($note, 1)
!elseif $noteDir == "^"
!if $storyLayout == "left-to-right"
note bottom of $boundary : %substr($note, 1)
!else
note top of $boundary : %substr($note, 1)
!endif
!elseif $noteDir == ">"
note right of $boundary : %substr($note, 1)
!else
note right of $boundary : $note
!endif
!endif
!endprocedure
!function $ensureObjectExists($object, $color = "", $scale = "")
!$objectName = $object
!$objectSeparator = %strpos($object, ":")
!if $objectSeparator > -1
!$objectCounter = %intval($objectCounter) + 1
!$objectKind = %substr($object, 0, $objectSeparator)
!$objectLabel = %substr($object, $objectSeparator + 1)
!$objectName = $objectKind + $objectCounter
%invoke_procedure($objectKind, $objectName, $objectLabel, $color, $scale)
!endif
!return $objectName
!endfunction
!function $arrow($from, $to, $spec)
!if %substr($spec, 0, 1) == "<"
!return $to + " " + $spec + " " + $from
!else
!return $from + " " + $spec + " " + $to
!endif
!endfunction
!function $computeStep($step)
!if $step == "_"
!$stepCounter = $stepCounter + 1
!return $stepCounter
!elseif $step == "|"
!return $stepCounter
!elseif $step == "."
!return ""
!elseif %substr($step, 0, 1) == "="
!$stepCounter = %intval(%substr($step, 1))
!return $stepCounter
!else
!return $step
!endif
!endfunction
!function $stepLabel($step)
!$result = ""
!$stepNum = $computeStep($step)
!if $stepNum != ""
!$result = "(" + $stepNum + ")"
!if ($stepColor != "")
!$result = "<back:" + $stepColor + ">" + $result + "</back>"
!endif
!if ($stepFontColor != "")
!$result = "<color:" + $stepFontColor + ">" + $result + "</color>"
!endif
!if ($stepFontSize != "")
!$result = "<size:" + $stepFontSize + ">" + $result + "</size>"
!endif
!endif
!return $result
!endfunction