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

Dcat oai #1718

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
25 changes: 23 additions & 2 deletions invenio_rdm_records/resources/serializers/datacite/schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

Check failure on line 1 in invenio_rdm_records/resources/serializers/datacite/schema.py

View workflow job for this annotation

GitHub Actions / Tests (3.9, postgresql14, opensearch2, 18.x)

isort-check # it under the terms of the MIT License; see LICENSE file for more details. """DataCite based Schema for Invenio RDM Records.""" + +import json from babel_edtf import parse_edtf from edtf.parser.grammar import ParseException from marshmallow import Schema, ValidationError, fields, missing, post_dump, validate from marshmallow_utils.fields import SanitizedUnicode from marshmallow_utils.html import strip_html -import json + from ....proxies import current_rdm_records_service from ...serializers.ui.schema import current_default_locale from ..utils import get_preferred_identifier, get_vocabulary_props

Check failure on line 1 in invenio_rdm_records/resources/serializers/datacite/schema.py

View workflow job for this annotation

GitHub Actions / Tests (3.9, postgresql14, opensearch2, 20.x)

isort-check # it under the terms of the MIT License; see LICENSE file for more details. """DataCite based Schema for Invenio RDM Records.""" + +import json from babel_edtf import parse_edtf from edtf.parser.grammar import ParseException from marshmallow import Schema, ValidationError, fields, missing, post_dump, validate from marshmallow_utils.fields import SanitizedUnicode from marshmallow_utils.html import strip_html -import json + from ....proxies import current_rdm_records_service from ...serializers.ui.schema import current_default_locale from ..utils import get_preferred_identifier, get_vocabulary_props

Check failure on line 1 in invenio_rdm_records/resources/serializers/datacite/schema.py

View workflow job for this annotation

GitHub Actions / Tests (3.12, postgresql14, opensearch2, 18.x)

isort-check # it under the terms of the MIT License; see LICENSE file for more details. """DataCite based Schema for Invenio RDM Records.""" + +import json from babel_edtf import parse_edtf from edtf.parser.grammar import ParseException from marshmallow import Schema, ValidationError, fields, missing, post_dump, validate from marshmallow_utils.fields import SanitizedUnicode from marshmallow_utils.html import strip_html -import json + from ....proxies import current_rdm_records_service from ...serializers.ui.schema import current_default_locale from ..utils import get_preferred_identifier, get_vocabulary_props

Check failure on line 1 in invenio_rdm_records/resources/serializers/datacite/schema.py

View workflow job for this annotation

GitHub Actions / Tests (3.12, postgresql14, opensearch2, 20.x)

isort-check # it under the terms of the MIT License; see LICENSE file for more details. """DataCite based Schema for Invenio RDM Records.""" + +import json from babel_edtf import parse_edtf from edtf.parser.grammar import ParseException from marshmallow import Schema, ValidationError, fields, missing, post_dump, validate from marshmallow_utils.fields import SanitizedUnicode from marshmallow_utils.html import strip_html -import json + from ....proxies import current_rdm_records_service from ...serializers.ui.schema import current_default_locale from ..utils import get_preferred_identifier, get_vocabulary_props
#
# Copyright (C) 2021-2024 CERN.
# Copyright (C) 2021 Northwestern University.
Expand All @@ -20,7 +20,7 @@
from marshmallow import Schema, ValidationError, fields, missing, post_dump, validate
from marshmallow_utils.fields import SanitizedUnicode
from marshmallow_utils.html import strip_html

import json
from ....proxies import current_rdm_records_service
from ...serializers.ui.schema import current_default_locale
from ..utils import get_preferred_identifier, get_vocabulary_props
Expand Down Expand Up @@ -73,18 +73,26 @@
"""Get name identifier list."""
serialized_identifiers = []
identifiers = obj["person_or_org"].get("identifiers", [])

scheme_uri = ""
for identifier in identifiers:
scheme = identifier["scheme"]
id_scheme = get_scheme_datacite(
scheme, "RDM_RECORDS_PERSONORG_SCHEMES", default=scheme
)

if id_scheme:
if scheme == "orcid":
scheme_uri = "http://orcid.org/"
elif scheme == "ror":
scheme_uri = "https://ror.org/"

name_id = {
"nameIdentifier": identifier["identifier"],
"nameIdentifierScheme": id_scheme,
}
if scheme_uri:
name_id["schemeUri"] = scheme_uri

serialized_identifiers.append(name_id)

return serialized_identifiers
Expand Down Expand Up @@ -247,6 +255,19 @@

result.append(item)

if field == "description":
# References
refs = obj["metadata"].get("references")
if refs:
result.append(
{
field: json.dumps(
{"references": [r["reference"] for r in refs]}
),
f"{field}Type": "Other",
}
)

return result or missing

def get_titles(self, obj):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,9 @@
<!--
<rdf:type rdf:resource="{$foaf}Agent"/>
-->
<xsl:if test="$uri != ''">
<dct:identifier rdf:datatype="{$xsd}string"><xsl:value-of select="$nameIdentifier"/></dct:identifier>
</xsl:if>
<xsl:if test="$agentName != ''">
<foaf:name><xsl:value-of select="$agentName"/></foaf:name>
</xsl:if>
Expand Down
Loading