From 2b68f3dbf4a258f39e2a13e5eb51d6782bb673bc Mon Sep 17 00:00:00 2001 From: Borys Feldman Date: Tue, 19 Sep 2017 17:35:45 +0100 Subject: [PATCH] updating the datacite plugin --- cfg/cfg.d/z_datacitedoi.pl | 75 +---- lib/cfg.d/z_datacite_mapping.pl | 267 ++++++++++++++++ lib/cfg.d/zz_datacite_mapping_overide.pl | 28 ++ .../EPrints/Plugin/Export/DataCiteXML.pm | 296 +----------------- 4 files changed, 312 insertions(+), 354 deletions(-) create mode 100644 lib/cfg.d/z_datacite_mapping.pl create mode 100644 lib/cfg.d/zz_datacite_mapping_overide.pl mode change 100644 => 120000 lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm diff --git a/cfg/cfg.d/z_datacitedoi.pl b/cfg/cfg.d/z_datacitedoi.pl index 08aaa27..2d7f112 100644 --- a/cfg/cfg.d/z_datacitedoi.pl +++ b/cfg/cfg.d/z_datacitedoi.pl @@ -1,3 +1,5 @@ +use Data::Dumper; + #Enable the plugin $c->{plugins}{"Export::DataCiteXML"}{params}{disable} = 0; $c->{plugins}{"Event::DataCiteEvent"}{params}{disable} = 0; @@ -13,11 +15,13 @@ #set these (you will get the from data site) # doi = {prefix}/{repoid}/{eprintid} -$c->{datacitedoi}{prefix} = "10.5072"; -$c->{datacitedoi}{repoid} = $c->{host}; -$c->{datacitedoi}{apiurl} = "https://test.datacite.org/mds/"; -$c->{datacitedoi}{user} = "USER"; -$c->{datacitedoi}{pass} = "PASS"; +#$c->{datacitedoi}{prefix} = "10.5072"; +$c->{datacitedoi}{prefix} = "10.17864"; +$c->{datacitedoi}{repoid} = "1947"; +$c->{datacitedoi}{apiurl} = "https://mds.datacite.org/"; +#$c->{datacitedoi}{apiurl} = "https://mds.test.datacite.org/"; +$c->{datacitedoi}{user} = "BL.READING"; +$c->{datacitedoi}{pass} = "rdawk201"; # datacite requires a Publisher # The name of the entity that holds, archives, publishes, @@ -25,12 +29,13 @@ # resource. This property will be used to formulate the # citation, so consider the prominence of the role. # eg World Data Center for Climate (WDCC); -$c->{datacitedoi}{publisher} = "Eprints Repo"; +$c->{datacitedoi}{publisher} = "University of Reading"; # Namespace and location for datacite XML schema # feel free to update, though no guarantees it'll be accepted if you do -$c->{datacitedoi}{xmlns} = "http://datacite.org/schema/kernel-4.0"; -$c->{datacitedoi}{schemaLocation} = $c->{datacitedoi}{xmlns}." http://schema.datacite.org/meta/kernel-4.0/metadata.xsd"; +#$c->{datacitedoi}{xmlns} = "http://datacite.org/schema/kernel-2.2"; +$c->{datacitedoi}{xmlns} = "http://datacite.org/schema/kernel-4"; +$c->{datacitedoi}{schemaLocation} = $c->{datacitedoi}{xmlns}." http://schema.datacite.org/meta/kernel-4/metadata.xsd"; # need to map eprint type (article, dataset etc) to ResourceType # Controled list http://schema.datacite.org/meta/kernel-2.2/doc/DataCite-MetadataKernel_v2.2.pdf @@ -66,7 +71,7 @@ $c->{datacitedoi}{allow_custom_doi} = 0; #Datacite recommend digits of length 8-10 set this param to pad the id to required length -$c->{datacitedoi}{zero_padding} = 8; +$c->{datacitedoi}{zero_padding} = 0; ########################################## ### Override which URL gets registered ### @@ -99,7 +104,7 @@ return undef if (!defined $repository); - if (defined $params{dataobj}) { + if (defined %params->{dataobj}) { my $dataobj = $params{dataobj}; my $eprint_id = $dataobj->id; $repository->dataset( "event_queue" )->create_dataobj({ @@ -119,52 +124,4 @@ } - - - -#BF sub method for can call for funder -$c->{datacite_custom_funder} = sub - { - - my ( $xml, $entry, $dataobj ) = @_; - - if ($dataobj->exists_and_set( "funders" )) { - my $funders = $dataobj->get_value( "funders" ); - my $thefunders = $xml->create_element( "funders" ); - foreach my $funder ( @$funders ) - { - my $fund = $funder->{funders}; - my $grant = $funder->{grant}; - my $others = $dataobj->get_value( "funders_other_funder" ); - if($fund eq "other"){ - foreach my $other ( @$others ) - { - - $thefunders->appendChild( $xml->create_data_element( "funderName", $other) ); - }} else { - $thefunders->appendChild( $xml->create_data_element( "funderName", $fund) ); - } - -$thefunders->appendChild( $xml->create_data_element( "awardNumber", $grant) ); - - - } - $entry->appendChild( $thefunders ); - } - }; - - -#BF sub method for can call for language -$c->{datacite_custom_language} = sub - { - my ( $xml, $entry, $dataobj ) = @_; - - my $lan = $dataobj->get_value( "language" ); - if ($dataobj->exists_and_set( "language" )) { - foreach my $la ( @$lan ) - { - my $thelanguage = $la->{l}; - $entry->appendChild( $xml->create_data_element( "language", $thelanguage) ); - } - } - } +#With this we effectively turn off the repo_link => relatedIdentifier mapping for this repository diff --git a/lib/cfg.d/z_datacite_mapping.pl b/lib/cfg.d/z_datacite_mapping.pl new file mode 100644 index 0000000..2cd1e01 --- /dev/null +++ b/lib/cfg.d/z_datacite_mapping.pl @@ -0,0 +1,267 @@ +##################################################### +# New architecture +# for print => datacite mapping#################################################### + +# These first two both map to resourceType(and resourceTypeGeneral) the first is +# for pubs repos the second +# for data(but either can be used +# for ether f the eprint field is there) +$c->{datacite_mapping_type} = sub { + + my($xml, $dataobj, $repo, $value) = @_; + + my $pub_resourceType = $repo->get_conf("datacitedoi", "typemap", $value); + if (defined $pub_resourceType) { + return $xml->create_data_element("resourceType", $pub_resourceType->{'v'}, resourceTypeGeneral=>$pub_resourceType->{'a'}); + } + + return undef; +}; + +$c->{datacite_mapping_data_type} = sub { + + my($xml, $dataobj, $repo, $value) = @_; + + return $xml->create_data_element("resourceType", $value, resourceTypeGeneral=>$value); +}; + +$c->{datacite_mapping_creators} = sub { + + my($xml, $dataobj, $repo, $value) = @_; + + my $creators = $xml->create_element("creators"); + + foreach my $name(@$value) { + my $author = $xml->create_element("creator"); + + my $name_str = EPrints::Utils::make_name_string($name->{name}); + + my $family = $name->{name}->{family}; + my $given = $name->{name}->{given}; + my $orcid = $name->{orcid}; + + if ($family eq '' && $given eq '') { + $creators->appendChild($author); + } else { + $author->appendChild($xml->create_data_element("creatorName", $name_str)); + } + if ($given eq '') { + $creators->appendChild($author); + } else { + $author->appendChild($xml->create_data_element("givenName", $given)); + } + if ($family eq '') { + $creators->appendChild($author); + } else { + $author->appendChild($xml->create_data_element("familyName", $family)); + } + if ($dataobj->exists_and_set("creators_orcid")) { + + if ($orcid eq '') { + $creators->appendChild($author); + } else { + $author->appendChild($xml->create_data_element("nameIdentifier", $orcid, schemeURI =>"http://orcid.org/", nameIdentifierScheme=>"ORCID")); + } + } + + $creators->appendChild($author); + } + return $creators +}; + + +$c->{datacite_mapping_title} = sub { + my($xml, $dataobj, $repo, $value) = @_; + + + + my $titles = $xml->create_element("titles"); + $titles->appendChild($xml->create_data_element("title", $dataobj->render_value("title"), "xml:lang"=>"en-us")); + + + + + + + return $titles# of somedescription +}; + + + + + + +$c->{datacite_mapping_abstract} = sub { + my($xml, $dataobj, $repo, $value) = @_; + + my $abstract = $dataobj->get_value("abstract"); + my $description = $xml->create_element("descriptions"); + + $description->appendChild($xml->create_data_element("description", $abstract, "xml:lang"=>"en-us", descriptionType=>"Abstract")); + + if ($dataobj->exists_and_set("collection_method")) { + my $collection = $dataobj->get_value("collection_method"); + $description->appendChild($xml->create_data_element("description", $collection, descriptionType =>"Methods")); + } + + if ($dataobj->exists_and_set("provenance")) { + my $processing = $dataobj->get_value("provenance"); + $description->appendChild($xml->create_data_element("description", $processing, descriptionType =>"Methods")); + } + + + + + return $description# of somedescription +}; + + + + + + +$c->{datacite_mapping_date} = sub { + my ( $xml, $dataobj, $repo, $value ) = @_; + $dataobj->get_value( "date" ) =~ /^([0-9]{4})/; + return $xml->create_data_element( "publicationYear", $1 ) if $1; + +}; + + +$c->{datacite_mapping_keywords} = sub { + my($xml, $dataobj, $repo, $value) = @_; + + if ($dataobj->exists_and_set("keywords")) { + my $subjects = $xml->create_element("subjects"); + my $keywords = $dataobj->get_value("keywords"); + if (ref($keywords) eq "ARRAY") { + foreach my $keyword(@$keywords) { + $subjects->appendChild($xml->create_data_element("subject", $keyword, "xml:lang"=>"en-us")); + } + return $subjects + + } else { + $subjects->appendChild($xml->create_data_element("subject", $keywords, "xml:lang"=>"en-us")); + return $subjects + } + } +}; + +$c->{datacite_mapping_geographic_cover} = sub { + my($xml, $dataobj, $repo, $value) = @_; + + my $geo_locations = $xml->create_element("geoLocations"); + my $geo_location = $xml->create_element("geoLocation"); + if ($dataobj->exists_and_set("geographic_cover")) { + + # + #Create XML elements + + # Get value of geographic_cover field and append to $geo_location XML element + my $geographic_cover = $dataobj->get_value("geographic_cover"); + $geo_location->appendChild($xml->create_data_element("geoLocationPlace", $geographic_cover)); + + # + # Get values of bounding box + my $west = $dataobj->get_value("bounding_box_west_edge"); + my $east = $dataobj->get_value("bounding_box_east_edge"); + my $south = $dataobj->get_value("bounding_box_south_edge"); + my $north = $dataobj->get_value("bounding_box_north_edge"); + + # + # Check to see + # if $north, $south, $east, or $west values are defined + if (defined $north && defined $south && defined $east && defined $west) {# + #Created $geo_location_box XML element + my $geo_location_box = $xml->create_element("geoLocationBox");# + #If $long / lat is defined, created XML element with the appropriate value + $geo_location_box->appendChild($xml->create_data_element("westBoundLongitude", $west)); + $geo_location_box->appendChild($xml->create_data_element("eastBoundLongitude", $east)); + $geo_location_box->appendChild($xml->create_data_element("southBoundLatitude", $south)); + $geo_location_box->appendChild($xml->create_data_element("northBoundLatitude", $north));# + #Append child $geo_location_box XML element to parent $geo_location XML element + $geo_location->appendChild($geo_location_box); + } + #Append child $geo_location XML element to parent $geo_locations XML element + $geo_locations->appendChild($geo_location); + #Append $geo_locations XML element to XML document# $entry - > appendChild($geo_locations); + } + + return $geo_locations; +}; + +$c->{datacite_mapping_funders} = sub { + my($xml, $dataobj, $repo, $value) = @_; + + + # + # if ($repo - >can_call("datacite_custom_funder")) {# + # return $repo - > call("datacite_custom_funder", $xml, $dataobj);# + # } + + my $funders = $dataobj->get_value("funders"); + my $grant = $dataobj->get_value("grant"); + my $projects = $dataobj->get_value("projects"); + if ($dataobj->exists_and_set("funders")) { + my $thefunders = $xml->create_element("funders"); + foreach my $funder(@$funders) { + foreach my $project(@$projects) { + $thefunders->appendChild($xml->create_data_element("funderName", $funder)); + $thefunders->appendChild($xml->create_data_element("awardNumber", $grant)); + } + } + return $thefunders; + } +}; + + + +$c->{datacite_mapping_rights} = sub { + my($xml, $dataobj, $repo, $value) = @_; + my $author = $xml->create_element("rightsList"); + + foreach my $doc($dataobj->get_all_documents()) { + + my $license = $doc->get_value("license"); + + if (defined $license && $license ne '') { + + if ($license eq "attached") { + + $author ->appendChild($xml->create_data_element("rights", $repo->phrase("licenses_typename_attached"), rightsURI =>$doc->get_url)); + } else { + + my $licenseuri = $repo->phrase("licenses_uri_$license"); + $author->appendChild($xml->create_data_element("rights", $license, rightsURI =>$licenseuri)); + } + } + + + } + return $author; +}; + + + + + + +$c->{datacite_mapping_repo_link} = sub { + + my($xml, $entry, $dataobj) = @_; + + my $relatedIdentifiers = undef; + #default codein plugin (for reference) + # my $theurls = $dataobj->get_value( "repo_link" ); + # my $relatedIdentifiers = $xml->create_element( "relatedIdentifiers" ); + # foreach my $theurl ( @$theurls ) { + # my $linkk = $theurl->{link}; + # if (!$linkk eq ''){ + # $relatedIdentifiers->appendChild( $xml->create_data_element( "relatedIdentifier", $linkk, relatedIdentifierType=>"URL", relationType=>"IsReferencedBy" ) ); + # } + # } + + + return $relatedIdentifiers; + +}; diff --git a/lib/cfg.d/zz_datacite_mapping_overide.pl b/lib/cfg.d/zz_datacite_mapping_overide.pl new file mode 100644 index 0000000..7572748 --- /dev/null +++ b/lib/cfg.d/zz_datacite_mapping_overide.pl @@ -0,0 +1,28 @@ +$c->{datacite_mapping_funders} = sub { + + my($xml, $dataobj) = @_; + + if ($dataobj->exists_and_set("funders")) { + my $funders = $dataobj->get_value("funders"); + my $thefunders = $xml->create_element("fundingReferences"); + foreach my $funder(@$funders) { + my $author = $xml->create_element("fundingReference"); + my $fund = $funder->{funders}; + my $grant = $funder->{grant}; + my $others = $dataobj->get_value("funders_other_funder"); + if ($fund eq "other") { + foreach my $other(@$others) { + $author->appendChild($xml->create_data_element("funderName", $other)); + } + } else { + $author->appendChild($xml->create_data_element("funderName", $fund)); + } + + $author->appendChild($xml->create_data_element("awardNumber", $grant)); + + $thefunders->appendChild($author); + } + return $thefunders; + } + return undef; +}; diff --git a/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm b/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm deleted file mode 100644 index 24eeb02..0000000 --- a/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm +++ /dev/null @@ -1,295 +0,0 @@ -=head1 NAME -EPrints::Plugin::Export::DataCiteXML - -=cut - -package EPrints::Plugin::Export::DataCiteXML; -use EPrints::Plugin::Export::Feed; - -@ISA = ('EPrints::Plugin::Export::Feed'); - -use strict; - -use Data::Dumper; -sub new -{ - my ($class, %opts) = @_; - - my $self = $class->SUPER::new(%opts); - - $self->{name} = 'Data Cite XML'; - $self->{accept} = [ 'dataobj/eprint']; - $self->{visible} = 'all'; - $self->{suffix} = '.xml'; - $self->{mimetype} = 'application/xml; charset=utf-8'; - $self->{arguments}->{doi} = undef; - - return $self; -} - -sub output_dataobj -{ - my ($self, $dataobj, %opts) = @_; - - my $repo = $self->{repository}; - my $xml = $repo->xml; - - #reference the datacite schema from config - our $entry = $xml->create_element( "resource", - xmlns=> $repo->get_conf( "datacitedoi", "xmlns"), - "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", - "xsi:schemaLocation" => $repo->get_conf( "datacitedoi", "schemaLocation")); - - #RM We pass in the DOI from Event::DataCite... or from --args on the cmd line - - # AH my $thisdoi = $opts{doi}; always returns undefined, even when DOI exists - # Ideally coining should NOT happen in this script but opts{doi} should have it - # but is always blank - my $thisdoi = $dataobj->get_value("id_number"); - #RM coin a DOI if either - # - not come via event or - # - no doi arg passed in via cmd_line - # ie when someone exports DataCiteXML from the Action tab - if(!defined $thisdoi){ - #nick the coining sub from event plugin - my $event = $repo->plugin("Event::DataCiteEvent"); - $thisdoi = $event->coin_doi($repo, $dataobj); - #coin_doi may return an event error code if no prefix present assume this is the case - my $prefix = $repo->get_conf( "datacitedoi", "prefix"); - return $thisdoi if($thisdoi !~ /^$prefix/); - } - $entry->appendChild( $xml->create_data_element( "identifier", $thisdoi , identifierType=>"DOI" ) ); - - foreach my $field ( $dataobj->{dataset}->get_fields ) - { - my $mapping_fn = "datacite_mapping_".$field->get_name; - if($repo->can_call($mapping_fn) && $dataobj->exists_and_set($field->get_name)){ - my $mapped_element = $repo->call( $mapping_fn, $xml, $dataobj, $repo, $dataobj->value($field->get_name) ); - $entry->appendChild( $mapped_element ) if(defined $mapped_element); - } - } - - #RM extract licens from documents by some means: - my $license = undef; - if( $repo->can_call( "datacite_license" ) ){ - $license = $repo->call( "datacite_license", $xml, $entry, $dataobj, $repo ); - } - - - ########################################################################################################################################################################## - ################################# From here on in you can redefine datacite_ampping_[fieldname] sub routines in lib/cfg.d/zzz_datacite_mapping.pl ####################### - - - if ($dataobj->exists_and_set( "title" )) { - my $titles = $xml->create_element( "titles" ); - $titles->appendChild( $xml->create_data_element( "title", $dataobj->render_value( "title" ), "xml:lang"=>"en-us" ) ); - - $entry->appendChild( $titles ); - } - $entry->appendChild( $xml->create_data_element( "publisher", $repo->get_conf( "datacitedoi", "publisher") ) ); - - if ($dataobj->exists_and_set( "date" )) { - $dataobj->get_value( "date" ) =~ /^([0-9]{4})/; - $entry->appendChild( $xml->create_data_element( "publicationYear", $1 ) ) if $1; - } - - # AH 03/11/2016: mapping the data in the EPrints keywords field to a tag. - # If the keywords field is a multiple - and therefore, an array ref - then - # iterate through array and make each array element its own element. - # Otherwise, if the keywords field is a single block of text, take the string - # and make it a single element - if ($dataobj->exists_and_set( "keywords" )) { - my $subjects = $xml->create_element( "subjects" ); - my $keywords = $dataobj->get_value("keywords"); - if(ref($keywords) eq "ARRAY") { - foreach my $keyword ( @$keywords ) { - $subjects->appendChild( $xml->create_data_element( "subject", $keyword, "xml:lang"=>"en-us") ); - } - - $entry->appendChild( $subjects ); - } else { - $subjects->appendChild( $xml->create_data_element( "subject", $keywords, "xml:lang"=>"en-us") ); - $entry->appendChild( $subjects ); - } - } - - # AH 16/12/2016: commenting out the creation of the element. This is because the - # DataCite 4.0 Schema requires a contributorType attribute, which needs to be mapped. According to - # https://schema.datacite.org/meta/kernel-4.0/doc/DataCite-MetadataKernel_v4.0.pdf (page 16), there - # is a controlled list of contributorType options and it would be advisable to alter the - # Recollect workflow to make use of this controlled list (e.g. a namedset of approved values) - # and then map the values from this field to the XML found below. - # Note: if you do not supply a contributorType, the coin DOI process will fail - # because the contributorType attribute is mandatory. As such, and because the parent - # element is not mandatory, it will be commented out and not sent to DataCite pending further work from ULCC. - - # if( $dataobj->exists_and_set( "contributors" ) ) - # { - # - # my $contributors = $xml->create_element( "contributors" ); - # - # my $names = $dataobj->get_value( "contributors" ); - # - # foreach my $name ( @$names ) - # { - # my $author = $xml->create_element( "contributor" ); - # - # my $name_str = EPrints::Utils::make_name_string( $name->{name}); - # - # my $orcid = $name->{orcid}; - # - # my $typee = $name->{type}; - # my $family = $name->{name}->{family}; - # my $given = $name->{name}->{given}; - # - # if ($family eq '' && $given eq ''){ - # $contributors->appendChild( $author ); - # } else { - # $author->appendChild( $xml->create_data_element("contributorName", $name_str ) ); - # } - - - # if ($given eq '') { - # $contributors->appendChild( $author ); - # } else { - # $author->appendChild( $xml->create_data_element("givenName",$given ) ); - # } - # if ($family eq ''){ - # $contributors->appendChild( $author ); - # } else { - # $author->appendChild( $xml->create_data_element("familyName", $family ) ); - # } - # - # if ($dataobj->exists_and_set( "contributors_orcid" )) { - # my $orcid = $name->{orcid}; - # if ($orcid eq '') { - # $contributors->appendChild( $author ); - # } else { - # $author->appendChild( $xml->create_data_element("nameIdentifier", $orcid, schemeURI=>"http://orcid.org/", nameIdentifierScheme=>"ORCID" ) ); - # } - # } - # if ($dataobj->exists_and_set( "contributors_affiliation" )) { - # my $affiliation = $dataobj->get_value("contributors_affiliation"); - # $author->appendChild( $xml->create_data_element("affillation", $affiliation) ); - # } - # $contributors->appendChild( $author ); - # } - # $entry->appendChild( $contributors ); - # } - - #BF this is a can call which checks and calls for a sub inside the z_datacitedoi called funderrr - if( $repo->can_call( "datacite_custom_funder" ) ){ - unless( defined( $repo->call( "datacite_custom_funder", $xml, $entry, $dataobj ) ) ){ - my $funders = $dataobj->get_value( "funders" ); - my $grant = $dataobj->get_value( "grant" ); - my $projects = $dataobj->get_value( "projects" ); - if ($dataobj->exists_and_set( "funders" )) { - my $thefunders = $xml->create_element( "funders" ); - foreach my $funder ( @$funders ){ - foreach my $project ( @$projects ){ - $thefunders->appendChild( $xml->create_data_element( "funderName", $funder) ); - $thefunders->appendChild( $xml->create_data_element( "awardNumber", $grant) ); - } - } - $entry->appendChild( $thefunders ); - } - } - } - - if ($dataobj->exists_and_set( "repo_link" )) { - -# RelatedIdentifier should be more careful in identifying the relationType so we will revisit after more input from the DataCite community probably for milestone 1.3 - -# #If we have a custom override -# if( $repo->can_call( "datacite_custom_repo_link" ) ){ -# my $relatedIdentifiers = $repo->call( "datacite_custom_repo_link", $xml, $entry, $dataobj ); -# $entry->appendChild( $relatedIdentifiers ) if (defined $relatedIdentifiers); -# #default action -# }else{ -# my $theurls = $dataobj->get_value( "repo_link" ); -# my $relatedIdentifiers = $xml->create_element( "relatedIdentifiers" ); -# foreach my $theurl ( @$theurls ) { -# my $linkk = $theurl->{link}; -# if (!$linkk eq ''){ -# $relatedIdentifiers->appendChild( $xml->create_data_element( "relatedIdentifier", $linkk, relatedIdentifierType=>"URL", relationType=>"IsReferencedBy" ) ); -# } -# $entry->appendChild( $relatedIdentifiers ); -# } -# } - } - - if ($dataobj->exists_and_set( "abstract" )) { - - my $abstract = $dataobj->get_value( "abstract" ); - my $description = $xml->create_element( "descriptions" ); - - $description->appendChild( $xml->create_data_element( "description", $abstract, "xml:lang"=>"en-us", descriptionType=>"Abstract" ) ); - - if ($dataobj->exists_and_set( "collection_method" )) { - my $collection = $dataobj->get_value("collection_method"); - $description->appendChild( $xml->create_data_element("description", $collection, descriptionType=>"Methods")); - } - - if ($dataobj->exists_and_set( "provenance" )) { - my $processing = $dataobj->get_value("provenance"); - $description->appendChild( $xml->create_data_element("description", $processing, descriptionType=>"Methods")); - } - - $entry->appendChild( $description ); - } - - #BF this is a can call which checks and calls for a sub inside the z_datacitedoi called laaanguages - if( $repo->can_call( "datacite_custom_language" ) ){ - unless( defined( $repo->call( "datacite_custom_language", $xml, $entry, $dataobj ) ) ){ - if ($dataobj->exists_and_set( "language" )) { - my $lan = $dataobj->get_value( "language" ); - $entry->appendChild( $xml->create_data_element( "language", $lan) ); - } - } - } - - # AH 16/11/2016: rendering the geoLocations XML elements - # Note: the initial conditional checks to see if the geographic_cover - # metadata field exists and is set. This was done because geographic_cover - # is part of the z_recollect_metadata_profile.pl file within the Recollect - # plugin and many repositories make it a mandatory field in the workflow. - - if( $dataobj->exists_and_set( "geographic_cover" ) ) { - - #Create XML elements - my $geo_locations = $xml->create_element( "geoLocations" ); - my $geo_location = $xml->create_element( "geoLocation" ); - - # Get value of geographic_cover field and append to $geo_location XML element - my $geographic_cover = $dataobj->get_value( "geographic_cover" ); - $geo_location->appendChild( $xml->create_data_element("geoLocationPlace", $geographic_cover ) ); - - # Get values of bounding box - my $west = $dataobj->get_value( "bounding_box_west_edge" ); - my $east = $dataobj->get_value( "bounding_box_east_edge" ); - my $south = $dataobj->get_value( "bounding_box_south_edge" ); - my $north = $dataobj->get_value( "bounding_box_north_edge" ); - - # Check to see if $north, $south, $east, or $west values are defined - if (defined $north && defined $south && defined $east && defined $west ) { - # Created $geo_location_box XML element - my $geo_location_box = $xml->create_element( "geoLocationBox" ); - # If $long/lat is defined, created XML element with the appropriate value - $geo_location_box->appendChild( $xml->create_data_element( "westBoundLongitude", $west) ); - $geo_location_box->appendChild( $xml->create_data_element( "eastBoundLongitude", $east) ); - $geo_location_box->appendChild( $xml->create_data_element( "southBoundLatitude", $south) ); - $geo_location_box->appendChild( $xml->create_data_element( "northBoundLatitude", $north) ); - # Append child $geo_location_box XML element to parent $geo_location XML element - $geo_location->appendChild( $geo_location_box ); - } - # Append child $geo_location XML element to parent $geo_locations XML element - $geo_locations->appendChild( $geo_location ); - # Append $geo_locations XML element to XML document - $entry->appendChild( $geo_locations ); - } - - return ''."\n".$xml->to_string($entry); -} - - -1; diff --git a/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm b/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm new file mode 120000 index 0000000..32f29e5 --- /dev/null +++ b/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm @@ -0,0 +1 @@ +/home/thething/eprints/relrdgdr/eprints3/lib/epm/DataCiteDoi/lib/plugins/EPrints/Plugin/Export/DataCiteXML.pm \ No newline at end of file