Skip to content

Usage

Commands

doi

  1. delete-dois: delete all DOIs from the database (not datacite).

    ckan -c $CONFIG_FILE doi delete-dois
    

  2. update-doi: update the datacite metadata for one or all packages.

    ckan -c $CONFIG_FILE doi update-doi [PACKAGE_ID]
    

Interfaces

The IDoi interface allows plugins to extend the build_metadata_dict and build_xml_dict methods.

build_metadata_dict(pkg_dict, metadata_dict, errors)

Breaking changes from v1:

  1. previously called build_metadata
  2. new parameter: errors
  3. new return value: tuple of metadata_dict, errors

Extracts metadata from a pkg_dict for use in generating datacite DOIs. The base method from this extension is run first, then the metadata dict is passed through all the implementations of this method. After running these, if any of the required values (see above) are still in the errors dict (i.e. they still could not be handled by any other extension), a DOIMetadataException will be thrown.

Parameter Description
pkg_dict The original package dictionary from which the metadata were extracted.
metadata_dict The current metadata dict, created by the ckanext-doi extension and any previous plugins implementing IDoi.
errors A dictionary of metadata keys and errors generated by previous plugins; this method should remove any keys that it successfully processes and overwrites.

build_xml_dict(metadata_dict, xml_dict)

Breaking changes from v1:

  1. previously called metadata_to_xml
  2. parameters rearranged (previously xml_dict, metadata)

Converts the metadata_dict into an xml_dict that can be passed to the datacite library's schema42.tostring() and schema42.validate() methods. The base method from this extension is run first, then the xml dict is passed through all the implementations of this method.

Parameter Description
metadata_dict The original metadata dictionary from which the xml attributes are extracted.
xml_dict The current xml dict, created by the ckanext-doi extension and any previous plugins implementing IDoi.

Templates

Package citation snippet

{% snippet "doi/snippets/package_citation.html", pkg_dict=g.pkg_dict %}

Resource citation snippet

{% snippet "doi/snippets/resource_citation.html", pkg_dict=g.pkg_dict, res=res %}