line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::MARC::Decoder; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
50833
|
use Catmandu::Sane; |
|
29
|
|
|
|
|
136304
|
|
|
29
|
|
|
|
|
241
|
|
4
|
29
|
|
|
29
|
|
5548
|
use Moo; |
|
29
|
|
|
|
|
73
|
|
|
29
|
|
|
|
|
185
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.20'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub fake_marc_file { |
9
|
2
|
|
|
2
|
0
|
183
|
my ($self,$fh,$class) = @_; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
14
|
my $obj = { |
12
|
|
|
|
|
|
|
filename => scalar($fh), |
13
|
|
|
|
|
|
|
fh => $fh, |
14
|
|
|
|
|
|
|
recnum => 0, |
15
|
|
|
|
|
|
|
warnings => [], |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
11
|
return( bless $obj , $class ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub decode { |
22
|
44
|
|
|
44
|
0
|
40762
|
my ($self, $record, $id) = @_; |
23
|
44
|
100
|
|
|
|
71
|
return unless eval { $record->isa('MARC::Record') }; |
|
44
|
|
|
|
|
196
|
|
24
|
40
|
|
|
|
|
76
|
my @result = (); |
25
|
|
|
|
|
|
|
|
26
|
40
|
|
|
|
|
97
|
push @result , [ 'LDR' , undef, undef, '_' , $record->leader ]; |
27
|
|
|
|
|
|
|
|
28
|
40
|
|
|
|
|
319
|
for my $field ($record->fields()) { |
29
|
846
|
|
|
|
|
1625
|
my $tag = $field->tag; |
30
|
846
|
|
|
|
|
3100
|
my $ind1 = $field->indicator(1); |
31
|
846
|
|
|
|
|
7652
|
my $ind2 = $field->indicator(2); |
32
|
|
|
|
|
|
|
|
33
|
846
|
|
|
|
|
7131
|
my @sf = (); |
34
|
|
|
|
|
|
|
|
35
|
846
|
100
|
|
|
|
1247
|
if ($field->is_control_field) { |
36
|
166
|
|
|
|
|
677
|
push @sf , '_', $field->data; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
846
|
|
|
|
|
3806
|
for my $subfield ($field->subfields) { |
40
|
1161
|
|
|
|
|
9666
|
push @sf , @$subfield; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
846
|
|
|
|
|
3794
|
push @result, [$tag,$ind1,$ind2,@sf]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
40
|
|
|
|
|
77
|
my $sysid = undef; |
47
|
|
|
|
|
|
|
|
48
|
40
|
100
|
66
|
|
|
225
|
if ($id =~ /^00/ && $record->field($id)) { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
49
|
39
|
|
|
|
|
1024
|
$sysid = $record->field($id)->data(); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ($id =~ /^([0-9]{3})([[0-9a-zA-Z])$/) { |
52
|
0
|
|
|
|
|
0
|
my $field = $record->field($1); |
53
|
0
|
0
|
|
|
|
0
|
$sysid = $field->subfield($2) if ($field); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif (defined $id && $record->field($id)) { |
56
|
0
|
|
|
|
|
0
|
$sysid = $record->field($id)->subfield("a"); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
40
|
|
|
|
|
1252
|
return { _id => $sysid , record => \@result }; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |