|
Lines 134-140
sub merge_records {
Link Here
|
| 134 |
my $rules = $self->context_rules($context); |
134 |
my $rules = $self->context_rules($context); |
| 135 |
|
135 |
|
| 136 |
# Default when no rules found is to overwrite with incoming record |
136 |
# Default when no rules found is to overwrite with incoming record |
| 137 |
return $incoming_record unless $rules; |
137 |
return (0, $incoming_record) unless $rules; |
| 138 |
|
138 |
|
| 139 |
my $fields_by_tag = sub { |
139 |
my $fields_by_tag = sub { |
| 140 |
my ($record) = @_; |
140 |
my ($record) = @_; |
|
Lines 219-224
sub merge_records {
Link Here
|
| 219 |
# Then we get the intersection of fields, present both in |
219 |
# Then we get the intersection of fields, present both in |
| 220 |
# current and incoming record (possibly to be overwritten) |
220 |
# current and incoming record (possibly to be overwritten) |
| 221 |
my @common_field_tags = grep { exists $incoming_fields->{$_} } keys %{$current_fields}; |
221 |
my @common_field_tags = grep { exists $incoming_fields->{$_} } keys %{$current_fields}; |
|
|
222 |
my $blocked; |
| 222 |
foreach my $tag (@common_field_tags) { |
223 |
foreach my $tag (@common_field_tags) { |
| 223 |
my $rule = $get_matching_field_rule->($tag); |
224 |
my $rule = $get_matching_field_rule->($tag); |
| 224 |
|
225 |
|
|
Lines 236-241
sub merge_records {
Link Here
|
| 236 |
push @{$merged_record_fields{$tag}}, @{$incoming_fields->{$tag}}; |
237 |
push @{$merged_record_fields{$tag}}, @{$incoming_fields->{$tag}}; |
| 237 |
} |
238 |
} |
| 238 |
else { |
239 |
else { |
|
|
240 |
$blocked = 1; |
| 239 |
push @{$merged_record_fields{$tag}}, @{$current_fields->{$tag}}; |
241 |
push @{$merged_record_fields{$tag}}, @{$current_fields->{$tag}}; |
| 240 |
} |
242 |
} |
| 241 |
} |
243 |
} |
|
Lines 269-274
sub merge_records {
Link Here
|
| 269 |
} |
271 |
} |
| 270 |
else { |
272 |
else { |
| 271 |
# else keep existing subfield order |
273 |
# else keep existing subfield order |
|
|
274 |
$blocked = 1; |
| 272 |
push @merged_fields, map { $_->[0] } @{$common_fields}; |
275 |
push @merged_fields, map { $_->[0] } @{$common_fields}; |
| 273 |
} |
276 |
} |
| 274 |
} |
277 |
} |
|
Lines 276-287
sub merge_records {
Link Here
|
| 276 |
if (@{$current_fields_only}) { |
279 |
if (@{$current_fields_only}) { |
| 277 |
if (!$rule->{remove}->{allow}) { |
280 |
if (!$rule->{remove}->{allow}) { |
| 278 |
push @merged_fields, @{$current_fields_only}; |
281 |
push @merged_fields, @{$current_fields_only}; |
|
|
282 |
} else { |
| 283 |
$blocked = 1; |
| 279 |
} |
284 |
} |
| 280 |
} |
285 |
} |
| 281 |
# Appended |
286 |
# Appended |
| 282 |
if (@{$incoming_fields_only}) { |
287 |
if (@{$incoming_fields_only}) { |
| 283 |
if ($rule->{append}->{allow}) { |
288 |
if ($rule->{append}->{allow}) { |
| 284 |
push @merged_fields, @{$incoming_fields_only}; |
289 |
push @merged_fields, @{$incoming_fields_only}; |
|
|
290 |
} else { |
| 291 |
$blocked = 1; |
| 285 |
} |
292 |
} |
| 286 |
} |
293 |
} |
| 287 |
$merged_record_fields{$tag} //= []; |
294 |
$merged_record_fields{$tag} //= []; |
|
Lines 301-307
sub merge_records {
Link Here
|
| 301 |
$merged_record->append_fields(@{$merged_record_fields{$tag}}); |
308 |
$merged_record->append_fields(@{$merged_record_fields{$tag}}); |
| 302 |
} |
309 |
} |
| 303 |
} |
310 |
} |
| 304 |
return $merged_record; |
311 |
return ($blocked, $merged_record); |
| 305 |
} |
312 |
} |
| 306 |
|
313 |
|
| 307 |
sub _clear_caches { |
314 |
sub _clear_caches { |