Lines 1473-1517
sub merge {
Link Here
|
1473 |
: { map { ( $_->[0], 1 ); } ( @record_from, @record_to ) }; |
1473 |
: { map { ( $_->[0], 1 ); } ( @record_from, @record_to ) }; |
1474 |
foreach my $marcrecord(@reccache){ |
1474 |
foreach my $marcrecord(@reccache){ |
1475 |
my $update = 0; |
1475 |
my $update = 0; |
1476 |
foreach my $tagfield (@$tags_using_authtype){ |
1476 |
foreach my $tagfield (@$tags_using_authtype) { |
1477 |
my $countfrom = 0; # used in strict mode to remove duplicates |
1477 |
my $countfrom = 0; # used in strict mode to remove duplicates |
1478 |
foreach my $field ($marcrecord->field($tagfield)){ |
1478 |
foreach my $field ( $marcrecord->field($tagfield) ) { |
1479 |
my $auth_number = $field->subfield("9"); # link to authority |
1479 |
my $auth_number = $field->subfield("9"); # link to authority |
1480 |
my $tag=$field->tag(); |
1480 |
my $tag = $field->tag(); |
1481 |
next if !defined($auth_number) || $auth_number ne $mergefrom; |
1481 |
next if !defined($auth_number) || $auth_number ne $mergefrom; |
1482 |
$countfrom++; |
1482 |
$countfrom++; |
1483 |
if( $overwrite && $countfrom > 1 ) { |
1483 |
if ( $overwrite && $countfrom > 1 ) { |
1484 |
# remove this duplicate in strict mode |
1484 |
# remove this duplicate in strict mode |
1485 |
$marcrecord->delete_field( $field ); |
1485 |
$marcrecord->delete_field($field); |
1486 |
$update = 1; |
1486 |
$update = 1; |
1487 |
next; |
1487 |
next; |
1488 |
} |
1488 |
} |
1489 |
my $newtag = $tags_new |
1489 |
my $newtag = $tags_new |
1490 |
? _merge_newtag( $tag, $tags_new ) |
1490 |
? _merge_newtag( $tag, $tags_new ) |
1491 |
: $tag; |
1491 |
: $tag; |
1492 |
my $field_to = MARC::Field->new( |
1492 |
my $field_to = MARC::Field->new( |
1493 |
$newtag, |
1493 |
$newtag, |
1494 |
$field->indicator(1), |
1494 |
$field->indicator(1), |
1495 |
$field->indicator(2), |
1495 |
$field->indicator(2), |
1496 |
"9" => $mergeto, |
1496 |
"9" => $mergeto, |
1497 |
); |
1497 |
); |
1498 |
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { |
1498 |
foreach my $subfield ( grep { $_->[0] ne '9' } @record_to ) { |
1499 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1499 |
$field_to->add_subfields( $subfield->[0] => $subfield->[1] ); |
1500 |
} |
1500 |
} |
1501 |
if( !$overwrite ) { |
1501 |
if ( !$overwrite ) { |
1502 |
# add subfields back in loose mode, check skip_subfields |
1502 |
# add subfields back in loose mode, check skip_subfields |
1503 |
foreach my $subfield ( $field->subfields ) { |
1503 |
foreach my $subfield ( $field->subfields ) { |
1504 |
next if $skip_subfields->{ $subfield->[0] }; |
1504 |
next if $skip_subfields->{ $subfield->[0] }; |
1505 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1505 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1506 |
} |
1506 |
} |
1507 |
} |
1507 |
} |
1508 |
if( $tags_new ) { |
1508 |
if ($tags_new) { |
1509 |
$marcrecord->delete_field( $field ); |
1509 |
$marcrecord->delete_field($field); |
1510 |
append_fields_ordered( $marcrecord, $field_to ); |
1510 |
append_fields_ordered( $marcrecord, $field_to ); |
1511 |
} else { |
1511 |
} else { |
1512 |
$field->replace_with($field_to); |
1512 |
$field->replace_with($field_to); |
1513 |
} |
1513 |
} |
1514 |
$update=1; |
1514 |
$update = 1; |
1515 |
} |
1515 |
} |
1516 |
} |
1516 |
} |
1517 |
my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; |
1517 |
my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; |
1518 |
- |
|
|