45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
|
|
|
|
def map_access_right(ar: str) -> str:
|
|
match ar:
|
|
case 'open':
|
|
return 'Open Access'
|
|
case 'closed':
|
|
return 'Closed'
|
|
case 'embargo':
|
|
return 'Embargo'
|
|
case 'restricted':
|
|
return 'Restricted'
|
|
case _:
|
|
return ''
|
|
|
|
|
|
def trasform_graph_entity(p: dict) -> dict:
|
|
p['_id'] = p['local_identifier']
|
|
return p
|
|
|
|
|
|
def trasform_catalog_entity(p: dict) -> dict:
|
|
p['_id'] = p['id']
|
|
return p
|
|
|
|
def trasform_product(p: dict) -> dict:
|
|
p = trasform_graph_entity(p)
|
|
p['accessRights'] = list(
|
|
filter(lambda ar: ar != '', map(lambda m: map_access_right(m.get('access_right')), p.get('manifestations'))))
|
|
return p
|
|
|
|
transform_entities = {
|
|
# SKG-IF graph entities
|
|
"datasource": trasform_graph_entity,
|
|
"grants": trasform_graph_entity,
|
|
"organizations": trasform_graph_entity,
|
|
"persons": trasform_graph_entity,
|
|
"products": trasform_graph_entity,
|
|
"topics": trasform_graph_entity,
|
|
"venues": trasform_graph_entity,
|
|
# EOSC catalog entities
|
|
"interoperability": trasform_catalog_entity,
|
|
"services": trasform_catalog_entity,
|
|
"training": trasform_catalog_entity,
|
|
} |