Lines 1467-1472
sub merge {
Link Here
|
1467 |
# BulkEdit marc records |
1467 |
# BulkEdit marc records |
1468 |
# May be used as a template for a bulkedit field |
1468 |
# May be used as a template for a bulkedit field |
1469 |
my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict'; |
1469 |
my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict'; |
|
|
1470 |
my $skip_subfields = $overwrite |
1471 |
# This hash contains all subfields from the authority report fields |
1472 |
# Including $MARCfrom as well as $MARCto |
1473 |
# We only need it in loose merge mode; replaces the former $exclude |
1474 |
? {} |
1475 |
: { map { ( $_->[0], 1 ); } ( @record_from, @record_to ) }; |
1470 |
foreach my $marcrecord(@reccache){ |
1476 |
foreach my $marcrecord(@reccache){ |
1471 |
my $update = 0; |
1477 |
my $update = 0; |
1472 |
foreach my $tagfield (@$tags_using_authtype){ |
1478 |
foreach my $tagfield (@$tags_using_authtype){ |
Lines 1485-1501
sub merge {
Link Here
|
1485 |
$field->indicator(2), |
1491 |
$field->indicator(2), |
1486 |
"9" => $mergeto, |
1492 |
"9" => $mergeto, |
1487 |
); |
1493 |
); |
1488 |
my $exclude='9'; |
|
|
1489 |
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { |
1494 |
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { |
1490 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1495 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1491 |
$exclude.= $subfield->[0]; |
|
|
1492 |
} |
1496 |
} |
1493 |
$exclude='['.$exclude.']'; |
1497 |
if( !$overwrite ) { |
1494 |
# add subfields in $field not included in @record_to |
1498 |
# add subfields back in loose mode, check skip_subfields |
1495 |
my @restore= $overwrite ? () : grep {$_->[0]!~/$exclude/} $field->subfields(); |
1499 |
foreach my $subfield ( $field->subfields ) { |
1496 |
foreach my $subfield (@restore) { |
1500 |
next if $skip_subfields->{ $subfield->[0] }; |
1497 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1501 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1498 |
} |
1502 |
} |
|
|
1503 |
} |
1499 |
if( $tags_new ) { |
1504 |
if( $tags_new ) { |
1500 |
$marcrecord->delete_field( $field ); |
1505 |
$marcrecord->delete_field( $field ); |
1501 |
append_fields_ordered( $marcrecord, $field_to ); |
1506 |
append_fields_ordered( $marcrecord, $field_to ); |