ORCID

From EPrints Documentation
Revision as of 18:24, 26 September 2016 by Bdgregg@pitt.edu (talk | contribs) (Notes from Pittsburgh:: - Added warning:orcid_invalid phrase.)
Jump to: navigation, search

This page has been created to gather information about how different EPrints repositories have integrated ORCID. At this time (April 2016) there doesn't seem to be a 'best practice' approach that has been adopted widely - this will hopefully change over time.

If you are looking to retrieve publications from the ORCID service, the Import from ORCID (Tier 1 API) Bazaar package, or the ORCID Tier 2 api framework are good places to start.

2016-05-20 Alan Stiles at The Open University is working on a plugin to connect EPrints with ORCID via the Tier 2 Members API to retrieve ORCID ids and synchronise publications and affiliation details.

Some aspects that need to be considered when adopting ORCIDs, and making them available to other systems are:

NB The examples below may refer to the 'creators' field - but the same approach could be used to extend other 'person' fields - e.g. contributors.

Re-using creators.id subfield

The creators.id field is labelled 'email' by default, but as it's an 'id' type field, it can be used to store ORCIDs. To re-label the field, a simple addition to a phrase file in archives/ARCHIVEID/cfg/lang/en/phrases/ needs to be made:

<epp:phrase id="eprint_fieldname_creators_id">ORCID / Creators email (if known)</epp:phrase>

Rendering the ORCID in a citation

The rendering of this field then needs to be changed to accommodate an author with an ORCID. The following script adds methods that can be called via the EPScript language:

# add to e.g. ~/archives/ARCHIVEID/cfg/cfg.d/z_add_to_EPrints_Script_Compiled.pl
# Write into EPrints::Script::Compiled package to allow use of function in epscript
{
package EPrints::Script::Compiled;
use strict;

sub run_wrro_people_with_orcids
{
  my( $self, $state, $value ) = @_;

  my $session = $state->{session};
  my $r = $state->{session}->make_doc_fragment;

  my $creators = $value->[0];

  foreach my $i (0..$#$creators){

    my $creator = @$creators[$i];

    if( $i > 0 ){
      #not first item (or only one item)
      if( $i == $#$creators ){
        #last item
        $r->appendChild( $session->make_text( " and " ) );
      } else {
        $r->appendChild( $session->make_text( ", " ) );
      }
    }

    my $person_span = $session->make_element( "span", "class" => "person" );
    $person_span->appendChild( $session->render_name( $creator->{name} ) );

    my $id = $creator->{id};
    if( defined $id && $id =~ m/^(?:orcid.org\/)?(\d{4}\-\d{4}\-\d{4}\-\d{3}(?:\d|X))$/ )
    {
      my $orcid_span = $session->make_element( "span", "class" => "orcid" );

#   According to https://orcid.org/trademark-and-id-display-guidelines
#     "recommended display is a hyperlinked URI preceded by the iD icon"
#   This looks terrible in a citation. Removed for the time being.
#
#   my $orcid_link = $session->make_element(
#     "a",
#     "href" => "http://orcid.org/",
#     "target" => "_blank",
#     "class" => "orcid-icon"
#   );
#   $orcid_link->appendChild( $session->make_element(
#     "img",
#     "src" => "/images/orcid_16x16.png",
#     "title" => "ORCID"
#   ) );
#   $orcid_span->appendChild( $orcid_link );

      my $link = $session->make_element(
        "a",
        "href" => "http://orcid.org/$1",
        "target" => "_blank",
      );
      $link->appendChild( $session->make_text( "orcid.org/$1" ) );

      $orcid_span->appendChild( $session->make_text( "(" ) );
      $orcid_span->appendChild( $link );
      $orcid_span->appendChild( $session->make_text( ")" ) );

      $person_span->appendChild( $session->make_text( " " ) );
      $person_span->appendChild( $orcid_span );
    }
    $r->appendChild( $person_span );
  }

  return [ $r, "XHTML" ];
}

}
# END EPrints::Script::Compiled additions

You may also want a bit of CSS to style ORCID links

