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