Lines 24-29
use C4::Biblio;
Link Here
|
24 |
use C4::Search; |
24 |
use C4::Search; |
25 |
use C4::AuthoritiesMarc::MARC21; |
25 |
use C4::AuthoritiesMarc::MARC21; |
26 |
use C4::AuthoritiesMarc::UNIMARC; |
26 |
use C4::AuthoritiesMarc::UNIMARC; |
|
|
27 |
use C4::AuthoritiesRameau; |
27 |
use C4::Charset; |
28 |
use C4::Charset; |
28 |
use C4::Log; |
29 |
use C4::Log; |
29 |
use Koha::MetadataRecord::Authority; |
30 |
use Koha::MetadataRecord::Authority; |
Lines 1407-1413
Then we should add some new parameter : bibliotargettag, authtargettag
Link Here
|
1407 |
=cut |
1408 |
=cut |
1408 |
|
1409 |
|
1409 |
sub merge { |
1410 |
sub merge { |
1410 |
my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_; |
1411 |
my ($mergefrom,$MARCfrom,$mergeto,$MARCto, $biblionumber) = @_; |
1411 |
my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); |
1412 |
my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); |
1412 |
my $dbh=C4::Context->dbh; |
1413 |
my $dbh=C4::Context->dbh; |
1413 |
my $authfrom = Koha::Authorities->find($mergefrom); |
1414 |
my $authfrom = Koha::Authorities->find($mergefrom); |
Lines 1427-1460
sub merge {
Link Here
|
1427 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $MARCfrom->field($auth_tag_to_report_from); |
1428 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $MARCfrom->field($auth_tag_to_report_from); |
1428 |
|
1429 |
|
1429 |
my @reccache; |
1430 |
my @reccache; |
1430 |
# search all biblio tags using this authority. |
1431 |
if ($biblionumber) { |
1431 |
#Getting marcbiblios impacted by the change. |
1432 |
my $marcrecorddb = GetMarcBiblio($biblionumber); |
1432 |
#zebra connection |
|
|
1433 |
my $oConnection=C4::Context->Zconn("biblioserver",0); |
1434 |
# We used to use XML syntax here, but that no longer works. |
1435 |
# Thankfully, we don't need it. |
1436 |
my $query; |
1437 |
$query= "an=".$mergefrom; |
1438 |
my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); |
1439 |
my $count = 0; |
1440 |
if ($oResult) { |
1441 |
$count=$oResult->size(); |
1442 |
} |
1443 |
my $z=0; |
1444 |
while ( $z<$count ) { |
1445 |
my $marcrecordzebra = C4::Search::new_record_from_zebra( |
1446 |
'biblioserver', |
1447 |
$oResult->record($z)->raw() |
1448 |
); |
1449 |
my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' ); |
1450 |
my $i = ($biblionumbertagfield < 10) |
1451 |
? $marcrecordzebra->field( $biblionumbertagfield )->data |
1452 |
: $marcrecordzebra->subfield( $biblionumbertagfield, $biblionumbertagsubfield ); |
1453 |
my $marcrecorddb = GetMarcBiblio($i); |
1454 |
push @reccache, $marcrecorddb; |
1433 |
push @reccache, $marcrecorddb; |
1455 |
$z++; |
1434 |
} else { |
|
|
1435 |
# search all biblio tags using this authority. |
1436 |
#Getting marcbiblios impacted by the change. |
1437 |
#zebra connection |
1438 |
my $oConnection=C4::Context->Zconn("biblioserver",0); |
1439 |
# We used to use XML syntax here, but that no longer works. |
1440 |
# Thankfully, we don't need it. |
1441 |
my $query; |
1442 |
$query= "an=".$mergefrom; |
1443 |
my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); |
1444 |
my $count = 0; |
1445 |
if ($oResult) { |
1446 |
$count=$oResult->size(); |
1447 |
} |
1448 |
my $z=0; |
1449 |
while ( $z<$count ) { |
1450 |
my $marcrecordzebra = C4::Search::new_record_from_zebra( |
1451 |
'biblioserver', |
1452 |
$oResult->record($z)->raw() |
1453 |
); |
1454 |
my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' ); |
1455 |
my $i = ($biblionumbertagfield < 10) |
1456 |
? $marcrecordzebra->field( $biblionumbertagfield )->data |
1457 |
: $marcrecordzebra->subfield( $biblionumbertagfield, $biblionumbertagsubfield ); |
1458 |
my $marcrecorddb = GetMarcBiblio($i); |
1459 |
push @reccache, $marcrecorddb; |
1460 |
$z++; |
1461 |
} |
1462 |
$oResult->destroy(); |
1456 |
} |
1463 |
} |
1457 |
$oResult->destroy(); |
|
|
1458 |
#warn scalar(@reccache)." biblios to update"; |
1464 |
#warn scalar(@reccache)." biblios to update"; |
1459 |
# Get All candidate Tags for the change |
1465 |
# Get All candidate Tags for the change |
1460 |
# (This will reduce the search scope in marc records). |
1466 |
# (This will reduce the search scope in marc records). |
Lines 1478-1483
sub merge {
Link Here
|
1478 |
foreach my $tagfield (@tags_using_authtype){ |
1484 |
foreach my $tagfield (@tags_using_authtype){ |
1479 |
# warn "tagfield : $tagfield "; |
1485 |
# warn "tagfield : $tagfield "; |
1480 |
foreach my $field ($marcrecord->field($tagfield)){ |
1486 |
foreach my $field ($marcrecord->field($tagfield)){ |
|
|
1487 |
|
1488 |
# If Rameau authorities are enabled and there are multiple $9's in the field, skip it. |
1489 |
my @internallinks = $field->subfield("9"); |
1490 |
next if (C4::Context->preference('useRameau') && scalar(@internallinks) > 1); |
1491 |
|
1481 |
# biblio is linked to authority with $9 subfield containing authid |
1492 |
# biblio is linked to authority with $9 subfield containing authid |
1482 |
my $auth_number=$field->subfield("9"); |
1493 |
my $auth_number=$field->subfield("9"); |
1483 |
my $tag=$field->tag(); |
1494 |
my $tag=$field->tag(); |
Lines 1512-1517
sub merge {
Link Here
|
1512 |
warn "pas de numéro de notice bibliographique dans : ".$marcrecord->as_formatted; |
1523 |
warn "pas de numéro de notice bibliographique dans : ".$marcrecord->as_formatted; |
1513 |
next; |
1524 |
next; |
1514 |
} |
1525 |
} |
|
|
1526 |
if (C4::Context->preference('useRameau')) { |
1527 |
my $rameauUpdate = rameauProcessing($marcrecord); |
1528 |
$update = 1 if ($rameauUpdate == 1); |
1529 |
} |
1515 |
if ($update==1){ |
1530 |
if ($update==1){ |
1516 |
&ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; |
1531 |
&ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; |
1517 |
$counteditedbiblio++; |
1532 |
$counteditedbiblio++; |