Lines 1455-1461
sub merge {
Link Here
|
1455 |
$z++; |
1455 |
$z++; |
1456 |
} |
1456 |
} |
1457 |
$oResult->destroy(); |
1457 |
$oResult->destroy(); |
1458 |
#warn scalar(@reccache)." biblios to update"; |
|
|
1459 |
# Get All candidate Tags for the change |
1458 |
# Get All candidate Tags for the change |
1460 |
# (This will reduce the search scope in marc records). |
1459 |
# (This will reduce the search scope in marc records). |
1461 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1460 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
Lines 1464-1471
sub merge {
Link Here
|
1464 |
if ($authtypeto->authtypecode ne $authtypefrom->authtypecode){ |
1463 |
if ($authtypeto->authtypecode ne $authtypefrom->authtypecode){ |
1465 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
1464 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
1466 |
} |
1465 |
} |
1467 |
# BulkEdit marc records |
1466 |
|
1468 |
# May be used as a template for a bulkedit field |
|
|
1469 |
my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict'; |
1467 |
my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict'; |
1470 |
my $skip_subfields = $overwrite |
1468 |
my $skip_subfields = $overwrite |
1471 |
# This hash contains all subfields from the authority report fields |
1469 |
# This hash contains all subfields from the authority report fields |
Lines 1476-1486
sub merge {
Link Here
|
1476 |
foreach my $marcrecord(@reccache){ |
1474 |
foreach my $marcrecord(@reccache){ |
1477 |
my $update = 0; |
1475 |
my $update = 0; |
1478 |
foreach my $tagfield (@$tags_using_authtype){ |
1476 |
foreach my $tagfield (@$tags_using_authtype){ |
1479 |
# warn "tagfield : $tagfield "; |
|
|
1480 |
my $countfrom = 0; # used in strict mode to remove duplicates |
1477 |
my $countfrom = 0; # used in strict mode to remove duplicates |
1481 |
foreach my $field ($marcrecord->field($tagfield)){ |
1478 |
foreach my $field ($marcrecord->field($tagfield)){ |
1482 |
# biblio is linked to authority with $9 subfield containing authid |
1479 |
my $auth_number = $field->subfield("9"); # link to authority |
1483 |
my $auth_number=$field->subfield("9"); |
|
|
1484 |
my $tag=$field->tag(); |
1480 |
my $tag=$field->tag(); |
1485 |
next if !defined($auth_number) || $auth_number ne $mergefrom; |
1481 |
next if !defined($auth_number) || $auth_number ne $mergefrom; |
1486 |
$countfrom++; |
1482 |
$countfrom++; |
Lines 1516-1523
sub merge {
Link Here
|
1516 |
$field->replace_with($field_to); |
1512 |
$field->replace_with($field_to); |
1517 |
} |
1513 |
} |
1518 |
$update=1; |
1514 |
$update=1; |
1519 |
}#for each tag |
1515 |
} |
1520 |
}#foreach tagfield |
1516 |
} |
1521 |
my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; |
1517 |
my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; |
1522 |
my $biblionumber; |
1518 |
my $biblionumber; |
1523 |
if ($bibliotag<10){ |
1519 |
if ($bibliotag<10){ |
Lines 1535-1591
sub merge {
Link Here
|
1535 |
$counteditedbiblio++; |
1531 |
$counteditedbiblio++; |
1536 |
warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); |
1532 |
warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); |
1537 |
} |
1533 |
} |
1538 |
}#foreach $marc |
1534 |
} |
1539 |
return $counteditedbiblio; |
1535 |
return $counteditedbiblio; |
1540 |
# now, find every other authority linked with this authority |
1536 |
} |
1541 |
# now, find every other authority linked with this authority |
|
|
1542 |
# my $oConnection=C4::Context->Zconn("authorityserver"); |
1543 |
# my $query; |
1544 |
# # att 9210 Auth-Internal-authtype |
1545 |
# # att 9220 Auth-Internal-LN |
1546 |
# # ccl.properties to add for authorities |
1547 |
# $query= "= ".$mergefrom; |
1548 |
# my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); |
1549 |
# my $count=$oResult->size() if ($oResult); |
1550 |
# my @reccache; |
1551 |
# my $z=0; |
1552 |
# while ( $z<$count ) { |
1553 |
# my $rec; |
1554 |
# $rec=$oResult->record($z); |
1555 |
# my $marcdata = $rec->raw(); |
1556 |
# push @reccache, $marcdata; |
1557 |
# $z++; |
1558 |
# } |
1559 |
# $oResult->destroy(); |
1560 |
# foreach my $marc(@reccache){ |
1561 |
# my $update; |
1562 |
# my $marcrecord; |
1563 |
# $marcrecord = MARC::File::USMARC::decode($marc); |
1564 |
# foreach my $tagfield (@tags_using_authtype){ |
1565 |
# $tagfield=substr($tagfield,0,3); |
1566 |
# my @tags = $marcrecord->field($tagfield); |
1567 |
# foreach my $tag (@tags){ |
1568 |
# my $tagsubs=$tag->subfield("9"); |
1569 |
# #warn "$tagfield:$tagsubs:$mergefrom"; |
1570 |
# if ($tagsubs== $mergefrom) { |
1571 |
# $tag->update("9" =>$mergeto); |
1572 |
# foreach my $subfield (@record_to) { |
1573 |
# # warn "$subfield,$subfield->[0],$subfield->[1]"; |
1574 |
# $tag->update($subfield->[0] =>$subfield->[1]); |
1575 |
# }#for $subfield |
1576 |
# } |
1577 |
# $marcrecord->delete_field($tag); |
1578 |
# $marcrecord->add_fields($tag); |
1579 |
# $update=1; |
1580 |
# }#for each tag |
1581 |
# }#foreach tagfield |
1582 |
# my $authoritynumber = TransformMarcToKoha($marcrecord,"") ; |
1583 |
# if ($update==1){ |
1584 |
# &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ; |
1585 |
# } |
1586 |
# |
1587 |
# }#foreach $marc |
1588 |
}#sub |
1589 |
|
1537 |
|
1590 |
sub _merge_newtag { |
1538 |
sub _merge_newtag { |
1591 |
# Routine is only called for an (exceptional) authtypecode change |
1539 |
# Routine is only called for an (exceptional) authtypecode change |