/* Add to e.g. ~/archives/ARCHIVEID/cfg/static/style/auto/zzz_orcid.css */
.person:hover {border-bottom: 1px dashed #a6ce39;}
.orcid {}
.orcid a:hover {
        color: #a6ce39;
}
.orcid-icon {}
.orcid-icon img { vertical-align: text-bottom; margin: 0 4px 0 2px; }

And finally, you have to call the new EPScript function from a citation file e.g. archives/ARCHIVEID/cfg/citations/eprint/default.xml

<!-- replace reference to e.g. <print expr="creators_name"/> with this: -->
    <print expr="wrro_people_with_orcids(creators)" />

Exposing the ORCID in RIOXX

Based on re-using the creators.id field, this block of code over-writes the default rioxx2_value_author function.

# Add to e.g. ~/archives/ARCHIVEID/cfg/cfg.d/zzz_rioxx2_overwrites.pl
$c->{rioxx2_value_author} = sub {
  my( $eprint ) = @_;

  my @authors;
  for( @{ $eprint->value( "creators" ) } )
  {
    my $id = $_->{id};
    if( defined $id && $id =~ m/^(?:orcid.org\/)?(\d{4}\-\d{4}\-\d{4}\-\d{3}(?:\d|X))$/ )
    {
      push @authors, {
        author => EPrints::Utils::make_name_string( $_->{name} ),
        id => "http://orcid.org/$1"
      };
    } else {
      push @authors, {
        author => EPrints::Utils::make_name_string( $_->{name} ),
      };
    }
  }

  #NB If your corp_creators has DOIs or ISNIs for the entries, a similar method could be used to include these here.
  foreach my $corp ( @{ $eprint->value( "corp_creators" ) } )
  {
    my $entry = {};
    $entry->{name} = $corp;
    push @authors, { author => $corp };
  }

  return \@authors;
};


Add additional identifiers to creators

Another approach to storing ORCIDs is to add an additional sub-field to the creator field. This has been discussed on the Eprints tech list. If you know how to do this, please document it here!

This is how University of Bath has done it. We're getting the ORCID data from another system, so have used a text field to capture it for display. At present there is no special rendering on it, it's just displaying as a number.

{
	name => 'creators',
	type => 'compound',
	multiple => 1,
	fields => [
		{
			sub_name => 'name',
			type => 'name',
			hide_honourific => 1,
			hide_lineage => 1,
			family_first => 1,
		},
		{
			sub_name => 'id',
			type => 'text',
			input_cols => 20,
			allow_null => 1,
		},
		{
			sub_name => 'orcid',
			type => 'text',
			input_cols => 20,
			allow_null => 1,
		}

	],
	input_boxes => 4,
},

This is how University of Pittsburgh has done it:

          {
            'name' => 'creators',
            'type' => 'compound',
            'multiple' => 1,
            'fields' => [
                          {
                            'sub_name' => 'name',
                            'type' => 'name',
                            'hide_honourific' => 1,
                            'hide_lineage' => 1,
                            'family_first' => 1,
                          },
                          {
                            'sub_name' => 'email',
                            'type' => 'text',
                            'input_cols' => 20,
                            'allow_null' => 1,
                          },
                          {
                            'sub_name' => 'id',
                            'type' => 'text',
                            'input_cols' => 20,
                            'allow_null' => 1,
                          },
                          {
                            'sub_name' => 'orcid',
                            'type' => 'id',
                            'input_cols' => 19,
                            'allow_null' => 1,
                          },
                        ],
            'input_boxes' => 4,
            'render_value' => 'custom_render_creators_with_orcid',
          },

Notes from Pittsburgh:

We have added some ORCID functionality in our IR System here at the University of Pittsburgh. We however have not “linked” our IR with orcid.org in anyway such as we do not have a lookup user in ORCID or the ability to add publications from ORCID to our IR. The only link is the entering of the ORCID into the system so that it can be displayed.

An example record is available here: http://d-scholarship.pitt.edu/28114/

  1. Users have an ORCID field in their profile – user_fields.pl
  2. Any “Creator” types have an ORCID field added to the workflow – eprint_fields.pl
  3. We have added ORCID validation adhering to this document: [1] - eprint_validate.pl
  4. We have added the ORCID to the “lookup” function to populate the ORCID field from any user entries in the database. – cgi/users/lookup/name
  5. We display the ORCID as such on the input form, where the green icon links out to our own orcid.pitt.edu site, but could be to orcid.org by default.
  6. We display the ORCID as such on the public display of the record where the ORCID is linked out to orcid.org (see example record)

ORCID Validator - snippet for eprints_validate.pl

        # ORCID ID Validator for individuals
        # Reference: http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
        # REGEX: ^\d{4}-\d{4}-\d{4}-(\d{3}X|\d{4})$
        #
        my @name_fields = qw( creators contributors exhibitors producers conductors lyricists );  #which ever name fields you added 'orcid' to.
        foreach my $name_field ( @name_fields )
        {
           if( $eprint->is_set( $name_field ) )
           {
              foreach my $creator ( @{ $eprint->value( $name_field ) } )
              {
                 my $orcid = $creator->{orcid};
                 next unless defined $orcid;
                 if ($repository->get_repository->can_call ( "validators", "isValidORCID" ) )
                 {
                    if (!$repository->get_repository->call( [ "validators", "isValidORCID" ], $orcid ))
                    {
                       my $field_text = $repository->html_phrase( "eprint_fieldname_$name_field" );
                       my $field_frag = $repository->make_element( "span", class=>"ep_problem_field:$name_field" );
                       $field_frag->appendChild($field_text);
                       push @problems, $repository->html_phrase( "warnings:orcid_invalid",
                            orcid => $repository->get_repository->make_text($orcid),
                            field => $field_frag,
                        );
                    }
                 } else {
                    $repository->get_repository->log( "Can not call isValidORCID." );
                 }
              }
           }
        }

Phrase for "warnings:orcid_invalid":

<epp:phrase id="warnings:orcid_invalid">The ORCID ID: <b><epc:pin name="orcid"/></b> is not a valid ORCID ID as it does not conform to the ORCID ID specification.  Please edit the <epc:pin name="field"/> with the associated ORCID or remove it from the name completely.</epp:phrase>


Additional Function that can be placed either at the end of eprints_validate.pl (after the final };) or elsewhere:

############################################
# Function:     isValidORCID
# Description:  Used to validate ORCID IDs
# 
# From: http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier (Checksum)
#
$c->{validators}->{isValidORCID} = sub {
   my $ORCID = $_[0];
   #Check for valid length of 19 characters.
   my $size = length($ORCID);
   if ($size > 19 )
   {
        return 0;
   } else {
      #Check actual validity of the ID mathematically.
      $ORCID =~ s/\-//g;
      my @chars = split(//, $ORCID);
      my $total = 0;
      for ( my $i=0; $i<15; $i++) {
         $total = ($total + $chars[$i]) *2;
      }
      my $remainder = $total % 11;
      my $result = (12 - $remainder) % 11;
      return ($chars[15] == ($result==10 ? 'X' : $result))
  }
};

Additionally you will have to define a custom render to add the fields to be displayed in the abstract/summary page.


(Information courtesy of Brian Gregg - bdgregg@pitt.edu)