Skip to content

Commit 33f6d27

Browse files
author
Maxim Muratov
committed
Пример формирования L1 контекста
1 parent 5cea95b commit 33f6d27

3 files changed

Lines changed: 234 additions & 0 deletions

File tree

src/l1_drilldown/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Пример формирования L1 контекста
2+
3+
**Цель примера:** Представить пример контекстной диаграммы

src/l1_drilldown/dochub.yaml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
datasets:
2+
arch.levels.l1:
3+
source: >
4+
(
5+
$components := $.components;
6+
$links:= $components.$spread().{
7+
"src_id": $keys()[0],
8+
"src": $.*
9+
}[$exists($lookup({"system":{}, "actor": {}, "database": {}}, src.entity))].(
10+
$src_id:= src_id;
11+
src.links.({
12+
"src": $src_id,
13+
"dst": $.id,
14+
"direction": $.direction,
15+
"title": $.title
16+
})
17+
);
18+
19+
$srcs := $distinct($links.(
20+
$.src
21+
));
22+
$links := $srcs.(
23+
$src_id := $;
24+
$dsts := $distinct($links[src=$src_id].(dst));
25+
$dsts.(
26+
$dst_id := $;
27+
$titles := $append([], $links[src=$src_id and dst=$dst_id].(
28+
$.title
29+
));
30+
{
31+
"src": $src_id,
32+
"dst": $dst_id,
33+
"title": $titles,
34+
"direction": ($links[src=$src_id and dst=$dst_id and (direction = "<->" or direction = "<--")] ? "<" : "-") &
35+
"-" &
36+
($links[src=$src_id and dst=$dst_id and (direction = "<->" or direction = "-->")] ? ">" : "-")
37+
}
38+
)
39+
);
40+
$map:= $mergedeep($links.({
41+
$.src & "#" & $.dst : $
42+
}));
43+
$dublicates:= $distinct($map.$spread().{
44+
"link": $.*
45+
}.(
46+
$exists($lookup($map, link.dst & "#" & link.src)) ? ($join($sort([link.src, link.dst]),"#"))
47+
));
48+
$links := $links.(
49+
$.src & "#" & $.dst in $dublicates ? (
50+
$remote := $lookup($map, $.dst & "#" & $.src);
51+
$titles := $append($.title, $remote.title);
52+
{
53+
"src": $.src,
54+
"dst": $.dst,
55+
"title": $count($titles) > 1 ? (
56+
"[[/docs/arch.tech.flows.group?flow=" & $join($titles, ",") & " #]]"
57+
):(
58+
"[[/docs/arch.tech.flows.single?flow=" & $titles[0] & " " & $titles[0] & "]]"
59+
),
60+
"direction": (($remote.direction = "<->" or $remote.direction = "-->" or $.direction = "<->" or $.direction = "<--") ? "<" : "-") &
61+
"-" &
62+
(($remote.direction = "<->" or $remote.direction = "<--" or $.direction = "<->" or $.direction = "-->") ? ">" : "-")
63+
}) : (
64+
$not($.dst & "#" & $.src in $dublicates) ? (
65+
$merge ([$,
66+
{
67+
"title": $count($.title) > 1 ? (
68+
"[[/docs/arch.tech.flows.group?flow=" & $join($.title, ",") & " #]]"
69+
):(
70+
"[[/docs/arch.tech.flows.single?flow=" & $.title[0] & " " & $.title[0] & "]]"
71+
)
72+
}
73+
]);
74+
)
75+
)
76+
);
77+
$components := $mergedeep($components.$spread().{
78+
"src_id": $keys()[0],
79+
"src": $.*
80+
}.(
81+
$exists($lookup({"system":{}, "actor": {}, "database": {}}, src.entity)) and $exists(src.links) ? (
82+
{ src_id: $merge([src, { "links" : []}])}
83+
):(
84+
{ src_id: src}
85+
)
86+
));
87+
$srcs := $distinct($links.(
88+
$.src
89+
));
90+
$links := $mergedeep($srcs.(
91+
$id := $;
92+
{
93+
$id : {
94+
"links": $append([],$links[src = $id].(
95+
{
96+
"id": $.dst,
97+
"title": $.title,
98+
"direction": $.direction
99+
}
100+
))
101+
}
102+
}
103+
));
104+
$merge([$, {"components": $mergedeep([$components, $links])}]);
105+
106+
)
107+
arch.tech.flows:
108+
source: >
109+
(
110+
$components:= $.components;
111+
$.components.$spread().{
112+
"id": $keys()[0],
113+
"component": $.*
114+
}[$exists($lookup({"system": {}, "actor": {}, "database": {}}, component.entity))].(
115+
$source:= component.title;
116+
$exists(component.links) ? (
117+
component.links.(
118+
{
119+
"source": $source,
120+
"destination": $lookup($components, $.id).title,
121+
"title": $.title,
122+
"description": $.description,
123+
"direction" : $.direction
124+
})
125+
)
126+
)
127+
)
128+
components:
129+
systems.a:
130+
entity: system
131+
title: Система 1
132+
links:
133+
- id: systems.b
134+
description: Это ссылка П1
135+
direction: -->
136+
title: П1
137+
- id: systems.b
138+
description: Это ссылка П3
139+
direction: -->
140+
title: П3
141+
- id: systems.b
142+
description: Это ссылка П4
143+
direction: <--
144+
title: П4
145+
systems.b:
146+
entity: system
147+
title: Система 2
148+
links:
149+
- id: systems.a
150+
description: Это ссылка П2
151+
direction: -->
152+
title: П2
153+
- id: systems.a
154+
description: Это ссылка П5
155+
direction: -->
156+
title: П5
157+
- id: systems.c
158+
description: Это ссылка П6
159+
direction: -->
160+
title: П6
161+
systems.c:
162+
entity: system
163+
title: Система 3
164+
links:
165+
- id: systems.a
166+
description: Это ссылка П7
167+
direction: -->
168+
title: П7
169+
- id: systems.d
170+
description: Это ссылка П9
171+
direction: -->
172+
title: П9
173+
systems.d:
174+
entity: system
175+
title: Система 4
176+
links:
177+
- id: systems.c
178+
description: Это ссылка П8
179+
direction: <->
180+
title: П8
181+
contexts:
182+
example:
183+
title: L1
184+
location: L1
185+
extra-links: true
186+
source: arch.levels.l1
187+
components:
188+
- systems.*
189+
docs:
190+
arch.tech.flows.single:
191+
type: markdown
192+
template: single.md
193+
source: >
194+
(
195+
$.components.*.links[title=$params.flow]
196+
)
197+
198+
arch.tech.flows.group:
199+
type: table
200+
headers:
201+
- value: title
202+
text: Название потока
203+
sortable: true
204+
link: link
205+
align: left
206+
- value: description
207+
text: Описание
208+
align: left
209+
- value: source
210+
text: Система источник
211+
align: left
212+
sortable: true
213+
- value: destination
214+
text: Система приемник
215+
align: left
216+
sortable: true
217+
- value: direction
218+
text: Направление
219+
align: left
220+
sortable: true
221+
origin: arch.tech.flows
222+
source: >
223+
(
224+
$[title in $split($params.flow, ",")].(
225+
$merge([$, {
226+
"link": "/docs/arch.tech.flows.single?flow="&$.title}]
227+
)
228+
)
229+
)
230+

src/l1_drilldown/single.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Описание: {{#description}} {{.}} {{/description}}

0 commit comments

Comments
 (0)