Alef1986 commited on
Commit
b27f3da
·
1 Parent(s): 5dcb35a

chore: migrate to GitHub, replace with lightweight Docker stub

Browse files
.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ISO15288_Archi_Import.xml DELETED
The diff for this file is too large to render. See raw diff
 
README.md DELETED
@@ -1,19 +0,0 @@
1
- ---
2
- title: ISO Model Analysis
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: Prototype for process model analysis
12
- ---
13
-
14
- # Welcome to Streamlit!
15
-
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
-
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app_det.py DELETED
@@ -1,77 +0,0 @@
1
- import os
2
- import streamlit as st
3
- from parser import load_and_parse_xml
4
- import case_manager
5
-
6
- st.set_page_config(page_title="ISO 15288 Analyzer", layout="wide")
7
-
8
- st.markdown("""
9
- <style>
10
- .main .block-container { max-width: 100% !important; padding: 1rem 1rem 0 1rem !important; }
11
- iframe { width: 100% !important; height: 85vh !important; border: 1px solid #ccc; border-radius: 8px; }
12
- header { visibility: hidden; }
13
- div.row-widget.stRadio { margin-bottom: -5px; }
14
- </style>
15
- """, unsafe_allow_html=True)
16
-
17
- st.title("ISO 15288: Architecture Analyzer")
18
-
19
- mode = st.radio(
20
- "Select analysis scenario:",
21
- (
22
- "Case 1: Interface exchange between selected processes",
23
- "Case 2: Shortest DATA FLOW path (Directed)",
24
- "Case 3: Closest STRUCTURAL connection (Undirected)",
25
- "Case 4: All possible DATA FLOW paths (Directed)",
26
- "Case 5: Process Neighborhood & Internal Steps (Subgraphs)",
27
- "Case 6: Shortest connection between Business Objects (Undirected)",
28
- "Case 7: N2 Chart Simulation (Process Inputs & Outputs)"
29
- )
30
- )
31
-
32
- # Expand to 3 columns to accommodate the new checkbox
33
- col_opt1, col_opt2, col_opt3 = st.columns(3)
34
- with col_opt1:
35
- use_hierarchy = st.checkbox("Include derived connections (Whole-Part, Specialization hierarchy)", value=True)
36
- with col_opt2:
37
- connect_border_objects = st.checkbox("Show relationships between boundary objects on diagram", value=True)
38
- with col_opt3:
39
- # New checkbox for the meta-level
40
- include_enablers = st.checkbox("Include Enablers and Controls", value=False)
41
-
42
- try:
43
- current_script_dir = os.path.dirname(os.path.abspath(__file__))
44
- xml_file_path = os.path.join(current_script_dir, "ISO15288_Archi_Import.xml")
45
-
46
- # Pass the checkbox state to the parser
47
- G_full, G_direct, processes, business_objects = load_and_parse_xml(xml_file_path, include_enablers)
48
- sorted_process_names = sorted(list(processes.values()))
49
- sorted_object_names = sorted(list(business_objects.values()))
50
- except FileNotFoundError:
51
- # Получаем список всех файлов в директории скрипта
52
- files_in_dir = os.listdir(current_script_dir)
53
-
54
- st.error(f"Файл 'ISO15288_Archi_Import.xml' не найден.")
55
- st.warning(f"Скрипт искал его по пути: {xml_file_path}")
56
- st.info(f"Фактическое содержимое папки {current_script_dir}:")
57
- st.write(files_in_dir) # Выведет список файлов прямо на экран Streamlit
58
- st.stop()
59
-
60
- # Build the global context to pass to the cases
61
- ctx = {
62
- "G_full": G_full,
63
- "G_active": G_full if use_hierarchy else G_direct,
64
- "U_active": (G_full if use_hierarchy else G_direct).to_undirected(),
65
- "processes": processes,
66
- "business_objects": business_objects,
67
- "sorted_process_names": sorted_process_names,
68
- "sorted_object_names": sorted_object_names,
69
- "use_hierarchy": use_hierarchy,
70
- "connect_border_objects": connect_border_objects,
71
- "include_enablers": include_enablers # Added to the context for potential use within cases
72
- }
73
-
74
- st.markdown("---")
75
-
76
- # Pass execution to the router
77
- case_manager.run_case(mode, ctx)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
case_manager.py DELETED
@@ -1,17 +0,0 @@
1
- from cases import case_1, case_2, case_3, case_4, case_5, case_6, case_7
2
-
3
- def run_case(mode, ctx):
4
- if mode.startswith("Case 1"):
5
- case_1.run(ctx)
6
- elif mode.startswith("Case 2"):
7
- case_2.run(ctx)
8
- elif mode.startswith("Case 3"):
9
- case_3.run(ctx)
10
- elif mode.startswith("Case 4"):
11
- case_4.run(ctx)
12
- elif mode.startswith("Case 5"):
13
- case_5.run(ctx)
14
- elif mode.startswith("Case 6"):
15
- case_6.run(ctx)
16
- elif mode.startswith("Case 7"):
17
- case_7.run(ctx)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/__pycache__/case_1.cpython-314.pyc DELETED
Binary file (4.58 kB)
 
cases/__pycache__/case_2.cpython-314.pyc DELETED
Binary file (2.7 kB)
 
cases/__pycache__/case_3.cpython-314.pyc DELETED
Binary file (2.75 kB)
 
cases/__pycache__/case_4.cpython-314.pyc DELETED
Binary file (3.02 kB)
 
cases/__pycache__/case_5.cpython-314.pyc DELETED
Binary file (3.59 kB)
 
cases/__pycache__/case_6.cpython-314.pyc DELETED
Binary file (2.74 kB)
 
cases/__pycache__/case_7.cpython-314.pyc DELETED
Binary file (11.4 kB)
 
