line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::marc_add; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
50694
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
20
|
|
4
|
3
|
|
|
3
|
|
957
|
use Catmandu::MARC; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
61
|
|
5
|
3
|
|
|
3
|
|
14
|
use Moo; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
6
|
3
|
|
|
3
|
|
1316
|
use Catmandu::Fix::Has; |
|
3
|
|
|
|
|
749
|
|
|
3
|
|
|
|
|
22
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has subfields => (fix_arg => 'collect'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub fix { |
16
|
7
|
|
|
7
|
0
|
55189
|
my ($self, $data) = @_; |
17
|
7
|
|
|
|
|
30
|
my $marc_path = $self->marc_path; |
18
|
7
|
|
|
|
|
13
|
my @subfields = @{$self->subfields}; |
|
7
|
|
|
|
|
37
|
|
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
46
|
return Catmandu::MARC->instance->marc_add($data,$marc_path,@subfields); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Catmandu::Fix::marc_add - add new fields to marc |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Set literal values |
30
|
|
|
|
|
|
|
marc_add('900', a, 'test' , 'b', test) |
31
|
|
|
|
|
|
|
marc_add('900', ind1 , ' ' , a, 'test' , 'b', test) |
32
|
|
|
|
|
|
|
marc_add('900', ind1 , ' ' , a, 'test' , 'b', test) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Set control fields |
35
|
|
|
|
|
|
|
marc_add('009','_','23123131') |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Copy data from an other field (when the field value is an array, the |
38
|
|
|
|
|
|
|
# subfield will be repeated) |
39
|
|
|
|
|
|
|
marc_add('900', a, '$.my.data.field') |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Add a new subfield to MARC record. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 marc_add(MARC_FIELD, SUBFIELD, VALUE, [ SUBFIELD, VALUE , ... ]) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Add new subfields to a MARC record. The MARC_FIELD should contain a marc field |
50
|
|
|
|
|
|
|
name, all other arguments contain the subfields to be added. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
By default literal values will be added. To point to an existing value in |
53
|
|
|
|
|
|
|
a record use the JSON_PATH syntax with a dollar '$.' added in front. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 INLINE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This Fix can be used inline in a Perl script: |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use Catmandu::Fix::marc_add as => 'marc_add'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $data = { record => [...] }; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$data = marc_add($data,'245','a','title'); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SEE ALSO |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_set>, |
68
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_copy>, |
69
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_cut>, |
70
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_paste> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |