das-cli 1.5.0__tar.gz → 1.5.1__tar.gz
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.
- {das_cli-1.5.0/das_cli.egg-info → das_cli-1.5.1}/PKG-INFO +1 -1
- {das_cli-1.5.0 → das_cli-1.5.1}/das/managers/entries_manager.py +64 -33
- {das_cli-1.5.0 → das_cli-1.5.1/das_cli.egg-info}/PKG-INFO +1 -1
- {das_cli-1.5.0 → das_cli-1.5.1}/pyproject.toml +1 -1
- {das_cli-1.5.0 → das_cli-1.5.1}/LICENSE +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/MANIFEST.in +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/README.md +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/__init__.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/ai/plugins/dasai.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/ai/plugins/entries/entries_plugin.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/app.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/authentication/auth.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/authentication/oauth.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/authentication/secure_input.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/cli.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/common/api.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/common/config.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/common/entry_fields_constants.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/common/enums.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/common/file_utils.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/managers/__init__.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/managers/digital_objects_manager.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/managers/download_manager.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/managers/search_manager.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/attributes.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/cache.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/das_elastic_search.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/digital_objects.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/downloads.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/entries.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/entry_fields.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/hangfire.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/search.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/service_base.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das/services/users.py +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das_cli.egg-info/SOURCES.txt +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das_cli.egg-info/dependency_links.txt +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das_cli.egg-info/entry_points.txt +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das_cli.egg-info/requires.txt +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/das_cli.egg-info/top_level.txt +0 -0
- {das_cli-1.5.0 → das_cli-1.5.1}/setup.cfg +0 -0
|
@@ -382,44 +382,75 @@ class EntryManager:
|
|
|
382
382
|
if "tag" in customdata:
|
|
383
383
|
tag = customdata.get("tag")
|
|
384
384
|
if "relations" in customdata:
|
|
385
|
-
relations =
|
|
385
|
+
relations = [
|
|
386
|
+
{str(k).lower(): v for k, v in rel.items()}
|
|
387
|
+
for rel in customdata.get("relations")
|
|
388
|
+
if isinstance(rel, dict)
|
|
389
|
+
]
|
|
386
390
|
except json.JSONDecodeError:
|
|
387
391
|
raise ValueError(f"Invalid customdata JSON: {field.get('customdata')}")
|
|
388
392
|
|
|
389
393
|
result_list = []
|
|
390
394
|
for value in values:
|
|
391
|
-
response = self.
|
|
392
|
-
if response
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
395
|
+
response = self.entry_service.get_entry(value)
|
|
396
|
+
if response is None:
|
|
397
|
+
raise ValueError(f"No results found for {field.get('displayname')}: {value}")
|
|
398
|
+
|
|
399
|
+
if not isinstance(response, dict):
|
|
400
|
+
raise ValueError(f"Invalid response: {response}")
|
|
401
|
+
|
|
402
|
+
# response shape: { "entry": { ... }, "attributeId": <int> }
|
|
403
|
+
response = {str(k).lower(): v for k, v in response.items()}
|
|
404
|
+
attribute_id = response.get('attributeid')
|
|
405
|
+
try:
|
|
406
|
+
attribute_id = int(attribute_id) if attribute_id is not None else None
|
|
407
|
+
except (TypeError, ValueError):
|
|
408
|
+
pass
|
|
409
|
+
|
|
410
|
+
# check that the entry's attributeId is allowed in the relations list
|
|
411
|
+
if relations and not any(
|
|
412
|
+
int(rel.get('attributeid')) == attribute_id
|
|
413
|
+
for rel in relations
|
|
414
|
+
if rel.get('attributeid') is not None and attribute_id is not None
|
|
415
|
+
):
|
|
416
|
+
raise ValueError(f"Attribute ID {attribute_id} for value '{value}' is not allowed in the relations list")
|
|
417
|
+
|
|
418
|
+
entry = response.get('entry', {})
|
|
419
|
+
if isinstance(entry, dict):
|
|
420
|
+
entry = {str(k).lower(): v for k, v in entry.items()}
|
|
421
|
+
|
|
422
|
+
item = {
|
|
423
|
+
"id": entry.get('id'),
|
|
424
|
+
"name": entry.get('displayname'),
|
|
425
|
+
"code": entry.get('code'),
|
|
426
|
+
"attributeId": attribute_id,
|
|
427
|
+
"tag": tag,
|
|
428
|
+
"acronym": entry.get('acronym'),
|
|
429
|
+
"order": entry.get('order', 0)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
# get the attribute name from the relations where the attribute id matches the entry's attributeId
|
|
433
|
+
attribute_name = next(
|
|
434
|
+
(attr.get('attributealias') for attr in relations
|
|
435
|
+
if attr.get('attributeid') is not None and attribute_id is not None
|
|
436
|
+
and int(attr.get('attributeid')) == attribute_id),
|
|
437
|
+
None
|
|
438
|
+
) if attribute_id is not None else None
|
|
439
|
+
|
|
440
|
+
# We need to check if the relation item already exists in the result list, if it does we need to append the item to the relations list of that item, if not we need to create a new item in the result list
|
|
441
|
+
existing_item = next((i for i in result_list if i.get('attribute') == attribute_name), None)
|
|
442
|
+
if existing_item:
|
|
443
|
+
existing_item.get('relations', []).append(item)
|
|
444
|
+
continue
|
|
445
|
+
|
|
446
|
+
item_relation = {
|
|
447
|
+
"attribute": attribute_name,
|
|
448
|
+
"relations": [item],
|
|
449
|
+
"tag": tag
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
result_list.append(item_relation)
|
|
453
|
+
|
|
423
454
|
|
|
424
455
|
return json.dumps(result_list) if result_list else source
|
|
425
456
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|