cases/case_1.py DELETED
@@ -1,50 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, U_active, processes = ctx["G_active"], ctx["U_active"], ctx["processes"]
8
- sorted_process_names = ctx["sorted_process_names"]
9
-
10
- st.write("Select 2 to 5 processes. The script will find objects they exchange data through.")
11
- selected_names = st.multiselect("Select processes:", sorted_process_names, max_selections=5)
12
-
13
- if st.button("Generate Diagram") and len(selected_names) >= 2:
14
- selected_ids = [k for k, v in processes.items() if v in selected_names]
15
- nodes_to_draw, edges_to_draw = set(selected_ids), []
16
-
17
- def safe_add_edge(u, v):
18
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse':
19
- edges_to_draw.append((u, v, G_active[u][v]))
20
-
21
- cutoff = 4 if ctx["use_hierarchy"] else 2
22
-
23
- for i in range(len(selected_ids)):
24
- for j in range(i + 1, len(selected_ids)):
25
- p1, p2 = selected_ids[i], selected_ids[j]
26
- if G_active.has_edge(p1, p2): safe_add_edge(p1, p2)
27
- if G_active.has_edge(p2, p1): safe_add_edge(p2, p1)
28
-
29
- try:
30
- paths = list(nx.all_simple_paths(U_active, p1, p2, cutoff=cutoff))
31
- for path in paths:
32
- if len(path) > 2:
33
- is_valid = all('BusinessProcess' not in U_active.nodes[n].get('type', '') and 'BusinessFunction' not in U_active.nodes[n].get('type', '') for n in path[1:-1])
34
- if is_valid:
35
- nodes_to_draw.update(path)
36
- for k in range(len(path)-1):
37
- u, v = path[k], path[k+1]
38
- if G_active.has_edge(u, v): safe_add_edge(u, v)
39
- elif G_active.has_edge(v, u): safe_add_edge(v, u)
40
- except nx.NetworkXNoPath:
41
- pass
42
-
43
- if len(nodes_to_draw) == len(selected_ids) and not edges_to_draw:
44
- st.warning("No links or shared exchange objects found between these processes.")
45
- else:
46
- st.success("Exchange interfaces found!")
47
- if ctx["connect_border_objects"]:
48
- edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
49
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_to_draw, edges_to_draw)
50
- render_mermaid(mermaid_code, json_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/case_2.py DELETED
@@ -1,26 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, processes = ctx["G_active"], ctx["processes"]
8
-
9
- st.write("Finds the shortest valid data sequence (respecting Input/Output directions).")
10
- col1, col2 = st.columns(2)
11
- with col1: p1_name = st.selectbox("Process A (From):", ctx["sorted_process_names"], key="c2_p1")
12
- with col2: p2_name = st.selectbox("Process B (To):", ctx["sorted_process_names"], key="c2_p2")
13
-
14
- if st.button("Generate Diagram") and p1_name != p2_name:
15
- p1_id = [k for k, v in processes.items() if v == p1_name][0]
16
- p2_id = [k for k, v in processes.items() if v == p2_name][0]
17
- try:
18
- path = nx.shortest_path(G_active, source=p1_id, target=p2_id)
19
- edges_in_path = get_original_edges(G_active, path)
20
- if ctx["connect_border_objects"]:
21
- edges_in_path = enforce_border_object_relations(G_active, set(path), edges_in_path)
22
- st.success(f"Data flow path found! Length: {len(path)-1} step(s).")
23
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, path, edges_in_path)
24
- render_mermaid(mermaid_code, json_data)
25
- except nx.NetworkXNoPath:
26
- st.error("No valid DATA FLOW exists between these processes.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/case_3.py DELETED
@@ -1,26 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, U_active, processes = ctx["G_active"], ctx["U_active"], ctx["processes"]
8
-
9
- st.write("Finds any connection (e.g., sharing the same input document), ignoring direction.")
10
- col1, col2 = st.columns(2)
11
- with col1: p1_name = st.selectbox("Process A:", ctx["sorted_process_names"], key="c3_p1")
12
- with col2: p2_name = st.selectbox("Process B:", ctx["sorted_process_names"], key="c3_p2")
13
-
14
- if st.button("Generate Diagram") and p1_name != p2_name:
15
- p1_id = [k for k, v in processes.items() if v == p1_name][0]
16
- p2_id = [k for k, v in processes.items() if v == p2_name][0]
17
- try:
18
- path = nx.shortest_path(U_active, source=p1_id, target=p2_id)
19
- edges_in_path = get_original_edges(G_active, path)
20
- if ctx["connect_border_objects"]:
21
- edges_in_path = enforce_border_object_relations(G_active, set(path), edges_in_path)
22
- st.success(f"Structural connection found! Length: {len(path)-1} step(s).")
23
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, path, edges_in_path)
24
- render_mermaid(mermaid_code, json_data)
25
- except nx.NetworkXNoPath:
26
- st.error("These processes are completely disconnected in the model.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/case_4.py DELETED
@@ -1,32 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, processes = ctx["G_active"], ctx["processes"]
8
-
9
- st.write("Finds all valid data flow sequences (respecting directions).")
10
- col1, col2 = st.columns(2)
11
- with col1: p1_name = st.selectbox("Process A (From):", ctx["sorted_process_names"], key="c4_p1")
12
- with col2: p2_name = st.selectbox("Process B (To):", ctx["sorted_process_names"], key="c4_p2")
13
-
14
- if st.button("Generate Diagram") and p1_name != p2_name:
15
- p1_id = [k for k, v in processes.items() if v == p1_name][0]
16
- p2_id = [k for k, v in processes.items() if v == p2_name][0]
17
- try:
18
- paths = list(nx.all_simple_paths(G_active, source=p1_id, target=p2_id, cutoff=6))
19
- if not paths:
20
- st.error("No valid data flow paths found within 6 steps.")
21
- else:
22
- st.success(f"Found {len(paths)} unique data flow path(s).")
23
- nodes_in_paths, edges_in_paths = set(), []
24
- for path in paths:
25
- nodes_in_paths.update(path)
26
- edges_in_paths.extend(get_original_edges(G_active, path))
27
- if ctx["connect_border_objects"]:
28
- edges_in_paths = enforce_border_object_relations(G_active, nodes_in_paths, edges_in_paths)
29
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_in_paths, edges_in_paths)
30
- render_mermaid(mermaid_code, json_data)
31
- except nx.NetworkXNoPath:
32
- st.error("No valid DATA FLOW exists between these processes.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/case_5.py DELETED
@@ -1,60 +0,0 @@
1
- import streamlit as st
2
- from mermaid_generator import graph_to_mermaid_and_data, enforce_border_object_relations
3
- from frontend import render_mermaid
4
-
5
- def run(ctx):
6
- G_active, G_full, U_active = ctx["G_active"], ctx["G_full"], ctx["U_active"]
7
- processes = ctx["processes"]
8
-
9
- st.write("Shows all connected objects up to X steps away. Renders internal steps inside the function block.")
10
- p_name = st.selectbox("Select Process (Business Function):", ctx["sorted_process_names"], key="c5_p")
11
- distance = st.radio("Search depth (steps):", (1, 2), horizontal=True)
12
-
13
- if st.button("Generate Diagram"):
14
- p_id = [k for k, v in processes.items() if v == p_name][0]
15
- nodes_to_draw, edges_to_draw = set([p_id]), []
16
-
17
- # Фикс 1: Принудительно собираем все ребра композиции из G_full, чтобы сабграфы всегда строились
18
- comp_edges = []
19
- for u, v, d in G_full.out_edges(p_id, data=True):
20
- if 'Composition' in d.get('type','') and 'BusinessProcess' in G_full.nodes[v].get('type',''):
21
- comp_edges.append((u, v, d))
22
- nodes_to_draw.add(v)
23
-
24
- visited, current_front = set(nodes_to_draw), set(nodes_to_draw)
25
- for step in range(distance):
26
- next_front = set()
27
- for node in current_front:
28
- for neighbor in U_active.neighbors(node):
29
- if neighbor not in visited:
30
- n_type = G_full.nodes[neighbor].get('type', '')
31
- # Если это объект/артефакт - добавляем в отрисовку и идем через него дальше
32
- if 'BusinessFunction' not in n_type and 'BusinessProcess' not in n_type:
33
- next_front.add(neighbor)
34
- visited.add(neighbor)
35
- # Фикс 2: Упираемся в ЛЮБОЙ смежный процесс (Function или Process)
36
- else:
37
- nodes_to_draw.add(neighbor)
38
- visited.add(neighbor)
39
- nodes_to_draw.update(next_front)
40
- current_front = next_front
41
-
42
- existing_edges = set()
43
- for u in nodes_to_draw:
44
- for v in nodes_to_draw:
45
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse':
46
- edges_to_draw.append((u, v, G_active[u][v]))
47
- existing_edges.add((u, v))
48
-
49
- # Фикс 1 (продолжение): Гарантируем присутствие ребер композиции в массиве для Mermaid
50
- for u, v, d in comp_edges:
51
- if (u, v) not in existing_edges:
52
- edges_to_draw.append((u, v, d))
53
- existing_edges.add((u, v))
54
-
55
- if ctx["connect_border_objects"]:
56
- edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
57
-
58
- st.success(f"Neighborhood built with radius {distance}.")
59
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_to_draw, edges_to_draw, render_subgraphs=True)
60
- render_mermaid(mermaid_code, json_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/case_6.py DELETED
@@ -1,26 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, U_active, business_objects = ctx["G_active"], ctx["U_active"], ctx["business_objects"]
8
-
9
- st.write("Finds any connection between two Business Objects, ignoring direction.")
10
- col1, col2 = st.columns(2)
11
- with col1: o1_name = st.selectbox("Object A:", ctx["sorted_object_names"], key="c6_o1")
12
- with col2: o2_name = st.selectbox("Object B:", ctx["sorted_object_names"], key="c6_o2")
13
-
14
- if st.button("Generate Diagram") and o1_name != o2_name:
15
- o1_id = [k for k, v in business_objects.items() if v == o1_name][0]
16
- o2_id = [k for k, v in business_objects.items() if v == o2_name][0]
17
- try:
18
- path = nx.shortest_path(U_active, source=o1_id, target=o2_id)
19
- edges_in_path = get_original_edges(G_active, path)
20
- if ctx["connect_border_objects"]:
21
- edges_in_path = enforce_border_object_relations(G_active, set(path), edges_in_path)
22
- st.success(f"Connection found! Length: {len(path)-1} step(s).")
23
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, path, edges_in_path)
24
- render_mermaid(mermaid_code, json_data)
25
- except nx.NetworkXNoPath:
26
- st.error("These objects are completely disconnected in the model.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cases/case_7.py DELETED
@@ -1,107 +0,0 @@
1
- import streamlit as st
2
- from mermaid_generator import graph_to_mermaid_and_data, enforce_border_object_relations
3
- from frontend import render_mermaid
4
-
5
- def run(ctx):
6
- G_active, G_full, processes = ctx["G_active"], ctx["G_full"], ctx["processes"]
7
-
8
- st.write("Simulates an N2 Chart. Select a central process, then choose which of its actual inputs and outputs to analyze.")
9
- p_center_name = st.selectbox("Select Central Process (Business Function):", ctx["sorted_process_names"], key="c7_p_center")
10
- p_center_id = [k for k, v in processes.items() if v == p_center_name][0]
11
-
12
- actual_inputs_ids = [n for n in G_active.predecessors(p_center_id) if 'BusinessProcess' not in G_active.nodes[n].get('type', '') and 'BusinessFunction' not in G_active.nodes[n].get('type', '')]
13
- actual_outputs_ids = [n for n in G_active.successors(p_center_id) if 'BusinessProcess' not in G_active.nodes[n].get('type', '') and 'BusinessFunction' not in G_active.nodes[n].get('type', '')]
14
-
15
- inputs_dict = {n: G_active.nodes[n].get('name', 'Unnamed') for n in actual_inputs_ids}
16
- outputs_dict = {n: G_active.nodes[n].get('name', 'Unnamed') for n in actual_outputs_ids}
17
-
18
- st.write("Configure N2 Chart Interface:")
19
- col_l, col_m, col_r = st.columns(3)
20
- with col_l: selected_inputs = st.multiselect("Input Artifacts (from XML):", sorted(list(inputs_dict.values())), max_selections=5, key="c7_inputs")
21
- with col_m: st.info(f"**Central Process Node:** {p_center_name}")
22
- with col_r: selected_outputs = st.multiselect("Output Artifacts (from XML):", sorted(list(outputs_dict.values())), max_selections=5, key="c7_outputs")
23
-
24
- show_all_producers_for_outputs = st.checkbox("Show all producing processes for selected output artifacts", value=False)
25
-
26
- if st.button("Generate Diagram"):
27
- nodes_to_draw, edges_to_draw, custom_labels = set([p_center_id]), [], {}
28
-
29
- def get_artifact_cluster(start_node):
30
- if not ctx["use_hierarchy"]: return set([start_node])
31
- visited, queue = set([start_node]), [start_node]
32
- while queue:
33
- curr = queue.pop(0)
34
- for neighbor in G_full.neighbors(curr):
35
- if neighbor not in visited:
36
- edata = G_full[curr][neighbor]
37
- if any(x in edata.get('type', '') for x in ['Composition', 'Aggregation', 'Specialization']) or edata.get('access') == 'hierarchy_reverse':
38
- ntype = G_full.nodes[neighbor].get('type', '')
39
- if 'BusinessProcess' not in ntype and 'BusinessFunction' not in ntype:
40
- visited.add(neighbor); queue.append(neighbor)
41
- for neighbor in G_full.predecessors(curr):
42
- if neighbor not in visited:
43
- edata = G_full[neighbor][curr]
44
- if any(x in edata.get('type', '') for x in ['Composition', 'Aggregation', 'Specialization']) or edata.get('access') == 'hierarchy_reverse':
45
- ntype = G_full.nodes[neighbor].get('type', '')
46
- if 'BusinessProcess' not in ntype and 'BusinessFunction' not in ntype:
47
- visited.add(neighbor); queue.append(neighbor)
48
- return visited
49
-
50
- def add_custom_edge(u, v):
51
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse': edges_to_draw.append((u, v, G_active[u][v]))
52
- elif G_active.has_edge(v, u) and G_active[v][u].get('access') != 'hierarchy_reverse': edges_to_draw.append((v, u, G_active[v][u]))
53
-
54
- sel_input_ids = [k for k, v in inputs_dict.items() if v in selected_inputs]
55
- for in_id in sel_input_ids:
56
- cluster = get_artifact_cluster(in_id)
57
- nodes_to_draw.update(cluster)
58
- for u in cluster:
59
- for v in cluster:
60
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse': edges_to_draw.append((u, v, G_active[u][v]))
61
- add_custom_edge(in_id, p_center_id)
62
- for c_item in cluster:
63
- for pred in G_full.predecessors(c_item):
64
- p_type = G_full.nodes[pred].get('type', '')
65
- if ('BusinessFunction' in p_type or 'BusinessProcess' in p_type) and pred != p_center_id:
66
- if G_full.has_edge(pred, c_item) and G_full[pred][c_item].get('access') != 'hierarchy_reverse':
67
- nodes_to_draw.add(pred); edges_to_draw.append((pred, c_item, G_full[pred][c_item]))
68
-
69
- sel_output_ids = [k for k, v in outputs_dict.items() if v in selected_outputs]
70
- for out_id in sel_output_ids:
71
- cluster = get_artifact_cluster(out_id)
72
- nodes_to_draw.update(cluster)
73
- for u in cluster:
74
- for v in cluster:
75
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse': edges_to_draw.append((u, v, G_active[u][v]))
76
- add_custom_edge(p_center_id, out_id)
77
-
78
- direct_producers = set()
79
- for pred in G_full.predecessors(out_id):
80
- p_type = G_full.nodes[pred].get('type', '')
81
- if 'BusinessFunction' in p_type or 'BusinessProcess' in p_type:
82
- if G_full.has_edge(pred, out_id) and G_full[pred][out_id].get('access') != 'hierarchy_reverse':
83
- direct_producers.add(pred)
84
- if len(direct_producers) > 1:
85
- custom_labels[out_id] = f"{G_active.nodes[out_id].get('name', 'Unnamed')} [Shared Output]"
86
-
87
- if show_all_producers_for_outputs:
88
- for c_item in cluster:
89
- for pred in G_full.predecessors(c_item):
90
- p_type = G_full.nodes[pred].get('type', '')
91
- if 'BusinessFunction' in p_type or 'BusinessProcess' in p_type:
92
- if G_full.has_edge(pred, c_item) and G_full[pred][c_item].get('access') != 'hierarchy_reverse' and pred != p_center_id:
93
- nodes_to_draw.add(pred); edges_to_draw.append((pred, c_item, G_full[pred][c_item]))
94
-
95
- for c_item in cluster:
96
- for succ in G_full.successors(c_item):
97
- s_type = G_full.nodes[succ].get('type', '')
98
- if ('BusinessFunction' in s_type or 'BusinessProcess' in s_type) and succ != p_center_id:
99
- if G_full.has_edge(c_item, succ):
100
- nodes_to_draw.add(succ); edges_to_draw.append((c_item, succ, G_full[c_item][succ]))
101
-
102
- if ctx["connect_border_objects"]:
103
- edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
104
-
105
- st.success("N2 Chart simulation diagram compiled!")
106
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_to_draw, edges_to_draw, custom_labels=custom_labels)
107
- render_mermaid(mermaid_code, json_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
frontend.py DELETED
@@ -1,211 +0,0 @@
1
- import streamlit.components.v1 as components
2
-
3
- def render_mermaid(mermaid_code, nodes_json):
4
- """
5
- Renders the Mermaid.js diagram inside a custom HTML iframe.
6
- Injects SVG-pan-zoom for navigation, handles custom mouse click events for the sidebar,
7
- and provides canvas-based PNG and JSON data export features with a watermark.
8
- """
9
- safe_mermaid_code = mermaid_code.replace('`', '\\`').replace('$', '\\$')
10
-
11
- html_code = f"""
12
- <!DOCTYPE html>
13
- <html>
14
- <head>
15
- <script src="https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.6.1/dist/svg-pan-zoom.min.js"></script>
16
-
17
- <style>
18
- body {{ margin: 0; padding: 0; font-family: sans-serif; background: #ffffff; overflow: hidden; }}
19
- #graphDiv {{ width: 100%; height: 100vh; cursor: grab; position: relative; }}
20
- #graphDiv:active {{ cursor: grabbing; }}
21
-
22
- /* Export buttons bottom-left */
23
- #toolbar {{
24
- position: absolute; bottom: 25px; left: 25px; z-index: 100;
25
- display: flex; gap: 10px;
26
- }}
27
- button.export-btn {{
28
- background: #ffffff; border: 1px solid #ccc; padding: 10px 18px;
29
- border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: bold;
30
- box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: all 0.2s;
31
- }}
32
- button.export-btn:hover {{ background: #f0f0f0; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.15); }}
33
-
34
- /* Sidebar info panel styles */
35
- #infoPanel {{
36
- display: none; position: absolute; top: 20px; right: 20px;
37
- width: 350px; max-height: 80vh; background: #ffffff;
38
- border: 1px solid #e0e0e0; border-radius: 8px;
39
- box-shadow: 0 10px 25px rgba(0,0,0,0.2); padding: 20px;
40
- overflow-y: auto; z-index: 1000; flex-direction: column;
41
- }}
42
- #infoPanel h3 {{ margin: 0 0 15px 0; font-size: 18px; color: #333; }}
43
- #infoPanel p {{ margin: 0; font-size: 14px; color: #555; line-height: 1.6; }}
44
-
45
- #closeBtn {{
46
- position: absolute; top: 15px; right: 15px; cursor: pointer;
47
- font-size: 24px; color: #aaa; background: none; border: none; padding: 0;
48
- }}
49
- #closeBtn:hover {{ color: #333; }}
50
-
51
- .node {{ cursor: pointer !important; }}
52
- .cluster {{ cursor: pointer !important; }}
53
- </style>
54
-
55
- <script>
56
- window.downloadJson = function() {{
57
- const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(nodeData, null, 4));
58
- const a = document.createElement("a");
59
- a.href = dataStr;
60
- a.download = "Architecture_Dictionary.json";
61
- a.click();
62
- }};
63
-
64
- window.downloadPng = function() {{
65
- const svg = document.querySelector('#graphDiv svg');
66
- if (!svg) return;
67
-
68
- const oldZoom = window.panZoomSetup.getZoom();
69
- const oldPan = window.panZoomSetup.getPan();
70
- window.panZoomSetup.resetZoom();
71
- window.panZoomSetup.resetPan();
72
-
73
- setTimeout(() => {{
74
- const svgData = new XMLSerializer().serializeToString(svg);
75
- const canvas = document.createElement("canvas");
76
- const bbox = svg.getBoundingClientRect();
77
-
78
- canvas.width = bbox.width * 2;
79
- canvas.height = bbox.height * 2;
80
-
81
- const ctx = canvas.getContext("2d");
82
- ctx.fillStyle = "white";
83
- ctx.fillRect(0, 0, canvas.width, canvas.height);
84
- ctx.scale(2, 2);
85
-
86
- const img = new Image();
87
- img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgData)));
88
-
89
- img.onload = function() {{
90
- ctx.drawImage(img, 0, 0);
91
-
92
- ctx.font = "12px sans-serif";
93
- ctx.fillStyle = "#888888";
94
- const dateStr = new Date().toLocaleString('en-US');
95
- const watermarkText1 = `Diagram generated on ${{dateStr}} by the model analysis script.`;
96
- const watermarkText2 = `Script rights belong to INCOSE. Developed by Alexander Efremov.`;
97
-
98
- ctx.fillText(watermarkText1, 15, bbox.height - 25);
99
- ctx.fillText(watermarkText2, 15, bbox.height - 10);
100
-
101
- const a = document.createElement("a");
102
- a.download = "Architecture_Diagram.png";
103
- a.href = canvas.toDataURL("image/png");
104
- a.click();
105
-
106
- window.panZoomSetup.zoom(oldZoom);
107
- window.panZoomSetup.pan(oldPan);
108
- }};
109
- }}, 100);
110
- }};
111
-
112
- window.closePanel = function() {{
113
- document.getElementById('infoPanel').style.display = 'none';
114
- }};
115
- </script>
116
-
117
- <script type="module">
118
- import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
119
- mermaid.initialize({{ startOnLoad: false, theme: 'default', securityLevel: 'loose' }});
120
-
121
- window.nodeData = {nodes_json};
122
- const nodeByName = {{}};
123
- for (const key in nodeData) {{
124
- let cleanName = nodeData[key].name.replace(/['"]/g, '');
125
- nodeByName[cleanName] = nodeData[key];
126
- }}
127
-
128
- window.renderDiagram = async function() {{
129
- const container = document.getElementById('graphDiv');
130
-
131
- container.addEventListener('wheel', function(e) {{
132
- e.preventDefault();
133
- }}, {{ passive: false }});
134
-
135
- const {{ svg }} = await mermaid.render('mermaidSvg', `{safe_mermaid_code}`);
136
- container.innerHTML = svg;
137
-
138
- const svgElement = container.querySelector('svg');
139
- svgElement.style.width = "100%";
140
- svgElement.style.height = "100%";
141
-
142
- window.panZoomSetup = svgPanZoom(svgElement, {{
143
- zoomEnabled: true,
144
- controlIconsEnabled: true,
145
- fit: true,
146
- center: true,
147
- minZoom: 0.1,
148
- maxZoom: 10,
149
- preventMouseEventsDefault: false
150
- }});
151
-
152
- window.addEventListener('resize', function() {{
153
- if (window.panZoomSetup) window.panZoomSetup.resize();
154
- }});
155
-
156
- let isDragging = false;
157
- let startPos = {{x: 0, y: 0}};
158
-
159
- container.addEventListener('mousedown', function(e) {{
160
- isDragging = false;
161
- startPos = {{x: e.clientX, y: e.clientY}};
162
- }}, true);
163
-
164
- container.addEventListener('mousemove', function(e) {{
165
- if (Math.abs(e.clientX - startPos.x) > 3 || Math.abs(e.clientY - startPos.y) > 3) {{
166
- isDragging = true;
167
- }}
168
- }}, true);
169
-
170
- container.addEventListener('mouseup', function(e) {{
171
- if (!isDragging) {{
172
- let node = e.target.closest('.node') || e.target.closest('.cluster');
173
- if (node) {{
174
- let label = "";
175
- let span = node.querySelector('.nodeLabel') || node.querySelector('.cluster-label');
176
- if (span) {{
177
- label = span.textContent.trim();
178
- }} else {{
179
- label = node.textContent.trim();
180
- }}
181
- label = label.replace(/['"]/g, '');
182
-
183
- let data = nodeByName[label];
184
- if (data) {{
185
- document.getElementById('panelTitle').innerText = data.name;
186
- document.getElementById('panelDoc').innerText = data.doc ? data.doc : "Description is missing in the model.";
187
- document.getElementById('infoPanel').style.display = 'flex';
188
- }}
189
- }}
190
- }}
191
- }}, true);
192
- }};
193
-
194
- window.addEventListener('load', window.renderDiagram);
195
- </script>
196
- </head>
197
- <body>
198
- <div id="toolbar">
199
- <button class="export-btn" onclick="downloadPng()">📸 Export PNG</button>
200
- <button class="export-btn" onclick="downloadJson()">💾 Export Data (JSON)</button>
201
- </div>
202
- <div id="infoPanel">
203
- <button id="closeBtn" onclick="closePanel()">&times;</button>
204
- <h3 id="panelTitle">Process Name</h3>
205
- <p id="panelDoc">Documentation...</p>
206
- </div>
207
- <div id="graphDiv"></div>
208
- </body>
209
- </html>
210
- """
211
- components.html(html_code, height=800, scrolling=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
mermaid_generator.py DELETED
@@ -1,203 +0,0 @@
1
- import json
2
-
3
- def graph_to_mermaid_and_data(G_active, nodes_to_include, edges_to_include, render_subgraphs=False, custom_labels=None):
4
- if not nodes_to_include:
5
- return "", "{}"
6
-
7
- if custom_labels is None:
8
- custom_labels = {}
9
-
10
- lines = [
11
- "flowchart LR",
12
- "classDef process fill:#FFF2CC,stroke:#D6B656,stroke-width:2px,color:#000;",
13
- "classDef object fill:#D5E8D4,stroke:#82B366,stroke-width:2px,color:#000;"
14
- ]
15
-
16
- nodes_data = {}
17
- parent_map = {}
18
- filtered_edges = []
19
-
20
- if render_subgraphs:
21
- for u, v, data in edges_to_include:
22
- u_type = G_active.nodes[u].get('type', '')
23
- v_type = G_active.nodes[v].get('type', '')
24
- if 'Composition' in data.get('type', '') and 'BusinessFunction' in u_type and 'BusinessProcess' in v_type:
25
- parent_map[v] = u
26
- else:
27
- filtered_edges.append((u, v, data))
28
- else:
29
- filtered_edges = edges_to_include
30
-
31
- children_by_parent = {}
32
- standalone_nodes = []
33
-
34
- for n in nodes_to_include:
35
- if render_subgraphs and n in parent_map:
36
- p = parent_map[n]
37
- if p not in children_by_parent:
38
- children_by_parent[p] = []
39
- children_by_parent[p].append(n)
40
- else:
41
- standalone_nodes.append(n)
42
-
43
- for p in children_by_parent.keys():
44
- if p in standalone_nodes:
45
- standalone_nodes.remove(p)
46
-
47
- # Initialize link counter and list for grey link indices
48
- link_index = 0
49
- grey_link_indices = []
50
-
51
- for p_id, children in children_by_parent.items():
52
- if p_id in nodes_to_include:
53
- p_data = G_active.nodes[p_id]
54
- m_pid = p_id.replace("-", "_")
55
- p_name = custom_labels.get(p_id, p_data.get("name", "Unknown")).replace('"', "'")
56
-
57
- lines.append(f' subgraph {m_pid} ["{p_name}"]')
58
- lines.append(f' direction TB')
59
- lines.append(f' style {m_pid} fill:#FFF2CC,stroke:#D6B656,stroke-width:2px,color:#000;')
60
-
61
- prev_cid = None
62
- for c_id in children:
63
- c_data = G_active.nodes[c_id]
64
- m_cid = c_id.replace("-", "_")
65
- c_name = custom_labels.get(c_id, c_data.get("name", "Unknown")).replace('"', "'")
66
-
67
- lines.append(f' {m_cid}("{c_name}"):::process')
68
- lines.append(f' click {m_cid} call handleNodeClick()')
69
- nodes_data[m_cid] = {"name": c_name, "doc": c_data.get("doc", "").replace('"', "'").replace("\n", " ")}
70
-
71
- if prev_cid:
72
- lines.append(f' {prev_cid} ~~~ {m_cid}')
73
- # Include hidden links in the index count
74
- link_index += 1
75
- prev_cid = m_cid
76
-
77
- lines.append(f' end')
78
- lines.append(f' click {m_pid} call handleNodeClick()')
79
- nodes_data[m_pid] = {"name": p_name, "doc": p_data.get("doc", "").replace('"', "'").replace("\n", " ")}
80
- else:
81
- for c_id in children:
82
- standalone_nodes.append(c_id)
83
-
84
- for n_id in standalone_nodes:
85
- data = G_active.nodes.get(n_id, {})
86
- m_id = n_id.replace("-", "_")
87
- name = custom_labels.get(n_id, data.get("name", "Unknown")).replace('"', "'")
88
- n_type = data.get("type", "")
89
- doc = data.get("doc", "").replace('"', "'").replace("\n", " ")
90
-
91
- if 'BusinessProcess' in n_type or 'BusinessFunction' in n_type:
92
- lines.append(f' {m_id}("{name}"):::process')
93
- else:
94
- lines.append(f' {m_id}["{name}"]:::object')
95
-
96
- lines.append(f' click {m_id} call handleNodeClick()')
97
- nodes_data[m_id] = {"name": name, "doc": doc}
98
-
99
- # === LINK SORTING LOGIC ===
100
- def get_sort_weight(data):
101
- e_type = data.get("type", "")
102
- access = data.get("access", "")
103
- rel_name = data.get("name", "")
104
- subclass = data.get("subclass", "")
105
-
106
- if 'Access' in e_type:
107
- if subclass == 'Controls' or rel_name == 'Controls': return 0
108
- if access.lower() == 'read': return 1 # Input
109
- if subclass == 'Situational' or rel_name == 'Situational': return 2
110
- if subclass == 'Enables' or rel_name == 'Enables': return 3
111
- if access.lower() == 'write': return 4 # Output
112
- return 5 # Other Access types
113
- return 6 # All other relation types (Composition, Aggregation, etc.)
114
-
115
- # Sort the list of edges by weight before generating them
116
- filtered_edges.sort(key=lambda edge: get_sort_weight(edge[2]))
117
-
118
- added_edges = set()
119
- for u, v, data in filtered_edges:
120
- edge_key = (u, v)
121
- if edge_key not in added_edges:
122
- u_id = u.replace("-", "_")
123
- v_id = v.replace("-", "_")
124
- e_type = data.get("type", "")
125
- access = data.get("access", "")
126
- # Extract Name attribute from edge data
127
- rel_name = data.get("name", "")
128
- # Extract subclass attribute
129
- subclass = data.get("subclass", "")
130
-
131
- if 'Access' in e_type:
132
- if subclass == 'Controls' or rel_name == 'Controls':
133
- label = "Controls"
134
- elif subclass == 'Enables' or rel_name == 'Enables':
135
- label = "Enables"
136
- elif subclass == 'Situational' or rel_name == 'Situational':
137
- label = "Situational"
138
- elif access.lower() == 'read':
139
- label = "Input"
140
- elif access.lower() == 'write':
141
- label = "Output"
142
- else:
143
- label = "Access"
144
- else:
145
- label = e_type.replace("Relationship", "").replace("archimate:", "")
146
-
147
- # === LINK GENERATION ===
148
- if 'Composition' in e_type:
149
- lines.append(f' {v_id} == "{label}" ==> {u_id}')
150
- elif 'Aggregation' in e_type:
151
- lines.append(f' {v_id} -- "{label}" --o {u_id}')
152
- elif 'Specialization' in e_type:
153
- lines.append(f' {u_id} -. "{label}" .-> {v_id}')
154
- # Draw dashed lines for specific systemic link types
155
- elif label in ["Controls", "Situational", "Enables"]:
156
- lines.append(f' {u_id} -.->|{label}| {v_id}')
157
- # Default to solid lines for Input, Output, and others
158
- else:
159
- lines.append(f' {u_id} -->|{label}| {v_id}')
160
-
161
- # Store the index for the required system links
162
- if label in ["Controls", "Enables", "Situational"]:
163
- grey_link_indices.append(str(link_index))
164
-
165
- link_index += 1
166
- added_edges.add(edge_key)
167
-
168
- # Add style for grey links (grouped by comma WITHOUT a trailing semicolon)
169
- if grey_link_indices:
170
- indices_str = ",".join(grey_link_indices)
171
- lines.append(f' linkStyle {indices_str} stroke:#808080,stroke-width:2px,color:#808080')
172
-
173
- return "\n".join(lines), json.dumps(nodes_data)
174
-
175
- def get_original_edges(G_graph, path):
176
- edges = []
177
- for i in range(len(path)-1):
178
- u, v = path[i], path[i+1]
179
- if G_graph.has_edge(u, v) and G_graph[u][v].get('access') != 'hierarchy_reverse':
180
- edges.append((u, v, G_graph[u][v]))
181
- elif G_graph.has_edge(v, u) and G_graph[v][u].get('access') != 'hierarchy_reverse':
182
- edges.append((v, u, G_graph[v][u]))
183
- return edges
184
-
185
- def enforce_border_object_relations(G_graph, nodes_set, edges_list):
186
- objects_in_graph = [n for n in nodes_set if 'BusinessProcess' not in G_graph.nodes[n].get('type','') and 'BusinessFunction' not in G_graph.nodes[n].get('type','')]
187
- existing_edges = set((u, v) for u, v, _ in edges_list)
188
-
189
- for i in range(len(objects_in_graph)):
190
- for j in range(i + 1, len(objects_in_graph)):
191
- o1, o2 = objects_in_graph[i], objects_in_graph[j]
192
-
193
- if G_graph.has_edge(o1, o2) and G_graph[o1][o2].get('access') != 'hierarchy_reverse':
194
- if (o1, o2) not in existing_edges:
195
- edges_list.append((o1, o2, G_graph[o1][o2]))
196
- existing_edges.add((o1, o2))
197
-
198
- if G_graph.has_edge(o2, o1) and G_graph[o2][o1].get('access') != 'hierarchy_reverse':
199
- if (o2, o1) not in existing_edges:
200
- edges_list.append((o2, o1, G_graph[o2][o1]))
201
- existing_edges.add((o2, o1))
202
-
203
- return edges_list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
parser.py DELETED
@@ -1,192 +0,0 @@
1
- import xml.etree.ElementTree as ET
2
- import networkx as nx
3
- import streamlit as st
4
-
5
- @st.cache_data
6
- def load_and_parse_xml(file_path, include_enablers=False):
7
- """
8
- Reads the ArchiMate Open Exchange XML and constructs NetworkX graphs.
9
- Returns: (G_full, G_direct, processes_dict, objects_dict)
10
- """
11
- tree = ET.parse(file_path)
12
- root = tree.getroot()
13
-
14
- G_full = nx.DiGraph()
15
- G_direct = nx.DiGraph()
16
- processes = {}
17
- business_objects = {}
18
-
19
- # 1. Collect graph nodes
20
- for elem in root.findall('.//*'):
21
- if elem.tag.endswith('element'):
22
- n_id = elem.get('identifier')
23
- n_type = next((v for k, v in elem.attrib.items() if k.endswith('type')), 'Unknown')
24
-
25
- name = "Unnamed"
26
- doc = ""
27
- for child in elem:
28
- if child.tag.endswith('name') and child.text:
29
- name = child.text
30
- elif child.tag.endswith('documentation') and child.text:
31
- doc = child.text
32
-
33
- G_full.add_node(n_id, name=name, type=n_type, doc=doc)
34
- G_direct.add_node(n_id, name=name, type=n_type, doc=doc)
35
-
36
- if 'BusinessFunction' in n_type:
37
- processes[n_id] = name
38
- elif 'BusinessProcess' not in n_type and 'Unknown' not in n_type and 'Role' not in n_type and 'Actor' not in n_type:
39
- business_objects[n_id] = name
40
-
41
- # 1.5 Identify Profile and Property IDs for specializations (Handling UUIDs)
42
- specialization_prop_ids = set(['specialization'])
43
- profile_dict = {}
44
-
45
- for elem in root.findall('.//*'):
46
- if elem.tag.endswith('propertyDefinition'):
47
- prop_id = elem.get('identifier')
48
- for child in elem:
49
- if child.tag.endswith('name') and child.text and child.text.lower() == 'specialization':
50
- specialization_prop_ids.add(prop_id)
51
- elif elem.tag.endswith('profile'):
52
- prof_id = elem.get('identifier')
53
- prof_name = elem.get('name')
54
- if prof_id and prof_name:
55
- profile_dict[prof_id] = prof_name
56
-
57
- # 2. Preliminary collection of relationships, including the Name and Subclass fields
58
- relationships = []
59
- for rel in root.findall('.//*'):
60
- if rel.tag.endswith('relationship'):
61
- src = rel.get('source')
62
- tgt = rel.get('target')
63
- r_type = next((v for k, v in rel.attrib.items() if k.endswith('type')), 'Association')
64
- access = rel.get('accessType', '')
65
-
66
- rel_name = ""
67
- subclass = ""
68
-
69
- for child in rel:
70
- if child.tag.endswith('name') and child.text:
71
- rel_name = child.text
72
- elif child.tag.endswith('properties'):
73
- for prop in child:
74
- if prop.tag.endswith('property'):
75
- is_spec = prop.get('propertyDefinitionRef') in specialization_prop_ids
76
- for val in prop:
77
- if val.tag.endswith('value') and val.text:
78
- # Fallback: take value if it belongs to specialization property OR directly matches our targets
79
- if is_spec or val.text in ['Controls', 'Enables', 'Situational']:
80
- subclass = val.text
81
- elif child.tag.endswith('profiles'):
82
- for prof in child:
83
- if prof.tag.endswith('profileRef'):
84
- ref_id = prof.get('ref')
85
- if ref_id in profile_dict:
86
- subclass = profile_dict[ref_id]
87
-
88
- # Принудительно присваиваем имя связи на основе её подкласса
89
- if subclass in ['Controls', 'Enables', 'Situational']:
90
- rel_name = subclass
91
-
92
- relationships.append((src, tgt, r_type, access, rel_name, subclass))
93
-
94
- # 3. Identify the meta-level (Only Specialization between BusinessFunctions)
95
- meta_parents_children = {}
96
- for src, tgt, r_type, access, rel_name, subclass in relationships:
97
- if 'Specialization' in r_type:
98
- # Ensure both nodes exist in the graph
99
- if G_full.has_node(src) and G_full.has_node(tgt):
100
- src_type = G_full.nodes[src].get('type', '')
101
- tgt_type = G_full.nodes[tgt].get('type', '')
102
-
103
- # Ignore specialization of business objects, catch only processes
104
- if 'BusinessFunction' in src_type and 'BusinessFunction' in tgt_type:
105
- if tgt not in meta_parents_children:
106
- meta_parents_children[tgt] = []
107
- meta_parents_children[tgt].append(src)
108
-
109
- # 4. Build the base graph (adding the name and subclass attributes)
110
- for src, tgt, r_type, access, rel_name, subclass in relationships:
111
- if not (G_full.has_node(src) and G_full.has_node(tgt)):
112
- continue
113
-
114
- if 'Access' in r_type:
115
- if access.lower() == 'read':
116
- G_full.add_edge(tgt, src, type=r_type, access=access, name=rel_name, subclass=subclass)
117
- G_direct.add_edge(tgt, src, type=r_type, access=access, name=rel_name, subclass=subclass)
118
- else:
119
- G_full.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
120
- G_direct.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
121
- else:
122
- G_full.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
123
- if not any(x in r_type for x in ['Composition', 'Aggregation', 'Specialization']):
124
- G_direct.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
125
- if any(x in r_type for x in ['Composition', 'Aggregation', 'Specialization']):
126
- G_full.add_edge(tgt, src, type=r_type, access='hierarchy_reverse', name=rel_name, subclass=subclass)
127
-
128
- # 5. Apply meta-level processing logic
129
- if not include_enablers:
130
- # Option 1: Ignore the parent element and its exclusive business objects
131
- for parent in meta_parents_children.keys():
132
- if G_full.has_node(parent):
133
- # Remember neighbors before deletion to check for orphans
134
- neighbors = list(G_full.predecessors(parent)) + list(G_full.successors(parent))
135
-
136
- # Remove the parent element itself from graphs and dictionaries
137
- G_full.remove_node(parent)
138
- if G_direct.has_node(parent):
139
- G_direct.remove_node(parent)
140
- if parent in processes:
141
- del processes[parent]
142
-
143
- # Clean up associated business objects if they are left without connections (isolated)
144
- for n in set(neighbors):
145
- if n in business_objects and G_full.has_node(n):
146
- if G_full.degree(n) == 0:
147
- G_full.remove_node(n)
148
- if G_direct.has_node(n):
149
- G_direct.remove_node(n)
150
- del business_objects[n]
151
- else:
152
- # Option 2: Dynamic projection of Enables, Controls, and Situational relationships
153
- for parent, children in meta_parents_children.items():
154
- if not G_full.has_node(parent):
155
- continue
156
-
157
- edges_to_project = []
158
-
159
- # Collect outgoing connections of the parent
160
- for u, v, data in G_full.edges(parent, data=True):
161
- is_valid_type = 'Access' in data.get('type', '')
162
- is_valid_subclass = data.get('subclass') in ['Controls', 'Enables', 'Situational']
163
- is_target_object = v in business_objects
164
-
165
- if is_valid_type and is_valid_subclass and is_target_object:
166
- edges_to_project.append((u, v, data))
167
-
168
- # Collect incoming connections of the parent (in case of reverse reading / Read Access)
169
- for u, v, data in G_full.in_edges(parent, data=True):
170
- is_valid_type = 'Access' in data.get('type', '')
171
- is_valid_subclass = data.get('subclass') in ['Controls', 'Enables', 'Situational']
172
- is_source_object = u in business_objects
173
-
174
- if is_valid_type and is_valid_subclass and is_source_object:
175
- edges_to_project.append((u, v, data))
176
-
177
- # Duplicate the found relationships to all children
178
- for u, v, data in edges_to_project:
179
- for child in children:
180
- if not G_full.has_node(child):
181
- continue
182
-
183
- # Determine which end the parent was on, and substitute the child instead
184
- new_u = child if u == parent else u
185
- new_v = child if v == parent else v
186
-
187
- G_full.add_edge(new_u, new_v, **data)
188
- # Check that both nodes exist in the direct graph before duplicating the relationship there
189
- if G_direct.has_node(new_u) and G_direct.has_node(new_v):
190
- G_direct.add_edge(new_u, new_v, **data)
191
-
192
- return G_full, G_direct, processes, business_objects
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt DELETED
@@ -1,2 +0,0 @@
1
- streamlit
2
- networkx
 
 
 
src/ISO15288_Archi_Import.xml DELETED
The diff for this file is too large to render. See raw diff
 
src/app_det.py DELETED
@@ -1,77 +0,0 @@
1
- import os
2
- import streamlit as st
3
- from parser import load_and_parse_xml
4
- import case_manager
5
-
6
- st.set_page_config(page_title="ISO 15288 Analyzer", layout="wide")
7
-
8
- st.markdown("""
9
- <style>
10
- .main .block-container { max-width: 100% !important; padding: 1rem 1rem 0 1rem !important; }
11
- iframe { width: 100% !important; height: 85vh !important; border: 1px solid #ccc; border-radius: 8px; }
12
- header { visibility: hidden; }
13
- div.row-widget.stRadio { margin-bottom: -5px; }
14
- </style>
15
- """, unsafe_allow_html=True)
16
-
17
- st.title("ISO 15288: Architecture Analyzer")
18
-
19
- mode = st.radio(
20
- "Select analysis scenario:",
21
- (
22
- "Case 1: Interface exchange between selected processes",
23
- "Case 2: Shortest DATA FLOW path (Directed)",
24
- "Case 3: Closest STRUCTURAL connection (Undirected)",
25
- "Case 4: All possible DATA FLOW paths (Directed)",
26
- "Case 5: Process Neighborhood & Internal Steps (Subgraphs)",
27
- "Case 6: Shortest connection between Business Objects (Undirected)",
28
- "Case 7: N2 Chart Simulation (Process Inputs & Outputs)"
29
- )
30
- )
31
-
32
- # Expand to 3 columns to accommodate the new checkbox
33
- col_opt1, col_opt2, col_opt3 = st.columns(3)
34
- with col_opt1:
35
- use_hierarchy = st.checkbox("Include derived connections (Whole-Part, Specialization hierarchy)", value=True)
36
- with col_opt2:
37
- connect_border_objects = st.checkbox("Show relationships between boundary objects on diagram", value=True)
38
- with col_opt3:
39
- # New checkbox for the meta-level
40
- include_enablers = st.checkbox("Include Enablers and Controls", value=False)
41
-
42
- try:
43
- current_script_dir = os.path.dirname(os.path.abspath(__file__))
44
- xml_file_path = os.path.join(current_script_dir, "ISO15288_Archi_Import.xml")
45
-
46
- # Pass the checkbox state to the parser
47
- G_full, G_direct, processes, business_objects = load_and_parse_xml(xml_file_path, include_enablers)
48
- sorted_process_names = sorted(list(processes.values()))
49
- sorted_object_names = sorted(list(business_objects.values()))
50
- except FileNotFoundError:
51
- # Получаем список всех файлов в директории скрипта
52
- files_in_dir = os.listdir(current_script_dir)
53
-
54
- st.error(f"Файл 'ISO15288_Archi_Import.xml' не найден.")
55
- st.warning(f"Скрипт искал его по пути: {xml_file_path}")
56
- st.info(f"Фактическое содержимое папки {current_script_dir}:")
57
- st.write(files_in_dir) # Выведет список файлов прямо на экран Streamlit
58
- st.stop()
59
-
60
- # Build the global context to pass to the cases
61
- ctx = {
62
- "G_full": G_full,
63
- "G_active": G_full if use_hierarchy else G_direct,
64
- "U_active": (G_full if use_hierarchy else G_direct).to_undirected(),
65
- "processes": processes,
66
- "business_objects": business_objects,
67
- "sorted_process_names": sorted_process_names,
68
- "sorted_object_names": sorted_object_names,
69
- "use_hierarchy": use_hierarchy,
70
- "connect_border_objects": connect_border_objects,
71
- "include_enablers": include_enablers # Added to the context for potential use within cases
72
- }
73
-
74
- st.markdown("---")
75
-
76
- # Pass execution to the router
77
- case_manager.run_case(mode, ctx)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/case_manager.py DELETED
@@ -1,17 +0,0 @@
1
- from cases import case_1, case_2, case_3, case_4, case_5, case_6, case_7
2
-
3
- def run_case(mode, ctx):
4
- if mode.startswith("Case 1"):
5
- case_1.run(ctx)
6
- elif mode.startswith("Case 2"):
7
- case_2.run(ctx)
8
- elif mode.startswith("Case 3"):
9
- case_3.run(ctx)
10
- elif mode.startswith("Case 4"):
11
- case_4.run(ctx)
12
- elif mode.startswith("Case 5"):
13
- case_5.run(ctx)
14
- elif mode.startswith("Case 6"):
15
- case_6.run(ctx)
16
- elif mode.startswith("Case 7"):
17
- case_7.run(ctx)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/__pycache__/case_1.cpython-314.pyc DELETED
Binary file (4.58 kB)
 
src/cases/__pycache__/case_2.cpython-314.pyc DELETED
Binary file (2.7 kB)
 
src/cases/__pycache__/case_3.cpython-314.pyc DELETED
Binary file (2.75 kB)
 
src/cases/__pycache__/case_4.cpython-314.pyc DELETED
Binary file (3.02 kB)
 
src/cases/__pycache__/case_5.cpython-314.pyc DELETED
Binary file (3.59 kB)
 
src/cases/__pycache__/case_6.cpython-314.pyc DELETED
Binary file (2.74 kB)
 
src/cases/__pycache__/case_7.cpython-314.pyc DELETED
Binary file (11.4 kB)
 
src/cases/case_1.py DELETED
@@ -1,50 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, U_active, processes = ctx["G_active"], ctx["U_active"], ctx["processes"]
8
- sorted_process_names = ctx["sorted_process_names"]
9
-
10
- st.write("Select 2 to 5 processes. The script will find objects they exchange data through.")
11
- selected_names = st.multiselect("Select processes:", sorted_process_names, max_selections=5)
12
-
13
- if st.button("Generate Diagram") and len(selected_names) >= 2:
14
- selected_ids = [k for k, v in processes.items() if v in selected_names]
15
- nodes_to_draw, edges_to_draw = set(selected_ids), []
16
-
17
- def safe_add_edge(u, v):
18
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse':
19
- edges_to_draw.append((u, v, G_active[u][v]))
20
-
21
- cutoff = 4 if ctx["use_hierarchy"] else 2
22
-
23
- for i in range(len(selected_ids)):
24
- for j in range(i + 1, len(selected_ids)):
25
- p1, p2 = selected_ids[i], selected_ids[j]
26
- if G_active.has_edge(p1, p2): safe_add_edge(p1, p2)
27
- if G_active.has_edge(p2, p1): safe_add_edge(p2, p1)
28
-
29
- try:
30
- paths = list(nx.all_simple_paths(U_active, p1, p2, cutoff=cutoff))
31
- for path in paths:
32
- if len(path) > 2:
33
- is_valid = all('BusinessProcess' not in U_active.nodes[n].get('type', '') and 'BusinessFunction' not in U_active.nodes[n].get('type', '') for n in path[1:-1])
34
- if is_valid:
35
- nodes_to_draw.update(path)
36
- for k in range(len(path)-1):
37
- u, v = path[k], path[k+1]
38
- if G_active.has_edge(u, v): safe_add_edge(u, v)
39
- elif G_active.has_edge(v, u): safe_add_edge(v, u)
40
- except nx.NetworkXNoPath:
41
- pass
42
-
43
- if len(nodes_to_draw) == len(selected_ids) and not edges_to_draw:
44
- st.warning("No links or shared exchange objects found between these processes.")
45
- else:
46
- st.success("Exchange interfaces found!")
47
- if ctx["connect_border_objects"]:
48
- edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
49
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_to_draw, edges_to_draw)
50
- render_mermaid(mermaid_code, json_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/case_2.py DELETED
@@ -1,26 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, processes = ctx["G_active"], ctx["processes"]
8
-
9
- st.write("Finds the shortest valid data sequence (respecting Input/Output directions).")
10
- col1, col2 = st.columns(2)
11
- with col1: p1_name = st.selectbox("Process A (From):", ctx["sorted_process_names"], key="c2_p1")
12
- with col2: p2_name = st.selectbox("Process B (To):", ctx["sorted_process_names"], key="c2_p2")
13
-
14
- if st.button("Generate Diagram") and p1_name != p2_name:
15
- p1_id = [k for k, v in processes.items() if v == p1_name][0]
16
- p2_id = [k for k, v in processes.items() if v == p2_name][0]
17
- try:
18
- path = nx.shortest_path(G_active, source=p1_id, target=p2_id)
19
- edges_in_path = get_original_edges(G_active, path)
20
- if ctx["connect_border_objects"]:
21
- edges_in_path = enforce_border_object_relations(G_active, set(path), edges_in_path)
22
- st.success(f"Data flow path found! Length: {len(path)-1} step(s).")
23
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, path, edges_in_path)
24
- render_mermaid(mermaid_code, json_data)
25
- except nx.NetworkXNoPath:
26
- st.error("No valid DATA FLOW exists between these processes.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/case_3.py DELETED
@@ -1,26 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, U_active, processes = ctx["G_active"], ctx["U_active"], ctx["processes"]
8
-
9
- st.write("Finds any connection (e.g., sharing the same input document), ignoring direction.")
10
- col1, col2 = st.columns(2)
11
- with col1: p1_name = st.selectbox("Process A:", ctx["sorted_process_names"], key="c3_p1")
12
- with col2: p2_name = st.selectbox("Process B:", ctx["sorted_process_names"], key="c3_p2")
13
-
14
- if st.button("Generate Diagram") and p1_name != p2_name:
15
- p1_id = [k for k, v in processes.items() if v == p1_name][0]
16
- p2_id = [k for k, v in processes.items() if v == p2_name][0]
17
- try:
18
- path = nx.shortest_path(U_active, source=p1_id, target=p2_id)
19
- edges_in_path = get_original_edges(G_active, path)
20
- if ctx["connect_border_objects"]:
21
- edges_in_path = enforce_border_object_relations(G_active, set(path), edges_in_path)
22
- st.success(f"Structural connection found! Length: {len(path)-1} step(s).")
23
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, path, edges_in_path)
24
- render_mermaid(mermaid_code, json_data)
25
- except nx.NetworkXNoPath:
26
- st.error("These processes are completely disconnected in the model.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/case_4.py DELETED
@@ -1,32 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, processes = ctx["G_active"], ctx["processes"]
8
-
9
- st.write("Finds all valid data flow sequences (respecting directions).")
10
- col1, col2 = st.columns(2)
11
- with col1: p1_name = st.selectbox("Process A (From):", ctx["sorted_process_names"], key="c4_p1")
12
- with col2: p2_name = st.selectbox("Process B (To):", ctx["sorted_process_names"], key="c4_p2")
13
-
14
- if st.button("Generate Diagram") and p1_name != p2_name:
15
- p1_id = [k for k, v in processes.items() if v == p1_name][0]
16
- p2_id = [k for k, v in processes.items() if v == p2_name][0]
17
- try:
18
- paths = list(nx.all_simple_paths(G_active, source=p1_id, target=p2_id, cutoff=6))
19
- if not paths:
20
- st.error("No valid data flow paths found within 6 steps.")
21
- else:
22
- st.success(f"Found {len(paths)} unique data flow path(s).")
23
- nodes_in_paths, edges_in_paths = set(), []
24
- for path in paths:
25
- nodes_in_paths.update(path)
26
- edges_in_paths.extend(get_original_edges(G_active, path))
27
- if ctx["connect_border_objects"]:
28
- edges_in_paths = enforce_border_object_relations(G_active, nodes_in_paths, edges_in_paths)
29
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_in_paths, edges_in_paths)
30
- render_mermaid(mermaid_code, json_data)
31
- except nx.NetworkXNoPath:
32
- st.error("No valid DATA FLOW exists between these processes.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/case_5.py DELETED
@@ -1,60 +0,0 @@
1
- import streamlit as st
2
- from mermaid_generator import graph_to_mermaid_and_data, enforce_border_object_relations
3
- from frontend import render_mermaid
4
-
5
- def run(ctx):
6
- G_active, G_full, U_active = ctx["G_active"], ctx["G_full"], ctx["U_active"]
7
- processes = ctx["processes"]
8
-
9
- st.write("Shows all connected objects up to X steps away. Renders internal steps inside the function block.")
10
- p_name = st.selectbox("Select Process (Business Function):", ctx["sorted_process_names"], key="c5_p")
11
- distance = st.radio("Search depth (steps):", (1, 2), horizontal=True)
12
-
13
- if st.button("Generate Diagram"):
14
- p_id = [k for k, v in processes.items() if v == p_name][0]
15
- nodes_to_draw, edges_to_draw = set([p_id]), []
16
-
17
- # Фикс 1: Принудительно собираем все ребра композиции из G_full, чтобы сабграфы всегда строились
18
- comp_edges = []
19
- for u, v, d in G_full.out_edges(p_id, data=True):
20
- if 'Composition' in d.get('type','') and 'BusinessProcess' in G_full.nodes[v].get('type',''):
21
- comp_edges.append((u, v, d))
22
- nodes_to_draw.add(v)
23
-
24
- visited, current_front = set(nodes_to_draw), set(nodes_to_draw)
25
- for step in range(distance):
26
- next_front = set()
27
- for node in current_front:
28
- for neighbor in U_active.neighbors(node):
29
- if neighbor not in visited:
30
- n_type = G_full.nodes[neighbor].get('type', '')
31
- # Если это объект/артефакт - добавляем в отрисовку и идем через него дальше
32
- if 'BusinessFunction' not in n_type and 'BusinessProcess' not in n_type:
33
- next_front.add(neighbor)
34
- visited.add(neighbor)
35
- # Фикс 2: Упираемся в ЛЮБОЙ смежный процесс (Function или Process)
36
- else:
37
- nodes_to_draw.add(neighbor)
38
- visited.add(neighbor)
39
- nodes_to_draw.update(next_front)
40
- current_front = next_front
41
-
42
- existing_edges = set()
43
- for u in nodes_to_draw:
44
- for v in nodes_to_draw:
45
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse':
46
- edges_to_draw.append((u, v, G_active[u][v]))
47
- existing_edges.add((u, v))
48
-
49
- # Фикс 1 (продолжение): Гарантируем присутствие ребер композиции в массиве для Mermaid
50
- for u, v, d in comp_edges:
51
- if (u, v) not in existing_edges:
52
- edges_to_draw.append((u, v, d))
53
- existing_edges.add((u, v))
54
-
55
- if ctx["connect_border_objects"]:
56
- edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
57
-
58
- st.success(f"Neighborhood built with radius {distance}.")
59
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_to_draw, edges_to_draw, render_subgraphs=True)
60
- render_mermaid(mermaid_code, json_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/case_6.py DELETED
@@ -1,26 +0,0 @@
1
- import streamlit as st
2
- import networkx as nx
3
- from mermaid_generator import graph_to_mermaid_and_data, get_original_edges, enforce_border_object_relations
4
- from frontend import render_mermaid
5
-
6
- def run(ctx):
7
- G_active, U_active, business_objects = ctx["G_active"], ctx["U_active"], ctx["business_objects"]
8
-
9
- st.write("Finds any connection between two Business Objects, ignoring direction.")
10
- col1, col2 = st.columns(2)
11
- with col1: o1_name = st.selectbox("Object A:", ctx["sorted_object_names"], key="c6_o1")
12
- with col2: o2_name = st.selectbox("Object B:", ctx["sorted_object_names"], key="c6_o2")
13
-
14
- if st.button("Generate Diagram") and o1_name != o2_name:
15
- o1_id = [k for k, v in business_objects.items() if v == o1_name][0]
16
- o2_id = [k for k, v in business_objects.items() if v == o2_name][0]
17
- try:
18
- path = nx.shortest_path(U_active, source=o1_id, target=o2_id)
19
- edges_in_path = get_original_edges(G_active, path)
20
- if ctx["connect_border_objects"]:
21
- edges_in_path = enforce_border_object_relations(G_active, set(path), edges_in_path)
22
- st.success(f"Connection found! Length: {len(path)-1} step(s).")
23
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, path, edges_in_path)
24
- render_mermaid(mermaid_code, json_data)
25
- except nx.NetworkXNoPath:
26
- st.error("These objects are completely disconnected in the model.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/cases/case_7.py DELETED
@@ -1,107 +0,0 @@
1
- import streamlit as st
2
- from mermaid_generator import graph_to_mermaid_and_data, enforce_border_object_relations
3
- from frontend import render_mermaid
4
-
5
- def run(ctx):
6
- G_active, G_full, processes = ctx["G_active"], ctx["G_full"], ctx["processes"]
7
-
8
- st.write("Simulates an N2 Chart. Select a central process, then choose which of its actual inputs and outputs to analyze.")
9
- p_center_name = st.selectbox("Select Central Process (Business Function):", ctx["sorted_process_names"], key="c7_p_center")
10
- p_center_id = [k for k, v in processes.items() if v == p_center_name][0]
11
-
12
- actual_inputs_ids = [n for n in G_active.predecessors(p_center_id) if 'BusinessProcess' not in G_active.nodes[n].get('type', '') and 'BusinessFunction' not in G_active.nodes[n].get('type', '')]
13
- actual_outputs_ids = [n for n in G_active.successors(p_center_id) if 'BusinessProcess' not in G_active.nodes[n].get('type', '') and 'BusinessFunction' not in G_active.nodes[n].get('type', '')]
14
-
15
- inputs_dict = {n: G_active.nodes[n].get('name', 'Unnamed') for n in actual_inputs_ids}
16
- outputs_dict = {n: G_active.nodes[n].get('name', 'Unnamed') for n in actual_outputs_ids}
17
-
18
- st.write("Configure N2 Chart Interface:")
19
- col_l, col_m, col_r = st.columns(3)
20
- with col_l: selected_inputs = st.multiselect("Input Artifacts (from XML):", sorted(list(inputs_dict.values())), max_selections=5, key="c7_inputs")
21
- with col_m: st.info(f"**Central Process Node:** {p_center_name}")
22
- with col_r: selected_outputs = st.multiselect("Output Artifacts (from XML):", sorted(list(outputs_dict.values())), max_selections=5, key="c7_outputs")
23
-
24
- show_all_producers_for_outputs = st.checkbox("Show all producing processes for selected output artifacts", value=False)
25
-
26
- if st.button("Generate Diagram"):
27
- nodes_to_draw, edges_to_draw, custom_labels = set([p_center_id]), [], {}
28
-
29
- def get_artifact_cluster(start_node):
30
- if not ctx["use_hierarchy"]: return set([start_node])
31
- visited, queue = set([start_node]), [start_node]
32
- while queue:
33
- curr = queue.pop(0)
34
- for neighbor in G_full.neighbors(curr):
35
- if neighbor not in visited:
36
- edata = G_full[curr][neighbor]
37
- if any(x in edata.get('type', '') for x in ['Composition', 'Aggregation', 'Specialization']) or edata.get('access') == 'hierarchy_reverse':
38
- ntype = G_full.nodes[neighbor].get('type', '')
39
- if 'BusinessProcess' not in ntype and 'BusinessFunction' not in ntype:
40
- visited.add(neighbor); queue.append(neighbor)
41
- for neighbor in G_full.predecessors(curr):
42
- if neighbor not in visited:
43
- edata = G_full[neighbor][curr]
44
- if any(x in edata.get('type', '') for x in ['Composition', 'Aggregation', 'Specialization']) or edata.get('access') == 'hierarchy_reverse':
45
- ntype = G_full.nodes[neighbor].get('type', '')
46
- if 'BusinessProcess' not in ntype and 'BusinessFunction' not in ntype:
47
- visited.add(neighbor); queue.append(neighbor)
48
- return visited
49
-
50
- def add_custom_edge(u, v):
51
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse': edges_to_draw.append((u, v, G_active[u][v]))
52
- elif G_active.has_edge(v, u) and G_active[v][u].get('access') != 'hierarchy_reverse': edges_to_draw.append((v, u, G_active[v][u]))
53
-
54
- sel_input_ids = [k for k, v in inputs_dict.items() if v in selected_inputs]
55
- for in_id in sel_input_ids:
56
- cluster = get_artifact_cluster(in_id)
57
- nodes_to_draw.update(cluster)
58
- for u in cluster:
59
- for v in cluster:
60
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse': edges_to_draw.append((u, v, G_active[u][v]))
61
- add_custom_edge(in_id, p_center_id)
62
- for c_item in cluster:
63
- for pred in G_full.predecessors(c_item):
64
- p_type = G_full.nodes[pred].get('type', '')
65
- if ('BusinessFunction' in p_type or 'BusinessProcess' in p_type) and pred != p_center_id:
66
- if G_full.has_edge(pred, c_item) and G_full[pred][c_item].get('access') != 'hierarchy_reverse':
67
- nodes_to_draw.add(pred); edges_to_draw.append((pred, c_item, G_full[pred][c_item]))
68
-
69
- sel_output_ids = [k for k, v in outputs_dict.items() if v in selected_outputs]
70
- for out_id in sel_output_ids:
71
- cluster = get_artifact_cluster(out_id)
72
- nodes_to_draw.update(cluster)
73
- for u in cluster:
74
- for v in cluster:
75
- if G_active.has_edge(u, v) and G_active[u][v].get('access') != 'hierarchy_reverse': edges_to_draw.append((u, v, G_active[u][v]))
76
- add_custom_edge(p_center_id, out_id)
77
-
78
- direct_producers = set()
79
- for pred in G_full.predecessors(out_id):
80
- p_type = G_full.nodes[pred].get('type', '')
81
- if 'BusinessFunction' in p_type or 'BusinessProcess' in p_type:
82
- if G_full.has_edge(pred, out_id) and G_full[pred][out_id].get('access') != 'hierarchy_reverse':
83
- direct_producers.add(pred)
84
- if len(direct_producers) > 1:
85
- custom_labels[out_id] = f"{G_active.nodes[out_id].get('name', 'Unnamed')} [Shared Output]"
86
-
87
- if show_all_producers_for_outputs:
88
- for c_item in cluster:
89
- for pred in G_full.predecessors(c_item):
90
- p_type = G_full.nodes[pred].get('type', '')
91
- if 'BusinessFunction' in p_type or 'BusinessProcess' in p_type:
92
- if G_full.has_edge(pred, c_item) and G_full[pred][c_item].get('access') != 'hierarchy_reverse' and pred != p_center_id:
93
- nodes_to_draw.add(pred); edges_to_draw.append((pred, c_item, G_full[pred][c_item]))
94
-
95
- for c_item in cluster:
96
- for succ in G_full.successors(c_item):
97
- s_type = G_full.nodes[succ].get('type', '')
98
- if ('BusinessFunction' in s_type or 'BusinessProcess' in s_type) and succ != p_center_id:
99
- if G_full.has_edge(c_item, succ):
100
- nodes_to_draw.add(succ); edges_to_draw.append((c_item, succ, G_full[c_item][succ]))
101
-
102
- if ctx["connect_border_objects"]:
103
- edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
104
-
105
- st.success("N2 Chart simulation diagram compiled!")
106
- mermaid_code, json_data = graph_to_mermaid_and_data(G_active, nodes_to_draw, edges_to_draw, custom_labels=custom_labels)
107
- render_mermaid(mermaid_code, json_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/frontend.py DELETED
@@ -1,211 +0,0 @@
1
- import streamlit.components.v1 as components
2
-
3
- def render_mermaid(mermaid_code, nodes_json):
4
- """
5
- Renders the Mermaid.js diagram inside a custom HTML iframe.
6
- Injects SVG-pan-zoom for navigation, handles custom mouse click events for the sidebar,
7
- and provides canvas-based PNG and JSON data export features with a watermark.
8
- """
9
- safe_mermaid_code = mermaid_code.replace('`', '\\`').replace('$', '\\$')
10
-
11
- html_code = f"""
12
- <!DOCTYPE html>
13
- <html>
14
- <head>
15
- <script src="https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.6.1/dist/svg-pan-zoom.min.js"></script>
16
-
17
- <style>
18
- body {{ margin: 0; padding: 0; font-family: sans-serif; background: #ffffff; overflow: hidden; }}
19
- #graphDiv {{ width: 100%; height: 100vh; cursor: grab; position: relative; }}
20
- #graphDiv:active {{ cursor: grabbing; }}
21
-
22
- /* Export buttons bottom-left */
23
- #toolbar {{
24
- position: absolute; bottom: 25px; left: 25px; z-index: 100;
25
- display: flex; gap: 10px;
26
- }}
27
- button.export-btn {{
28
- background: #ffffff; border: 1px solid #ccc; padding: 10px 18px;
29
- border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: bold;
30
- box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: all 0.2s;
31
- }}
32
- button.export-btn:hover {{ background: #f0f0f0; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.15); }}
33
-
34
- /* Sidebar info panel styles */
35
- #infoPanel {{
36
- display: none; position: absolute; top: 20px; right: 20px;
37
- width: 350px; max-height: 80vh; background: #ffffff;
38
- border: 1px solid #e0e0e0; border-radius: 8px;
39
- box-shadow: 0 10px 25px rgba(0,0,0,0.2); padding: 20px;
40
- overflow-y: auto; z-index: 1000; flex-direction: column;
41
- }}
42
- #infoPanel h3 {{ margin: 0 0 15px 0; font-size: 18px; color: #333; }}
43
- #infoPanel p {{ margin: 0; font-size: 14px; color: #555; line-height: 1.6; }}
44
-
45
- #closeBtn {{
46
- position: absolute; top: 15px; right: 15px; cursor: pointer;
47
- font-size: 24px; color: #aaa; background: none; border: none; padding: 0;
48
- }}
49
- #closeBtn:hover {{ color: #333; }}
50
-
51
- .node {{ cursor: pointer !important; }}
52
- .cluster {{ cursor: pointer !important; }}
53
- </style>
54
-
55
- <script>
56
- window.downloadJson = function() {{
57
- const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(nodeData, null, 4));
58
- const a = document.createElement("a");
59
- a.href = dataStr;
60
- a.download = "Architecture_Dictionary.json";
61
- a.click();
62
- }};
63
-
64
- window.downloadPng = function() {{
65
- const svg = document.querySelector('#graphDiv svg');
66
- if (!svg) return;
67
-
68
- const oldZoom = window.panZoomSetup.getZoom();
69
- const oldPan = window.panZoomSetup.getPan();
70
- window.panZoomSetup.resetZoom();
71
- window.panZoomSetup.resetPan();
72
-
73
- setTimeout(() => {{
74
- const svgData = new XMLSerializer().serializeToString(svg);
75
- const canvas = document.createElement("canvas");
76
- const bbox = svg.getBoundingClientRect();
77
-
78
- canvas.width = bbox.width * 2;
79
- canvas.height = bbox.height * 2;
80
-
81
- const ctx = canvas.getContext("2d");
82
- ctx.fillStyle = "white";
83
- ctx.fillRect(0, 0, canvas.width, canvas.height);
84
- ctx.scale(2, 2);
85
-
86
- const img = new Image();
87
- img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgData)));
88
-
89
- img.onload = function() {{
90
- ctx.drawImage(img, 0, 0);
91
-
92
- ctx.font = "12px sans-serif";
93
- ctx.fillStyle = "#888888";
94
- const dateStr = new Date().toLocaleString('en-US');
95
- const watermarkText1 = `Diagram generated on ${{dateStr}} by the model analysis script.`;
96
- const watermarkText2 = `Script rights belong to INCOSE. Developed by Alexander Efremov.`;
97
-
98
- ctx.fillText(watermarkText1, 15, bbox.height - 25);
99
- ctx.fillText(watermarkText2, 15, bbox.height - 10);
100
-
101
- const a = document.createElement("a");
102
- a.download = "Architecture_Diagram.png";
103
- a.href = canvas.toDataURL("image/png");
104
- a.click();
105
-
106
- window.panZoomSetup.zoom(oldZoom);
107
- window.panZoomSetup.pan(oldPan);
108
- }};
109
- }}, 100);
110
- }};
111
-
112
- window.closePanel = function() {{
113
- document.getElementById('infoPanel').style.display = 'none';
114
- }};
115
- </script>
116
-
117
- <script type="module">
118
- import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
119
- mermaid.initialize({{ startOnLoad: false, theme: 'default', securityLevel: 'loose' }});
120
-
121
- window.nodeData = {nodes_json};
122
- const nodeByName = {{}};
123
- for (const key in nodeData) {{
124
- let cleanName = nodeData[key].name.replace(/['"]/g, '');
125
- nodeByName[cleanName] = nodeData[key];
126
- }}
127
-
128
- window.renderDiagram = async function() {{
129
- const container = document.getElementById('graphDiv');
130
-
131
- container.addEventListener('wheel', function(e) {{
132
- e.preventDefault();
133
- }}, {{ passive: false }});
134
-
135
- const {{ svg }} = await mermaid.render('mermaidSvg', `{safe_mermaid_code}`);
136
- container.innerHTML = svg;
137
-
138
- const svgElement = container.querySelector('svg');
139
- svgElement.style.width = "100%";
140
- svgElement.style.height = "100%";
141
-
142
- window.panZoomSetup = svgPanZoom(svgElement, {{
143
- zoomEnabled: true,
144
- controlIconsEnabled: true,
145
- fit: true,
146
- center: true,
147
- minZoom: 0.1,
148
- maxZoom: 10,
149
- preventMouseEventsDefault: false
150
- }});
151
-
152
- window.addEventListener('resize', function() {{
153
- if (window.panZoomSetup) window.panZoomSetup.resize();
154
- }});
155
-
156
- let isDragging = false;
157
- let startPos = {{x: 0, y: 0}};
158
-
159
- container.addEventListener('mousedown', function(e) {{
160
- isDragging = false;
161
- startPos = {{x: e.clientX, y: e.clientY}};
162
- }}, true);
163
-
164
- container.addEventListener('mousemove', function(e) {{
165
- if (Math.abs(e.clientX - startPos.x) > 3 || Math.abs(e.clientY - startPos.y) > 3) {{
166
- isDragging = true;
167
- }}
168
- }}, true);
169
-
170
- container.addEventListener('mouseup', function(e) {{
171
- if (!isDragging) {{
172
- let node = e.target.closest('.node') || e.target.closest('.cluster');
173
- if (node) {{
174
- let label = "";
175
- let span = node.querySelector('.nodeLabel') || node.querySelector('.cluster-label');
176
- if (span) {{
177
- label = span.textContent.trim();
178
- }} else {{
179
- label = node.textContent.trim();
180
- }}
181
- label = label.replace(/['"]/g, '');
182
-
183
- let data = nodeByName[label];
184
- if (data) {{
185
- document.getElementById('panelTitle').innerText = data.name;
186
- document.getElementById('panelDoc').innerText = data.doc ? data.doc : "Description is missing in the model.";
187
- document.getElementById('infoPanel').style.display = 'flex';
188
- }}
189
- }}
190
- }}
191
- }}, true);
192
- }};
193
-
194
- window.addEventListener('load', window.renderDiagram);
195
- </script>
196
- </head>
197
- <body>
198
- <div id="toolbar">
199
- <button class="export-btn" onclick="downloadPng()">📸 Export PNG</button>
200
- <button class="export-btn" onclick="downloadJson()">💾 Export Data (JSON)</button>
201
- </div>
202
- <div id="infoPanel">
203
- <button id="closeBtn" onclick="closePanel()">&times;</button>
204
- <h3 id="panelTitle">Process Name</h3>
205
- <p id="panelDoc">Documentation...</p>
206
- </div>
207
- <div id="graphDiv"></div>
208
- </body>
209
- </html>
210
- """
211
- components.html(html_code, height=800, scrolling=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/mermaid_generator.py DELETED
@@ -1,203 +0,0 @@
1
- import json
2
-
3
- def graph_to_mermaid_and_data(G_active, nodes_to_include, edges_to_include, render_subgraphs=False, custom_labels=None):
4
- if not nodes_to_include:
5
- return "", "{}"
6
-
7
- if custom_labels is None:
8
- custom_labels = {}
9
-
10
- lines = [
11
- "flowchart LR",
12
- "classDef process fill:#FFF2CC,stroke:#D6B656,stroke-width:2px,color:#000;",
13
- "classDef object fill:#D5E8D4,stroke:#82B366,stroke-width:2px,color:#000;"
14
- ]
15
-
16
- nodes_data = {}
17
- parent_map = {}
18
- filtered_edges = []
19
-
20
- if render_subgraphs:
21
- for u, v, data in edges_to_include:
22
- u_type = G_active.nodes[u].get('type', '')
23
- v_type = G_active.nodes[v].get('type', '')
24
- if 'Composition' in data.get('type', '') and 'BusinessFunction' in u_type and 'BusinessProcess' in v_type:
25
- parent_map[v] = u
26
- else:
27
- filtered_edges.append((u, v, data))
28
- else:
29
- filtered_edges = edges_to_include
30
-
31
- children_by_parent = {}
32
- standalone_nodes = []
33
-
34
- for n in nodes_to_include:
35
- if render_subgraphs and n in parent_map:
36
- p = parent_map[n]
37
- if p not in children_by_parent:
38
- children_by_parent[p] = []
39
- children_by_parent[p].append(n)
40
- else:
41
- standalone_nodes.append(n)
42
-
43
- for p in children_by_parent.keys():
44
- if p in standalone_nodes:
45
- standalone_nodes.remove(p)
46
-
47
- # Initialize link counter and list for grey link indices
48
- link_index = 0
49
- grey_link_indices = []
50
-
51
- for p_id, children in children_by_parent.items():
52
- if p_id in nodes_to_include:
53
- p_data = G_active.nodes[p_id]
54
- m_pid = p_id.replace("-", "_")
55
- p_name = custom_labels.get(p_id, p_data.get("name", "Unknown")).replace('"', "'")
56
-
57
- lines.append(f' subgraph {m_pid} ["{p_name}"]')
58
- lines.append(f' direction TB')
59
- lines.append(f' style {m_pid} fill:#FFF2CC,stroke:#D6B656,stroke-width:2px,color:#000;')
60
-
61
- prev_cid = None
62
- for c_id in children:
63
- c_data = G_active.nodes[c_id]
64
- m_cid = c_id.replace("-", "_")
65
- c_name = custom_labels.get(c_id, c_data.get("name", "Unknown")).replace('"', "'")
66
-
67
- lines.append(f' {m_cid}("{c_name}"):::process')
68
- lines.append(f' click {m_cid} call handleNodeClick()')
69
- nodes_data[m_cid] = {"name": c_name, "doc": c_data.get("doc", "").replace('"', "'").replace("\n", " ")}
70
-
71
- if prev_cid:
72
- lines.append(f' {prev_cid} ~~~ {m_cid}')
73
- # Include hidden links in the index count
74
- link_index += 1
75
- prev_cid = m_cid
76
-
77
- lines.append(f' end')
78
- lines.append(f' click {m_pid} call handleNodeClick()')
79
- nodes_data[m_pid] = {"name": p_name, "doc": p_data.get("doc", "").replace('"', "'").replace("\n", " ")}
80
- else:
81
- for c_id in children:
82
- standalone_nodes.append(c_id)
83
-
84
- for n_id in standalone_nodes:
85
- data = G_active.nodes.get(n_id, {})
86
- m_id = n_id.replace("-", "_")
87
- name = custom_labels.get(n_id, data.get("name", "Unknown")).replace('"', "'")
88
- n_type = data.get("type", "")
89
- doc = data.get("doc", "").replace('"', "'").replace("\n", " ")
90
-
91
- if 'BusinessProcess' in n_type or 'BusinessFunction' in n_type:
92
- lines.append(f' {m_id}("{name}"):::process')
93
- else:
94
- lines.append(f' {m_id}["{name}"]:::object')
95
-
96
- lines.append(f' click {m_id} call handleNodeClick()')
97
- nodes_data[m_id] = {"name": name, "doc": doc}
98
-
99
- # === LINK SORTING LOGIC ===
100
- def get_sort_weight(data):
101
- e_type = data.get("type", "")
102
- access = data.get("access", "")
103
- rel_name = data.get("name", "")
104
- subclass = data.get("subclass", "")
105
-
106
- if 'Access' in e_type:
107
- if subclass == 'Controls' or rel_name == 'Controls': return 0
108
- if access.lower() == 'read': return 1 # Input
109
- if subclass == 'Situational' or rel_name == 'Situational': return 2
110
- if subclass == 'Enables' or rel_name == 'Enables': return 3
111
- if access.lower() == 'write': return 4 # Output
112
- return 5 # Other Access types
113
- return 6 # All other relation types (Composition, Aggregation, etc.)
114
-
115
- # Sort the list of edges by weight before generating them
116
- filtered_edges.sort(key=lambda edge: get_sort_weight(edge[2]))
117
-
118
- added_edges = set()
119
- for u, v, data in filtered_edges:
120
- edge_key = (u, v)
121
- if edge_key not in added_edges:
122
- u_id = u.replace("-", "_")
123
- v_id = v.replace("-", "_")
124
- e_type = data.get("type", "")
125
- access = data.get("access", "")
126
- # Extract Name attribute from edge data
127
- rel_name = data.get("name", "")
128
- # Extract subclass attribute
129
- subclass = data.get("subclass", "")
130
-
131
- if 'Access' in e_type:
132
- if subclass == 'Controls' or rel_name == 'Controls':
133
- label = "Controls"
134
- elif subclass == 'Enables' or rel_name == 'Enables':
135
- label = "Enables"
136
- elif subclass == 'Situational' or rel_name == 'Situational':
137
- label = "Situational"
138
- elif access.lower() == 'read':
139
- label = "Input"
140
- elif access.lower() == 'write':
141
- label = "Output"
142
- else:
143
- label = "Access"
144
- else:
145
- label = e_type.replace("Relationship", "").replace("archimate:", "")
146
-
147
- # === LINK GENERATION ===
148
- if 'Composition' in e_type:
149
- lines.append(f' {v_id} == "{label}" ==> {u_id}')
150
- elif 'Aggregation' in e_type:
151
- lines.append(f' {v_id} -- "{label}" --o {u_id}')
152
- elif 'Specialization' in e_type:
153
- lines.append(f' {u_id} -. "{label}" .-> {v_id}')
154
- # Draw dashed lines for specific systemic link types
155
- elif label in ["Controls", "Situational", "Enables"]:
156
- lines.append(f' {u_id} -.->|{label}| {v_id}')
157
- # Default to solid lines for Input, Output, and others
158
- else:
159
- lines.append(f' {u_id} -->|{label}| {v_id}')
160
-
161
- # Store the index for the required system links
162
- if label in ["Controls", "Enables", "Situational"]:
163
- grey_link_indices.append(str(link_index))
164
-
165
- link_index += 1
166
- added_edges.add(edge_key)
167
-
168
- # Add style for grey links (grouped by comma WITHOUT a trailing semicolon)
169
- if grey_link_indices:
170
- indices_str = ",".join(grey_link_indices)
171
- lines.append(f' linkStyle {indices_str} stroke:#808080,stroke-width:2px,color:#808080')
172
-
173
- return "\n".join(lines), json.dumps(nodes_data)
174
-
175
- def get_original_edges(G_graph, path):
176
- edges = []
177
- for i in range(len(path)-1):
178
- u, v = path[i], path[i+1]
179
- if G_graph.has_edge(u, v) and G_graph[u][v].get('access') != 'hierarchy_reverse':
180
- edges.append((u, v, G_graph[u][v]))
181
- elif G_graph.has_edge(v, u) and G_graph[v][u].get('access') != 'hierarchy_reverse':
182
- edges.append((v, u, G_graph[v][u]))
183
- return edges
184
-
185
- def enforce_border_object_relations(G_graph, nodes_set, edges_list):
186
- objects_in_graph = [n for n in nodes_set if 'BusinessProcess' not in G_graph.nodes[n].get('type','') and 'BusinessFunction' not in G_graph.nodes[n].get('type','')]
187
- existing_edges = set((u, v) for u, v, _ in edges_list)
188
-
189
- for i in range(len(objects_in_graph)):
190
- for j in range(i + 1, len(objects_in_graph)):
191
- o1, o2 = objects_in_graph[i], objects_in_graph[j]
192
-
193
- if G_graph.has_edge(o1, o2) and G_graph[o1][o2].get('access') != 'hierarchy_reverse':
194
- if (o1, o2) not in existing_edges:
195
- edges_list.append((o1, o2, G_graph[o1][o2]))
196
- existing_edges.add((o1, o2))
197
-
198
- if G_graph.has_edge(o2, o1) and G_graph[o2][o1].get('access') != 'hierarchy_reverse':
199
- if (o2, o1) not in existing_edges:
200
- edges_list.append((o2, o1, G_graph[o2][o1]))
201
- existing_edges.add((o2, o1))
202
-
203
- return edges_list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/parser.py DELETED
@@ -1,192 +0,0 @@
1
- import xml.etree.ElementTree as ET
2
- import networkx as nx
3
- import streamlit as st
4
-
5
- @st.cache_data
6
- def load_and_parse_xml(file_path, include_enablers=False):
7
- """
8
- Reads the ArchiMate Open Exchange XML and constructs NetworkX graphs.
9
- Returns: (G_full, G_direct, processes_dict, objects_dict)
10
- """
11
- tree = ET.parse(file_path)
12
- root = tree.getroot()
13
-
14
- G_full = nx.DiGraph()
15
- G_direct = nx.DiGraph()
16
- processes = {}
17
- business_objects = {}
18
-
19
- # 1. Collect graph nodes
20
- for elem in root.findall('.//*'):
21
- if elem.tag.endswith('element'):
22
- n_id = elem.get('identifier')
23
- n_type = next((v for k, v in elem.attrib.items() if k.endswith('type')), 'Unknown')
24
-
25
- name = "Unnamed"
26
- doc = ""
27
- for child in elem:
28
- if child.tag.endswith('name') and child.text:
29
- name = child.text
30
- elif child.tag.endswith('documentation') and child.text:
31
- doc = child.text
32
-
33
- G_full.add_node(n_id, name=name, type=n_type, doc=doc)
34
- G_direct.add_node(n_id, name=name, type=n_type, doc=doc)
35
-
36
- if 'BusinessFunction' in n_type:
37
- processes[n_id] = name
38
- elif 'BusinessProcess' not in n_type and 'Unknown' not in n_type and 'Role' not in n_type and 'Actor' not in n_type:
39
- business_objects[n_id] = name
40
-
41
- # 1.5 Identify Profile and Property IDs for specializations (Handling UUIDs)
42
- specialization_prop_ids = set(['specialization'])
43
- profile_dict = {}
44
-
45
- for elem in root.findall('.//*'):
46
- if elem.tag.endswith('propertyDefinition'):
47
- prop_id = elem.get('identifier')
48
- for child in elem:
49
- if child.tag.endswith('name') and child.text and child.text.lower() == 'specialization':
50
- specialization_prop_ids.add(prop_id)
51
- elif elem.tag.endswith('profile'):
52
- prof_id = elem.get('identifier')
53
- prof_name = elem.get('name')
54
- if prof_id and prof_name:
55
- profile_dict[prof_id] = prof_name
56
-
57
- # 2. Preliminary collection of relationships, including the Name and Subclass fields
58
- relationships = []
59
- for rel in root.findall('.//*'):
60
- if rel.tag.endswith('relationship'):
61
- src = rel.get('source')
62
- tgt = rel.get('target')
63
- r_type = next((v for k, v in rel.attrib.items() if k.endswith('type')), 'Association')
64
- access = rel.get('accessType', '')
65
-
66
- rel_name = ""
67
- subclass = ""
68
-
69
- for child in rel:
70
- if child.tag.endswith('name') and child.text:
71
- rel_name = child.text
72
- elif child.tag.endswith('properties'):
73
- for prop in child:
74
- if prop.tag.endswith('property'):
75
- is_spec = prop.get('propertyDefinitionRef') in specialization_prop_ids
76
- for val in prop:
77
- if val.tag.endswith('value') and val.text:
78
- # Fallback: take value if it belongs to specialization property OR directly matches our targets
79
- if is_spec or val.text in ['Controls', 'Enables', 'Situational']:
80
- subclass = val.text
81
- elif child.tag.endswith('profiles'):
82
- for prof in child:
83
- if prof.tag.endswith('profileRef'):
84
- ref_id = prof.get('ref')
85
- if ref_id in profile_dict:
86
- subclass = profile_dict[ref_id]
87
-
88
- # Принудительно присваиваем имя связи на основе её подкласса
89
- if subclass in ['Controls', 'Enables', 'Situational']:
90
- rel_name = subclass
91
-
92
- relationships.append((src, tgt, r_type, access, rel_name, subclass))
93
-
94
- # 3. Identify the meta-level (Only Specialization between BusinessFunctions)
95
- meta_parents_children = {}
96
- for src, tgt, r_type, access, rel_name, subclass in relationships:
97
- if 'Specialization' in r_type:
98
- # Ensure both nodes exist in the graph
99
- if G_full.has_node(src) and G_full.has_node(tgt):
100
- src_type = G_full.nodes[src].get('type', '')
101
- tgt_type = G_full.nodes[tgt].get('type', '')
102
-
103
- # Ignore specialization of business objects, catch only processes
104
- if 'BusinessFunction' in src_type and 'BusinessFunction' in tgt_type:
105
- if tgt not in meta_parents_children:
106
- meta_parents_children[tgt] = []
107
- meta_parents_children[tgt].append(src)
108
-
109
- # 4. Build the base graph (adding the name and subclass attributes)
110
- for src, tgt, r_type, access, rel_name, subclass in relationships:
111
- if not (G_full.has_node(src) and G_full.has_node(tgt)):
112
- continue
113
-
114
- if 'Access' in r_type:
115
- if access.lower() == 'read':
116
- G_full.add_edge(tgt, src, type=r_type, access=access, name=rel_name, subclass=subclass)
117
- G_direct.add_edge(tgt, src, type=r_type, access=access, name=rel_name, subclass=subclass)
118
- else:
119
- G_full.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
120
- G_direct.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
121
- else:
122
- G_full.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
123
- if not any(x in r_type for x in ['Composition', 'Aggregation', 'Specialization']):
124
- G_direct.add_edge(src, tgt, type=r_type, access=access, name=rel_name, subclass=subclass)
125
- if any(x in r_type for x in ['Composition', 'Aggregation', 'Specialization']):
126
- G_full.add_edge(tgt, src, type=r_type, access='hierarchy_reverse', name=rel_name, subclass=subclass)
127
-
128
- # 5. Apply meta-level processing logic
129
- if not include_enablers:
130
- # Option 1: Ignore the parent element and its exclusive business objects
131
- for parent in meta_parents_children.keys():
132
- if G_full.has_node(parent):
133
- # Remember neighbors before deletion to check for orphans
134
- neighbors = list(G_full.predecessors(parent)) + list(G_full.successors(parent))
135
-
136
- # Remove the parent element itself from graphs and dictionaries
137
- G_full.remove_node(parent)
138
- if G_direct.has_node(parent):
139
- G_direct.remove_node(parent)
140
- if parent in processes:
141
- del processes[parent]
142
-
143
- # Clean up associated business objects if they are left without connections (isolated)
144
- for n in set(neighbors):
145
- if n in business_objects and G_full.has_node(n):
146
- if G_full.degree(n) == 0:
147
- G_full.remove_node(n)
148
- if G_direct.has_node(n):
149
- G_direct.remove_node(n)
150
- del business_objects[n]
151
- else:
152
- # Option 2: Dynamic projection of Enables, Controls, and Situational relationships
153
- for parent, children in meta_parents_children.items():
154
- if not G_full.has_node(parent):
155
- continue
156
-
157
- edges_to_project = []
158
-
159
- # Collect outgoing connections of the parent
160
- for u, v, data in G_full.edges(parent, data=True):
161
- is_valid_type = 'Access' in data.get('type', '')
162
- is_valid_subclass = data.get('subclass') in ['Controls', 'Enables', 'Situational']
163
- is_target_object = v in business_objects
164
-
165
- if is_valid_type and is_valid_subclass and is_target_object:
166
- edges_to_project.append((u, v, data))
167
-
168
- # Collect incoming connections of the parent (in case of reverse reading / Read Access)
169
- for u, v, data in G_full.in_edges(parent, data=True):
170
- is_valid_type = 'Access' in data.get('type', '')
171
- is_valid_subclass = data.get('subclass') in ['Controls', 'Enables', 'Situational']
172
- is_source_object = u in business_objects
173
-
174
- if is_valid_type and is_valid_subclass and is_source_object:
175
- edges_to_project.append((u, v, data))
176
-
177
- # Duplicate the found relationships to all children
178
- for u, v, data in edges_to_project:
179
- for child in children:
180
- if not G_full.has_node(child):
181
- continue
182
-
183
- # Determine which end the parent was on, and substitute the child instead
184
- new_u = child if u == parent else u
185
- new_v = child if v == parent else v
186
-
187
- G_full.add_edge(new_u, new_v, **data)
188
- # Check that both nodes exist in the direct graph before duplicating the relationship there
189
- if G_direct.has_node(new_u) and G_direct.has_node(new_v):
190
- G_direct.add_edge(new_u, new_v, **data)
191
-
192
- return G_full, G_direct, processes, business_objects
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/streamlit_app.py DELETED
@@ -1,77 +0,0 @@
1
- import os
2
- import streamlit as st
3
- from parser import load_and_parse_xml
4
- import case_manager
5
-
6
- st.set_page_config(page_title="ISO 15288 Analyzer", layout="wide")
7
-
8
- st.markdown("""
9
- <style>
10
- .main .block-container { max-width: 100% !important; padding: 1rem 1rem 0 1rem !important; }
11
- iframe { width: 100% !important; height: 85vh !important; border: 1px solid #ccc; border-radius: 8px; }
12
- header { visibility: hidden; }
13
- div.row-widget.stRadio { margin-bottom: -5px; }
14
- </style>
15
- """, unsafe_allow_html=True)
16
-
17
- st.title("ISO 15288: Architecture Analyzer")
18
-
19
- mode = st.radio(
20
- "Select analysis scenario:",
21
- (
22
- "Case 1: Interface exchange between selected processes",
23
- "Case 2: Shortest DATA FLOW path (Directed)",
24
- "Case 3: Closest STRUCTURAL connection (Undirected)",
25
- "Case 4: All possible DATA FLOW paths (Directed)",
26
- "Case 5: Process Neighborhood & Internal Steps (Subgraphs)",
27
- "Case 6: Shortest connection between Business Objects (Undirected)",
28
- "Case 7: N2 Chart Simulation (Process Inputs & Outputs)"
29
- )
30
- )
31
-
32
- # Expand to 3 columns to accommodate the new checkbox
33
- col_opt1, col_opt2, col_opt3 = st.columns(3)
34
- with col_opt1:
35
- use_hierarchy = st.checkbox("Include derived connections (Whole-Part, Specialization hierarchy)", value=True)
36
- with col_opt2:
37
- connect_border_objects = st.checkbox("Show relationships between boundary objects on diagram", value=True)
38
- with col_opt3:
39
- # New checkbox for the meta-level
40
- include_enablers = st.checkbox("Include Enablers and Controls", value=False)
41
-
42
- try:
43
- current_script_dir = os.path.dirname(os.path.abspath(__file__))
44
- xml_file_path = os.path.join(current_script_dir, "ISO15288_Archi_Import.xml")
45
-
46
- # Pass the checkbox state to the parser
47
- G_full, G_direct, processes, business_objects = load_and_parse_xml(xml_file_path, include_enablers)
48
- sorted_process_names = sorted(list(processes.values()))
49
- sorted_object_names = sorted(list(business_objects.values()))
50
- except FileNotFoundError:
51
- # Получаем список всех файлов в директории скрипта
52
- files_in_dir = os.listdir(current_script_dir)
53
-
54
- st.error(f"Файл 'ISO15288_Archi_Import.xml' не найден.")
55
- st.warning(f"Скрипт искал его по пути: {xml_file_path}")
56
- st.info(f"Фактическое содержимое папки {current_script_dir}:")
57
- st.write(files_in_dir) # Выведет список файлов прямо на экран Streamlit
58
- st.stop()
59
-
60
- # Build the global context to pass to the cases
61
- ctx = {
62
- "G_full": G_full,
63
- "G_active": G_full if use_hierarchy else G_direct,
64
- "U_active": (G_full if use_hierarchy else G_direct).to_undirected(),
65
- "processes": processes,
66
- "business_objects": business_objects,
67
- "sorted_process_names": sorted_process_names,
68
- "sorted_object_names": sorted_object_names,
69
- "use_hierarchy": use_hierarchy,
70
- "connect_border_objects": connect_border_objects,
71
- "include_enablers": include_enablers # Added to the context for potential use within cases
72
- }
73
-
74
- st.markdown("---")
75
-
76
- # Pass execution to the router
77
- case_manager.run_case(mode, ctx)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
streamlit_app.py DELETED
@@ -1,77 +0,0 @@
1
- import os
2
- import streamlit as st
3
- from parser import load_and_parse_xml
4
- import case_manager
5
-
6
- st.set_page_config(page_title="ISO 15288 Analyzer", layout="wide")
7
-
8
- st.markdown("""
9
- <style>
10
- .main .block-container { max-width: 100% !important; padding: 1rem 1rem 0 1rem !important; }
11
- iframe { width: 100% !important; height: 85vh !important; border: 1px solid #ccc; border-radius: 8px; }
12
- header { visibility: hidden; }
13
- div.row-widget.stRadio { margin-bottom: -5px; }
14
- </style>
15
- """, unsafe_allow_html=True)
16
-
17
- st.title("ISO 15288: Architecture Analyzer")
18
-
19
- mode = st.radio(
20
- "Select analysis scenario:",
21
- (
22
- "Case 1: Interface exchange between selected processes",
23
- "Case 2: Shortest DATA FLOW path (Directed)",
24
- "Case 3: Closest STRUCTURAL connection (Undirected)",
25
- "Case 4: All possible DATA FLOW paths (Directed)",
26
- "Case 5: Process Neighborhood & Internal Steps (Subgraphs)",
27
- "Case 6: Shortest connection between Business Objects (Undirected)",
28
- "Case 7: N2 Chart Simulation (Process Inputs & Outputs)"
29
- )
30
- )
31
-
32
- # Expand to 3 columns to accommodate the new checkbox
33
- col_opt1, col_opt2, col_opt3 = st.columns(3)
34
- with col_opt1:
35
- use_hierarchy = st.checkbox("Include derived connections (Whole-Part, Specialization hierarchy)", value=True)
36
- with col_opt2:
37
- connect_border_objects = st.checkbox("Show relationships between boundary objects on diagram", value=True)
38
- with col_opt3:
39
- # New checkbox for the meta-level
40
- include_enablers = st.checkbox("Include Enablers and Controls", value=False)
41
-
42
- try:
43
- current_script_dir = os.path.dirname(os.path.abspath(__file__))
44
- xml_file_path = os.path.join(current_script_dir, "ISO15288_Archi_Import.xml")
45
-
46
- # Pass the checkbox state to the parser
47
- G_full, G_direct, processes, business_objects = load_and_parse_xml(xml_file_path, include_enablers)
48
- sorted_process_names = sorted(list(processes.values()))
49
- sorted_object_names = sorted(list(business_objects.values()))
50
- except FileNotFoundError:
51
- # Получаем список всех файлов в директории скрипта
52
- files_in_dir = os.listdir(current_script_dir)
53
-
54
- st.error(f"Файл 'ISO15288_Archi_Import.xml' не найден.")
55
- st.warning(f"Скрипт искал его по пути: {xml_file_path}")
56
- st.info(f"Фактическое содержимое папки {current_script_dir}:")
57
- st.write(files_in_dir) # Выведет список файлов прямо на экран Streamlit
58
- st.stop()
59
-
60
- # Build the global context to pass to the cases
61
- ctx = {
62
- "G_full": G_full,
63
- "G_active": G_full if use_hierarchy else G_direct,
64
- "U_active": (G_full if use_hierarchy else G_direct).to_undirected(),
65
- "processes": processes,
66
- "business_objects": business_objects,
67
- "sorted_process_names": sorted_process_names,
68
- "sorted_object_names": sorted_object_names,
69
- "use_hierarchy": use_hierarchy,
70
- "connect_border_objects": connect_border_objects,
71
- "include_enablers": include_enablers # Added to the context for potential use within cases
72
- }
73
-
74
- st.markdown("---")
75
-
76
- # Pass execution to the router
77
- case_manager.run_case(mode, ctx)