Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve metadata mapping for example datasets #63

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions test_data/create_test_data_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ def datacite_to_invenio_schema(datacite):
}
version = data["version"]
description = data["descriptions"][0]["description"]
references = [
related_identifiers = [
ri
for ri in data["relatedIdentifiers"]
if ri["relationType"] in ("References", "IsReferencedBy")
if not FILE_URI_REGEX.match(ri.get("relatedIdentifier", ""))
and not ri.get("relatedMetadataScheme") == "ORE"
]

return {
Expand Down Expand Up @@ -130,22 +131,35 @@ def datacite_to_invenio_schema(datacite):
for contributor in data["contributors"][3:]
],
"languages": [],
"related_identifiers": [],
"related_identifiers": [
{
"identifier": ri["relatedIdentifier"],
"scheme": ri["relatedIdentifierType"].lower(),
"relation_type": dict(id=ri["relationType"].lower()),
}
for ri in related_identifiers
],
"sizes": [],
"formats": [],
"version": version,
"description": description,
"additional_descriptions": [],
"funding": [],
"references": [
"references": [],
"identifiers": [],
"dates": [
{
"reference": reference["relationType"],
"identifier": reference["relatedIdentifier"],
"scheme": reference["relatedIdentifierType"].lower(),
"date": date_meta["date"],
"type": {"id": date_meta["dateType"].lower()},
}
for reference in references
for date_meta in data["dates"]
],
"rights": [
{
"id": rights_meta.get("rightsIdentifier", "cc0-1.0").lower(),
}
for rights_meta in data["rightsList"]
],
"identifiers": [],
},
}

Expand Down
Loading