Skip to content

Commit f23ca99

Browse files
authored
Merge pull request #65 from drscholly/fix/rdv
Ignore ReferenceDataValue links for now
2 parents cc2c409 + e80c031 commit f23ca99

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

toolbox/api/datagalaxy_api_modules.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ def __init__(self, url: str, token: str, workspace: dict, module: str):
2828

2929
def list_objects(self, workspace_name: str, include_links=False) -> list:
3030
version_id = self.workspace['defaultVersionId']
31+
params = {'versionId': version_id, 'limit': '5000'}
3132
if include_links is True:
32-
params = {'versionId': version_id, 'limit': '5000', 'includeLinks': 'true'}
33+
params['includeLinks'] = 'true'
3334
else:
34-
params = {'versionId': version_id, 'limit': '5000', 'includeAttributes': 'true'}
35+
params['includeAttributes'] = 'true'
3536
headers = {'Authorization': f"Bearer {self.token}"}
3637
response = requests.get(f"{self.url}/{self.route}", params=params, headers=headers)
3738
code = response.status_code
@@ -214,7 +215,7 @@ def bulk_upsert_source_tree(self, workspace_name: str, source: dict, objects: li
214215

215216
def delete_objects(self, workspace_name: str, ids: list) -> int:
216217
if len(ids) < 1:
217-
logging.warn(f'Nothing to delete on workspace "{workspace_name}" in module {self.module}, aborting.')
218+
logging.warning(f'Nothing to delete on workspace "{workspace_name}" in module {self.module}, aborting.')
218219
return 0
219220
version_id = self.workspace['defaultVersionId']
220221
headers = {'Authorization': f"Bearer {self.token}"}

toolbox/commands/copy_links.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,21 @@ def parse_links(obj: dict) -> list:
117117
# DPI are ignored since they are handled differently
118118
if "DataProcessingItem" in obj["typePath"]:
119119
return []
120+
# ReferenceDataValue have to be ignored (at least for now)
121+
if "ReferenceDataValue" in obj["typePath"]:
122+
return []
120123
for key in obj["links"]:
121124
for dest in obj["links"][key]:
122125
if "DataProcessingItem" in dest["typePath"]:
123126
continue
127+
if "ReferenceDataValue" in dest["typePath"]:
128+
logging.warning('The following link cannot be created with the API, please create it manually:')
129+
logging.warning(obj["path"])
130+
logging.warning(obj["typePath"])
131+
logging.warning(key)
132+
logging.warning(dest["path"])
133+
logging.warning(dest["typePath"])
134+
continue
124135
link = {
125136
'fromPath': obj["path"],
126137
'fromType': obj["typePath"],
@@ -132,6 +143,24 @@ def parse_links(obj: dict) -> list:
132143
return links
133144

134145

146+
# This is a WIP and not used yet in the codebase
147+
def handle_reference_data_value(source_glossary: list) -> str:
148+
for page in source_glossary:
149+
page_index = source_glossary.index(page)
150+
for glossary_object in page:
151+
go_index = page.index(glossary_object)
152+
if glossary_object['type'] == 'ReferenceDataValue' and glossary_object['links']:
153+
if 'attributes' in glossary_object and 'code' in glossary_object['attributes']:
154+
new_path = glossary_object['path'] + '\\' + glossary_object['attributes']['code']
155+
new_type_path = glossary_object['typePath'].replace('\\ReferenceDataValue', '\\Value\\ValueCode')
156+
page[go_index]['path'] = new_path
157+
page[go_index]['typePath'] = new_type_path
158+
else:
159+
logging.warning(f'Links of Reference Data Value {glossary_object["technicalName"]} cannot be imported without editor attribute Code')
160+
logging.warning('Please add it to your DataGalaxy screen for Reference Data Value objects')
161+
source_glossary[page_index] = page
162+
163+
135164
def copy_links_parse(subparsers):
136165
# create the parser for the "copy_links" command
137166
copy_links_parse = subparsers.add_parser('copy-links', help='copy-links help')

0 commit comments

Comments
 (0)