Ckan 2 zenodo library

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

Jump to: navigation, search

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

Overview

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
..
<Category>Repository</Category>
..
<Platform>
  <Name>Zenodo</Name>
...
  • XML Mapping Generic Resource
NB: one XML Mapping per profile is supported
..
<SecondaryType>Ckan-Zenodo-Mappings</SecondaryType>
 
<Name>[***PROFILE_ID***]</Name>
..

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.

<mapping>
  <source>
   <value type="constant">dataset</value>					
  <//source>					
  <targetPath>$.metadata</targetPath>
  <targetElement>upload_type</targetElement>
</mapping>

Directives Options

Source
  • 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.
<mapping>
 <source>
  <value type="jsonPath">$.extras[?(@.key=='Author')].value</value>
  <value type="jsonPath" split=";">$.author</value>						
 <//source>
 <targetPath>$.metadata.creators[0]</targetPath>
 <targetElement>name</targetElement>
</mapping>
Target
  • Append : [optional, default = false] append the value to the existing one instead of overwriting it.
Regexp
  • The use of Regexp directive is optional.
  • Multiple Regexp directives can be declared.
  • Extract : Extract only matching string from processed values
<mapping>
 <source type="jsonPath">
  <value>$.extras[?(@.key=='Author')].value</value>
 <//source>
 <targetPath>$.metadata.contributors[0]</targetPath>
 <targetElement>orcid</targetElement>
 <regexp type="extract">
  <target>(https://)?orcid.org/.*</target>
 </regexp>
</mapping>
  • Replace : Replace matching pattern with replacementString
<mapping>
 <source>
  <value type="jsonPath">$.extras[?(@.key=='AccessMode:Accessibility')].value</value>
 <//source>
 <targetPath>$.metadata</targetPath>
 <targetElement append="true">access_conditions</targetElement>
 <regexp type="replace">
  <target>^</target>
  <replacement>AccessMode.Accessibility : </replacement>
 </regexp>
 <regexp type="replace">
  <target>$</target>
  <replacement>; </replacement>
 </regexp>
</mapping>

Integration

Maven coordinates

<groupId>org.gcube.data.publishing</groupId>
<artifactId>ckan2zenodo-library</artifactId>
<version>0.0.2-SNAPSHOT</version>

Source Code

Source code available [[here]].