diff --git a/cfg/cfg.d/z_datacitedoi.pl b/cfg/cfg.d/z_datacitedoi.pl index 2d7f112..08aaa27 100644 --- a/cfg/cfg.d/z_datacitedoi.pl +++ b/cfg/cfg.d/z_datacitedoi.pl @@ -1,5 +1,3 @@ -use Data::Dumper; - #Enable the plugin $c->{plugins}{"Export::DataCiteXML"}{params}{disable} = 0; $c->{plugins}{"Event::DataCiteEvent"}{params}{disable} = 0; @@ -15,13 +13,11 @@ #set these (you will get the from data site) # doi = {prefix}/{repoid}/{eprintid} -#$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"; +$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"; # datacite requires a Publisher # The name of the entity that holds, archives, publishes, @@ -29,13 +25,12 @@ # 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} = "University of Reading"; +$c->{datacitedoi}{publisher} = "Eprints Repo"; # 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-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"; +$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"; # 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 @@ -71,7 +66,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} = 0; +$c->{datacitedoi}{zero_padding} = 8; ########################################## ### Override which URL gets registered ### @@ -104,7 +99,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({ @@ -124,4 +119,52 @@ } -#With this we effectively turn off the repo_link => relatedIdentifier mapping for this repository + + + +#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) ); + } + } + } diff --git a/lib/cfg.d/zzz_datacite_mapping.pl b/lib/cfg.d/zzz_datacite_mapping.pl deleted file mode 100644 index 491c928..0000000 --- a/lib/cfg.d/zzz_datacite_mapping.pl +++ /dev/null @@ -1,83 +0,0 @@ -#################################################### -# 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 -}; - -=comment - -$c->{datacite_mapping_somefield} = sub { - - - my ( $xml, $dataobj, $repo, $value ) = @_; - - #Do the mapping/validation here.... - - return $xml #of somedescription - - -} - -=cut