Skip to content

Commit

Permalink
Add optional date types that can be used when generating a DOI for a …
Browse files Browse the repository at this point in the history
…thesis (as they tend to use completed/awarded dates rather than published dates)
  • Loading branch information
wfyson committed Aug 1, 2023
1 parent f7538fa commit a915948
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
10 changes: 5 additions & 5 deletions DataCiteDoi.epmi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<datasetid>document</datasetid>
<filename>cfg.d/z_datacite_mapping.pl</filename>
<mime_type>text/plain</mime_type>
<hash>901e381322a012bdd7835425088ed55e</hash>
<hash>a8ea31619777aed5849a83cdc1d7e7e1</hash>
<hash_type>MD5</hash_type>
<filesize>34933</filesize>
<filesize>35704</filesize>
</file>
<file>
<datasetid>document</datasetid>
Expand Down Expand Up @@ -65,9 +65,9 @@
<datasetid>document</datasetid>
<filename>epm/DataCiteDoi/cfg/cfg.d/z_datacitedoi.pl</filename>
<mime_type>text/plain</mime_type>
<hash>9558d25247d0c9478a7cc43633ae08d3</hash>
<hash>278527931e0771de0a6a55f582ba2b8c</hash>
<hash_type>MD5</hash_type>
<filesize>12320</filesize>
<filesize>12422</filesize>
</file>
<file>
<datasetid>document</datasetid>
Expand Down Expand Up @@ -147,7 +147,7 @@
<content>coverimage</content>
</document>
</documents>
<version>3.2.2</version>
<version>3.2.3</version>
<creators>
<item>
<name>
Expand Down
3 changes: 3 additions & 0 deletions cfg/cfg.d/z_datacitedoi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
$c->{datacitedoi}{eprintdoifield} = "id_number";
$c->{datacitedoi}{documentdoifield} = "id_number";

# date types valid for thesis DOIs
$c->{datacitedoi}{thesis_date_types} = [qw( awarded completed )];

#for xml:lang attributes in XML
$c->{datacitedoi}{defaultlangtag} = "en-GB";

Expand Down
29 changes: 27 additions & 2 deletions lib/cfg.d/z_datacite_mapping.pl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@

my $publicationYear = undef;
my $pub_year = undef;
if( $dataobj->exists_and_set( "date" ) && $dataobj->exists_and_set( "date_type" ) && $dataobj->value( "date_type" ) eq "published" ) {
if( $dataobj->exists_and_set( "date" ) && $dataobj->exists_and_set( "date_type" ) && $repo->call(["datacitedoi", "validate_date_type"], $repo, $dataobj ) )
{
$dataobj->get_value( "date" ) =~ /^([0-9]{4})/;
$pub_year = $1;
}
Expand All @@ -281,6 +282,8 @@
return $publicationYear;
};



##################################################
# resourceType this is derived from the eprint.type and the datacitedoi->{typemap} in cfg/cfg.d/z_datacite.pl
# https://schema.datacite.org/meta/kernel-4.0/metadata.xsd#resourceType
Expand Down Expand Up @@ -866,7 +869,7 @@
}

my $no_pub_year = 1;
if( $eprint->exists_and_set( "date" ) && $eprint->exists_and_set( "date_type" ) && $eprint->value( "date_type" ) eq "published" )
if( $eprint->exists_and_set( "date" ) && $eprint->exists_and_set( "date_type" ) && $repository->call(["datacitedoi", "validate_date_type"], $repository, $eprint ) )
{
$no_pub_year = 0;
}
Expand Down Expand Up @@ -982,3 +985,25 @@
return( @problems );
};

$c->{datacitedoi}->{validate_date_type} = sub {

my( $repo, $eprint ) = @_;

return 1 if $eprint->value( "date_type" ) eq "published";
return 1 if $eprint->value( "date_type" ) eq "published_online";

# if this is a thesis, we might not have a published date
# but an awarded or completed date will do in most cases

my $thesis_date_types = $repo->get_conf( "datacitedoi", "thesis_date_types" );
if( defined $thesis_date_types )
{
if( $eprint->value( "type" ) eq "thesis" &&
( grep $eprint->value( "date_type") eq $_, @$thesis_date_types ) )
{
return 1; # we have date type acceptable for a thesis
}
}

return 0;
};

0 comments on commit a915948

Please sign in to comment.