line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::MARC::Base; |
2
|
34
|
|
|
34
|
|
1482314
|
use Moo::Role; |
|
34
|
|
|
|
|
12298
|
|
|
34
|
|
|
|
|
209
|
|
3
|
34
|
|
|
34
|
|
18674
|
use MARC::Record; |
|
34
|
|
|
|
|
155907
|
|
|
34
|
|
|
|
|
1350
|
|
4
|
34
|
|
|
34
|
|
237
|
use MARC::Field; |
|
34
|
|
|
|
|
68
|
|
|
34
|
|
|
|
|
14136
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.20'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _raw_to_marc_record { |
9
|
4
|
|
|
4
|
|
10
|
my ($self,$data) = @_; |
10
|
4
|
|
|
|
|
28
|
my $marc = MARC::Record->new(); |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
|
|
47
|
for my $field (@$data) { |
13
|
26
|
|
|
|
|
4584
|
my ($tag, $ind1, $ind2, @data) = @$field; |
14
|
|
|
|
|
|
|
|
15
|
26
|
|
100
|
|
|
75
|
$ind1 //= ' '; |
16
|
26
|
|
100
|
|
|
54
|
$ind2 //= ' '; |
17
|
|
|
|
|
|
|
|
18
|
26
|
|
|
|
|
57
|
@data = $self->_clean_raw_data($tag,@data); |
19
|
|
|
|
|
|
|
|
20
|
26
|
100
|
|
|
|
82
|
if (@data < 2) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
21
|
6
|
|
|
|
|
114
|
$self->log->warn("$tag doesn't have any data"); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
elsif ($tag eq 'LDR') { |
24
|
0
|
|
|
|
|
0
|
$marc->leader($data[1]); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($tag =~ /^00/) { |
27
|
4
|
|
|
|
|
21
|
my $field = MARC::Field->new($tag,$data[1]); |
28
|
4
|
|
|
|
|
132
|
$marc->append_fields($field); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
16
|
|
|
|
|
59
|
my $field = MARC::Field->new($tag, $ind1, $ind2, @data); |
32
|
16
|
|
|
|
|
776
|
$marc->append_fields($field); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
83
|
$marc; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _json_to_raw { |
40
|
1
|
|
|
1
|
|
2
|
my ($self,$data) = @_; |
41
|
1
|
|
|
|
|
3
|
my @record = (); |
42
|
|
|
|
|
|
|
|
43
|
1
|
50
|
|
|
|
3
|
push (@record , [ 'LDR', ' ', ' ', '_' , $data->{leader}] ) if defined $data->{leader}; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
for my $field (@{$data->{fields}}) { |
|
1
|
|
|
|
|
3
|
|
46
|
8
|
|
|
|
|
15
|
my ($tag) = keys %$field; |
47
|
8
|
|
|
|
|
11
|
my $val = $field->{$tag}; |
48
|
|
|
|
|
|
|
|
49
|
8
|
100
|
|
|
|
13
|
if (ref $val) { |
50
|
7
|
|
50
|
|
|
13
|
my $ind1 = $val->{ind1} // ' '; |
51
|
7
|
|
50
|
|
|
14
|
my $ind2 = $val->{ind2} // ' '; |
52
|
|
|
|
|
|
|
|
53
|
7
|
|
|
|
|
8
|
my @parts; |
54
|
7
|
|
|
|
|
7
|
for my $subfield (@{$val->{subfields}}) { |
|
7
|
|
|
|
|
12
|
|
55
|
8
|
|
|
|
|
12
|
my ($code) = keys %$subfield; |
56
|
8
|
|
|
|
|
10
|
my $str = $subfield->{$code}; |
57
|
8
|
|
|
|
|
16
|
push @parts , $code, $str; |
58
|
|
|
|
|
|
|
} |
59
|
7
|
|
|
|
|
16
|
push @record , [ $tag, $ind1 , $ind2 , @parts]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
1
|
|
|
|
|
4
|
push @record , [ $tag, ' ' , ' ', '_', $val]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
4
|
{ _id => $data->{_id} , record => \@record }; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _clean_raw_data { |
70
|
246
|
|
|
246
|
|
729
|
my ($self, $tag, @data) = @_; |
71
|
246
|
|
|
|
|
460
|
my @result = (); |
72
|
246
|
|
|
|
|
716
|
for (my $i = 0 ; $i < @data ; $i += 2) { |
73
|
346
|
100
|
66
|
|
|
2996
|
if (($tag =~ /^00/ || defined $data[$i]) && defined $data[$i+1] && $data[$i+1] =~ /\S+/) { |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
74
|
334
|
|
|
|
|
1373
|
push(@result, $data[$i], $data[$i+1]); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
246
|
|
|
|
|
1143
|
@result; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |