line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::MARC::Decoder; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
62274
|
use Catmandu::Sane; |
|
29
|
|
|
|
|
141390
|
|
|
29
|
|
|
|
|
244
|
|
4
|
29
|
|
|
29
|
|
5667
|
use Moo; |
|
29
|
|
|
|
|
65
|
|
|
29
|
|
|
|
|
190
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub fake_marc_file { |
9
|
2
|
|
|
2
|
0
|
157
|
my ($self,$fh,$class) = @_; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
13
|
my $obj = { |
12
|
|
|
|
|
|
|
filename => scalar($fh), |
13
|
|
|
|
|
|
|
fh => $fh, |
14
|
|
|
|
|
|
|
recnum => 0, |
15
|
|
|
|
|
|
|
warnings => [], |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
9
|
return( bless $obj , $class ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub decode { |
22
|
44
|
|
|
44
|
0
|
60027
|
my ($self, $record, $id) = @_; |
23
|
44
|
100
|
|
|
|
113
|
return unless eval { $record->isa('MARC::Record') }; |
|
44
|
|
|
|
|
323
|
|
24
|
40
|
|
|
|
|
124
|
my @result = (); |
25
|
|
|
|
|
|
|
|
26
|
40
|
|
|
|
|
186
|
push @result , [ 'LDR' , undef, undef, '_' , $record->leader ]; |
27
|
|
|
|
|
|
|
|
28
|
40
|
|
|
|
|
517
|
for my $field ($record->fields()) { |
29
|
846
|
|
|
|
|
2476
|
my $tag = $field->tag; |
30
|
846
|
|
|
|
|
4695
|
my $ind1 = $field->indicator(1); |
31
|
846
|
|
|
|
|
11078
|
my $ind2 = $field->indicator(2); |
32
|
|
|
|
|
|
|
|
33
|
846
|
|
|
|
|
10607
|
my @sf = (); |
34
|
|
|
|
|
|
|
|
35
|
846
|
100
|
|
|
|
1831
|
if ($field->is_control_field) { |
36
|
166
|
|
|
|
|
1039
|
push @sf , '_', $field->data; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
846
|
|
|
|
|
5785
|
for my $subfield ($field->subfields) { |
40
|
1161
|
|
|
|
|
14526
|
push @sf , @$subfield; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
846
|
|
|
|
|
5870
|
push @result, [$tag,$ind1,$ind2,@sf]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
40
|
|
|
|
|
137
|
my $sysid = undef; |
47
|
|
|
|
|
|
|
|
48
|
40
|
100
|
66
|
|
|
372
|
if ($id =~ /^00/ && $record->field($id)) { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
49
|
39
|
|
|
|
|
1717
|
$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
|
|
|
|
|
2298
|
return { _id => $sysid , record => \@result }; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |