Ckan 2 zenodo library

From Gcube Wiki
Revision as of 16:28, 26 June 2020 by Fabio.sinibaldi (Talk | contribs) (Regexp)

Jump to: navigation, search

The gCube component is a Java library which translates CKAN items into Zenodo depositions, allowing to further editing and publication.


Ckan2 zenodo.png

The library is invoked by the client (in this case the gCube CKAN GUI), which relies on the gCat service for interacting with CKAN. After the ckan item is loaded, a default translation is then applied on the item's core fields generating in a Draft Zenodo Deposition. NB If the item has already a linked Zenodo DOI, the Draft Deposition overrides its specified informations.

A XML Mapping associated with item's profile, is then loaded from the IS (token must be specified by the client). The XML Mapping extracts data from the CKAN item and applies them to the Draft Deposition, resulting in a Final Deposition.

The Final Deposition is then returned to the client for further editing, which can eventually ask for its publication (the new Zenodo Doi will be then applied to the CKAN item through gCat).

IS Configuration

  • Zenodo Credentials ServiceEndpoint
  • XML Mapping Generic Resource
NB: one XML Mapping per profile is supported

XML Mappings

Each mapping directive selects a source value list and applies them to a specific deposition field.

Several options and features are supported on both source values and target values directives.

Field are selected using JSON paths (see [[JsonPath library]]).

Following is a simple directive setting a constan value to path $.metadata.upload_type.

   <value type="constant">dataset</value>					

Directives Options

  • Type : can be either constant or jsonPath
  • Split : [optional] is used to split found values
  • Multiple value directives can be declared. The first one to actual produce values is used.
  <value type="jsonPath">$.extras[?(@.key=='Author')].value</value>
  <value type="jsonPath" split=";">$.author</value>						
  • Append : [optional, default = false] append the value to the existing one instead of overwriting it.
  • The use of Regexp directive is optional.
  • Multiple Regexp directives can be declared.
  • Extract : Extract only matching string from processed values
 <source type="jsonPath">
<regexp type="extract">

</mapping> </source>

  • Replace : Replace matching pattern with replacementString
  <value type="jsonPath">$.extras[?(@.key=='AccessMode:Accessibility')].value</value>
 <targetElement append="true">access_conditions</targetElement>
 <regexp type="replace">
  <replacement>AccessMode.Accessibility : </replacement>
 <regexp type="replace">
  <replacement>; </replacement>


Maven coordinates

Source Code