Skip to content
Draft
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
4 changes: 2 additions & 2 deletions invenio_rdm_records/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Copyright (C) 2019-2025 CERN.
# Copyright (C) 2019 Northwestern University.
# Copyright (C) 2021-2024 Graz University of Technology.
# Copyright (C) 2021-2025 Graz University of Technology.
# Copyright (C) 2023 TU Wien.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -423,7 +423,7 @@ def always_valid(identifier):
providers.DataCitePIDProvider(
"datacite",
client=providers.DataCiteClient("datacite", config_prefix="DATACITE"),
serializer=DataCite43JSONSerializer(schema_context={"is_parent": True}),
serializer=DataCite43JSONSerializer(is_parent=True),
label=_("Concept DOI"),
),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021-2024 CERN.
# Copyright (C) 2025 Graz University of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -18,13 +19,16 @@
class DataCite43JSONSerializer(MarshmallowSerializer):
"""Marshmallow based DataCite serializer for records."""

def __init__(self, **options):
def __init__(self, is_parent=False, **options):
"""Constructor."""
super().__init__(
format_serializer_cls=JSONSerializer,
object_schema_cls=DataCite43Schema,
list_schema_cls=BaseListSchema,
schema_kwargs={"dumpers": [JournalDataciteDumper()]}, # Order matters
schema_kwargs={
"dumpers": [JournalDataciteDumper()], # Order matters
"is_parent": is_parent,
},
**options,
)

Expand Down
9 changes: 7 additions & 2 deletions invenio_rdm_records/resources/serializers/datacite/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Copyright (C) 2021-2024 CERN.
# Copyright (C) 2021-2025 Northwestern University.
# Copyright (C) 2023 Graz University of Technology.
# Copyright (C) 2023-2025 Graz University of Technology.
# Copyright (C) 2023 Caltech.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -205,6 +205,11 @@ class DataCite43Schema(BaseSerializerSchema):
fundingReferences = fields.Method("get_funding")
schemaVersion = fields.Constant("http://datacite.org/schema/kernel-4")

def __init__(self, is_parent=False, **kwargs):
"""Construct."""
super().__init__(**kwargs)
self.is_parent = is_parent

def get_type(self, obj):
"""Get resource type."""
resource_type_id = py_.get(obj, "metadata.resource_type.id")
Expand Down Expand Up @@ -408,7 +413,7 @@ def get_related_identifiers(self, obj):
serialized_identifiers.append(serialized_identifier)

# Generate parent/child versioning relationships
if self.context.get("is_parent"):
if self.is_parent:
# Fetch DOIs for all versions
# NOTE: The refresh is safe to do here since we'll be in Celery task
current_rdm_records_service.indexer.refresh()
Expand Down
Loading