line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::MARC::Base; |
2
|
34
|
|
|
34
|
|
1954630
|
use Moo::Role; |
|
34
|
|
|
|
|
13048
|
|
|
34
|
|
|
|
|
231
|
|
3
|
34
|
|
|
34
|
|
21639
|
use MARC::Record; |
|
34
|
|
|
|
|
178485
|
|
|
34
|
|
|
|
|
1563
|
|
4
|
34
|
|
|
34
|
|
294
|
use MARC::Field; |
|
34
|
|
|
|
|
87
|
|
|
34
|
|
|
|
|
14886
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _raw_to_marc_record { |
9
|
2
|
|
|
2
|
|
10
|
my ($self,$data) = @_; |
10
|
2
|
|
|
|
|
16
|
my $marc = MARC::Record->new(); |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
26
|
for my $field (@$data) { |
13
|
8
|
|
|
|
|
106
|
my ($tag, $ind1, $ind2, @data) = @$field; |
14
|
|
|
|
|
|
|
|
15
|
8
|
50
|
|
|
|
31
|
if ($tag eq 'LDR') { |
|
|
100
|
|
|
|
|
|
16
|
0
|
|
|
|
|
0
|
$marc->leader($data[1]); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
elsif ($tag =~ /^00/) { |
19
|
2
|
|
|
|
|
16
|
my $field = MARC::Field->new($tag,$data[1]); |
20
|
2
|
|
|
|
|
99
|
$marc->append_fields($field); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
6
|
|
|
|
|
17
|
my $field = MARC::Field->new($tag, $ind1, $ind2, @data); |
24
|
6
|
|
|
|
|
286
|
$marc->append_fields($field); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
80
|
$marc; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _json_to_raw { |
32
|
1
|
|
|
1
|
|
2
|
my ($self,$data) = @_; |
33
|
1
|
|
|
|
|
2
|
my @record = (); |
34
|
|
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
4
|
push (@record , [ 'LDR', ' ', ' ', '_' , $data->{leader}] ) if defined $data->{leader}; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
2
|
for my $field (@{$data->{fields}}) { |
|
1
|
|
|
|
|
3
|
|
38
|
8
|
|
|
|
|
17
|
my ($tag) = keys %$field; |
39
|
8
|
|
|
|
|
11
|
my $val = $field->{$tag}; |
40
|
|
|
|
|
|
|
|
41
|
8
|
100
|
|
|
|
15
|
if (ref $val) { |
42
|
7
|
|
50
|
|
|
12
|
my $ind1 = $val->{ind1} // ' '; |
43
|
7
|
|
50
|
|
|
14
|
my $ind2 = $val->{ind2} // ' '; |
44
|
|
|
|
|
|
|
|
45
|
7
|
|
|
|
|
8
|
my @parts; |
46
|
7
|
|
|
|
|
8
|
for my $subfield (@{$val->{subfields}}) { |
|
7
|
|
|
|
|
11
|
|
47
|
8
|
|
|
|
|
14
|
my ($code) = keys %$subfield; |
48
|
8
|
|
|
|
|
11
|
my $str = $subfield->{$code}; |
49
|
8
|
|
|
|
|
13
|
push @parts , $code, $str; |
50
|
|
|
|
|
|
|
} |
51
|
7
|
|
|
|
|
16
|
push @record , [ $tag, $ind1 , $ind2 , @parts]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
1
|
|
|
|
|
3
|
push @record , [ $tag, ' ' , ' ', '_', $val]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
4
|
{ _id => $data->{_id} , record => \@record }; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _clean_raw_data { |
62
|
220
|
|
|
220
|
|
530
|
my ($self, $tag, @data) = @_; |
63
|
220
|
|
|
|
|
319
|
my @result = (); |
64
|
220
|
|
|
|
|
460
|
for (my $i = 0 ; $i < @data ; $i += 2) { |
65
|
315
|
100
|
66
|
|
|
2064
|
if (($tag =~ /^00/ || defined $data[$i]) && defined $data[$i+1] && $data[$i+1] =~ /\S+/) { |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
66
|
309
|
|
|
|
|
1044
|
push(@result, $data[$i], $data[$i+1]); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
220
|
|
|
|
|
756
|
@result; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |