line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: sw=4 |
2
|
|
|
|
|
|
|
package MARC::Transform; |
3
|
1
|
|
|
1
|
|
66704
|
use 5.10.0; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
6
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
7
|
1
|
|
|
1
|
|
525
|
use MARC::Record; |
|
1
|
|
|
|
|
6362
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
6
|
use YAML; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
9
|
1
|
|
|
1
|
|
4
|
use Scalar::Util qw< reftype >; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
108
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.003009'; |
11
|
|
|
|
|
|
|
our $DEBUG = 0; |
12
|
0
|
0
|
|
0
|
0
|
0
|
sub debug { $DEBUG and say STDERR @_ } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %fields; |
15
|
|
|
|
|
|
|
my $globalcondition; |
16
|
|
|
|
|
|
|
my $record; |
17
|
|
|
|
|
|
|
our $mth; |
18
|
|
|
|
|
|
|
my $globalsubs; |
19
|
|
|
|
|
|
|
my $verbose=0; |
20
|
|
|
|
|
|
|
my @errors; |
21
|
|
|
|
|
|
|
my $global_LUT; |
22
|
|
|
|
|
|
|
our $this=""; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
29
|
|
|
29
|
1
|
129921
|
my ($self,$recordsource,$yaml,$mthsource,$verb,$yamlencode) = @_; |
26
|
29
|
|
|
|
|
59
|
my @yaml; |
27
|
1
|
|
|
1
|
|
5
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
28
|
1
|
|
|
1
|
|
4
|
no warnings 'newline'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6172
|
|
29
|
|
|
|
|
|
|
my $yamltoload; |
30
|
29
|
50
|
|
|
|
1068
|
if ( -e $yaml ) { |
31
|
0
|
|
|
|
|
0
|
my $yamls; |
32
|
0
|
0
|
|
|
|
0
|
if(defnonull($yamlencode)){ |
33
|
0
|
0
|
|
|
|
0
|
open $yamls, "<:encoding($yamlencode)", $yaml or die "can't open file: $!"; |
34
|
|
|
|
|
|
|
} else { |
35
|
0
|
0
|
|
|
|
0
|
open $yamls, "< $yaml" or die "can't open file: $!"; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
0
|
my $yamlline; |
38
|
0
|
|
|
|
|
0
|
while ($yamlline = <$yamls>){ $yamltoload.=$yamlline; } |
|
0
|
|
|
|
|
0
|
|
39
|
0
|
|
|
|
|
0
|
close $yamls; |
40
|
|
|
|
|
|
|
#@yaml = YAML::LoadFile($yamls); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
29
|
|
|
|
|
73
|
$yamltoload=$yaml; |
44
|
|
|
|
|
|
|
#@yaml = YAML::Load($yaml); |
45
|
|
|
|
|
|
|
} |
46
|
29
|
|
|
|
|
95
|
$yamltoload=~s/#_dollars_#/\\#_dollars_\\#/g; |
47
|
29
|
|
|
|
|
59
|
$yamltoload=~s/#_dbquote_#/\\#_dbquote_\\#/g; |
48
|
29
|
|
|
|
|
168
|
@yaml = YAML::Load($yamltoload); |
49
|
|
|
|
|
|
|
#warn "================". Data::Dumper::Dumper (\@yaml)."------------------"; |
50
|
29
|
|
|
|
|
178179
|
$record=$recordsource; |
51
|
29
|
|
|
|
|
56
|
$mth=$mthsource; |
52
|
29
|
100
|
|
|
|
113
|
$$mth{"_defaultLUT_to_mth_"}={} if $mth; |
53
|
29
|
|
|
|
|
124
|
ReplaceAllInRecord("before"); |
54
|
29
|
50
|
|
|
|
401
|
$verbose = 1 if ($verb); |
55
|
29
|
|
|
|
|
65
|
foreach my $rulesub(@yaml) { |
56
|
79
|
100
|
|
|
|
156
|
if ( ref($rulesub) eq "HASH" ) { |
57
|
67
|
100
|
|
|
|
158
|
if ( defnonull ( $$rulesub{'global_subs'} ) ) { |
58
|
6
|
|
|
|
|
28
|
$globalsubs = $$rulesub{'global_subs'}; |
59
|
6
|
|
|
1
|
0
|
603
|
eval ($globalsubs); |
|
1
|
|
|
1
|
0
|
6
|
|
|
1
|
|
|
1
|
0
|
5
|
|
|
1
|
|
|
1
|
0
|
4
|
|
|
1
|
|
|
1
|
0
|
9
|
|
|
1
|
|
|
0
|
0
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
67
|
100
|
|
|
|
153
|
if ( defnonull ( $$rulesub{'global_LUT'} ) ) { |
62
|
3
|
50
|
|
|
|
11
|
if (ref($$rulesub{'global_LUT'}) eq "HASH") { |
63
|
3
|
|
|
|
|
16
|
$global_LUT=$$rulesub{'global_LUT'}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
29
|
|
|
|
|
52
|
foreach my $rule(@yaml) { |
69
|
|
|
|
|
|
|
#print Data::Dumper::Dumper ($rule); |
70
|
79
|
100
|
|
|
|
242
|
if ( ref($rule) eq "ARRAY" ) { |
|
|
50
|
|
|
|
|
|
71
|
12
|
|
|
|
|
24
|
my $subs=""; |
72
|
12
|
|
|
|
|
26
|
foreach my $rul ( @$rule ) { |
73
|
28
|
100
|
|
|
|
65
|
if ( defnonull ( $$rul{'subs'} ) ) { |
74
|
7
|
|
|
|
|
15
|
$subs.=$$rul{'subs'}; |
75
|
|
|
|
|
|
|
} |
76
|
28
|
100
|
|
|
|
63
|
if ( defnonull ( $$rul{'LUT'} ) ) { |
77
|
3
|
|
|
|
|
10
|
$$global_LUT{"lookuptableforthis"}=$$rul{'LUT'};#warn Data::Dumper::Dumper $global_LUT; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
12
|
|
|
|
|
21
|
foreach my $rul ( @$rule ) { |
81
|
13
|
|
|
|
|
32
|
my ($actionsin, $actionsinter, $actionsout)= parseactions($rul);#warn Data::Dumper::Dumper ($rul); |
82
|
13
|
|
|
|
|
32
|
my $boolcondition = testrule($rul, $actionsin, $actionsinter, $actionsout, $subs); |
83
|
|
|
|
|
|
|
#warn $boolcondition;warn "actionsin : ".$actionsin;warn "actionsout : ".$actionsout; |
84
|
13
|
100
|
|
|
|
34
|
if ($boolcondition) { |
85
|
12
|
|
|
|
|
38
|
last; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
elsif ( ref($rule) eq "HASH" ) { |
90
|
67
|
|
|
|
|
91
|
my $subs=""; |
91
|
67
|
50
|
|
|
|
171
|
if ( defnonull ( $$rule{'subs'} ) ) { |
92
|
0
|
|
|
|
|
0
|
$subs.=$$rule{'subs'}; |
93
|
|
|
|
|
|
|
} |
94
|
67
|
100
|
|
|
|
147
|
if ( defnonull ( $$rule{'LUT'} ) ) { |
95
|
1
|
|
|
|
|
4
|
$$global_LUT{"lookuptableforthis"}=$$rule{'LUT'}; |
96
|
|
|
|
|
|
|
} |
97
|
67
|
|
|
|
|
172
|
my ($actionsin, $actionsinter, $actionsout)= parseactions($rule); |
98
|
67
|
|
|
|
|
130
|
my $boolcondition = testrule($rule, $actionsin, $actionsinter, $actionsout, $subs); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a scalar rule.'); #error |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
29
|
|
|
|
|
63
|
foreach my $error (@errors) { |
105
|
0
|
|
|
|
|
0
|
print "\n$error"; |
106
|
|
|
|
|
|
|
} |
107
|
29
|
|
|
|
|
71
|
ReplaceAllInRecord("after"); |
108
|
29
|
|
|
|
|
499
|
$record; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
1046
|
100
|
66
|
1046
|
0
|
1208
|
sub defnonull { my $var = shift; if (defined $var and $var ne "") { return 1; } else { return 0; } } |
|
1046
|
|
|
|
|
1706
|
|
|
165
|
|
|
|
|
306
|
|
|
881
|
|
|
|
|
1363
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub LUT { |
114
|
11
|
|
|
11
|
1
|
29
|
my ( $inLUT, $type ) = @_; |
115
|
11
|
100
|
|
|
|
27
|
if (!defined($type)) { |
116
|
5
|
|
|
|
|
8
|
$type = "lookuptableforthis"; |
117
|
|
|
|
|
|
|
} |
118
|
11
|
|
|
|
|
16
|
my $outLUT=$inLUT; |
119
|
11
|
|
|
|
|
11
|
my $boolnocor = 1; |
120
|
11
|
50
|
|
|
|
32
|
if ( ref($global_LUT) eq "HASH") { |
121
|
11
|
50
|
|
|
|
23
|
if (exists($$global_LUT{$type})) { |
122
|
11
|
|
|
|
|
16
|
my $correspondance=$$global_LUT{$type}; |
123
|
11
|
50
|
|
|
|
19
|
if ( ref($correspondance) eq "HASH") { |
124
|
11
|
|
|
|
|
32
|
foreach my $cor (keys(%$correspondance)) { |
125
|
30
|
100
|
|
|
|
51
|
if ($inLUT eq $cor) { |
126
|
9
|
|
|
|
|
15
|
$outLUT=$$correspondance{$cor}; |
127
|
9
|
|
|
|
|
11
|
$boolnocor = 0; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
11
|
100
|
|
|
|
23
|
if ($boolnocor) { |
131
|
2
|
100
|
|
|
|
7
|
$outLUT=$$correspondance{"_default_value_"} if (defnonull($$correspondance{"_default_value_"})); |
132
|
2
|
50
|
|
|
|
6
|
push (@{$$mth{"_defaultLUT_to_mth_"}->{"$type"}} , $inLUT) if $mth; |
|
2
|
|
|
|
|
7
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
11
|
|
|
|
|
75
|
return $outLUT; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub update { |
141
|
24
|
|
|
24
|
1
|
51
|
my ($field,$subfields)=@_; |
142
|
24
|
|
|
|
|
52
|
transform ("update",$field,$subfields); |
143
|
24
|
|
|
|
|
295
|
return 1; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
sub forceupdate { |
146
|
29
|
|
|
29
|
1
|
58
|
my ($field,$subfields)=@_; |
147
|
29
|
|
|
|
|
82
|
transform ("forceupdate",$field,$subfields); |
148
|
29
|
|
|
|
|
318
|
return 1; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
sub updatefirst { |
151
|
5
|
|
|
5
|
1
|
11
|
my ($field,$subfields)=@_; |
152
|
5
|
|
|
|
|
12
|
transform ("updatefirst",$field,$subfields); |
153
|
5
|
|
|
|
|
55
|
return 1; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
sub forceupdatefirst { |
156
|
5
|
|
|
5
|
1
|
11
|
my ($field,$subfields)=@_; |
157
|
5
|
|
|
|
|
12
|
transform ("forceupdatefirst",$field,$subfields); |
158
|
5
|
|
|
|
|
58
|
return 1; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
sub create { |
161
|
24
|
|
|
24
|
1
|
54
|
my ($field,$subfields)=@_; |
162
|
24
|
|
|
|
|
67
|
transform ("create",$field,$subfields); |
163
|
24
|
|
|
|
|
286
|
return 1; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub transform { |
167
|
87
|
|
|
87
|
0
|
143
|
my ($ttype,$field,$subfields)=@_; |
168
|
|
|
|
|
|
|
#print "\n------------$ttype------------ : \n".Data::Dumper::Dumper (@_); |
169
|
87
|
100
|
100
|
|
|
314
|
if ($ttype eq "forceupdate" or $ttype eq "forceupdatefirst" ) { |
170
|
34
|
100
|
66
|
|
|
78
|
if (ref($field) eq "" or ref($field) eq "SCALAR") { |
171
|
28
|
100
|
|
|
|
58
|
if (!defined $record->field($field) ) {$ttype="create"} |
|
10
|
|
|
|
|
571
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
87
|
100
|
33
|
|
|
1081
|
if (ref($field) eq "MARC::Field") { |
|
|
50
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#print "\n------------$ttype------------ : \n".Data::Dumper::Dumper ($subfields); |
176
|
27
|
|
|
|
|
85
|
foreach my $tag(keys(%$subfields)) { |
177
|
27
|
50
|
33
|
|
|
130
|
if ( $tag eq 'i1' or $tag eq 'µ') { |
|
|
50
|
33
|
|
|
|
|
178
|
|
|
|
|
|
|
#print "\n------------$ttype------------ : \n"; |
179
|
0
|
|
|
|
|
0
|
$this=$field->indicator(1); |
180
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
181
|
0
|
0
|
0
|
|
|
0
|
$field->update( ind1 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
elsif ( $tag eq 'i2' or $tag eq '£') { |
184
|
0
|
|
|
|
|
0
|
$this=$field->indicator(2); |
185
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
186
|
0
|
0
|
0
|
|
|
0
|
$field->update( ind2 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
else { |
189
|
27
|
50
|
33
|
|
|
84
|
if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) { |
|
|
0
|
|
|
|
|
|
190
|
27
|
50
|
|
|
|
64
|
if($field->is_control_field()) { |
191
|
0
|
|
|
|
|
0
|
$this=$field->data(); |
192
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
193
|
0
|
|
|
|
|
0
|
$field->update($finalvalue); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
27
|
100
|
|
|
|
170
|
if ($ttype eq "create") { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
197
|
6
|
|
|
|
|
11
|
$this=""; |
198
|
6
|
|
|
|
|
13
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
199
|
6
|
|
|
|
|
21
|
$field->add_subfields( $tag => $finalvalue ); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
elsif ($ttype eq "updatefirst") { |
202
|
1
|
50
|
|
|
|
3
|
if ( defined $field->subfield( $tag ) ) { |
203
|
1
|
|
|
|
|
27
|
$this=$field->subfield( $tag ); |
204
|
1
|
|
|
|
|
24
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
205
|
1
|
|
|
|
|
4
|
$field->update( $tag => $finalvalue ); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
#warn $tag.$$subfields{$tag}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
elsif ($ttype eq "forceupdatefirst") { |
210
|
3
|
50
|
|
|
|
6
|
if ( defined $field->subfield( $tag ) ) { |
211
|
3
|
|
|
|
|
79
|
$this=$field->subfield( $tag ); |
212
|
3
|
|
|
|
|
70
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
213
|
3
|
|
|
|
|
11
|
$field->update( $tag => $finalvalue ); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
else { |
216
|
0
|
|
|
|
|
0
|
$this=""; |
217
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
218
|
0
|
|
|
|
|
0
|
$field->add_subfields( $tag => $finalvalue ); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
elsif( ref($$subfields{$tag}) eq "ARRAY" ) { |
224
|
0
|
0
|
|
|
|
0
|
if(!$field->is_control_field()) { |
225
|
0
|
|
|
|
|
0
|
foreach my $subfield(@{$$subfields{$tag}}) { |
|
0
|
|
|
|
|
0
|
|
226
|
0
|
0
|
|
|
|
0
|
if ($ttype eq "create") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
227
|
0
|
|
|
|
|
0
|
$this=""; |
228
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($subfield); |
229
|
0
|
|
|
|
|
0
|
$field->add_subfields( $tag => $finalvalue ); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
elsif ($ttype eq "updatefirst") { |
232
|
0
|
0
|
|
|
|
0
|
if ( defined $field->subfield( $tag ) ) { |
233
|
0
|
|
|
|
|
0
|
$this=$field->subfield( $tag ); |
234
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($subfield); |
235
|
0
|
|
|
|
|
0
|
$field->update( $tag => $finalvalue ); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
elsif ($ttype eq "forceupdatefirst") { |
239
|
0
|
0
|
|
|
|
0
|
if ( defined $field->subfield( $tag ) ) { |
240
|
0
|
|
|
|
|
0
|
$this=$field->subfield( $tag ); |
241
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($subfield); |
242
|
0
|
|
|
|
|
0
|
$field->update( $tag => $finalvalue ); |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
else { |
245
|
0
|
|
|
|
|
0
|
$this=""; |
246
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($subfield); |
247
|
0
|
|
|
|
|
0
|
$field->add_subfields( $tag => $finalvalue ); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
else { |
253
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use an array to '.$ttype.' in existing condition\'s controlfield value.'); #error |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
} |
258
|
27
|
100
|
100
|
|
|
250
|
if((!$field->is_control_field()) and ($ttype eq "update" or $ttype eq "forceupdate" )) { |
|
|
|
66
|
|
|
|
|
259
|
17
|
|
|
|
|
103
|
my @usubfields; |
260
|
17
|
|
|
|
|
34
|
foreach my $subfield ( $field->subfields() ) { |
261
|
58
|
100
|
|
|
|
468
|
if ( exists($$subfields{$$subfield[0]}) ) { |
262
|
|
|
|
|
|
|
#implementation de l'eval des fonctions et de $this |
263
|
15
|
|
|
|
|
33
|
$this=$$subfield[1]; |
264
|
15
|
|
|
|
|
39
|
my $finalvalue=parsestringactions($$subfields{$$subfield[0]}); |
265
|
15
|
|
|
|
|
44
|
push @usubfields, ( $$subfield[0],$finalvalue ); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
else { |
268
|
43
|
|
|
|
|
73
|
push @usubfields, ( $$subfield[0], $$subfield[1] ); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
17
|
|
|
|
|
59
|
my $newfield = MARC::Field->new( $field->tag(), $field->indicator(1), $field->indicator(2), @usubfields ); |
272
|
17
|
|
|
|
|
1075
|
foreach my $tag(keys(%$subfields)) { |
273
|
17
|
100
|
33
|
|
|
141
|
if($tag ne 'i1' and $tag ne 'µ' and $tag ne 'i2' and $tag ne '£' and !defined($newfield->subfield( $tag )) ) { |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
274
|
2
|
50
|
33
|
|
|
51
|
if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) { |
275
|
2
|
|
|
|
|
6
|
$this=""; |
276
|
2
|
|
|
|
|
6
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
277
|
2
|
50
|
|
|
|
10
|
$newfield->add_subfields( $tag => $finalvalue ) if $ttype eq "forceupdate"; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
else { |
280
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a non-scalar value to '.$ttype.' in existing condition\'s field value.'); #error |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
} |
284
|
17
|
|
|
|
|
399
|
$field->replace_with($newfield); |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
elsif (ref($field) eq "" or ref($field) eq "SCALAR") { |
288
|
|
|
|
|
|
|
#print "\n------------$ttype------------ : \n".Data::Dumper::Dumper (@_); |
289
|
60
|
100
|
100
|
|
|
286
|
if ($ttype eq "update" or $ttype eq "updatefirst" or $ttype eq "forceupdate" or $ttype eq "forceupdatefirst") { |
|
|
50
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
290
|
32
|
50
|
|
|
|
57
|
if ( defined $record->field($field) ) { |
291
|
32
|
|
|
|
|
1593
|
for my $updatefield ( $record->field($field) ) { |
292
|
42
|
|
|
|
|
1926
|
foreach my $tag(keys(%$subfields)) { |
293
|
46
|
50
|
33
|
|
|
304
|
if ( $tag eq 'i1' or $tag eq 'µ') { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
294
|
0
|
|
|
|
|
0
|
$this=$updatefield->indicator(1); |
295
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
296
|
0
|
0
|
0
|
|
|
0
|
$updatefield->update( ind1 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ); |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
elsif ( $tag eq 'i2' or $tag eq '£') { |
299
|
0
|
|
|
|
|
0
|
$this=$updatefield->indicator(2); |
300
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
301
|
0
|
0
|
0
|
|
|
0
|
$updatefield->update( ind2 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ); |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
elsif( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) { |
304
|
46
|
100
|
|
|
|
94
|
if($updatefield->is_control_field()) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
305
|
2
|
|
|
|
|
11
|
$this=$updatefield->data(); |
306
|
2
|
|
|
|
|
18
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
307
|
2
|
|
|
|
|
5
|
$updatefield->update($finalvalue); |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
elsif ( $ttype eq "updatefirst" ) { |
310
|
7
|
100
|
|
|
|
34
|
if ( defined $updatefield->subfield( $tag ) ) { |
311
|
6
|
|
|
|
|
133
|
$this=$updatefield->subfield( $tag ); |
312
|
6
|
|
|
|
|
122
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
313
|
6
|
|
|
|
|
17
|
$updatefield->update( $tag => $finalvalue ); |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
elsif ($ttype eq "forceupdatefirst") { |
317
|
3
|
100
|
|
|
|
16
|
if ( defined $updatefield->subfield( $tag ) ) { |
318
|
2
|
|
|
|
|
47
|
$this=$updatefield->subfield( $tag ); |
319
|
2
|
|
|
|
|
43
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
320
|
2
|
|
|
|
|
6
|
$updatefield->update( $tag => $finalvalue ); |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
else { |
323
|
1
|
|
|
|
|
17
|
$this=""; |
324
|
1
|
|
|
|
|
2
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
325
|
1
|
|
|
|
|
5
|
$updatefield->add_subfields( $tag => $finalvalue ); |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
else { |
330
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a non-scalar value to '.$ttype.' field.');#error |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
} |
333
|
42
|
100
|
100
|
|
|
409
|
if((!$updatefield->is_control_field()) and ($ttype eq "update" or $ttype eq "forceupdate" )) { |
|
|
|
100
|
|
|
|
|
334
|
31
|
|
|
|
|
169
|
my @usubfields; |
335
|
31
|
|
|
|
|
49
|
foreach my $subfield ( $updatefield->subfields() ) { |
336
|
121
|
100
|
|
|
|
732
|
if ( exists($$subfields{$$subfield[0]}) ) { |
337
|
26
|
|
|
|
|
33
|
$this=$$subfield[1]; |
338
|
26
|
|
|
|
|
49
|
my $finalvalue=parsestringactions($$subfields{$$subfield[0]}); |
339
|
26
|
|
|
|
|
67
|
push @usubfields, ( $$subfield[0],$finalvalue ); |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
else { |
342
|
95
|
|
|
|
|
139
|
push @usubfields, ( $$subfield[0], $$subfield[1] ); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
31
|
|
|
|
|
84
|
my $newfield = MARC::Field->new( $updatefield->tag(), $updatefield->indicator(1), $updatefield->indicator(2), @usubfields ); |
346
|
31
|
|
|
|
|
1870
|
foreach my $tag(keys(%$subfields)) { |
347
|
34
|
100
|
33
|
|
|
289
|
if($tag ne 'i1' and $tag ne 'µ' and $tag ne 'i2' and $tag ne '£' and !defined($newfield->subfield( $tag )) ) { |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
348
|
13
|
50
|
33
|
|
|
371
|
if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) { |
349
|
13
|
|
|
|
|
18
|
$this=""; |
350
|
13
|
|
|
|
|
25
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
351
|
13
|
100
|
|
|
|
50
|
$newfield->add_subfields( $tag => $finalvalue ) if $ttype eq "forceupdate"; |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
else { |
354
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a non-scalar value to '.$ttype.' field.');#error |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
} |
358
|
31
|
|
|
|
|
549
|
$updatefield->replace_with($newfield); |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
elsif ($ttype eq "create") { |
364
|
28
|
|
|
|
|
31
|
my $newfield; |
365
|
28
|
|
|
|
|
39
|
$this=""; |
366
|
28
|
100
|
|
|
|
64
|
if ($field < "010" ) { |
367
|
2
|
|
|
|
|
12
|
$newfield = MARC::Field->new( $field, 'temp'); |
368
|
|
|
|
|
|
|
} |
369
|
|
|
|
|
|
|
else { |
370
|
26
|
|
|
|
|
67
|
$newfield = MARC::Field->new( $field, '', '', '0'=>'temp'); |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
28
|
|
|
|
|
1355
|
foreach my $tag(keys(%$subfields)) { |
374
|
35
|
50
|
33
|
|
|
262
|
if ( $tag eq 'i1' or $tag eq 'µ') { |
|
|
50
|
33
|
|
|
|
|
375
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
376
|
0
|
0
|
0
|
|
|
0
|
$newfield->update( ind1 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
elsif ( $tag eq 'i2' or $tag eq '£') { |
379
|
0
|
|
|
|
|
0
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
380
|
0
|
0
|
0
|
|
|
0
|
$newfield->update( ind2 => $finalvalue ) if ( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ); |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
else { |
383
|
35
|
100
|
66
|
|
|
97
|
if( ref($$subfields{$tag}) eq "" or ref($$subfields{$tag}) eq "SCALAR" ) { |
|
|
50
|
|
|
|
|
|
384
|
31
|
100
|
|
|
|
55
|
if($newfield->is_control_field()) { |
385
|
2
|
|
|
|
|
9
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
386
|
2
|
|
|
|
|
6
|
$newfield->update($finalvalue); |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
else { |
389
|
29
|
|
|
|
|
128
|
my $finalvalue=parsestringactions($$subfields{$tag}); |
390
|
29
|
|
|
|
|
80
|
$newfield->add_subfields( $tag => $finalvalue ); |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
elsif( ref($$subfields{$tag}) eq "ARRAY" ) { |
394
|
4
|
50
|
|
|
|
8
|
if(!$newfield->is_control_field()) { |
395
|
4
|
|
|
|
|
14
|
foreach my $subfield(@{$$subfields{$tag}}) { |
|
4
|
|
|
|
|
9
|
|
396
|
10
|
|
|
|
|
69
|
my $finalvalue=parsestringactions($subfield); |
397
|
10
|
|
|
|
|
22
|
$newfield->add_subfields( $tag => $finalvalue ); |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
} |
403
|
28
|
100
|
|
|
|
346
|
if (!$newfield->is_control_field()) { |
404
|
26
|
|
|
|
|
131
|
$newfield->delete_subfield(pos => '0'); |
405
|
|
|
|
|
|
|
} |
406
|
28
|
|
|
|
|
1740
|
$record->insert_fields_ordered($newfield); |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
else { |
410
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use an array or hash value to '.$ttype.' field.');#error |
411
|
|
|
|
|
|
|
} |
412
|
87
|
|
|
|
|
2727
|
return 1; |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
sub parsestringactions { |
416
|
118
|
|
|
118
|
0
|
128
|
my $subfieldtemp=shift; |
417
|
118
|
|
|
|
|
172
|
$subfieldtemp=~s/tempnameforcurrentvalueofthissubfield/\$this/g; |
418
|
118
|
|
|
|
|
150
|
$subfieldtemp=~s/temporarycallfunction/\\&/g; |
419
|
118
|
|
|
|
|
103
|
my $finalvalue; |
420
|
118
|
100
|
|
|
|
200
|
if ($subfieldtemp=~/\\&/) { |
421
|
24
|
|
|
|
|
47
|
$subfieldtemp=~s/\\&/&/g; |
422
|
24
|
|
|
|
|
1090
|
$finalvalue = eval ($subfieldtemp); |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
else { |
425
|
94
|
|
|
|
|
3412
|
$finalvalue = eval '"'.$subfieldtemp.'"'; |
426
|
|
|
|
|
|
|
} |
427
|
118
|
|
|
|
|
406
|
return $finalvalue; |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
sub parseactions { |
431
|
80
|
|
|
80
|
0
|
86
|
my $rul = shift; |
432
|
80
|
|
|
|
|
110
|
my $actionsintemp=""; |
433
|
80
|
|
|
|
|
88
|
my $actionsin=""; |
434
|
80
|
|
|
|
|
94
|
my $actionsinter=""; |
435
|
80
|
|
|
|
|
77
|
my $actionsouttemp=""; |
436
|
80
|
|
|
|
|
96
|
my $actionsout=""; |
437
|
|
|
|
|
|
|
#print "\n".Data::Dumper::Dumper $rul; |
438
|
|
|
|
|
|
|
#create duplicatefield forceupdate forceupdatefirst update updatefirst execute delete |
439
|
80
|
100
|
|
|
|
149
|
if ( defnonull ( $$rul{'create'} ) ) { |
440
|
20
|
|
|
|
|
33
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'create'},'create'); |
441
|
20
|
|
|
|
|
29
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
20
|
|
|
|
|
31
|
|
442
|
|
|
|
|
|
|
} |
443
|
80
|
100
|
|
|
|
163
|
if ( defnonull ( $$rul{'duplicatefield'} ) ) { |
444
|
6
|
|
|
|
|
13
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'duplicatefield'},'duplicatefield'); |
445
|
6
|
|
|
|
|
14
|
$actionsinter.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
6
|
|
|
|
|
14
|
|
446
|
|
|
|
|
|
|
} |
447
|
80
|
100
|
|
|
|
159
|
if ( defnonull ( $$rul{'forceupdate'} ) ) { |
448
|
22
|
|
|
|
|
34
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'forceupdate'},'forceupdate'); |
449
|
22
|
|
|
|
|
33
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
22
|
|
|
|
|
25
|
|
450
|
|
|
|
|
|
|
} |
451
|
80
|
100
|
|
|
|
172
|
if ( defnonull ( $$rul{'forceupdatefirst'} ) ) { |
452
|
3
|
|
|
|
|
9
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'forceupdatefirst'},'forceupdatefirst'); |
453
|
3
|
|
|
|
|
6
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
3
|
|
|
|
|
5
|
|
454
|
|
|
|
|
|
|
} |
455
|
80
|
100
|
|
|
|
156
|
if ( defnonull ( $$rul{'update'} ) ) { |
456
|
11
|
|
|
|
|
33
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'update'},'update'); |
457
|
11
|
|
|
|
|
29
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
11
|
|
|
|
|
15
|
|
458
|
|
|
|
|
|
|
} |
459
|
80
|
100
|
|
|
|
155
|
if ( defnonull ( $$rul{'updatefirst'} ) ) { |
460
|
3
|
|
|
|
|
9
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'updatefirst'},'updatefirst'); |
461
|
3
|
|
|
|
|
5
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
3
|
|
|
|
|
6
|
|
462
|
|
|
|
|
|
|
} |
463
|
80
|
100
|
|
|
|
170
|
if ( defnonull ( $$rul{'execute'} ) ) { |
464
|
7
|
|
|
|
|
13
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'execute'},'execute'); |
465
|
7
|
|
|
|
|
9
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
7
|
|
|
|
|
11
|
|
466
|
|
|
|
|
|
|
} |
467
|
80
|
100
|
|
|
|
161
|
if ( defnonull ( $$rul{'delete'} ) ) { |
468
|
12
|
|
|
|
|
25
|
($actionsintemp,$actionsouttemp)=parsesubaction ($$rul{'delete'},'delete'); |
469
|
12
|
|
|
|
|
21
|
$actionsin.=$actionsintemp; $actionsout.=$actionsouttemp; |
|
12
|
|
|
|
|
18
|
|
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
#print "\n----------------------actionsin---------------------- : \n$actionsin\n\n----------------------actionsout---------------------- : \n$actionsout\n----------------------actionsend----------------------"; |
472
|
80
|
|
|
|
|
229
|
return ($actionsin, $actionsinter, $actionsout) |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
sub parsesubaction { |
476
|
84
|
|
|
84
|
0
|
136
|
my ($intaction,$type)=@_; |
477
|
84
|
|
|
|
|
91
|
my $actionsin=""; |
478
|
84
|
|
|
|
|
85
|
my $actionsout=""; |
479
|
84
|
|
|
|
|
75
|
my $boolin=0; |
480
|
84
|
|
|
|
|
89
|
my $specaction=""; |
481
|
84
|
|
|
|
|
96
|
my $currentaction="";#warn ref($intaction); |
482
|
84
|
|
|
|
|
104
|
$specaction=" $type"; |
483
|
|
|
|
|
|
|
#print "\n".Data::Dumper::Dumper $intaction; |
484
|
84
|
100
|
100
|
|
|
517
|
if ($type eq "create" or $type eq "forceupdate" or $type eq "update" or $type eq "forceupdatefirst" or $type eq "updatefirst") { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
485
|
59
|
50
|
|
|
|
126
|
if ( ref($intaction) eq "HASH" ) { |
486
|
59
|
|
|
|
|
147
|
foreach my $kint (keys(%$intaction)) { |
487
|
89
|
100
|
66
|
|
|
244
|
if( ref($$intaction{$kint}) eq "HASH" ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
488
|
11
|
|
|
|
|
17
|
my $ftag; |
489
|
11
|
|
|
|
|
19
|
$currentaction=""; |
490
|
11
|
|
|
|
|
16
|
$boolin=0; |
491
|
11
|
50
|
|
|
|
52
|
if($kint=~/^\$f(\d{3})$/) { |
|
|
50
|
|
|
|
|
|
492
|
0
|
|
|
|
|
0
|
$boolin=1; |
493
|
0
|
|
|
|
|
0
|
$ftag=$kint; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
elsif($kint=~/^f(\d{3})$/) { |
496
|
11
|
|
|
|
|
27
|
$ftag='"'.$1.'"'; |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
else { |
499
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
500
|
0
|
|
|
|
|
0
|
next; |
501
|
|
|
|
|
|
|
} |
502
|
11
|
|
|
|
|
27
|
$currentaction.=$specaction.'('.$ftag.',{'; |
503
|
11
|
|
|
|
|
17
|
my $subint=$$intaction{$kint}; |
504
|
11
|
|
|
|
|
28
|
foreach my $k (keys(%$subint)) { |
505
|
22
|
100
|
66
|
|
|
76
|
if( ref($$subint{$k}) eq "" or ref($$subint{$k}) eq "SCALAR" ) { |
|
|
50
|
|
|
|
|
|
506
|
19
|
|
|
|
|
41
|
$$subint{$k}=~s/"/\\"/g; |
507
|
19
|
100
|
|
|
|
47
|
$boolin=1 if($$subint{$k}=~/\$f/);#print $k." eq. ".$$subint{$k}."\n"; |
508
|
19
|
|
|
|
|
35
|
$$subint{$k}=~s/\$this/tempnameforcurrentvalueofthissubfield/g; |
509
|
19
|
|
|
|
|
33
|
$$subint{$k}=~s/\\&/temporarycallfunction/g; |
510
|
19
|
|
|
|
|
50
|
$currentaction.='"'.$k.'"=> "'.$$subint{$k}.'",'; |
511
|
|
|
|
|
|
|
} |
512
|
|
|
|
|
|
|
elsif( ref($$subint{$k}) eq "ARRAY" ) { |
513
|
3
|
|
|
|
|
8
|
$currentaction.='"'.$k.'"=>['; |
514
|
3
|
|
|
|
|
5
|
foreach my $ssubint(@{$$subint{$k}}) { |
|
3
|
|
|
|
|
8
|
|
515
|
8
|
|
|
|
|
11
|
$ssubint=~s/"/\\"/g; |
516
|
8
|
50
|
|
|
|
15
|
$boolin=1 if($ssubint=~/\$f/); |
517
|
8
|
|
|
|
|
9
|
$ssubint=~s/\$this/tempnameforcurrentvalueofthissubfield/g; |
518
|
8
|
|
|
|
|
10
|
$ssubint=~s/\\&/temporarycallfunction/g; |
519
|
8
|
|
|
|
|
14
|
$currentaction.='"'.$ssubint.'",'; |
520
|
|
|
|
|
|
|
} |
521
|
3
|
|
|
|
|
6
|
$currentaction.='],'; |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
else { |
524
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a hash inside another hash in '.$type.' action.');#error |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
} |
527
|
11
|
|
|
|
|
22
|
$currentaction.='});'."\n"; |
528
|
11
|
100
|
|
|
|
25
|
if ($boolin) { $actionsin.=$currentaction; } else { $actionsout.=$currentaction; } |
|
6
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
12
|
|
529
|
|
|
|
|
|
|
} |
530
|
|
|
|
|
|
|
elsif( ref($$intaction{$kint}) eq "" or ref($$intaction{$kint}) eq "SCALAR" ) { |
531
|
77
|
|
|
|
|
74
|
$currentaction=""; |
532
|
77
|
|
|
|
|
70
|
$boolin=0; |
533
|
77
|
|
|
|
|
91
|
my $ftag; |
534
|
|
|
|
|
|
|
my $stag; |
535
|
77
|
100
|
|
|
|
353
|
if($kint=~/^\$f(\d{3})(\w)$/) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
536
|
8
|
|
|
|
|
11
|
$boolin=1; |
537
|
8
|
|
|
|
|
14
|
$ftag='$f'.$1; |
538
|
8
|
|
|
|
|
13
|
$stag=$2; |
539
|
|
|
|
|
|
|
} |
540
|
|
|
|
|
|
|
elsif($kint=~/^\$i(\d{3})(\w)$/) { |
541
|
0
|
|
|
|
|
0
|
$boolin=1; |
542
|
0
|
|
|
|
|
0
|
$ftag='$f'.$1; |
543
|
0
|
|
|
|
|
0
|
$stag='µ'; |
544
|
0
|
0
|
|
|
|
0
|
$stag='µ' if($2 eq "1"); |
545
|
0
|
0
|
|
|
|
0
|
$stag='£' if($2 eq "2"); |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
elsif($kint=~/^f(\d{3})(\w)$/) { |
548
|
50
|
|
|
|
|
117
|
$ftag='"'.$1.'"'; |
549
|
50
|
|
|
|
|
74
|
$stag=$2; |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
elsif($kint=~/^i(\d{3})(\w)$/) { |
552
|
0
|
|
|
|
|
0
|
$ftag='"'.$1.'"'; |
553
|
0
|
|
|
|
|
0
|
$stag='µ'; |
554
|
0
|
0
|
|
|
|
0
|
$stag='µ' if($2 eq "1"); |
555
|
0
|
0
|
|
|
|
0
|
$stag='£' if($2 eq "2"); |
556
|
|
|
|
|
|
|
} |
557
|
|
|
|
|
|
|
elsif($kint=~/^i(\d)$/) { |
558
|
0
|
|
|
|
|
0
|
$ftag='$$currentfield'; |
559
|
0
|
|
|
|
|
0
|
$stag='µ'; |
560
|
0
|
0
|
|
|
|
0
|
$stag='µ' if($1 eq "1"); |
561
|
0
|
0
|
|
|
|
0
|
$stag='£' if($1 eq "2"); |
562
|
0
|
|
|
|
|
0
|
$boolin=1; |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
elsif($kint=~/^(\w)$/) { |
565
|
19
|
|
|
|
|
31
|
$ftag='$$currentfield'; |
566
|
19
|
|
|
|
|
20
|
$boolin=1; |
567
|
19
|
|
|
|
|
26
|
$stag=$kint; |
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
else { |
570
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
571
|
0
|
|
|
|
|
0
|
next; |
572
|
|
|
|
|
|
|
} |
573
|
77
|
|
|
|
|
146
|
$$intaction{$kint}=~s/"/\\"/g; |
574
|
77
|
100
|
|
|
|
171
|
$boolin=1 if($$intaction{$kint}=~/\$f/); |
575
|
77
|
|
|
|
|
117
|
$$intaction{$kint}=~s/\$this/tempnameforcurrentvalueofthissubfield/g; |
576
|
77
|
|
|
|
|
124
|
$$intaction{$kint}=~s/\\&/temporarycallfunction/g; |
577
|
77
|
|
|
|
|
170
|
$currentaction.=$specaction.'('.$ftag.',{"'.$stag.'"=>"'.$$intaction{$kint}.'"});'."\n"; |
578
|
77
|
100
|
|
|
|
112
|
if ($boolin) { $actionsin.=$currentaction; } else { $actionsout.=$currentaction; } |
|
31
|
|
|
|
|
68
|
|
|
46
|
|
|
|
|
97
|
|
579
|
|
|
|
|
|
|
} |
580
|
|
|
|
|
|
|
elsif( ref($$intaction{$kint}) eq "ARRAY" ) { |
581
|
1
|
|
|
|
|
2
|
$currentaction=""; |
582
|
1
|
|
|
|
|
2
|
$boolin=0; |
583
|
1
|
|
|
|
|
3
|
my $ftag; |
584
|
|
|
|
|
|
|
my $stag; |
585
|
1
|
50
|
|
|
|
8
|
if($kint=~/^\$f(\d{3})(\w)$/) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
586
|
0
|
|
|
|
|
0
|
$boolin=1; |
587
|
0
|
|
|
|
|
0
|
$ftag='$f'.$1; |
588
|
0
|
|
|
|
|
0
|
$stag=$2; |
589
|
|
|
|
|
|
|
} |
590
|
|
|
|
|
|
|
elsif($kint=~/^\$i(\d{3})(\w)$/) { |
591
|
0
|
|
|
|
|
0
|
$boolin=1; |
592
|
0
|
|
|
|
|
0
|
$ftag='$f'.$1; |
593
|
0
|
|
|
|
|
0
|
$stag='µ'; |
594
|
0
|
0
|
|
|
|
0
|
$stag='µ' if($2 eq "1"); |
595
|
0
|
0
|
|
|
|
0
|
$stag='£' if($2 eq "2"); |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
elsif($kint=~/^f(\d{3})(\w)$/) { |
598
|
1
|
|
|
|
|
3
|
$ftag='"'.$1.'"'; |
599
|
1
|
|
|
|
|
2
|
$stag=$2; |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
elsif($kint=~/^i(\d{3})(\w)$/) { |
602
|
0
|
|
|
|
|
0
|
$ftag='"'.$1.'"'; |
603
|
0
|
|
|
|
|
0
|
$stag='µ'; |
604
|
0
|
0
|
|
|
|
0
|
$stag='µ' if($2 eq "1"); |
605
|
0
|
0
|
|
|
|
0
|
$stag='£' if($2 eq "2"); |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
elsif($kint=~/^(\w)$/) { |
608
|
0
|
|
|
|
|
0
|
$ftag='$$currentfield'; |
609
|
0
|
|
|
|
|
0
|
$boolin=1; |
610
|
0
|
|
|
|
|
0
|
$stag=$kint; |
611
|
|
|
|
|
|
|
} |
612
|
|
|
|
|
|
|
else { |
613
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
614
|
0
|
|
|
|
|
0
|
next; |
615
|
|
|
|
|
|
|
} |
616
|
1
|
|
|
|
|
3
|
$currentaction.=$specaction.'('.$ftag.',{"'.$stag.'"=>['; |
617
|
1
|
|
|
|
|
2
|
foreach my $sintaction(@{$$intaction{$kint}}) { |
|
1
|
|
|
|
|
4
|
|
618
|
2
|
|
|
|
|
4
|
$sintaction=~s/"/\\"/g; |
619
|
2
|
50
|
|
|
|
5
|
$boolin=1 if($sintaction=~/\$f/); |
620
|
2
|
|
|
|
|
4
|
$sintaction=~s/\$this/tempnameforcurrentvalueofthissubfield/g; |
621
|
2
|
|
|
|
|
3
|
$sintaction=~s/\\&/temporarycallfunction/g; |
622
|
2
|
|
|
|
|
3
|
$currentaction.='"'.$sintaction.'",'; |
623
|
|
|
|
|
|
|
} |
624
|
1
|
|
|
|
|
2
|
$currentaction.=']});'."\n"; |
625
|
1
|
50
|
|
|
|
6
|
if ($boolin) { $actionsin.=$currentaction; } else { $actionsout.=$currentaction; } |
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
3
|
|
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
} |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
else { |
630
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use non hash context in '.$type.' action.');#error |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
elsif ($type eq "duplicatefield") { |
634
|
6
|
100
|
33
|
|
|
25
|
if ( ref($intaction) eq "ARRAY" ) { |
|
|
50
|
|
|
|
|
|
635
|
3
|
|
|
|
|
8
|
foreach my $vint (@$intaction) { |
636
|
7
|
50
|
33
|
|
|
19
|
if( ref($vint) eq "" or ref($vint) eq "SCALAR" ) { |
637
|
7
|
100
|
|
|
|
32
|
if($vint=~/^\$f(\d{3})\s?>\s?f(\d{3})$/) { |
|
|
50
|
|
|
|
|
|
638
|
3
|
100
|
66
|
|
|
23
|
if ($1 < "010" and $2 < "010" ) { |
|
|
50
|
33
|
|
|
|
|
639
|
2
|
|
|
|
|
10
|
$actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->data() ) );'; |
640
|
|
|
|
|
|
|
} |
641
|
|
|
|
|
|
|
elsif ($1 >= "010" and $2 >= "010" ) { |
642
|
1
|
|
|
|
|
4
|
$actionsin.='my @dsubfields; foreach my $subfield ( $f'.$1.'->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n"; |
643
|
1
|
|
|
|
|
6
|
$actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->indicator(1), $f'.$1.'->indicator(2), @dsubfields ) );'; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
else { |
646
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
} |
649
|
|
|
|
|
|
|
elsif($vint=~/^f(\d{3})\s?>\s?f(\d{3})$/) { |
650
|
4
|
100
|
66
|
|
|
26
|
if ($1 < "010" and $2 < "010" ) { |
|
|
50
|
33
|
|
|
|
|
651
|
1
|
|
|
|
|
4
|
$actionsout.=' for my $fielddup($record->field("'.$1.'")){'; |
652
|
1
|
|
|
|
|
16
|
$actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->data() ) );'; |
653
|
1
|
|
|
|
|
3
|
$actionsout.='}'."\n"; |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
elsif ($1 >= "010" and $2 >= "010" ) { |
656
|
3
|
|
|
|
|
9
|
$actionsout.=' for my $fielddup($record->field("'.$1.'")){'; |
657
|
3
|
|
|
|
|
6
|
$actionsout.='my @dsubfields; foreach my $subfield ( $fielddup->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n"; |
658
|
3
|
|
|
|
|
8
|
$actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->indicator(1), $fielddup->indicator(2), @dsubfields ) );'; |
659
|
3
|
|
|
|
|
5
|
$actionsout.='}'."\n"; |
660
|
|
|
|
|
|
|
} |
661
|
|
|
|
|
|
|
else { |
662
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error |
663
|
|
|
|
|
|
|
} |
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
else { |
666
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
else { |
670
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use non scalar value in '.$type.' action.');#error |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
elsif ( ref($intaction) eq "" or ref($intaction) eq "SCALAR" ) { |
675
|
3
|
|
|
|
|
5
|
my $vint=$intaction; |
676
|
3
|
50
|
|
|
|
15
|
if($vint=~/^\$f(\d{3})\s?>\s?f(\d{3})$/) { |
|
|
0
|
|
|
|
|
|
677
|
3
|
100
|
66
|
|
|
28
|
if ($1 < "010" and $2 < "010" ) { |
|
|
50
|
33
|
|
|
|
|
678
|
1
|
|
|
|
|
6
|
$actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->data() ) );'; |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
elsif ($1 >= "010" and $2 >= "010" ) { |
681
|
2
|
|
|
|
|
9
|
$actionsin.='my @dsubfields; foreach my $subfield ( $f'.$1.'->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n"; |
682
|
2
|
|
|
|
|
8
|
$actionsin.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $f'.$1.'->indicator(1), $f'.$1.'->indicator(2), @dsubfields ) );'; |
683
|
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
else { |
685
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error |
686
|
|
|
|
|
|
|
} |
687
|
|
|
|
|
|
|
} |
688
|
|
|
|
|
|
|
elsif($vint=~/^f(\d{3})\s?>\s?f(\d{3})$/) { |
689
|
0
|
0
|
0
|
|
|
0
|
if ($1 < "010" and $2 < "010" ) { |
|
|
0
|
0
|
|
|
|
|
690
|
0
|
|
|
|
|
0
|
$actionsout.=' for my $fielddup($record->field("'.$1.'")){'; |
691
|
0
|
|
|
|
|
0
|
$actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->data() ) );'; |
692
|
0
|
|
|
|
|
0
|
$actionsout.='}'."\n"; |
693
|
|
|
|
|
|
|
} |
694
|
|
|
|
|
|
|
elsif ($1 >= "010" and $2 >= "010" ) { |
695
|
0
|
|
|
|
|
0
|
$actionsout.=' for my $fielddup($record->field("'.$1.'")){'; |
696
|
0
|
|
|
|
|
0
|
$actionsout.='my @dsubfields; foreach my $subfield ( $fielddup->subfields() ) { push @dsubfields, ( $$subfield[0], $$subfield[1] );}'."\n"; |
697
|
0
|
|
|
|
|
0
|
$actionsout.='$record->insert_fields_ordered( MARC::Field->new( "'.$2.'", $fielddup->indicator(1), $fielddup->indicator(2), @dsubfields ) );'; |
698
|
0
|
|
|
|
|
0
|
$actionsout.='}'."\n"; |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
else { |
701
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you want to duplicate a controlfield with a non-controlfield ');#error |
702
|
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
else { |
705
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
706
|
|
|
|
|
|
|
} |
707
|
|
|
|
|
|
|
} |
708
|
|
|
|
|
|
|
else { |
709
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a hash value in '.$type.' action.');#error |
710
|
|
|
|
|
|
|
} |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
elsif ($type eq "delete") { |
713
|
12
|
100
|
33
|
|
|
45
|
if ( ref($intaction) eq "ARRAY" ) { |
|
|
50
|
|
|
|
|
|
714
|
3
|
|
|
|
|
8
|
foreach my $vint (@$intaction) { |
715
|
6
|
50
|
33
|
|
|
20
|
if( ref($vint) eq "" or ref($vint) eq "SCALAR" ) { |
716
|
|
|
|
|
|
|
#print "$vint\n"; |
717
|
6
|
50
|
|
|
|
35
|
if($vint=~/^\$f(\d{3})(\w)$/) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
718
|
0
|
|
|
|
|
0
|
$actionsin.=' if ( defined $f'.$1.'->subfield("'.$2.'") ) { if (scalar($f'.$1.'->subfields())==1) { $record->delete_field($f'.$1.'); } else { $f'.$1.'->delete_subfield(code => "'.$2.'"); } }'."\n"; |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
elsif($vint=~/^\$f(\d{3})$/) { |
721
|
0
|
|
|
|
|
0
|
$actionsin.=' $record->delete_field('.$vint.');'."\n"; |
722
|
|
|
|
|
|
|
} |
723
|
|
|
|
|
|
|
elsif($vint=~/^f(\d{3})(\w)$/) { |
724
|
3
|
|
|
|
|
20
|
$actionsout.=' for my $fieldel($record->field("'.$1.'")){if ( defined $fieldel->subfield("'.$2.'") ) { if (scalar($fieldel->subfields())==1) { $record->delete_field($fieldel); } else { $fieldel->delete_subfield(code => "'.$2.'"); } }}'."\n"; |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
elsif($vint=~/^f(\d{3})$/) { |
727
|
3
|
|
|
|
|
10
|
$actionsout.=' $record->delete_fields($record->field("'.$1.'"));'."\n"; |
728
|
|
|
|
|
|
|
} |
729
|
|
|
|
|
|
|
elsif($vint=~/^(\w)$/) { |
730
|
0
|
|
|
|
|
0
|
$actionsin.=' if ( defined $$currentfield->subfield("'.$vint.'") ) { if (scalar($$currentfield->subfields())==1) { $record->delete_field($$currentfield); } else { $$currentfield->delete_subfield(code => "'.$vint.'"); } }'."\n"; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
else { |
733
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
else { |
737
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use non scalar value in '.$type.' action.');#error |
738
|
|
|
|
|
|
|
} |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
elsif ( ref($intaction) eq "" or ref($intaction) eq "SCALAR" ) { |
742
|
9
|
|
|
|
|
23
|
my $vint=$intaction; |
743
|
9
|
100
|
|
|
|
70
|
if($vint=~/^\$f(\d{3})(\w)$/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
744
|
1
|
|
|
|
|
9
|
$actionsin.=' if ( defined $f'.$1.'->subfield("'.$2.'") ) { if (scalar($f'.$1.'->subfields())==1) { $record->delete_field($f'.$1.'); } else { $f'.$1.'->delete_subfield(code => "'.$2.'"); } }'."\n"; |
745
|
|
|
|
|
|
|
} |
746
|
|
|
|
|
|
|
elsif($vint=~/^\$f(\d{3})$/) { |
747
|
1
|
|
|
|
|
6
|
$actionsin.=' $record->delete_field('.$vint.');'."\n"; |
748
|
|
|
|
|
|
|
} |
749
|
|
|
|
|
|
|
elsif($vint=~/^f(\d{3})(\w)$/) { |
750
|
2
|
|
|
|
|
14
|
$actionsout.=' for my $fieldel($record->field("'.$1.'")){if ( defined $fieldel->subfield("'.$2.'") ) { if (scalar($fieldel->subfields())==1) { $record->delete_field($fieldel); } else { $fieldel->delete_subfield(code => "'.$2.'"); } }}'."\n"; |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
elsif($vint=~/^f(\d{3})$/) { |
753
|
3
|
|
|
|
|
12
|
$actionsout.=' $record->delete_fields($record->field("'.$1.'"));'."\n"; |
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
elsif($vint=~/^(\w)$/) { |
756
|
2
|
|
|
|
|
10
|
$actionsin.=' if ( defined $$currentfield->subfield("'.$vint.'") ) { if (scalar($$currentfield->subfields())==1) { $record->delete_field($$currentfield); } else { $$currentfield->delete_subfield(code => "'.$vint.'"); } }'."\n"; |
757
|
|
|
|
|
|
|
} |
758
|
|
|
|
|
|
|
else { |
759
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : your field reference is not valid in '.$type.' action.');#error |
760
|
|
|
|
|
|
|
} |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
else { |
763
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a hash value in '.$type.' action.');#error |
764
|
|
|
|
|
|
|
} |
765
|
|
|
|
|
|
|
} |
766
|
|
|
|
|
|
|
elsif ($type eq "execute") { |
767
|
7
|
50
|
33
|
|
|
26
|
if( ref($intaction) eq "" or ref($intaction) eq "SCALAR" ) { |
|
|
0
|
|
|
|
|
|
768
|
7
|
50
|
|
|
|
20
|
if($intaction=~/\$(f|i)(\d{3})/) { |
769
|
0
|
|
|
|
|
0
|
$actionsin.=' eval ('.$intaction.');'; |
770
|
|
|
|
|
|
|
} |
771
|
|
|
|
|
|
|
else { |
772
|
7
|
|
|
|
|
19
|
$actionsout.=' eval ('.$intaction.');'; |
773
|
|
|
|
|
|
|
} |
774
|
|
|
|
|
|
|
} |
775
|
|
|
|
|
|
|
elsif( ref($intaction) eq "ARRAY" ) { |
776
|
0
|
|
|
|
|
0
|
foreach my $sintaction(@$intaction) { |
777
|
0
|
0
|
|
|
|
0
|
if($sintaction=~/\$(f|i)(\d{3})/) { |
778
|
0
|
|
|
|
|
0
|
$actionsin.=' eval ('.$sintaction.');'; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
else { |
781
|
0
|
|
|
|
|
0
|
$actionsout.=' eval ('.$sintaction.');'; |
782
|
|
|
|
|
|
|
} |
783
|
|
|
|
|
|
|
} |
784
|
|
|
|
|
|
|
} |
785
|
|
|
|
|
|
|
else { |
786
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : you try to use a hash value in '.$type.' action.');#error |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
else { |
790
|
0
|
|
|
|
|
0
|
push(@errors, 'Invalid yaml : this action : '.$type.' is not valid.');#error |
791
|
|
|
|
|
|
|
} |
792
|
84
|
|
|
|
|
211
|
return ($actionsin,$actionsout); |
793
|
|
|
|
|
|
|
} |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
sub testrule { |
796
|
80
|
|
|
80
|
0
|
151
|
my ($rul, $actionsin, $actionsinter, $actionsout, $subs) = @_; |
797
|
80
|
|
|
|
|
101
|
$globalcondition=""; |
798
|
80
|
100
|
|
|
|
139
|
$subs="no warnings 'redefine';".$subs if $subs ne ""; |
799
|
80
|
|
|
|
|
155
|
my $globalconditionstart='{ '."\n".$subs."\n".'my $boolcond=0;my $boolcondint=0;my $currentfield;no warnings \'substr\';no warnings \'uninitialized\';no warnings \'portable\';'."\n"; |
800
|
80
|
|
|
|
|
75
|
my $globalconditionint=""; |
801
|
80
|
|
|
|
|
96
|
my $globalconditionend="";#print Data::Dumper::Dumper ($rul); |
802
|
80
|
100
|
|
|
|
134
|
if ( defnonull ( $$rul{'condition'} ) ) { |
803
|
60
|
|
|
|
|
207
|
my @listconditiontags=grep( $_ , map({ $_=~/^(f|i)(\d{3})(.*)$/;$2 } (split(/\$/,$$rul{'condition'}))));#print $$rul{'condition'}; |
|
154
|
|
|
|
|
330
|
|
|
154
|
|
|
|
|
352
|
|
804
|
60
|
100
|
|
|
|
169
|
my @listconditionsubtags=grep( $_ , map({ if($_=~/^(f)(\d{3}\w)(.*)$/){$2}elsif($_=~/^(i)(\d{3})(.*)$/){$2} } (split(/\$/,$$rul{'condition'})))); |
|
154
|
50
|
|
|
|
377
|
|
|
68
|
|
|
|
|
180
|
|
|
0
|
|
|
|
|
0
|
|
805
|
60
|
|
|
|
|
109
|
my %tag_names = map( { $_ => 1 } @listconditiontags); |
|
79
|
|
|
|
|
181
|
|
806
|
60
|
|
|
|
|
170
|
my %tag_list; |
807
|
60
|
|
|
|
|
131
|
@listconditiontags = keys(%tag_names); |
808
|
60
|
|
|
|
|
95
|
foreach my $tag(@listconditiontags) { |
809
|
68
|
|
|
|
|
121
|
$tag_list{$tag}=[]; |
810
|
68
|
|
|
|
|
87
|
foreach my $subtag(@listconditionsubtags) { |
811
|
88
|
100
|
|
|
|
168
|
if (substr($subtag,0,3) eq $tag) { |
812
|
68
|
50
|
|
|
|
115
|
if(length($subtag) == 3) { |
813
|
0
|
|
|
|
|
0
|
push (@{$tag_list{$tag}}, "tempvalueforcurrentfield"); |
|
0
|
|
|
|
|
0
|
|
814
|
|
|
|
|
|
|
} |
815
|
|
|
|
|
|
|
else { |
816
|
68
|
|
|
|
|
70
|
push (@{$tag_list{$tag}}, substr($subtag,3,1)); |
|
68
|
|
|
|
|
188
|
|
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
} |
819
|
|
|
|
|
|
|
} |
820
|
|
|
|
|
|
|
} |
821
|
60
|
|
|
|
|
96
|
my $condition=$$rul{'condition'}; |
822
|
60
|
|
|
|
|
122
|
$condition=~s/(\$ldr(\d{1,2}))/\(substr\(\$record->leader\(\),$2,1)\)/g; |
823
|
60
|
|
|
|
|
112
|
$condition=~s/(\$ldr)/(\$record->leader\(\)\)/g; |
824
|
60
|
|
|
|
|
455
|
$condition=~s/(\$f\d{3})(\w)/defined($1$2) and $1$2/g; |
825
|
60
|
|
|
|
|
223
|
$condition=~s/(\$f\d{3})(\w)(\d{1,2})/\(substr($1$2,$3,1\)\)/g; |
826
|
60
|
|
|
|
|
322
|
$condition=~s/(\$f\d{3})(\w)/$1$2/g;#I can't remember why I did this |
827
|
60
|
|
|
|
|
100
|
$condition=~s/(\$i(\d{3}))(\d)/\(\$f$2->indicator\($3\)\)/g; |
828
|
60
|
|
|
|
|
66
|
my $booltagrule=0; |
829
|
60
|
|
|
|
|
77
|
my $boolsubtagrule=0; |
830
|
60
|
|
|
|
|
167
|
foreach my $tag (sort {$a cmp $b} keys(%tag_list)) { |
|
14
|
|
|
|
|
31
|
|
831
|
68
|
|
|
|
|
79
|
my %tag_listtag = map { $_, 1 } @{$tag_list{$tag}}; |
|
68
|
|
|
|
|
154
|
|
|
68
|
|
|
|
|
113
|
|
832
|
68
|
|
|
|
|
94
|
$boolsubtagrule=0; |
833
|
68
|
|
|
|
|
109
|
my @tag_listtagunique = keys %tag_listtag; |
834
|
68
|
|
|
|
|
113
|
$globalconditionstart.='my $f'.$tag.';'; |
835
|
68
|
|
|
|
|
105
|
foreach my $subtag (@tag_listtagunique) { |
836
|
63
|
|
|
|
|
90
|
my $matchdelaration='my \$f'.$tag.$subtag.';'; |
837
|
63
|
50
|
|
|
|
690
|
$globalconditionstart.='my $f'.$tag.$subtag.';' if $globalconditionstart!~$matchdelaration; |
838
|
|
|
|
|
|
|
} |
839
|
68
|
100
|
|
|
|
188
|
if ( defined $record->field($tag) ) { |
840
|
66
|
|
|
|
|
2713
|
$booltagrule=1; |
841
|
66
|
|
|
|
|
183
|
$globalconditionint.="\n".'for $f'.$tag.' ( $record->field("'.$tag.'") ) {'."\n".'$currentfield=\$f'.$tag.';'."\n"; |
842
|
66
|
|
|
|
|
99
|
foreach my $subtag (@tag_listtagunique) { |
843
|
62
|
|
|
|
|
68
|
$boolsubtagrule=1; |
844
|
62
|
100
|
66
|
|
|
250
|
if ($subtag ne "tempvalueforcurrentfield" and $tag >= "010") { |
|
|
50
|
|
|
|
|
|
845
|
58
|
|
|
|
|
151
|
$globalconditionint.='for $f'.$tag.$subtag.' ( $f'.$tag.'->subfield("'.$subtag.'"), my $tmpintesta=1 ) { my $tmpintestb=0; if ($tmpintesta==1) { $tmpintesta=undef;$tmpintestb=1; }'."\n"; |
846
|
58
|
|
|
|
|
125
|
$globalconditionint.='if ('.$condition.') {$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0 unless (!defined($tmpintesta) and $tmpintestb==0 );}'."\n"; |
847
|
58
|
|
|
|
|
79
|
$globalconditionend.='}'."\n"; |
848
|
|
|
|
|
|
|
} |
849
|
|
|
|
|
|
|
elsif ($subtag ne "tempvalueforcurrentfield") { |
850
|
4
|
|
|
|
|
14
|
$globalconditionint.='$f'.$tag.$subtag.' = $f'.$tag.'->data(); '."\n"; |
851
|
4
|
|
|
|
|
11
|
$globalconditionint.='if ('.$condition.') {$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}'."\n"; |
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
} |
854
|
66
|
100
|
|
|
|
131
|
$globalconditionint.='if ('.$condition.')'."\n".'{$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}' unless $boolsubtagrule; |
855
|
66
|
|
|
|
|
167
|
$globalconditionend.='if ($boolcondint){ eval{'.$actionsinter.'};}}'."\n"; |
856
|
|
|
|
|
|
|
}#else { $globalconditionint.='if ('.$condition.') {$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}'."\n"; } |
857
|
|
|
|
|
|
|
} |
858
|
60
|
100
|
|
|
|
218
|
$globalconditionint.='if ('.$condition.')'."\n".'{$boolcond=1;$boolcondint=1; eval{'.$actionsin.'}}else{$boolcondint=0;}' unless $booltagrule; |
859
|
60
|
|
|
|
|
114
|
$globalconditionend.="\n".' if ($boolcond){eval{'.$actionsout.'}}'."\n".' return $boolcond;}';#if ($boolcond or ('.$condition.')) |
860
|
60
|
|
|
|
|
173
|
$globalcondition=$globalconditionstart.$globalconditionint.$globalconditionend; |
861
|
60
|
50
|
|
|
|
91
|
print "\n--------globalcondition----------\n$globalcondition\n---------globalcondition---------\n" if $verbose; |
862
|
1
|
50
|
|
1
|
0
|
11
|
return eval($globalcondition); |
|
1
|
50
|
|
1
|
0
|
2
|
|
|
1
|
50
|
|
1
|
0
|
60
|
|
|
1
|
50
|
|
1
|
0
|
5
|
|
|
1
|
|
|
1
|
0
|
1
|
|
|
1
|
|
|
1
|
0
|
57
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
184
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
38
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
23
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
203
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
29
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|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7
|
|
|
2
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
863
|
|
|
|
|
|
|
} |
864
|
|
|
|
|
|
|
else { |
865
|
20
|
50
|
|
|
|
39
|
print "\n--------actionsout----------\n$globalconditionstart$actionsout}\n---------actionsout---------\n" if $verbose; |
866
|
1
|
|
|
1
|
0
|
6
|
eval($globalconditionstart.$actionsout.'}'); |
|
1
|
|
|
1
|
0
|
1
|
|
|
1
|
|
|
1
|
|
36
|
|
|
1
|
|
|
1
|
|
7
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
41
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
90
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
27
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
9
|
|
|
1
|
|
|
1
|
|
26
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
21
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
27
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
44
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
86
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
27
|
|
|
1
|
|
|
1
|
|
4
|
|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
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
|
20
|
|
|
|
|
1236
|
|
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
48
|
|
867
|
20
|
|
|
|
|
681
|
return 1; |
868
|
|
|
|
|
|
|
} |
869
|
0
|
|
|
|
|
0
|
return 1; |
870
|
|
|
|
|
|
|
} |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
sub ReplaceAllInRecord { |
873
|
58
|
|
|
58
|
0
|
140
|
my ($pos) = @_; |
874
|
58
|
100
|
66
|
|
|
282
|
return unless ( $record && $record->fields() ); |
875
|
56
|
|
|
|
|
439
|
foreach my $field ( $record->fields() ) { |
876
|
207
|
|
|
|
|
1712
|
my @subfields; |
877
|
207
|
100
|
|
|
|
315
|
if(!$field->is_control_field()) { |
878
|
178
|
100
|
|
|
|
720
|
if (scalar($field->subfields()) > 0) { |
879
|
177
|
|
|
|
|
2927
|
foreach my $subfield ( $field->subfields() ) { |
880
|
361
|
|
|
|
|
2546
|
my $newval=$$subfield[1]; |
881
|
361
|
100
|
|
|
|
516
|
if ($pos eq "before") { |
|
|
50
|
|
|
|
|
|
882
|
|
|
|
|
|
|
#$newval=~s/\$/#_dollarsd_#/g;#to force warn |
883
|
153
|
|
|
|
|
183
|
$newval=~s/\$/#_dollars_#/g; |
884
|
153
|
|
|
|
|
158
|
$newval=~s/"/#_dbquote_#/g; |
885
|
|
|
|
|
|
|
} |
886
|
|
|
|
|
|
|
elsif ($pos eq "after") { |
887
|
208
|
|
|
|
|
213
|
$newval=~s/#_dollars_#/\$/g; |
888
|
208
|
|
|
|
|
197
|
$newval=~s/#_dbquote_#/"/g; |
889
|
|
|
|
|
|
|
} |
890
|
361
|
|
|
|
|
500
|
push @subfields, ( $$subfield[0], $newval ); |
891
|
|
|
|
|
|
|
} |
892
|
177
|
|
|
|
|
365
|
my $newfield = MARC::Field->new( $field->tag(), $field->indicator(1), $field->indicator(2), @subfields ); |
893
|
177
|
|
|
|
|
10148
|
$field->replace_with($newfield); |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
} |
896
|
|
|
|
|
|
|
else { |
897
|
29
|
|
|
|
|
124
|
my $newval=$field->data(); |
898
|
29
|
100
|
|
|
|
234
|
if ($pos eq "before") { |
|
|
50
|
|
|
|
|
|
899
|
12
|
|
|
|
|
20
|
$newval=~s/\$/#_dollars_#/g; |
900
|
12
|
|
|
|
|
13
|
$newval=~s/"/#_dbquote_#/g; |
901
|
|
|
|
|
|
|
} |
902
|
|
|
|
|
|
|
elsif ($pos eq "after") { |
903
|
17
|
|
|
|
|
24
|
$newval=~s/#_dollars_#/\$/g; |
904
|
17
|
|
|
|
|
21
|
$newval=~s/#_dbquote_#/"/g; |
905
|
|
|
|
|
|
|
} |
906
|
29
|
|
|
|
|
63
|
$field->update($newval); |
907
|
|
|
|
|
|
|
} |
908
|
|
|
|
|
|
|
} |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
1; |
912
|
|
|
|
|
|
|
__END__ |