Lines 1517-1553
sub merge {
Link Here
|
1517 |
# biblio is linked to authority with $9 subfield containing authid |
1517 |
# biblio is linked to authority with $9 subfield containing authid |
1518 |
my $auth_number=$field->subfield("9"); |
1518 |
my $auth_number=$field->subfield("9"); |
1519 |
my $tag=$field->tag(); |
1519 |
my $tag=$field->tag(); |
1520 |
if ($auth_number==$mergefrom) { |
1520 |
if ( $auth_number == $mergefrom ) { |
1521 |
# If merging distinct authorities, |
1521 |
|
1522 |
# look if field to add already exists in the record |
1522 |
# If merging distinct authorities, |
1523 |
# in order to avoid a duplicate. |
1523 |
# look if field to add already exists in the record |
1524 |
my $field_to_exists; |
1524 |
# in order to avoid a duplicate. |
1525 |
if ( $mergefrom != $mergeto ) { |
1525 |
my $field_to_exists; |
1526 |
foreach ( $marcrecord->field( $tag_to ? $tag_to : $tag ) ) { |
1526 |
if ( $mergefrom != $mergeto ) { |
1527 |
if ( $_->subfield('9') && $_->subfield('9') == $mergeto ) { |
1527 |
foreach ( $marcrecord->field( $tag_to ? $tag_to : $tag ) ) { |
1528 |
$field_to_exists = 1; |
1528 |
if ( $_->subfield('9') && $_->subfield('9') == $mergeto ) { |
1529 |
last; |
1529 |
$field_to_exists = 1; |
|
|
1530 |
last; |
1531 |
} |
1530 |
} |
1532 |
} |
1531 |
} |
1533 |
} |
1532 |
} |
1534 |
|
1533 |
# Go editing |
1535 |
# Go editing |
1534 |
$marcrecord->delete_field($field); |
1536 |
$marcrecord->delete_field($field); |
1535 |
unless ($field_to_exists) { |
1537 |
unless ($field_to_exists) { |
1536 |
my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); |
1538 |
my $field_to = MARC::Field->new( |
1537 |
my $exclude='9'; |
1539 |
( $tag_to ? $tag_to : $tag ), |
1538 |
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { |
1540 |
$field->indicator(1), |
1539 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1541 |
$field->indicator(2), "9" => $mergeto |
1540 |
$exclude.= $subfield->[0]; |
1542 |
); |
1541 |
} |
1543 |
my $exclude = '9'; |
1542 |
$exclude='['.$exclude.']'; |
1544 |
foreach my $subfield ( grep { $_->[0] ne '9' } @record_to ) { |
1543 |
# add subfields in $field not included in @record_to |
1545 |
$field_to->add_subfields( $subfield->[0] => $subfield->[1] ); |
1544 |
my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); |
1546 |
$exclude .= $subfield->[0]; |
1545 |
foreach my $subfield (@restore) { |
1547 |
} |
1546 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1548 |
$exclude = '[' . $exclude . ']'; |
1547 |
} |
1549 |
|
1548 |
$marcrecord->insert_grouped_field($field_to); |
1550 |
# add subfields in $field not included in @record_to |
1549 |
} |
1551 |
my @restore = |
1550 |
$update=1; |
1552 |
grep { $_->[0] !~ /$exclude/ } $field->subfields(); |
|
|
1553 |
foreach my $subfield (@restore) { |
1554 |
$field_to->add_subfields( $subfield->[0] => $subfield->[1] ); |
1555 |
} |
1556 |
$marcrecord->insert_grouped_field($field_to); |
1557 |
} |
1558 |
$update = 1; |
1551 |
} |
1559 |
} |
1552 |
}#for each tag |
1560 |
}#for each tag |
1553 |
}#foreach tagfield |
1561 |
}#foreach tagfield |
Lines 1653-1658
sub get_auth_type_location {
Link Here
|
1653 |
|
1661 |
|
1654 |
END { } # module clean-up code here (global destructor) |
1662 |
END { } # module clean-up code here (global destructor) |
1655 |
|
1663 |
|
|
|
1664 |
|
1665 |
|
1656 |
1; |
1666 |
1; |
1657 |
__END__ |
1667 |
__END__ |
1658 |
|
1668 |
|
1659 |
- |
|
|