CERN CDS Media field not working with documents

Hi!

I was wondering if there is a way to easily reference CDS records from Drupal, disregarding whether they are photos or videos.

I would like to have let’s say a ‘general’ Document content type, where you could have a CDS record being the document, or link to an external URL, or upload a file to the site. Something like this:



I thought this approach was working, but then I realised that the CERN CDS Media field works only for photos and videos…

For example, if I try to link to this record: https://cds.cern.ch/record/2701507/ by using its CDS ID CERN-HR-Note-2019-030, it can’t retrieve info from CDS :frowning_face:

I get this alert:

CDS resource not recognised. Note that resource IDs relate to a specific video or image and are not the same as a record ID (which can contain several resources).

Is there any smart way to make this work? If not, are there any plans to extend the CDS field so it can automatically reference CDS records?

Thanks for the advice!

Óscar

Hi Oscar,

I believe that their API only serves Photos and Videos at the moment. That’s why we developed the module to support these two types.

Better open a ticket to CDS and ask them if their API serves other resources.

1 Like

Hi @sboutas,

thanks for the quick answer! I will ask them, and if their API does serve other resources it could be a nice project to have the ability to reference CDS records from Drupal websites, without duplicating content :wink:

Regards,
Óscar

Update: I found it myself :slight_smile:

If we issue this type of GET request:

https://cds.cern.ch/search?recid=2701507&of=recjson

So basically setting recid to the record number and of (output format) to recjson (for record JSON), we get all the info about the record:

[
    {
        "abstract": {
            "summary": "The goal of the Internal Mobility Policy is to make recommendations in order to enhance opportunities, harmonize processes and increase efficiency in the way Internal Mobility is managed at CERN."
        },
        "creation_date": "2019-11-14T07:46:32",
        "imprint": {
            "date": "2019"
        },
        "keywords": {
            "institute": "CERN-HR",
            "term": "Career"
        },
        "primary_report_number": "CERN-HR-Note-2019-030",
        "oai": {
            "indicator": "cerncds:FULLTEXT",
            "value": "oai:cds.cern.ch:2701507"
        },
        "owner": "PUBLIC",
        "subject": {
            "source": "SzGeCERN",
            "term": "Other Subjects"
        },
        "number_of_citations": 0,
        "title": {
            "title": "Internal Mobility Policy - June 2019"
        },
        "periodical_internal_note": {
            "reponsable": "anna.cook@cern.ch"
        },
        "persistent_identifiers_keys": [
            "recid",
            "oai"
        ],
        "corporate_name": [
            {},
            {
                "name": "CERN. Geneva. HR Department"
            }
        ],
        "files": [
            {
                "comment": null,
                "status": "SSO",
                "magic": [
                    "PDF document, version 1.4",
                    "application/pdf; charset=binary",
                    "PDF document, version 1.4",
                    "application/pdf; charset=binary",
                    "application/pdf"
                ],
                "description": null,
                "url": "http://cds.cern.ch/record/2701507/files/2019-0871-Internal Mobility Policy June 2019_FR_v.finale.pdf",
                "eformat": ".pdf",
                "subformat": "",
                "version": 1,
                "full_name": "2019-0871-Internal Mobility Policy June 2019_FR_v.finale.pdf",
                "superformat": ".pdf",
                "path": "/opt/cdsweb/var/data/files/g159/1598770/content.pdf;1",
                "size": 152180,
                "type": "Additional",
                "full_path": "/opt/cdsweb/var/data/files/g159/1598770/content.pdf;1",
                "name": "2019-0871-Internal Mobility Policy June 2019_FR_v.finale"
            },
            {
                "comment": null,
                "status": "SSO",
                "magic": [
                    "PDF document, version 1.4",
                    "application/pdf; charset=binary",
                    "PDF document, version 1.4",
                    "application/pdf; charset=binary",
                    "application/pdf"
                ],
                "description": "Access to fulltext",
                "url": "http://cds.cern.ch/record/2701507/files/Internal Mobility Policy June 2019 updated.pdf",
                "eformat": ".pdf",
                "subformat": "",
                "version": 2,
                "full_name": "Internal Mobility Policy June 2019 updated.pdf",
                "superformat": ".pdf",
                "path": "/opt/cdsweb/var/data/files/g152/1529920/content.pdf;2",
                "size": 147757,
                "type": "DEPIN_FILE",
                "full_path": "/opt/cdsweb/var/data/files/g152/1529920/content.pdf;2",
                "name": "Internal Mobility Policy June 2019 updated"
            }
        ],
        "collection": {
            "primary": "INTNOTEHRPUBL"
        },
        "filenames": [
            "2019-0871-Internal Mobility Policy June 2019_FR_v",
            "2019-0871-Internal Mobility Policy June 2019_FR_v.finale",
            "2019-0871-Internal Mobility Policy June 2019_FR_v.finale.pdf",
            "Internal Mobility Policy June 2019 updated.pdf",
            "Internal Mobility Policy June 2019 updated"
        ],
        "number_of_reviews": 0,
        "base": "12",
        "version_id": "2020-02-05T14:16:08",
        "authors": [
            {
                "first_name": "Valeria",
                "last_name": "Perez Reale",
                "control_number": [
                    "AUTHOR|(INSPIRE)INSPIRE-00306149",
                    "AUTHOR|(SzGeCERN)556007",
                    "AUTHOR|(CDS)2070979"
                ],
                "affiliation": "CERN",
                "full_name": "Perez Reale, Valeria",
                "e-mail": "Valeria.Perez.Reale@cern.ch"
            }
        ],
        "number_of_authors": 1,
        "language": "eng",
        "number_of_comments": 0,
        "status_week": {
            "status": "n",
            "status_week": "201946"
        },
        "email_message": {
            "address": "anna.cook@cern.ch"
        },
        "recid": 2701507,
        "filetypes": [
            "pdf",
            "pdf"
        ],
        "prepublication": {
            "date": "14 Nov 2019",
            "place": "Geneva",
            "publisher_name": "CERN"
        }
    }
]

So developing a new field type or simply adapting the existing one shouldn’t be so difficult… I don’t think I will have the time to do it but if I eventually do I will share my experience here for sure.

Note: of course, and as I expected, the API for search’s output has absolutely nothing to do with the media API (example) in terms of structure and field naming. I don’t expect these APIs to be unified any time soon so probably we should simply live with it :man_shrugging:

Note 2: Documentation: https://cds.cern.ch/help/hacking/search-engine-api?ln=en

Thanks, and regards!

1 Like