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

Add CSV export #1645

Merged
merged 4 commits into from
Feb 1, 2024
Merged
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
19 changes: 19 additions & 0 deletions invenio_rdm_records/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from .serializers import (
slint marked this conversation as resolved.
Show resolved Hide resolved
BibtexSerializer,
CSLJSONSerializer,
CSVRecordSerializer,
DataCite43JSONSerializer,
DataCite43XMLSerializer,
DCATSerializer,
Expand Down Expand Up @@ -80,6 +81,24 @@ def _bibliography_headers(obj_or_list, code, many=False):
record_serializers = {
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
"application/ld+json": ResponseHandler(SchemaorgJSONLDSerializer()),
"application/vnd.inveniordm.v1.full+csv": ResponseHandler(CSVRecordSerializer()),
"application/vnd.inveniordm.v1.simple+csv": ResponseHandler(
CSVRecordSerializer(
csv_included_fields=[
"id",
"created",
"pids.doi.identifier",
"metadata.title",
"metadata.description",
"metadata.resource_type.title.en",
"metadata.publication_date",
"metadata.creators.person_or_org.type",
"metadata.creators.person_or_org.name",
"metadata.rights.id",
],
collapse_lists=True,
)
),
"application/marcxml+xml": ResponseHandler(
MARCXMLSerializer(), headers=etag_headers
),
Expand Down
2 changes: 2 additions & 0 deletions invenio_rdm_records/resources/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .cff import CFFSerializer
from .codemeta import CodemetaSerializer
from .csl import CSLJSONSerializer, StringCitationSerializer
from .csv import CSVRecordSerializer
from .datacite import DataCite43JSONSerializer, DataCite43XMLSerializer
from .dcat import DCATSerializer
from .dublincore import DublinCoreJSONSerializer, DublinCoreXMLSerializer
Expand All @@ -31,6 +32,7 @@
"BibtexSerializer",
"CFFSerializer",
"CSLJSONSerializer",
"CSVRecordSerializer",
"DataCite43JSONSerializer",
"DataCite43XMLSerializer",
"DublinCoreJSONSerializer",
Expand Down
18 changes: 18 additions & 0 deletions invenio_rdm_records/resources/serializers/csv/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2024 CERN
#
# 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.

"""CSV Serializer for Invenio RDM Records."""

from flask_resources.serializers import CSVSerializer


class CSVRecordSerializer(CSVSerializer):
"""Marshmallow based CSV serializer for records."""

def __init__(self, **options):
"""Constructor."""
super().__init__(header_separator=".", **options)
Loading