line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::MARC::Base; |
2
|
34
|
|
|
34
|
|
1493902
|
use Moo::Role; |
|
34
|
|
|
|
|
12173
|
|
|
34
|
|
|
|
|
219
|
|
3
|
34
|
|
|
34
|
|
19671
|
use MARC::Record; |
|
34
|
|
|
|
|
161680
|
|
|
34
|
|
|
|
|
1470
|
|
4
|
34
|
|
|
34
|
|
292
|
use MARC::Field; |
|
34
|
|
|
|
|
70
|
|
|
34
|
|
|
|
|
15499
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.21'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _raw_to_marc_record { |
9
|
4
|
|
|
4
|
|
9
|
my ($self,$data) = @_; |
10
|
4
|
|
|
|
|
21
|
my $marc = MARC::Record->new(); |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
|
|
42
|
for my $field (@$data) { |
13
|
24
|
|
|
|
|
2832
|
my ($tag, $ind1, $ind2, @data) = @$field; |
14
|
|
|
|
|
|
|
|
15
|
24
|
|
100
|
|
|
82
|
$ind1 //= ' '; |
16
|
24
|
|
100
|
|
|
44
|
$ind2 //= ' '; |
17
|
|
|
|
|
|
|
|
18
|
24
|
|
|
|
|
48
|
@data = $self->_clean_raw_data($tag,@data); |
19
|
|
|
|
|
|
|
|
20
|
24
|
100
|
|
|
|
69
|
if (@data < 2) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
21
|
3
|
|
|
|
|
54
|
$self->log->warn("$tag doesn't have any data"); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
elsif ($tag eq 'LDR') { |
24
|
1
|
|
|
|
|
4
|
$marc->leader($data[1]); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($tag =~ /^00/) { |
27
|
5
|
|
|
|
|
23
|
my $field = MARC::Field->new($tag,$data[1]); |
28
|
5
|
|
|
|
|
162
|
$marc->append_fields($field); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
15
|
|
|
|
|
44
|
my $field = MARC::Field->new($tag, $ind1, $ind2, @data); |
32
|
15
|
|
|
|
|
670
|
$marc->append_fields($field); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
74
|
$marc; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _json_to_raw { |
40
|
1
|
|
|
1
|
|
3
|
my ($self,$data) = @_; |
41
|
1
|
|
|
|
|
2
|
my @record = (); |
42
|
|
|
|
|
|
|
|
43
|
1
|
50
|
|
|
|
5
|
push (@record , [ 'LDR', ' ', ' ', '_' , $data->{leader}] ) if defined $data->{leader}; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
for my $field (@{$data->{fields}}) { |
|
1
|
|
|
|
|
3
|
|
46
|
5
|
|
|
|
|
11
|
my ($tag) = keys %$field; |
47
|
5
|
|
|
|
|
7
|
my $val = $field->{$tag}; |
48
|
|
|
|
|
|
|
|
49
|
5
|
100
|
|
|
|
10
|
if (ref $val) { |
50
|
4
|
|
50
|
|
|
6
|
my $ind1 = $val->{ind1} // ' '; |
51
|
4
|
|
50
|
|
|
10
|
my $ind2 = $val->{ind2} // ' '; |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
6
|
my @parts; |
54
|
4
|
|
|
|
|
4
|
for my $subfield (@{$val->{subfields}}) { |
|
4
|
|
|
|
|
6
|
|
55
|
5
|
|
|
|
|
11
|
my ($code) = keys %$subfield; |
56
|
5
|
|
|
|
|
7
|
my $str = $subfield->{$code}; |
57
|
5
|
|
|
|
|
7
|
push @parts , $code, $str; |
58
|
|
|
|
|
|
|
} |
59
|
4
|
|
|
|
|
10
|
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
|
243
|
|
|
243
|
|
555
|
my ($self, $tag, @data) = @_; |
71
|
243
|
|
|
|
|
343
|
my @result = (); |
72
|
243
|
|
|
|
|
565
|
for (my $i = 0 ; $i < @data ; $i += 2) { |
73
|
343
|
100
|
66
|
|
|
2308
|
if (($tag =~ /^00/ || defined $data[$i]) && defined $data[$i+1] && $data[$i+1] =~ /\S+/) { |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
74
|
340
|
|
|
|
|
990
|
push(@result, $data[$i], $data[$i+1]); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
243
|
|
|
|
|
810
|
@result; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |