line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::viaf_read; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
177537
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
227
|
use Catmandu::Util qw(:is); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
277
|
|
5
|
1
|
|
|
1
|
|
305
|
use Catmandu::OCLC::xID; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
439
|
use Catmandu::OCLC::VIAFAuthorityCluster; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
7
|
1
|
|
|
1
|
|
8
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
1
|
|
|
1
|
|
1282
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
1951
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub fix { |
13
|
1
|
|
|
1
|
0
|
2002
|
my ($self, $data) = @_; |
14
|
1
|
|
|
|
|
4
|
my $path = $self->path; |
15
|
1
|
|
|
|
|
6
|
my $identifier = Catmandu::Util::data_at($path,$data); |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
32
|
if (is_string($identifier)) { |
18
|
1
|
|
|
|
|
5
|
my $authority = Catmandu::OCLC::VIAFAuthorityCluster::read($identifier); |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
return undef unless defined $authority; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$data->{record} = $authority->{record}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$data; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Catmandu::Fix::viaf_read - query the OCLC VIAF service |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
add_field('number','102333412'); |
35
|
|
|
|
|
|
|
do |
36
|
|
|
|
|
|
|
maybe(); |
37
|
|
|
|
|
|
|
viaf_read('number'); |
38
|
|
|
|
|
|
|
marc_map('700','author.$append') |
39
|
|
|
|
|
|
|
remove_field(record) |
40
|
|
|
|
|
|
|
end |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Search for an authority record by a VIAF control number. Will insert the parsed VIAF MARC |
45
|
|
|
|
|
|
|
record into the document (overwriting the 'record' key if available). Returns undef on failure. |
46
|
|
|
|
|
|
|
Use the maybe() Bind to secure against service failures undef return values |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SEE ALSO |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L, L, L |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |