WIP: resolve attributed_to for KISTE usecase #2

Draft
adina wants to merge 1 commit from adina/query-rse-group:attributed_to into main

View file

@ -25,8 +25,26 @@ def _resolve_record(
if resolved is not None: if resolved is not None:
break break
rules.append(resolved if resolved is not None else r) rules.append(resolved if resolved is not None else r)
attributed_to = []
attrs = rec.get('attributed_to', [])
for i in range(len(attrs)):
a = attrs[i].get('object', [])
resolved = None
for col in collection:
resolved = collection_read_record_with_pid(
api_url,
col,
a,
token=token,
)
if resolved is not None:
break
if resolved is not None:
attrs[i]['object'] = resolved
attributed_to.append(attrs[i])
out = deepcopy(rec) out = deepcopy(rec)
out['rules'] = rules out['rules'] = rules
out['attributed_to'] = attributed_to
return out return out