package EPrints::Plugin::Export::DOI; use EPrints::Plugin::Export::TextFile; @ISA = ( "EPrints::Plugin::Export::TextFile" ); use strict; sub new { my( $class, %opts ) = @_; my $self = $class->SUPER::new( %opts ); $self->{name} = "DOIs"; $self->{accept} = [ 'dataobj/eprint', 'list/eprint' ]; $self->{visible} = "all"; $self->{disable} = 1; return $self; } sub output_dataobj { my( $plugin, $dataobj ) = @_; my $doi; my $fields_to_check = $plugin->repository->config('doi_exporter','fields_to_check'); FIELD: foreach my $field (@{$fields_to_check}) { if ($dataobj->exists_and_set($field)) { my $val = $dataobj->value($field); if (!ref $val) { $val = [$val]; #normalise to an array } foreach my $v (@{$val}) { next FIELD if ref $v; #only handle arrays of scalars $v =~ s/^http:\/\/dx\.doi\.org//; if ( $v =~ /^(doi:)?10\.\d\d\d\d\// ) { $v =~ s/^doi://; $doi = $v } } } } return $dataobj->id . "\t$doi\thttp://dx.doi.org/$doi\n" if $doi; } 1;