pyegeria 5.4.3.4__py3-none-any.whl → 5.4.4__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.
- commands/cat/debug_log.2025-09-04_08-21-58_788009.log.zip +0 -0
- commands/cat/debug_log.2025-09-05_09-37-53_062579.log.zip +0 -0
- commands/cat/list_format_set.py +3 -1
- md_processing/__init__.py +9 -1
- md_processing/data/commands.json +7181 -1400
- md_processing/data/generated_format_sets.json +4137 -0
- md_processing/data/generated_format_sets.py +51 -0
- md_processing/dr_egeria.py +14 -2
- md_processing/md_commands/ext_ref_commands.py +543 -0
- md_processing/md_commands/old_solution_architect_commands.py +1139 -0
- md_processing/md_commands/solution_architect_commands.py +26 -59
- md_processing/md_processing_utils/debug_log +1 -3
- md_processing/md_processing_utils/dr-egeria-help-2025-09-09T11:10:03.md +3305 -0
- md_processing/md_processing_utils/gen_format_sets.py +422 -0
- md_processing/md_processing_utils/md_processing_constants.py +19 -1
- pyegeria/_output_formats.py +239 -85
- pyegeria/collection_manager.py +3 -3
- pyegeria/egeria_tech_client.py +3 -0
- pyegeria/external_references.py +1794 -0
- pyegeria/solution_architect.py +290 -485
- {pyegeria-5.4.3.4.dist-info → pyegeria-5.4.4.dist-info}/METADATA +1 -1
- {pyegeria-5.4.3.4.dist-info → pyegeria-5.4.4.dist-info}/RECORD +25 -199
- commands/.DS_Store +0 -0
- commands/cat/.DS_Store +0 -0
- commands/cat/.env +0 -8
- commands/cat/debug_log.2025-08-29_07-07-27_848189.log.zip +0 -0
- commands/cat/debug_log.2025-08-30_21-15-48_528443.log.zip +0 -0
- commands/cat/debug_log.log +0 -7276
- commands/cat/logs/pyegeria.log +0 -90
- commands/cli/debug_log.log +0 -0
- commands/doc/.DS_Store +0 -0
- commands/ops/logs/pyegeria.log +0 -0
- md_processing/.DS_Store +0 -0
- md_processing/.idea/.gitignore +0 -8
- md_processing/.idea/inspectionProfiles/Project_Default.xml +0 -59
- md_processing/.idea/md_processing.iml +0 -15
- md_processing/.idea/modules.xml +0 -8
- md_processing/.idea/sonarlint/issuestore/index.pb +0 -0
- md_processing/.idea/sonarlint/securityhotspotstore/index.pb +0 -0
- md_processing/.idea/vcs.xml +0 -6
- md_processing/.idea/workspace.xml +0 -107
- md_processing/dr_egeria_inbox/Derive-Dr-Gov-Defs.md +0 -8
- md_processing/dr_egeria_inbox/Dr.Egeria Templates.md +0 -873
- md_processing/dr_egeria_inbox/arch_test.md +0 -57
- md_processing/dr_egeria_inbox/archive/dr_egeria_intro.md +0 -254
- md_processing/dr_egeria_inbox/archive/dr_egeria_intro_more_terms.md +0 -696
- md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part1.md +0 -254
- md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part2.md +0 -298
- md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part3.md +0 -608
- md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part4.md +0 -94
- md_processing/dr_egeria_inbox/archive/freddie_intro.md +0 -284
- md_processing/dr_egeria_inbox/archive/freddie_intro_orig.md +0 -275
- md_processing/dr_egeria_inbox/archive/test-term.md +0 -110
- md_processing/dr_egeria_inbox/cat_test.md +0 -100
- md_processing/dr_egeria_inbox/collections.md +0 -39
- md_processing/dr_egeria_inbox/data_designer_debug.log +0 -6
- md_processing/dr_egeria_inbox/data_designer_out.md +0 -60
- md_processing/dr_egeria_inbox/data_designer_search_test.md +0 -11
- md_processing/dr_egeria_inbox/data_field.md +0 -54
- md_processing/dr_egeria_inbox/data_spec.md +0 -77
- md_processing/dr_egeria_inbox/data_spec_test.md +0 -2014
- md_processing/dr_egeria_inbox/data_test.md +0 -179
- md_processing/dr_egeria_inbox/data_test2.md +0 -429
- md_processing/dr_egeria_inbox/data_test3.md +0 -462
- md_processing/dr_egeria_inbox/dr_egeria_data_designer_1.md +0 -124
- md_processing/dr_egeria_inbox/dr_egeria_intro_categories.md +0 -168
- md_processing/dr_egeria_inbox/dr_egeria_intro_part1.md +0 -280
- md_processing/dr_egeria_inbox/dr_egeria_intro_part2.md +0 -318
- md_processing/dr_egeria_inbox/dr_egeria_intro_part3.md +0 -1073
- md_processing/dr_egeria_inbox/dr_egeria_isc1.md +0 -44
- md_processing/dr_egeria_inbox/generated_help_report.md +0 -9
- md_processing/dr_egeria_inbox/generated_help_terms.md +0 -842
- md_processing/dr_egeria_inbox/glossary_list.md +0 -5
- md_processing/dr_egeria_inbox/glossary_search_test.md +0 -40
- md_processing/dr_egeria_inbox/glossary_test1.md +0 -378
- md_processing/dr_egeria_inbox/gov_def.md +0 -718
- md_processing/dr_egeria_inbox/gov_def2.md +0 -447
- md_processing/dr_egeria_inbox/img.png +0 -0
- md_processing/dr_egeria_inbox/output_tests.md +0 -114
- md_processing/dr_egeria_inbox/product.md +0 -219
- md_processing/dr_egeria_inbox/rel.md +0 -8
- md_processing/dr_egeria_inbox/sb.md +0 -119
- md_processing/dr_egeria_inbox/solution-components.md +0 -136
- md_processing/dr_egeria_inbox/solution_blueprints.md +0 -118
- md_processing/dr_egeria_inbox/synonym_test.md +0 -42
- md_processing/dr_egeria_inbox/t2.md +0 -268
- md_processing/dr_egeria_outbox/.DS_Store +0 -0
- md_processing/dr_egeria_outbox/.obsidian/app.json +0 -1
- md_processing/dr_egeria_outbox/.obsidian/appearance.json +0 -1
- md_processing/dr_egeria_outbox/.obsidian/community-plugins.json +0 -7
- md_processing/dr_egeria_outbox/.obsidian/core-plugins.json +0 -33
- md_processing/dr_egeria_outbox/.obsidian/plugins/buttons/main.js +0 -5164
- md_processing/dr_egeria_outbox/.obsidian/plugins/buttons/manifest.json +0 -10
- md_processing/dr_egeria_outbox/.obsidian/plugins/buttons/styles.css +0 -624
- md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/data.json +0 -10
- md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/main.js +0 -4459
- md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/manifest.json +0 -10
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/data.json +0 -3
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/main.js +0 -153
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/manifest.json +0 -11
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/styles.css +0 -1
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/main.js +0 -500
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/manifest.json +0 -12
- md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/styles.css +0 -1
- md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/data.json +0 -38
- md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/main.js +0 -37
- md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/manifest.json +0 -11
- md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/styles.css +0 -220
- md_processing/dr_egeria_outbox/.obsidian/types.json +0 -28
- md_processing/dr_egeria_outbox/.obsidian/workspace.json +0 -270
- md_processing/dr_egeria_outbox/Button Test.md +0 -11
- md_processing/dr_egeria_outbox/Scripts/.DS_Store +0 -0
- md_processing/dr_egeria_outbox/Scripts/sendRest.js +0 -24
- md_processing/dr_egeria_outbox/Templates/sendToApi.md.md +0 -17
- md_processing/dr_egeria_outbox/Untitled.canvas +0 -1
- md_processing/dr_egeria_outbox/monday/processed-2025-09-01 09:26-product.md +0 -210
- md_processing/dr_egeria_outbox/monday/processed-2025-09-01 14:03-product.md +0 -209
- md_processing/dr_egeria_outbox/monday/processed-2025-09-01 14:24-product.md +0 -263
- md_processing/dr_egeria_outbox/monday/processed-2025-09-01 16:03-data_spec_test.md +0 -2374
- md_processing/dr_egeria_outbox/monday/processed-2025-09-01 16:05-data_spec_test.md +0 -2374
- md_processing/dr_egeria_outbox/monday/processed-2025-09-02 08:28-data_spec_test.md +0 -2321
- md_processing/dr_egeria_outbox/monday/processed-2025-09-02 08:37-data_spec_test.md +0 -2304
- md_processing/dr_egeria_outbox/monday/processed-2025-09-02 08:56-data_spec_test.md +0 -2324
- md_processing/dr_egeria_outbox/monday/processed-2025-09-02 09:00-data_spec_test.md +0 -2324
- md_processing/dr_egeria_outbox/processed-2025-08-30 16:56-generated_help_terms.md +0 -795
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +0 -719
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +0 -41
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +0 -33
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +0 -192
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:08-gov_def2.md +0 -486
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:10-gov_def2.md +0 -486
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:53-gov_def2.md +0 -486
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:54-gov_def2.md +0 -486
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:03-gov_def2.md +0 -486
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:06-gov_def2.md +0 -486
- md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:10-gov_def2.md +0 -486
- md_processing/family_docs/Data Designer/Create_Data_Class.md +0 -164
- md_processing/family_docs/Data Designer/Create_Data_Dictionary.md +0 -30
- md_processing/family_docs/Data Designer/Create_Data_Field.md +0 -162
- md_processing/family_docs/Data Designer/Create_Data_Specification.md +0 -36
- md_processing/family_docs/Data Designer/Create_Data_Structure.md +0 -38
- md_processing/family_docs/Data Designer/View_Data_Classes.md +0 -78
- md_processing/family_docs/Data Designer/View_Data_Dictionaries.md +0 -78
- md_processing/family_docs/Data Designer/View_Data_Fields.md +0 -78
- md_processing/family_docs/Data Designer/View_Data_Specifications.md +0 -78
- md_processing/family_docs/Data Designer/View_Data_Structures.md +0 -78
- md_processing/family_docs/Data Designer.md +0 -842
- md_processing/family_docs/Digital Product Manager/Add_Member->Collection.md +0 -42
- md_processing/family_docs/Digital Product Manager/Attach_Collection->Resource.md +0 -36
- md_processing/family_docs/Digital Product Manager/Create_Agreement.md +0 -96
- md_processing/family_docs/Digital Product Manager/Create_Data_Sharing_Agreement.md +0 -72
- md_processing/family_docs/Digital Product Manager/Create_DigitalSubscription.md +0 -102
- md_processing/family_docs/Digital Product Manager/Create_Digital_Product.md +0 -134
- md_processing/family_docs/Digital Product Manager/Link_Agreement_Items.md +0 -60
- md_processing/family_docs/Digital Product Manager/Link_Contracts.md +0 -26
- md_processing/family_docs/Digital Product Manager/Link_Digital_Product_-_Digital_Product.md +0 -30
- md_processing/family_docs/Digital Product Manager/Link_Subscribers.md +0 -48
- md_processing/family_docs/Digital Product Manager.md +0 -668
- md_processing/family_docs/Glossary/Attach_Category_Parent.md +0 -18
- md_processing/family_docs/Glossary/Attach_Term-Term_Relationship.md +0 -26
- md_processing/family_docs/Glossary/Create_Category.md +0 -38
- md_processing/family_docs/Glossary/Create_Glossary.md +0 -42
- md_processing/family_docs/Glossary/Create_Term.md +0 -70
- md_processing/family_docs/Glossary.md +0 -206
- md_processing/family_docs/Governance Officer/Create_Business_Imperative.md +0 -106
- md_processing/family_docs/Governance Officer/Create_Certification_Type.md +0 -112
- md_processing/family_docs/Governance Officer/Create_Governance_Approach.md +0 -114
- md_processing/family_docs/Governance Officer/Create_Governance_Obligation.md +0 -114
- md_processing/family_docs/Governance Officer/Create_Governance_Principle.md +0 -114
- md_processing/family_docs/Governance Officer/Create_Governance_Procedure.md +0 -128
- md_processing/family_docs/Governance Officer/Create_Governance_Process.md +0 -122
- md_processing/family_docs/Governance Officer/Create_Governance_Processing_Purpose.md +0 -106
- md_processing/family_docs/Governance Officer/Create_Governance_Responsibility.md +0 -122
- md_processing/family_docs/Governance Officer/Create_Governance_Rule.md +0 -122
- md_processing/family_docs/Governance Officer/Create_Governance_Strategy.md +0 -106
- md_processing/family_docs/Governance Officer/Create_License_Type.md +0 -112
- md_processing/family_docs/Governance Officer/Create_Naming_Standard_Rule.md +0 -122
- md_processing/family_docs/Governance Officer/Create_Regulation_Article.md +0 -106
- md_processing/family_docs/Governance Officer/Create_Regulation_Definition.md +0 -118
- md_processing/family_docs/Governance Officer/Create_Security_Access_Control.md +0 -114
- md_processing/family_docs/Governance Officer/Create_Security_Group.md +0 -120
- md_processing/family_docs/Governance Officer/Create_Service_Level_Objectives.md +0 -122
- md_processing/family_docs/Governance Officer/Create_Threat_Definition.md +0 -106
- md_processing/family_docs/Governance Officer/Link_Governance_Controls.md +0 -32
- md_processing/family_docs/Governance Officer/Link_Governance_Drivers.md +0 -32
- md_processing/family_docs/Governance Officer/Link_Governance_Policies.md +0 -32
- md_processing/family_docs/Governance Officer/View_Governance_Definitions.md +0 -82
- md_processing/family_docs/Governance Officer.md +0 -2412
- md_processing/family_docs/Solution Architect/Create_Information_Supply_Chain.md +0 -70
- md_processing/family_docs/Solution Architect/Create_Solution_Blueprint.md +0 -44
- md_processing/family_docs/Solution Architect/Create_Solution_Component.md +0 -96
- md_processing/family_docs/Solution Architect/Create_Solution_Role.md +0 -66
- md_processing/family_docs/Solution Architect/Link_Information_Supply_Chain_Peers.md +0 -32
- md_processing/family_docs/Solution Architect/Link_Solution_Component_Peers.md +0 -32
- md_processing/family_docs/Solution Architect/View_Information_Supply_Chains.md +0 -32
- md_processing/family_docs/Solution Architect/View_Solution_Blueprints.md +0 -32
- md_processing/family_docs/Solution Architect/View_Solution_Components.md +0 -32
- md_processing/family_docs/Solution Architect/View_Solution_Roles.md +0 -32
- md_processing/family_docs/Solution Architect.md +0 -490
- md_processing/md_commands/old_project_commands.py +0 -164
- md_processing/md_processing_utils/debug_log.log +0 -5580
- md_processing/md_processing_utils/generated_help_terms.md +0 -842
- md_processing/md_processing_utils/logs/pyegeria.log +0 -56
- pyegeria/.DS_Store +0 -0
- pyegeria/___external_references.py +0 -3255
- {pyegeria-5.4.3.4.dist-info → pyegeria-5.4.4.dist-info}/LICENSE +0 -0
- {pyegeria-5.4.3.4.dist-info → pyegeria-5.4.4.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.3.4.dist-info → pyegeria-5.4.4.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,543 @@
|
|
1
|
+
"""
|
2
|
+
This file contains Dr. Egeria commands for working with External References.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import json
|
6
|
+
import os
|
7
|
+
import re
|
8
|
+
from typing import List, Optional
|
9
|
+
|
10
|
+
from inflect import engine
|
11
|
+
from loguru import logger
|
12
|
+
from pydantic import ValidationError
|
13
|
+
from rich import print
|
14
|
+
from rich.console import Console
|
15
|
+
from rich.markdown import Markdown
|
16
|
+
|
17
|
+
from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command,
|
18
|
+
sync_collection_memberships, )
|
19
|
+
from md_processing.md_processing_utils.common_md_utils import (update_element_dictionary, set_update_body, set_element_status_request_body, set_element_prop_body, set_delete_request_body, set_rel_request_body,
|
20
|
+
set_peer_gov_def_request_body,
|
21
|
+
set_rel_request_body, set_create_body, set_object_classifications, set_product_body, set_rel_request_body_for_type,
|
22
|
+
set_rel_prop_body,)
|
23
|
+
|
24
|
+
from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, update_a_command)
|
25
|
+
from md_processing.md_processing_utils.md_processing_constants import (load_commands, ERROR)
|
26
|
+
from pyegeria import DEBUG_LEVEL, body_slimmer, to_pascal_case, PyegeriaException, print_basic_exception, \
|
27
|
+
print_exception_table, print_validation_error
|
28
|
+
from pyegeria.egeria_tech_client import EgeriaTech
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
from md_processing.md_processing_utils.common_md_utils import (debug_level, print_msg, set_debug_level,
|
33
|
+
get_element_dictionary, update_element_dictionary,
|
34
|
+
)
|
35
|
+
from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, extract_command,
|
36
|
+
process_simple_attribute, process_element_identifiers,
|
37
|
+
update_a_command, extract_attribute,
|
38
|
+
get_element_by_name, process_name_list)
|
39
|
+
from md_processing.md_processing_utils.md_processing_constants import (GLOSSARY_NAME_LABELS, TERM_NAME_LABELS,
|
40
|
+
TERM_RELATIONSHPS, ALWAYS, ERROR, INFO,
|
41
|
+
WARNING, pre_command, EXISTS_REQUIRED,
|
42
|
+
OUTPUT_LABELS, SEARCH_LABELS, GUID_LABELS,
|
43
|
+
ELEMENT_OUTPUT_FORMATS, command_seperator)
|
44
|
+
from pyegeria import body_slimmer
|
45
|
+
from pyegeria._globals import (NO_GLOSSARIES_FOUND, NO_ELEMENTS_FOUND, NO_CATEGORIES_FOUND)
|
46
|
+
from pyegeria.egeria_tech_client import EgeriaTech
|
47
|
+
|
48
|
+
# EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "170"))
|
49
|
+
# console = Console(width=EGERIA_WIDTH)
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
def process_external_reference_upsert_command(egeria_client: EgeriaTech, txt: str,
|
54
|
+
directive: str = "display") -> Optional[str]:
|
55
|
+
"""
|
56
|
+
Processes a project create or update object_action by extracting key attributes such as
|
57
|
+
glossary name, language, description, and usage from the given text.
|
58
|
+
|
59
|
+
:param txt: A string representing the input cell to be processed for
|
60
|
+
extracting glossary-related attributes.
|
61
|
+
:param directive: an optional string indicating the directive to be used - display, validate or execute
|
62
|
+
:return: A string summarizing the outcome of the processing.
|
63
|
+
"""
|
64
|
+
|
65
|
+
command, object_type, object_action = extract_command_plus(txt)
|
66
|
+
print(Markdown(f"# {command}\n"))
|
67
|
+
|
68
|
+
parsed_output = parse_upsert_command(egeria_client, object_type, object_action, txt, directive)
|
69
|
+
if not parsed_output:
|
70
|
+
logger.error(f"No output for `{object_action}`")
|
71
|
+
return None
|
72
|
+
|
73
|
+
valid = parsed_output['valid']
|
74
|
+
exists = parsed_output['exists']
|
75
|
+
|
76
|
+
qualified_name = parsed_output.get('qualified_name', None)
|
77
|
+
guid = parsed_output.get('guid', None)
|
78
|
+
|
79
|
+
print(Markdown(parsed_output['display']))
|
80
|
+
|
81
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
82
|
+
|
83
|
+
attributes = parsed_output['attributes']
|
84
|
+
|
85
|
+
display_name = attributes['Display Name'].get('value', None)
|
86
|
+
status = attributes.get('Status', {}).get('value', None)
|
87
|
+
#
|
88
|
+
|
89
|
+
if directive == "display":
|
90
|
+
return None
|
91
|
+
elif directive == "validate":
|
92
|
+
if valid:
|
93
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
94
|
+
else:
|
95
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
96
|
+
return valid
|
97
|
+
|
98
|
+
elif directive == "process":
|
99
|
+
try:
|
100
|
+
obj = "External Reference"
|
101
|
+
EXTERNAL_REFERENCE_PROPS = ["ExternalReferenceProperties", "ExternalDataSourceProperties",
|
102
|
+
"ExternalModelSourceProperties",
|
103
|
+
"RelatedMediaProperties", "CitedDocumentProperties"]
|
104
|
+
|
105
|
+
EXTERNAL_REFERENCE_TYPES = ["ExternalReference", "ExternalDataSource", "ExternalModelSource",
|
106
|
+
"RelatedMedia", "CitedDocument"]
|
107
|
+
|
108
|
+
|
109
|
+
# Set the property body for a glossary collection
|
110
|
+
#
|
111
|
+
prop_body = set_element_prop_body(obj, qualified_name, attributes)
|
112
|
+
prop_body["referenceTitle"] = attributes.get('Reference Title', {}).get('value', None)
|
113
|
+
prop_body["referenceAbstract"] = attributes.get('Reference Abstract', {}).get('value', None)
|
114
|
+
prop_body["authors"] = attributes.get('Authors', {}).get('name_list', None)
|
115
|
+
prop_body["organization"] = attributes.get('Organization', {}).get('value', None)
|
116
|
+
prop_body["url"] = attributes.get('URL', {}).get('value', None)
|
117
|
+
prop_body["sources"] = attributes.get('Sources', {}).get('value', None)
|
118
|
+
prop_body["license"] = attributes.get('License', {}).get('value', None)
|
119
|
+
prop_body["copyright"] = attributes.get('Copyright', {}).get('value', None)
|
120
|
+
prop_body["attribution"] = attributes.get('Attribution', {}).get('value', None)
|
121
|
+
|
122
|
+
if object_type == "RelatedMedia":
|
123
|
+
prop_body["class"] = "RelatedProperties"
|
124
|
+
prop_body["mediaType"] = attributes.get('Media Type', {}).get('value', None)
|
125
|
+
prop_body["mediaTypeOtherId"] = attributes.get('Media Type Other ID', {}).get('value', None)
|
126
|
+
prop_body["defaultMediaUsage"]= attributes.get('Default Media Usage', {}).get('value', None)
|
127
|
+
prop_body["defaultMediaUsageOtherId"] = attributes.get('Default Media Usage Other ID', {}).get('value', None)
|
128
|
+
elif object_type == "CitedDocument":
|
129
|
+
prop_body["class"] = "CitedDocumentProperties"
|
130
|
+
prop_body["numberOfPages"] = attributes.get('Number of Pages', {}).get('value', None)
|
131
|
+
prop_body["pageRange"] = attributes.get('Page Range', {}).get('value', None)
|
132
|
+
prop_body["publicationSeries"] = attributes.get('Publication Series', {}).get('value', None)
|
133
|
+
prop_body["publicationSeriesVolume"] = attributes.get('Publication Series Volume', {}).get('value', None)
|
134
|
+
prop_body["publisher"] = attributes.get('Publisher', {}).get('value', None)
|
135
|
+
prop_body["edition"] = attributes.get('Edition', {}).get('value', None)
|
136
|
+
prop_body["firstPublicationDate"] = attributes.get('First Publication Date', {}).get('value', None)
|
137
|
+
prop_body["publicationDate"] = attributes.get('Publication Date', {}).get('value', None)
|
138
|
+
prop_body["publicationCity"] = attributes.get('Publication City', {}).get('value', None)
|
139
|
+
prop_body["publicationYear"] = attributes.get('Publication Year', {}).get('value', None)
|
140
|
+
prop_body["publicationNumbers"]= attributes.get('Publication Numbers', {}).get('value', None)
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
if object_action == "Update":
|
145
|
+
if not exists:
|
146
|
+
msg = (f" Element `{display_name}` does not exist! Updating result document with Create "
|
147
|
+
f"{object_action}\n")
|
148
|
+
logger.error(msg)
|
149
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
150
|
+
elif not valid:
|
151
|
+
msg = (" The input data is invalid and cannot be processed. \nPlease review")
|
152
|
+
logger.error(msg)
|
153
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
154
|
+
print(Markdown(msg))
|
155
|
+
return None
|
156
|
+
else:
|
157
|
+
print(Markdown(
|
158
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
159
|
+
|
160
|
+
|
161
|
+
body = set_update_body(obj, attributes)
|
162
|
+
body['properties'] = prop_body
|
163
|
+
|
164
|
+
egeria_client.update_project(guid, body)
|
165
|
+
if status:
|
166
|
+
egeria_client.update_external_reference_status(guid, status)
|
167
|
+
|
168
|
+
logger.success(f"Updated {object_type} `{display_name}` with GUID {guid}\n\n___")
|
169
|
+
update_element_dictionary(qualified_name, {
|
170
|
+
'guid': guid, 'display_name': display_name
|
171
|
+
})
|
172
|
+
return egeria_client.get_external_reference_by_guid(guid, element_type= object_type,
|
173
|
+
output_format='MD', output_format_set = object_type)
|
174
|
+
|
175
|
+
|
176
|
+
elif object_action == "Create":
|
177
|
+
if valid is False and exists:
|
178
|
+
msg = (f"Project `{display_name}` already exists and result document updated changing "
|
179
|
+
f"`Create` to `Update` in processed output\n\n___")
|
180
|
+
logger.error(msg)
|
181
|
+
return update_a_command(txt, object_action, object_type, qualified_name, guid)
|
182
|
+
elif not valid:
|
183
|
+
msg = ("The input data is invalid and cannot be processed. \nPlease review")
|
184
|
+
logger.error(msg)
|
185
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
186
|
+
print(Markdown(msg))
|
187
|
+
return None
|
188
|
+
|
189
|
+
else:
|
190
|
+
body = set_create_body(object_type,attributes)
|
191
|
+
|
192
|
+
# if this is a root or folder (maybe more in the future), then make sure that the classification is set.
|
193
|
+
# body["initialClassifications"] = set_object_classifications(object_type, attributes, None)
|
194
|
+
|
195
|
+
body["properties"] = prop_body
|
196
|
+
slim_body = body_slimmer(body)
|
197
|
+
guid = egeria_client.create_external_reference(body = slim_body)
|
198
|
+
if guid:
|
199
|
+
update_element_dictionary(qualified_name, {
|
200
|
+
'guid': guid, 'display_name': display_name
|
201
|
+
})
|
202
|
+
msg = f"Created Element `{display_name}` with GUID {guid}\n\n___"
|
203
|
+
logger.success(msg)
|
204
|
+
return egeria_client.get_external_reference_by_guid(guid, element_type=object_type,
|
205
|
+
output_format='MD',
|
206
|
+
output_format_set=object_type)
|
207
|
+
else:
|
208
|
+
msg = f"Failed to create element `{display_name}` with GUID {guid}\n\n___"
|
209
|
+
logger.error(msg)
|
210
|
+
return None
|
211
|
+
|
212
|
+
except PyegeriaException as e:
|
213
|
+
logger.error(f"Pyegeria error performing {command}: {e}")
|
214
|
+
print_basic_exception(e)
|
215
|
+
return None
|
216
|
+
except Exception as e:
|
217
|
+
logger.error(f"Error performing {command}: {e}")
|
218
|
+
else:
|
219
|
+
return None
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
def process_link_to_external_reference_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
|
224
|
+
""" Link a referenceable to an external reference."""
|
225
|
+
|
226
|
+
command, object_type, object_action = extract_command_plus(txt)
|
227
|
+
print(Markdown(f"# {command}\n"))
|
228
|
+
|
229
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action,
|
230
|
+
txt, directive)
|
231
|
+
|
232
|
+
if not parsed_output:
|
233
|
+
logger.error(f"No output for `{object_action}`")
|
234
|
+
print(Markdown("## Parsing failed"))
|
235
|
+
return None
|
236
|
+
|
237
|
+
print(Markdown(parsed_output['display']))
|
238
|
+
|
239
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
240
|
+
|
241
|
+
attributes = parsed_output['attributes']
|
242
|
+
|
243
|
+
element_guid = attributes.get('Element Name', {}).get('guid', None)
|
244
|
+
external_reference_guid = attributes.get('Media Reference', {}).get('guid', None)
|
245
|
+
|
246
|
+
valid = parsed_output['valid']
|
247
|
+
exists = element_guid is not None and external_reference_guid is not None
|
248
|
+
prop_body = set_rel_prop_body("MediaReference", attributes)
|
249
|
+
|
250
|
+
if directive == "display":
|
251
|
+
|
252
|
+
return None
|
253
|
+
elif directive == "validate":
|
254
|
+
if valid:
|
255
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
256
|
+
else:
|
257
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
258
|
+
logger.error(msg)
|
259
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
260
|
+
return valid
|
261
|
+
|
262
|
+
elif directive == "process":
|
263
|
+
|
264
|
+
try:
|
265
|
+
if object_action == "Detach":
|
266
|
+
if not exists:
|
267
|
+
msg = " Link does not exist! Updating result document with Link object_action\n"
|
268
|
+
logger.error(msg)
|
269
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
270
|
+
return out
|
271
|
+
elif not valid:
|
272
|
+
return None
|
273
|
+
else:
|
274
|
+
print(Markdown(
|
275
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
276
|
+
body = set_delete_request_body(object_type, attributes)
|
277
|
+
|
278
|
+
egeria_client.detach_external_reference(element_guid, external_reference_guid, body)
|
279
|
+
|
280
|
+
logger.success(f"===> Detached segment from `{element_guid}`to {external_reference_guid}\n")
|
281
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
282
|
+
|
283
|
+
return (out)
|
284
|
+
|
285
|
+
|
286
|
+
elif object_action == "Link":
|
287
|
+
if valid is False and exists:
|
288
|
+
msg = "--> Link already exists and result document updated changing `Link` to `Detach` in processed output\n"
|
289
|
+
logger.error(msg)
|
290
|
+
|
291
|
+
elif valid is False:
|
292
|
+
msg = f"==>{object_type} Link is not valid and can't be created"
|
293
|
+
logger.error(msg)
|
294
|
+
return
|
295
|
+
|
296
|
+
else:
|
297
|
+
body = set_rel_request_body_for_type("CitedDocumentLink", attributes)
|
298
|
+
body['properties'] = prop_body
|
299
|
+
|
300
|
+
egeria_client.link_external_reference(element_guid,
|
301
|
+
external_reference_guid,
|
302
|
+
body=body_slimmer(body))
|
303
|
+
msg = f"==>Created {object_type} link \n"
|
304
|
+
logger.success(msg)
|
305
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
306
|
+
return out
|
307
|
+
|
308
|
+
except ValidationError as e:
|
309
|
+
print_validation_error(e)
|
310
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
311
|
+
return None
|
312
|
+
except PyegeriaException as e:
|
313
|
+
print_basic_exception(e)
|
314
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
315
|
+
return None
|
316
|
+
|
317
|
+
except Exception as e:
|
318
|
+
logger.error(f"Error performing {command}: {e}")
|
319
|
+
return None
|
320
|
+
else:
|
321
|
+
return None
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
def process_link_to_media_reference_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") \
|
326
|
+
-> Optional[str]:
|
327
|
+
# """ Link a referenceable to a related media reference."""
|
328
|
+
#
|
329
|
+
#
|
330
|
+
|
331
|
+
command, object_type, object_action = extract_command_plus(txt)
|
332
|
+
print(Markdown(f"# {command}\n"))
|
333
|
+
|
334
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action,
|
335
|
+
txt, directive)
|
336
|
+
|
337
|
+
if not parsed_output:
|
338
|
+
logger.error(f"No output for `{object_action}`")
|
339
|
+
print(Markdown("## Parsing failed"))
|
340
|
+
return None
|
341
|
+
|
342
|
+
print(Markdown(parsed_output['display']))
|
343
|
+
|
344
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
345
|
+
|
346
|
+
attributes = parsed_output['attributes']
|
347
|
+
|
348
|
+
element_guid = attributes.get('Element Name', {}).get('guid', None)
|
349
|
+
media_reference_guid = attributes.get('Media Reference', {}).get('guid', None)
|
350
|
+
media_id = attributes.get('Media Id', {}).get('value', None)
|
351
|
+
media_usage = attributes.get('Media Usage', {}).get('value', None)
|
352
|
+
media_usage_other_id = attributes.get('Media Usage Other Id', {}).get('value', None)
|
353
|
+
|
354
|
+
valid = parsed_output['valid']
|
355
|
+
exists = element_guid is not None and media_reference_guid is not None
|
356
|
+
prop_body = set_rel_prop_body("MediaReference", attributes)
|
357
|
+
prop_body["mediaId"] = media_id
|
358
|
+
prop_body["mediaUsageId"] = media_usage
|
359
|
+
prop_body["mediaUsageOtherId"] = media_usage_other_id
|
360
|
+
|
361
|
+
|
362
|
+
if directive == "display":
|
363
|
+
|
364
|
+
return None
|
365
|
+
elif directive == "validate":
|
366
|
+
if valid:
|
367
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
368
|
+
else:
|
369
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
370
|
+
logger.error(msg)
|
371
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
372
|
+
return valid
|
373
|
+
|
374
|
+
elif directive == "process":
|
375
|
+
|
376
|
+
try:
|
377
|
+
if object_action == "Detach":
|
378
|
+
if not exists:
|
379
|
+
msg = " Link does not exist! Updating result document with Link object_action\n"
|
380
|
+
logger.error(msg)
|
381
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
382
|
+
return out
|
383
|
+
elif not valid:
|
384
|
+
return None
|
385
|
+
else:
|
386
|
+
print(Markdown(
|
387
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
388
|
+
body = set_delete_request_body(object_type, attributes)
|
389
|
+
|
390
|
+
egeria_client.detach_cited_document(element_guid, media_reference_guid, body)
|
391
|
+
|
392
|
+
logger.success(f"===> Detached segment from `{element_guid}`to {media_reference_guid}\n")
|
393
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
394
|
+
|
395
|
+
return (out)
|
396
|
+
|
397
|
+
|
398
|
+
elif object_action == "Link":
|
399
|
+
if valid is False and exists:
|
400
|
+
msg = "--> Link already exists and result document updated changing `Link` to `Detach` in processed output\n"
|
401
|
+
logger.error(msg)
|
402
|
+
|
403
|
+
elif valid is False:
|
404
|
+
msg = f"==>{object_type} Link is not valid and can't be created"
|
405
|
+
logger.error(msg)
|
406
|
+
return
|
407
|
+
|
408
|
+
else:
|
409
|
+
body = set_rel_request_body_for_type("CitedDocumentLink", attributes)
|
410
|
+
body['properties'] = prop_body
|
411
|
+
|
412
|
+
egeria_client.link_cited_document(element_guid,
|
413
|
+
media_reference_guid,
|
414
|
+
body=body_slimmer(body))
|
415
|
+
msg = f"==>Created {object_type} link \n"
|
416
|
+
logger.success(msg)
|
417
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
418
|
+
return out
|
419
|
+
|
420
|
+
except ValidationError as e:
|
421
|
+
print_validation_error(e)
|
422
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
423
|
+
return None
|
424
|
+
except PyegeriaException as e:
|
425
|
+
print_basic_exception(e)
|
426
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
427
|
+
return None
|
428
|
+
|
429
|
+
except Exception as e:
|
430
|
+
logger.error(f"Error performing {command}: {e}")
|
431
|
+
return None
|
432
|
+
else:
|
433
|
+
return None
|
434
|
+
|
435
|
+
def process_link_to_cited_document_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") \
|
436
|
+
-> Optional[str]:
|
437
|
+
|
438
|
+
# """ Link a referenceable to a cited document."""
|
439
|
+
#
|
440
|
+
|
441
|
+
command, object_type, object_action = extract_command_plus(txt)
|
442
|
+
print(Markdown(f"# {command}\n"))
|
443
|
+
|
444
|
+
parsed_output = parse_view_command(egeria_client, object_type, object_action,
|
445
|
+
txt, directive)
|
446
|
+
|
447
|
+
if not parsed_output:
|
448
|
+
logger.error(f"No output for `{object_action}`")
|
449
|
+
print(Markdown("## Parsing failed"))
|
450
|
+
return None
|
451
|
+
|
452
|
+
print(Markdown(parsed_output['display']))
|
453
|
+
|
454
|
+
logger.debug(json.dumps(parsed_output, indent=4))
|
455
|
+
|
456
|
+
attributes = parsed_output['attributes']
|
457
|
+
|
458
|
+
element_guid = attributes.get('Element Name', {}).get('guid', None)
|
459
|
+
cited_document_guid = attributes.get('Cited Document', {}).get('guid', None)
|
460
|
+
reference_id = attributes.get('Reference Id', {}).get('value', None)
|
461
|
+
pages = attributes.get('Pages', {}).get('value', None)
|
462
|
+
|
463
|
+
valid = parsed_output['valid']
|
464
|
+
exists = element_guid is not None and cited_document_guid is not None
|
465
|
+
prop_body = set_rel_prop_body("CitedDocumentLink", attributes)
|
466
|
+
prop_body["referenceId"] = reference_id
|
467
|
+
prop_body["pages"] = pages
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
if directive == "display":
|
472
|
+
|
473
|
+
return None
|
474
|
+
elif directive == "validate":
|
475
|
+
if valid:
|
476
|
+
print(Markdown(f"==> Validation of {command} completed successfully!\n"))
|
477
|
+
else:
|
478
|
+
msg = f"Validation failed for object_action `{command}`\n"
|
479
|
+
logger.error(msg)
|
480
|
+
print(Markdown(f"==> Validation of {command} failed!!\n"))
|
481
|
+
return valid
|
482
|
+
|
483
|
+
elif directive == "process":
|
484
|
+
|
485
|
+
|
486
|
+
try:
|
487
|
+
if object_action == "Detach":
|
488
|
+
if not exists:
|
489
|
+
msg = f" Link does not exist! Updating result document with Link object_action\n"
|
490
|
+
logger.error(msg)
|
491
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
492
|
+
return out
|
493
|
+
elif not valid:
|
494
|
+
return None
|
495
|
+
else:
|
496
|
+
print(Markdown(
|
497
|
+
f"==> Validation of {command} completed successfully! Proceeding to apply the changes.\n"))
|
498
|
+
body = set_delete_request_body(object_type, attributes)
|
499
|
+
|
500
|
+
egeria_client.detach_cited_document(element_guid, cited_document_guid,body)
|
501
|
+
|
502
|
+
logger.success(f"===> Detached segment from `{element_guid}`to {cited_document_guid}\n")
|
503
|
+
out = parsed_output['display'].replace('Unlink', 'Link', 1)
|
504
|
+
|
505
|
+
return (out)
|
506
|
+
|
507
|
+
|
508
|
+
elif object_action == "Link":
|
509
|
+
if valid is False and exists:
|
510
|
+
msg = "--> Link already exists and result document updated changing `Link` to `Detach` in processed output\n"
|
511
|
+
logger.error(msg)
|
512
|
+
|
513
|
+
elif valid is False:
|
514
|
+
msg = f"==>{object_type} Link is not valid and can't be created"
|
515
|
+
logger.error(msg)
|
516
|
+
return
|
517
|
+
|
518
|
+
else:
|
519
|
+
body = set_rel_request_body_for_type("CitedDocumentLink", attributes)
|
520
|
+
body['properties'] = prop_body
|
521
|
+
|
522
|
+
egeria_client.link_cited_document(element_guid,
|
523
|
+
cited_document_guid,
|
524
|
+
body=body_slimmer(body))
|
525
|
+
msg = f"==>Created {object_type} link \n"
|
526
|
+
logger.success(msg)
|
527
|
+
out = parsed_output['display'].replace('Link', 'Detach', 1)
|
528
|
+
return out
|
529
|
+
|
530
|
+
except ValidationError as e:
|
531
|
+
print_validation_error(e)
|
532
|
+
logger.error(f"Validation Error performing {command}: {e}")
|
533
|
+
return None
|
534
|
+
except PyegeriaException as e:
|
535
|
+
print_basic_exception(e)
|
536
|
+
logger.error(f"PyegeriaException occurred: {e}")
|
537
|
+
return None
|
538
|
+
|
539
|
+
except Exception as e:
|
540
|
+
logger.error(f"Error performing {command}: {e}")
|
541
|
+
return None
|
542
|
+
else:
|
543
|
+
return None
|