pyegeria 5.3.6.2.4__py3-none-any.whl → 5.3.6.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyegeria/__init__.py +3 -0
- pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/freddie_intro.md +64 -16
- pyegeria/commands/cat/{freddie_jupyter.py → dr_egeria_jupyter.py} +8 -16
- pyegeria/commands/cat/{freddie_md.py → dr_egeria_md.py} +29 -32
- pyegeria/commands/cat/glossary_actions.py +59 -1
- pyegeria/commands/cat/list_categories.py +185 -0
- pyegeria/commands/cat/list_glossaries.py +26 -33
- pyegeria/commands/cat/list_terms.py +47 -47
- pyegeria/commands/cli/egeria.py +51 -61
- pyegeria/commands/cli/egeria_cat.py +53 -31
- pyegeria/create_tech_guid_lists.py +2 -5
- pyegeria/glossary_browser_omvs.py +257 -105
- pyegeria/glossary_manager_omvs.py +148 -1591
- pyegeria/md_processing_utils.py +816 -0
- {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/METADATA +1 -1
- {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/RECORD +21 -29
- {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/entry_points.txt +5 -0
- pyegeria/commands/cat/freddie_jup.py +0 -124
- pyegeria/commands/cat/freddie_utils.py +0 -590
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-19-29-Report.md +0 -69
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-20-30-Update-Form.md +0 -78
- pyegeria/commands/cat/glossary_creation_experiment.ipynb +0 -235
- pyegeria/test_j.html +0 -0
- pyegeria/test_m.html +0 -213
- pyegeria/test_m1.html +0 -273
- pyegeria/test_mer.ipynb +0 -596
- pyegeria/test_w.html +0 -213
- /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_creation_experiment.ipynb +0 -0
- /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_exp.md +0 -0
- {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/WHEEL +0 -0
@@ -1,590 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
|
3
|
-
This file contains functions to parse and process Egeria Markdown (Freddie)
|
4
|
-
|
5
|
-
|
6
|
-
"""
|
7
|
-
|
8
|
-
import json
|
9
|
-
from jupyter_notebook_parser import JupyterNotebookParser
|
10
|
-
import nbformat
|
11
|
-
import os
|
12
|
-
import re
|
13
|
-
from pyegeria import EgeriaTech
|
14
|
-
from rich import box, print
|
15
|
-
from rich.console import Console
|
16
|
-
from rich.markdown import Markdown
|
17
|
-
from rich.prompt import Prompt
|
18
|
-
from rich.table import Table
|
19
|
-
import click
|
20
|
-
from pyegeria import EgeriaTech, body_slimmer, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND, NO_PROJECTS_FOUND
|
21
|
-
from pyegeria._exceptions import (
|
22
|
-
InvalidParameterException,
|
23
|
-
PropertyServerException,
|
24
|
-
print_exception_response,
|
25
|
-
)
|
26
|
-
import datetime
|
27
|
-
commands = ["Create Glossary", "Update Glossary",
|
28
|
-
"Create Term", "Update Term",
|
29
|
-
"Create Personal Project", "Update Personal Project"]
|
30
|
-
ERROR = "ERROR-> "
|
31
|
-
INFO = "INFO- "
|
32
|
-
WARNING = "WARNING-> "
|
33
|
-
pre_command = "\n---\n==> Processing command:"
|
34
|
-
|
35
|
-
def is_valid_iso_date(date_text) -> bool:
|
36
|
-
"""Checks if the given string is a valid ISO date."""
|
37
|
-
try:
|
38
|
-
datetime.datetime.strptime(date_text, '%Y-%m-%d')
|
39
|
-
return True
|
40
|
-
except ValueError:
|
41
|
-
return False
|
42
|
-
|
43
|
-
def get_current_datetime_string():
|
44
|
-
"""Returns the current date and time as a human-readable string."""
|
45
|
-
now = datetime.datetime.now()
|
46
|
-
return now.strftime("%Y%m%d%H%M%S")
|
47
|
-
|
48
|
-
|
49
|
-
def extract_command(block: str) -> str | None:
|
50
|
-
match = re.search(r"#(.*?)(?:##|\n|$)", block) # Using a non capturing group
|
51
|
-
if match:
|
52
|
-
return match.group(1).strip()
|
53
|
-
return None
|
54
|
-
|
55
|
-
|
56
|
-
def extract_attribute (text: str, label: str) -> str | None:
|
57
|
-
"""
|
58
|
-
Extracts the glossary name from a string.
|
59
|
-
|
60
|
-
Args:
|
61
|
-
text: The input string.
|
62
|
-
label: The label to search for.
|
63
|
-
|
64
|
-
Returns:
|
65
|
-
The glossary name, or None if not found.
|
66
|
-
"""
|
67
|
-
pattern = r"## " + re.escape(label) + r"\n(.*?)(?:##|$)" # Construct pattern
|
68
|
-
match = re.search(pattern, text, re.DOTALL)
|
69
|
-
if match and not match.group(1).isspace():
|
70
|
-
txt =match.group(1).strip()
|
71
|
-
return txt
|
72
|
-
return None
|
73
|
-
|
74
|
-
def update_a_command(txt: str, command: str, obj_type: str, q_name: str, u_guid: str)->str:
|
75
|
-
u_guid = u_guid if u_guid else " "
|
76
|
-
verb = command.split(' ')[0].strip()
|
77
|
-
action = "Update" if (verb == "Create" and u_guid is not None) else "Create"
|
78
|
-
txt = txt.replace(f"{command}", f'**{action} {obj_type}**\n') # update the command
|
79
|
-
txt = txt.replace('<GUID>', f'**GUID**\n{u_guid}') # update with GUID
|
80
|
-
txt = txt.replace('<Qualified Name>', f"**Qualified Name**\n{q_name}")
|
81
|
-
if "Qualified Name" not in txt:
|
82
|
-
txt += f"\n## **Qualified Name**\n{q_name}\n"
|
83
|
-
if "GUID" not in txt:
|
84
|
-
txt += f"\n## **GUID**\n{u_guid}\n"
|
85
|
-
# if command == "Update Term":
|
86
|
-
# txt = txt.replace('Update Description', f"**Update Description**\n")
|
87
|
-
return txt
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
def process_glossary_upsert_command(egeria_client: EgeriaTech, element_dictionary: dict, txt: str,
|
92
|
-
directive: str = "display" ) -> str | None:
|
93
|
-
"""
|
94
|
-
Processes a glossary create or update command by extracting key attributes such as
|
95
|
-
glossary name, language, description, and usage from the given cell.
|
96
|
-
|
97
|
-
:param txt: A string representing the input cell to be processed for
|
98
|
-
extracting glossary-related attributes.
|
99
|
-
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
100
|
-
:return: A string summarizing the outcome of the processing.
|
101
|
-
"""
|
102
|
-
command = extract_command(txt)
|
103
|
-
object_type = command.split(' ')[1].strip()
|
104
|
-
object_action = command.split(' ')[0].strip()
|
105
|
-
|
106
|
-
glossary_name = extract_attribute(txt, 'Glossary Name')
|
107
|
-
print(Markdown(f"{pre_command} `{command}` for glossary: `{glossary_name}` with directive: `{directive}` "))
|
108
|
-
language = extract_attribute(txt, 'Language')
|
109
|
-
description = extract_attribute(txt, 'Description')
|
110
|
-
usage = extract_attribute(txt, 'Usage')
|
111
|
-
glossary_display = (f"\n* Command: {command}\n\t* Glossary: {glossary_name}\n\t"
|
112
|
-
f"* Language: {language}\n\t* Description:\n{description}\n"
|
113
|
-
f"* Usage: {usage}\n"
|
114
|
-
f"* Qualified Name: <Qualified Name>\n"
|
115
|
-
f"* GUID: <GUID>\n\n")
|
116
|
-
|
117
|
-
def validate_glossary(obj_action: str) -> tuple[bool, bool, str | None, str | None]:
|
118
|
-
valid = True
|
119
|
-
msg = ""
|
120
|
-
known_glossary_guid = None
|
121
|
-
known_q_name = None
|
122
|
-
|
123
|
-
glossary_details = egeria_client.get_glossaries_by_name(glossary_name)
|
124
|
-
if glossary_details == NO_GLOSSARIES_FOUND:
|
125
|
-
glossary_exists = False
|
126
|
-
else:
|
127
|
-
glossary_exists = True
|
128
|
-
|
129
|
-
if glossary_name is None:
|
130
|
-
msg = f"* {ERROR}Glossary name is missing\n"
|
131
|
-
valid = False
|
132
|
-
if language is None:
|
133
|
-
msg += f"* {ERROR}Language is missing\n"
|
134
|
-
valid = False
|
135
|
-
if description is None:
|
136
|
-
msg += f"* {INFO}Description is missing\n"
|
137
|
-
|
138
|
-
if len(glossary_details) > 1 and glossary_exists:
|
139
|
-
msg += f"* {ERROR}More than one glossary with name {glossary_name} found\n"
|
140
|
-
valid = False
|
141
|
-
if len(glossary_details) == 1:
|
142
|
-
known_glossary_guid = glossary_details[0]['elementHeader'].get('guid', None)
|
143
|
-
known_q_name = glossary_details[0]['glossaryProperties'].get('qualifiedName', None)
|
144
|
-
|
145
|
-
if obj_action == "Update":
|
146
|
-
q_name = extract_attribute(txt, 'Qualified Name')
|
147
|
-
|
148
|
-
if not glossary_exists:
|
149
|
-
msg += f"* {ERROR}Glossary {glossary_name} does not exist\n"
|
150
|
-
valid = False
|
151
|
-
# if len(glossary_details) > 1 and glossary_exists:
|
152
|
-
# msg += f"* {ERROR}More than one glossary with name {glossary_name} found\n"
|
153
|
-
# valid = False
|
154
|
-
# if len(glossary_details) == 1:
|
155
|
-
# known_glossary_guid = glossary_details[0]['elementHeader'].get('guid', None)
|
156
|
-
# known_q_name = glossary_details[0]['glossaryProperties'].get('qualifiedName',None)
|
157
|
-
if q_name is None:
|
158
|
-
msg += f"* {INFO}Qualified Name is missing => can use known qualified name of {known_q_name}\n"
|
159
|
-
valid = True
|
160
|
-
elif q_name != known_q_name:
|
161
|
-
msg += (f"* {ERROR}Glossary {glossary_name} qualifiedName mismatch between {q_name} and {known_q_name}\n")
|
162
|
-
valid = False
|
163
|
-
if valid:
|
164
|
-
msg += glossary_display
|
165
|
-
msg += f"* -->Glossary {glossary_name} exists and can be updated\n"
|
166
|
-
else:
|
167
|
-
msg += f"* --> validation failed\n"
|
168
|
-
|
169
|
-
print(Markdown(msg))
|
170
|
-
return valid, glossary_exists, known_glossary_guid, known_q_name
|
171
|
-
|
172
|
-
elif obj_action == "Create":
|
173
|
-
if glossary_exists:
|
174
|
-
msg += f"{ERROR}Glossary {glossary_name} already exists\n"
|
175
|
-
|
176
|
-
elif valid:
|
177
|
-
msg += f"-->It is valid to create Glossary \'{glossary_name}\' with:\n"
|
178
|
-
msg += glossary_display
|
179
|
-
|
180
|
-
print(Markdown(msg))
|
181
|
-
return valid, glossary_exists, known_glossary_guid, known_q_name
|
182
|
-
|
183
|
-
if directive == "display":
|
184
|
-
print(Markdown(glossary_display))
|
185
|
-
return None
|
186
|
-
|
187
|
-
elif directive == "validate":
|
188
|
-
is_valid, exists, known_guid, known_q_name = validate_glossary(object_action)
|
189
|
-
valid = is_valid if is_valid else None
|
190
|
-
return valid
|
191
|
-
|
192
|
-
elif directive == "process":
|
193
|
-
is_valid, exists, known_guid, known_q_name = validate_glossary(object_action)
|
194
|
-
if not is_valid:
|
195
|
-
return None
|
196
|
-
if object_action == "Update":
|
197
|
-
if not exists:
|
198
|
-
print(f"\n{ERROR}Glossary {glossary_name} does not exist! Updating result document with Create command\n")
|
199
|
-
return update_a_command(txt, command, object_type, known_q_name, known_guid)
|
200
|
-
|
201
|
-
body = {
|
202
|
-
"class": "ReferenceableRequestBody",
|
203
|
-
"elementProperties":
|
204
|
-
{
|
205
|
-
"class": "GlossaryProperties",
|
206
|
-
"qualifiedName": known_q_name,
|
207
|
-
"description": description,
|
208
|
-
"language": language,
|
209
|
-
"usage": usage
|
210
|
-
}
|
211
|
-
}
|
212
|
-
egeria_client.update_glossary(known_guid, body)
|
213
|
-
print(f"\n-->Updated Glossary {glossary_name} with GUID {known_guid}")
|
214
|
-
element_dictionary[f"glossary.{glossary_name}"] = {'guid' : known_guid,
|
215
|
-
'q_name' : known_q_name
|
216
|
-
}
|
217
|
-
return update_a_command(txt, command, object_type, known_q_name, known_guid)
|
218
|
-
elif object_action == "Create" :
|
219
|
-
guid = None
|
220
|
-
|
221
|
-
if exists:
|
222
|
-
print(f"\nGlossary {glossary_name} already exists and result document updated\n")
|
223
|
-
return update_a_command(txt, command, object_type, known_q_name, known_guid)
|
224
|
-
else:
|
225
|
-
guid = egeria_client.create_glossary(glossary_name, description,
|
226
|
-
language, usage)
|
227
|
-
glossary = egeria_client.get_glossary_by_guid(guid)
|
228
|
-
if glossary == NO_GLOSSARIES_FOUND:
|
229
|
-
print(f"{ERROR}Just created with GUID {guid} but Glossary not found\n")
|
230
|
-
return None
|
231
|
-
qualified_name = glossary['glossaryProperties']["qualifiedName"]
|
232
|
-
element_dictionary[f"glossary.{glossary_name}"] = {
|
233
|
-
'guid': guid,
|
234
|
-
'q_name': qualified_name
|
235
|
-
}
|
236
|
-
return update_a_command(txt, command, object_type, qualified_name, guid)
|
237
|
-
|
238
|
-
|
239
|
-
def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: dict, txt: str, directive: str = "display" ) -> str | None:
|
240
|
-
"""
|
241
|
-
Processes a term create or update command by extracting key attributes such as
|
242
|
-
term name, summary, description, abbreviation, examples, usage, version, and status from the given cell.
|
243
|
-
|
244
|
-
:param txt: A string representing the input cell to be processed for
|
245
|
-
extracting glossary-related attributes.
|
246
|
-
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
247
|
-
:return: A string summarizing the outcome of the processing.
|
248
|
-
"""
|
249
|
-
|
250
|
-
command = extract_command(txt)
|
251
|
-
object_type = command.split(' ')[1].strip()
|
252
|
-
object_action = command.split(' ')[0].strip()
|
253
|
-
|
254
|
-
term_name = extract_attribute(txt, 'Term Name')
|
255
|
-
summary = extract_attribute(txt, 'Summary')
|
256
|
-
description = extract_attribute(txt, 'Description')
|
257
|
-
abbreviation = extract_attribute(txt, 'Abbreviation')
|
258
|
-
examples = extract_attribute(txt, 'Examples')
|
259
|
-
usage = extract_attribute(txt, 'Usage')
|
260
|
-
version = extract_attribute(txt, 'Version')
|
261
|
-
status = extract_attribute(txt, 'Status')
|
262
|
-
glossary_name = extract_attribute(txt, 'Glossary Name')
|
263
|
-
|
264
|
-
print(Markdown(f"{pre_command} `{command}` for term: `{term_name}` with directive: `{directive}`"))
|
265
|
-
|
266
|
-
def validate_term(obj_action: str) -> tuple[bool, bool, str | None, str | None]:
|
267
|
-
nonlocal version
|
268
|
-
valid = True
|
269
|
-
msg = ""
|
270
|
-
known_term_guid = None
|
271
|
-
known_q_name = None
|
272
|
-
|
273
|
-
term_details = egeria_client.get_terms_by_name(term_name)
|
274
|
-
if term_details == NO_TERMS_FOUND:
|
275
|
-
term_exists = False
|
276
|
-
else:
|
277
|
-
term_exists = True
|
278
|
-
|
279
|
-
if term_name is None:
|
280
|
-
msg = f"* {ERROR}Term name is missing\n"
|
281
|
-
valid = False
|
282
|
-
if glossary_name is None:
|
283
|
-
msg += f"* {ERROR}Glossary name is missing\n"
|
284
|
-
valid = False
|
285
|
-
if status is None:
|
286
|
-
msg += f"* {INFO}Term status is missing - will default to DRAFT"
|
287
|
-
|
288
|
-
if summary is None:
|
289
|
-
msg += f"* {INFO}Term summary is missing\n"
|
290
|
-
|
291
|
-
if description is None:
|
292
|
-
msg += f"* {INFO}Term description is missing\n"
|
293
|
-
|
294
|
-
if abbreviation is None:
|
295
|
-
msg += f"* {INFO}Term abbreviation is missing\n"
|
296
|
-
if examples is None:
|
297
|
-
msg += f"* {INFO}Term examples is missing\n"
|
298
|
-
if usage is None:
|
299
|
-
msg += f"* {INFO}Term usage is missing\n"
|
300
|
-
if version is None:
|
301
|
-
msg += f"* {INFO}Term version is missing - will default to 0.0.1\n"
|
302
|
-
version = "0.0.1"
|
303
|
-
|
304
|
-
|
305
|
-
if obj_action == "Update": # check to see if provided information exists and is consistent with existing info
|
306
|
-
if not term_exists:
|
307
|
-
msg += f"* {ERROR}Term {term_name} does not exist\n"
|
308
|
-
valid = False
|
309
|
-
|
310
|
-
if len(term_details) > 1 and term_exists:
|
311
|
-
msg += f"* {ERROR}More than one term with name {term_name} found\n"
|
312
|
-
valid = False
|
313
|
-
elif len(term_details) == 1:
|
314
|
-
known_term_guid = term_details[0]['elementHeader'].get('guid', None)
|
315
|
-
known_q_name = term_details[0]['glossaryTermProperties'].get('qualifiedName', None)
|
316
|
-
if q_name != known_q_name:
|
317
|
-
msg += (f"* {ERROR}Term {term_name} qualifiedName mismatch between {q_name} and {known_q_name}\n")
|
318
|
-
valid = False
|
319
|
-
else:
|
320
|
-
msg += f"--> * Term {term_name} exists and can be updated\n"
|
321
|
-
msg += term_display
|
322
|
-
|
323
|
-
print(Markdown(msg))
|
324
|
-
return valid, term_exists, known_term_guid, known_q_name
|
325
|
-
|
326
|
-
elif obj_action == 'Create': # if the command is create, check that it doesn't already exist
|
327
|
-
if term_exists:
|
328
|
-
msg += f"\n{WARNING}Term \'{term_name}\' already exists, response document updated.\n"
|
329
|
-
elif not valid:
|
330
|
-
msg += f"\n-->Validation checks failed in creating Term \'{term_name}\' with: {term_display}\n"
|
331
|
-
else:
|
332
|
-
msg += f"\n-->It is valid to create Term \'{term_name}\' with: {term_display}\n"
|
333
|
-
|
334
|
-
print(Markdown(msg))
|
335
|
-
return valid, term_exists, known_term_guid, known_q_name
|
336
|
-
|
337
|
-
if object_action == "Update":
|
338
|
-
term_guid = extract_attribute(txt, 'GUID')
|
339
|
-
term_guid = term_guid if term_guid else " "
|
340
|
-
q_name = extract_attribute(txt, 'Qualified Name')
|
341
|
-
q_name = q_name if q_name else " "
|
342
|
-
update_description = extract_attribute(txt, 'Update Description')
|
343
|
-
update_description = update_description if update_description else " "
|
344
|
-
term_display = (f"\n* Command: {command}\n\t* Glossary: {glossary_name}\n\t"
|
345
|
-
f"* Term Name: {term_name}\n\t* Summary: {summary}\n\t* Description: {description}\n\t"
|
346
|
-
f"* Abbreviation: {abbreviation}\n\t* Examples: {examples}\n\t* Usage: {usage}\n\t"
|
347
|
-
f"* Version: {version}\n\t* Status: {status}\n\t* GUID: {term_guid}\n\t* Qualified Name: {q_name}"
|
348
|
-
f"\n\t* Update Description: {update_description}\n")
|
349
|
-
else:
|
350
|
-
term_display = (f"\n* Command: {command}\n\t* Glossary: {glossary_name}\n\t"
|
351
|
-
f"* Term Name: {term_name}\n\t* Summary: {summary}\n\t* Description: {description}\n\t"
|
352
|
-
f"* Abbreviation: {abbreviation}\n\t* Examples: {examples}\n\t* Usage: {usage}\n\t"
|
353
|
-
f"* Version: {version}\n\t* Status: {status}\n")
|
354
|
-
|
355
|
-
|
356
|
-
if directive == "display":
|
357
|
-
print(Markdown(term_display))
|
358
|
-
return None
|
359
|
-
elif directive == "validate":
|
360
|
-
is_valid, exists, known_guid, known_q_name = validate_term(object_action)
|
361
|
-
valid = is_valid if is_valid else None
|
362
|
-
return valid
|
363
|
-
elif directive == "process":
|
364
|
-
is_valid, exists, known_guid, known_q_name = validate_term(object_action)
|
365
|
-
if not is_valid: # First validate the term before we process it
|
366
|
-
return None
|
367
|
-
|
368
|
-
if object_action == "Update":
|
369
|
-
if not exists:
|
370
|
-
print(f"\n-->Term {term_name} does not exist")
|
371
|
-
return None
|
372
|
-
body = {
|
373
|
-
"class": "ReferenceableRequestBody",
|
374
|
-
"elementProperties":
|
375
|
-
{
|
376
|
-
"class": "GlossaryTermProperties",
|
377
|
-
"qualifiedName": known_q_name,
|
378
|
-
"summary": summary,
|
379
|
-
"description": description,
|
380
|
-
"abbreviation": abbreviation,
|
381
|
-
"examples": examples,
|
382
|
-
"usage": usage,
|
383
|
-
"publishVersionIdentifier": version,
|
384
|
-
"status": status
|
385
|
-
},
|
386
|
-
"updateDescription": update_description
|
387
|
-
}
|
388
|
-
egeria_client.update_term(known_guid, body)
|
389
|
-
print(f"\n-->Updated Term {term_name} with GUID {known_guid}")
|
390
|
-
return update_a_command(txt, command, object_type, known_q_name, known_guid)
|
391
|
-
|
392
|
-
elif object_action == "Create" :
|
393
|
-
guid = None
|
394
|
-
q_name = f"GlossaryTerm:{term_name}:{get_current_datetime_string()}"
|
395
|
-
if exists:
|
396
|
-
print(f"\n{ERROR}Term {term_name} exists and result document updated")
|
397
|
-
return update_a_command(txt, command, object_type, q_name, known_guid)
|
398
|
-
else:
|
399
|
-
## get the guid for the glossary from the name - first look locally
|
400
|
-
glossary = element_dictionary.get(f"glossary.{glossary_name}",None)
|
401
|
-
|
402
|
-
if glossary is not None:
|
403
|
-
glossary_guid = glossary.get('guid', None)
|
404
|
-
if glossary_guid is None:
|
405
|
-
print(f"{ERROR}Glossary reference {glossary_name} not found")
|
406
|
-
return None
|
407
|
-
else:
|
408
|
-
glossary_guid = egeria_client.__get_guid__(property_name="displayName", display_name=glossary_name)
|
409
|
-
if glossary_guid == NO_ELEMENTS_FOUND:
|
410
|
-
print(f"{ERROR}Glossary {glossary_name} not found")
|
411
|
-
return None
|
412
|
-
term_body = {
|
413
|
-
"class": "ReferenceableRequestBody",
|
414
|
-
"elementProperties":
|
415
|
-
{
|
416
|
-
"class": "GlossaryTermProperties",
|
417
|
-
"qualifiedName":q_name,
|
418
|
-
"displayName": term_name,
|
419
|
-
"summary": summary,
|
420
|
-
"description": description,
|
421
|
-
"abbreviation": abbreviation,
|
422
|
-
"examples": examples,
|
423
|
-
"usage": usage,
|
424
|
-
"publishVersionIdentifier": version
|
425
|
-
# "additionalProperties":
|
426
|
-
# {
|
427
|
-
# "propertyName1": "xxxx",
|
428
|
-
# "propertyName2": "xxxx"
|
429
|
-
# }
|
430
|
-
},
|
431
|
-
"initialStatus": status
|
432
|
-
}
|
433
|
-
term_guid = egeria_client.create_controlled_glossary_term(glossary_guid, term_body)
|
434
|
-
if term_guid == NO_ELEMENTS_FOUND:
|
435
|
-
print(f"{ERROR}Term {term_name} not created")
|
436
|
-
return None
|
437
|
-
print(f"\n-->Created Term {term_name} with GUID {term_guid}")
|
438
|
-
element_dictionary[f"term.{term_name}"] = {'guid': term_guid, 'q_name': q_name}
|
439
|
-
return update_a_command(txt, command, object_type, q_name, term_guid)
|
440
|
-
|
441
|
-
|
442
|
-
def process_per_proj_upsert_command(egeria_client: EgeriaTech, element_dictionary: dict, txt: str, directive: str = "display" ) -> str | None:
|
443
|
-
"""
|
444
|
-
Processes a personal project create or update command by extracting key attributes such as
|
445
|
-
glossary name, language, description, and usage from the given cell.
|
446
|
-
|
447
|
-
:param txt: A string representing the input cell to be processed for
|
448
|
-
extracting glossary-related attributes.
|
449
|
-
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
450
|
-
:return: A string summarizing the outcome of the processing.
|
451
|
-
"""
|
452
|
-
command = extract_command(txt)
|
453
|
-
object = command.split()
|
454
|
-
object_type = f"{object[1]} {object[2]}"
|
455
|
-
object_action = object[0]
|
456
|
-
|
457
|
-
project_name = extract_attribute(txt, 'Project Name')
|
458
|
-
description = extract_attribute(txt, 'Description')
|
459
|
-
project_identifier = extract_attribute(txt, 'Project Identifier')
|
460
|
-
project_status = extract_attribute(txt, 'Project Status')
|
461
|
-
project_phase = extract_attribute(txt, 'Project Phase')
|
462
|
-
project_health = extract_attribute(txt, 'Project Health')
|
463
|
-
start_date = extract_attribute(txt, 'Start Date')
|
464
|
-
planned_end_date = extract_attribute(txt, 'Planned End Date')
|
465
|
-
print(Markdown(f"{pre_command} `{command}` for project: `{project_name}` with directive: `{directive}` "))
|
466
|
-
|
467
|
-
project_display = (f"\n* Command: {command}\n\t* Project: {project_name}\n\t"
|
468
|
-
f"* Status: {project_status}\n\t* Description: {description}\n\t"
|
469
|
-
f"* Phase: {project_phase}\n\t* Health: {project_health}\n\t"
|
470
|
-
f"* Start Date: {start_date}\n\t* Planned End Date: {planned_end_date}\n")
|
471
|
-
|
472
|
-
def validate_project(obj_action: str) -> tuple[bool, bool, str, str]:
|
473
|
-
valid = True
|
474
|
-
msg = ""
|
475
|
-
known_guid = None
|
476
|
-
known_q_name = None
|
477
|
-
|
478
|
-
project_details = egeria_client.get_projects_by_name(project_name)
|
479
|
-
if project_details == NO_PROJECTS_FOUND:
|
480
|
-
project_exists = False
|
481
|
-
else:
|
482
|
-
project_exists = True
|
483
|
-
|
484
|
-
if project_name is None:
|
485
|
-
msg = f"* {ERROR}Project name is missing\n"
|
486
|
-
valid = False
|
487
|
-
if project_status is None:
|
488
|
-
msg += f"* {INFO}No Project status found\n"
|
489
|
-
|
490
|
-
if description is None:
|
491
|
-
msg += f"* {INFO}No Description found\n"
|
492
|
-
|
493
|
-
if project_identifier is None:
|
494
|
-
msg += f"* {INFO}No Project Identifier found\n"
|
495
|
-
|
496
|
-
if project_phase is None:
|
497
|
-
msg += f"* {INFO}No Project Phase found\n"
|
498
|
-
|
499
|
-
if project_health is None:
|
500
|
-
msg += f"* {INFO}No Project Health found\n"
|
501
|
-
|
502
|
-
if start_date is None:
|
503
|
-
msg += f"* {INFO}No Start Date found\n"
|
504
|
-
elif not is_valid_iso_date(start_date):
|
505
|
-
msg += f"* {ERROR}Start Date is not a valid ISO date of form YYYY-MM-DD\n"
|
506
|
-
valid = False
|
507
|
-
|
508
|
-
if planned_end_date is None:
|
509
|
-
msg += f"* {INFO} No Planned End Date found\n"
|
510
|
-
elif not is_valid_iso_date(planned_end_date):
|
511
|
-
msg += f"* {ERROR}Planned End Date is not a valid ISO date of form YYYY-MM-DD\n"
|
512
|
-
valid = False
|
513
|
-
|
514
|
-
if obj_action == "Update":
|
515
|
-
q_name = extract_attribute(txt, 'Qualified Name')
|
516
|
-
|
517
|
-
if not project_exists:
|
518
|
-
msg += f"* {ERROR}Project {project_name} does not exist\n"
|
519
|
-
valid = False
|
520
|
-
if len(project_details) > 1 and project_exists:
|
521
|
-
msg += f"* {ERROR}More than one project with name {project_name} found\n"
|
522
|
-
valid = False
|
523
|
-
if len(project_details) == 1:
|
524
|
-
known_guid = project_details[0]['elementHeader'].get('guid', None)
|
525
|
-
known_q_name = project_details[0]['glossaryProperties'].get('qualifiedName',None)
|
526
|
-
if q_name is None:
|
527
|
-
msg += f"* {INFO}Qualified Name is missing => can use known qualified name of {known_q_name}\n"
|
528
|
-
valid = True
|
529
|
-
elif q_name != known_q_name:
|
530
|
-
msg += (f"* {ERROR}Project {project_name} qualifiedName mismatch between {q_name} and {known_q_name}\n")
|
531
|
-
valid = False
|
532
|
-
if valid:
|
533
|
-
msg += project_display
|
534
|
-
msg += f"* -->Project {project_name} exists and can be updated\n"
|
535
|
-
else:
|
536
|
-
msg += f"* --> validation failed\n"
|
537
|
-
msg+='---'
|
538
|
-
print(Markdown(msg))
|
539
|
-
return valid, project_exists, known_guid, known_q_name
|
540
|
-
|
541
|
-
elif obj_action == "Create":
|
542
|
-
if project_exists:
|
543
|
-
msg += f"\n{ERROR}Project {project_name} already exists"
|
544
|
-
else:
|
545
|
-
msg += f"\n-->It is valid to create Project \'{project_name}\' with:\n"
|
546
|
-
print(Markdown(msg))
|
547
|
-
return valid, project_exists, known_guid, known_q_name
|
548
|
-
|
549
|
-
if directive == "display":
|
550
|
-
print(Markdown(project_display))
|
551
|
-
return None
|
552
|
-
|
553
|
-
elif directive == "validate":
|
554
|
-
is_valid, exists, known_guid, known_q_name = validate_project(object_action)
|
555
|
-
valid = is_valid if is_valid else None
|
556
|
-
return valid
|
557
|
-
|
558
|
-
elif directive == "process":
|
559
|
-
is_valid, exists, known_guid, known_q_name = validate_project(object_action)
|
560
|
-
if not is_valid:
|
561
|
-
return None
|
562
|
-
if object_action == "Update":
|
563
|
-
if not exists:
|
564
|
-
print(f"\n\n-->Project {project_name} does not exist")
|
565
|
-
return None
|
566
|
-
|
567
|
-
egeria_client.update_project(known_guid, known_q_name, project_identifier, project_name,
|
568
|
-
description,project_status,project_phase,project_health,
|
569
|
-
start_date, planned_end_date,False)
|
570
|
-
print(f"\n-->Updated Project {project_name} with GUID {known_guid}")
|
571
|
-
return update_a_command(txt, command, object_type, known_q_name, known_guid)
|
572
|
-
elif object_action == "Create" :
|
573
|
-
guid = None
|
574
|
-
if exists:
|
575
|
-
print(f"Project {project_name} already exists and update document created")
|
576
|
-
return update_a_command(txt, command, object_type, known_q_name, known_guid)
|
577
|
-
else:
|
578
|
-
guid = egeria_client.create_project(None,None, None, False,
|
579
|
-
project_name, description,
|
580
|
-
"PersonalProject",project_identifier, True,
|
581
|
-
project_status, project_phase, project_health,
|
582
|
-
start_date, planned_end_date)
|
583
|
-
project_g = egeria_client.get_project(guid)
|
584
|
-
if project_g == NO_GLOSSARIES_FOUND:
|
585
|
-
print(f"Just created with GUID {guid} but Project not found")
|
586
|
-
return None
|
587
|
-
|
588
|
-
q_name = project_g['projectProperties']["qualifiedName"]
|
589
|
-
element_dictionary[f"project.{project_name}"] = {'guid': guid, 'q_name': q_name}
|
590
|
-
return update_a_command(txt, command, object_type, q_name, guid)
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Glossaries Report - created at 2025-03-06 13:19
|
2
|
-
Glossaries found from the search string: `All Glossaries`
|
3
|
-
|
4
|
-
# Glossary Name: Egeria-Markdown
|
5
|
-
|
6
|
-
## Description
|
7
|
-
Glossary to describe the vocabulary of Freddie - an Egeria Markdown language to support the exchange of metadata in a Markdown form.
|
8
|
-
Freddie allows users to input metadata using any text entry system that supports the entry of standard Markdown characters and through post-processing
|
9
|
-
commands, validates the Egeria content and allows the requests to be sent to Egeria. This is an update
|
10
|
-
|
11
|
-
## Language
|
12
|
-
English
|
13
|
-
|
14
|
-
## Usage
|
15
|
-
1) (optional) load an example or template for the type of object from Egeria.
|
16
|
-
2) Create a new document (perhaps from the template) and edit it, adding in the content with the Freddie controlled Markdown language.
|
17
|
-
3) Process the document to validate and display it before you submit it, Validation may annotate your document with recommendations and potential issues.
|
18
|
-
4) Submit the document to Egeria using the Freddie_sings command.
|
19
|
-
5) anything?
|
20
|
-
|
21
|
-
## Qualified Name
|
22
|
-
Glossary:Egeria-Markdown
|
23
|
-
|
24
|
-
## GUID
|
25
|
-
5d45b499-d0d5-4fad-bc23-763bc4073296
|
26
|
-
|
27
|
-
|
28
|
-
---
|
29
|
-
|
30
|
-
# Glossary Name: Teddy Bear Drop Foot Terminology
|
31
|
-
|
32
|
-
## Description
|
33
|
-
This glossary describes terminology invented for the fictitious study into Teddy Bear Drop Foot that is being used to demonstrate aspects of open governance without risk to real patient data.
|
34
|
-
|
35
|
-
## Language
|
36
|
-
English
|
37
|
-
|
38
|
-
## Usage
|
39
|
-
Used with the Teddy Bear Drop Foot Demonstration Study.
|
40
|
-
|
41
|
-
## Qualified Name
|
42
|
-
Glossary:TeddyBearDropFootTerminology
|
43
|
-
|
44
|
-
## GUID
|
45
|
-
c103d0c9-7581-47e1-a684-6bbe0ecd596f
|
46
|
-
|
47
|
-
|
48
|
-
---
|
49
|
-
|
50
|
-
# Glossary Name: Sustainability Glossary
|
51
|
-
|
52
|
-
## Description
|
53
|
-
Terminology associated with Coco Pharmaceutical's sustainability initiative.
|
54
|
-
|
55
|
-
## Language
|
56
|
-
English
|
57
|
-
|
58
|
-
## Usage
|
59
|
-
For all Coco Pharmaceutical employees wishing to understand more about sustainability and the organization's efforts to improve its operations.
|
60
|
-
|
61
|
-
## Qualified Name
|
62
|
-
Glossary:Sustainability
|
63
|
-
|
64
|
-
## GUID
|
65
|
-
30bfe79e-adf2-4fda-b9c5-9c86ad6b0d6c
|
66
|
-
|
67
|
-
|
68
|
-
---
|
69
|
-
|