Skip to content

Commit

Permalink
Merge pull request #63 from ImperialCollegeLondon/feature/better-test…
Browse files Browse the repository at this point in the history
…-metadata

Improve metadata mapping for example datasets
  • Loading branch information
cc-a authored Aug 21, 2024
2 parents c3840c6 + 1e04cbe commit b6c1a5d
Showing 1 changed file with 23 additions and 9 deletions.
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

0 comments on commit b6c1a5d

Please sign in to comment.