Lines 1407-1415
Then we should add some new parameter : bibliotargettag, authtargettag
Link Here
|
1407 |
=cut |
1407 |
=cut |
1408 |
|
1408 |
|
1409 |
sub merge { |
1409 |
sub merge { |
1410 |
my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_; |
1410 |
my ($mergefrom, $MARCfrom, $mergeto, $MARCto) = @_; |
1411 |
my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); |
1411 |
my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); |
1412 |
my $dbh=C4::Context->dbh; |
1412 |
my $dbh = C4::Context->dbh; |
1413 |
my $authfrom = Koha::Authorities->find($mergefrom); |
1413 |
my $authfrom = Koha::Authorities->find($mergefrom); |
1414 |
my $authto = Koha::Authorities->find($mergeto); |
1414 |
my $authto = Koha::Authorities->find($mergeto); |
1415 |
my $authtypefrom = Koha::Authority::Types->find($authfrom->authtypecode); |
1415 |
my $authtypefrom = Koha::Authority::Types->find($authfrom->authtypecode); |
Lines 1425-1431
sub merge {
Link Here
|
1425 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $MARCto->field($auth_tag_to_report_to); |
1425 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $MARCto->field($auth_tag_to_report_to); |
1426 |
my @record_from; |
1426 |
my @record_from; |
1427 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $MARCfrom->field($auth_tag_to_report_from); |
1427 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $MARCfrom->field($auth_tag_to_report_from); |
1428 |
|
1428 |
|
1429 |
my @reccache; |
1429 |
my @reccache; |
1430 |
# search all biblio tags using this authority. |
1430 |
# search all biblio tags using this authority. |
1431 |
#Getting marcbiblios impacted by the change. |
1431 |
#Getting marcbiblios impacted by the change. |
Lines 1464-1505
sub merge {
Link Here
|
1464 |
while (my ($tagfield) = $sth->fetchrow) { |
1464 |
while (my ($tagfield) = $sth->fetchrow) { |
1465 |
push @tags_using_authtype,$tagfield ; |
1465 |
push @tags_using_authtype,$tagfield ; |
1466 |
} |
1466 |
} |
1467 |
my $tag_to=0; |
1467 |
my $tag_to=0; |
1468 |
if ($authtypeto->authtypecode ne $authtypefrom->authtypecode){ |
1468 |
if ($authtypeto->authtypecode ne $authtypefrom->authtypecode){ |
1469 |
# If many tags, take the first |
1469 |
# If many tags, take the first |
1470 |
$sth->execute($authtypeto->authtypecode); |
1470 |
$sth->execute($authtypeto->authtypecode); |
1471 |
$tag_to=$sth->fetchrow; |
1471 |
$tag_to=$sth->fetchrow; |
1472 |
#warn $tag_to; |
1472 |
} |
1473 |
} |
|
|
1474 |
# BulkEdit marc records |
1473 |
# BulkEdit marc records |
1475 |
# May be used as a template for a bulkedit field |
1474 |
# May be used as a template for a bulkedit field |
1476 |
foreach my $marcrecord(@reccache){ |
1475 |
foreach my $marcrecord(@reccache){ |
1477 |
my $update = 0; |
1476 |
my $update = 0; |
1478 |
foreach my $tagfield (@tags_using_authtype){ |
1477 |
foreach my $tagfield (@tags_using_authtype){ |
1479 |
# warn "tagfield : $tagfield "; |
|
|
1480 |
foreach my $field ($marcrecord->field($tagfield)){ |
1478 |
foreach my $field ($marcrecord->field($tagfield)){ |
1481 |
# biblio is linked to authority with $9 subfield containing authid |
1479 |
# biblio is linked to authority with $9 subfield containing authid |
1482 |
my $auth_number=$field->subfield("9"); |
1480 |
my $auth_number=$field->subfield("9"); |
1483 |
my $tag=$field->tag(); |
1481 |
my $tag=$field->tag(); |
1484 |
if ($auth_number==$mergefrom) { |
1482 |
if ($auth_number==$mergefrom) { |
1485 |
my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); |
1483 |
my $field_to = MARC::Field->new(($tag_to?$tag_to:$tag), |
1486 |
my $exclude='9'; |
1484 |
$field->indicator(1),$field->indicator(2),"9"=>$mergeto); |
1487 |
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { |
1485 |
my $exclude='9'; |
1488 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1486 |
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { |
1489 |
$exclude.= $subfield->[0]; |
1487 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1490 |
} |
1488 |
$exclude.= $subfield->[0]; |
1491 |
$exclude='['.$exclude.']'; |
1489 |
} |
1492 |
# add subfields in $field not included in @record_to |
1490 |
$exclude='['.$exclude.']'; |
1493 |
my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); |
1491 |
#add subfields in $field not included in @record_to |
1494 |
foreach my $subfield (@restore) { |
1492 |
my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); |
1495 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1493 |
foreach my $subfield (@restore) { |
1496 |
} |
1494 |
$field_to->add_subfields($subfield->[0] =>$subfield->[1]); |
1497 |
$marcrecord->delete_field($field); |
1495 |
} |
1498 |
$marcrecord->insert_grouped_field($field_to); |
1496 |
$marcrecord->delete_field($field); |
1499 |
$update=1; |
1497 |
$marcrecord->insert_grouped_field($field_to); |
|
|
1498 |
$update=1; |
1500 |
} |
1499 |
} |
1501 |
}#for each tag |
1500 |
}#for each tag |
1502 |
}#foreach tagfield |
1501 |
}#foreach tagfield |
|
|
1502 |
|
1503 |
my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; |
1503 |
my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; |
1504 |
my $biblionumber; |
1504 |
my $biblionumber; |
1505 |
if ($bibliotag<10){ |
1505 |
if ($bibliotag<10){ |
Lines 1516-1573
sub merge {
Link Here
|
1516 |
&ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; |
1516 |
&ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; |
1517 |
$counteditedbiblio++; |
1517 |
$counteditedbiblio++; |
1518 |
warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); |
1518 |
warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); |
1519 |
} |
1519 |
} |
1520 |
}#foreach $marc |
1520 |
}#foreach $marc |
1521 |
return $counteditedbiblio; |
1521 |
|
1522 |
# now, find every other authority linked with this authority |
1522 |
return $counteditedbiblio; |
1523 |
# now, find every other authority linked with this authority |
1523 |
} |
1524 |
# my $oConnection=C4::Context->Zconn("authorityserver"); |
|
|
1525 |
# my $query; |
1526 |
# # att 9210 Auth-Internal-authtype |
1527 |
# # att 9220 Auth-Internal-LN |
1528 |
# # ccl.properties to add for authorities |
1529 |
# $query= "= ".$mergefrom; |
1530 |
# my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); |
1531 |
# my $count=$oResult->size() if ($oResult); |
1532 |
# my @reccache; |
1533 |
# my $z=0; |
1534 |
# while ( $z<$count ) { |
1535 |
# my $rec; |
1536 |
# $rec=$oResult->record($z); |
1537 |
# my $marcdata = $rec->raw(); |
1538 |
# push @reccache, $marcdata; |
1539 |
# $z++; |
1540 |
# } |
1541 |
# $oResult->destroy(); |
1542 |
# foreach my $marc(@reccache){ |
1543 |
# my $update; |
1544 |
# my $marcrecord; |
1545 |
# $marcrecord = MARC::File::USMARC::decode($marc); |
1546 |
# foreach my $tagfield (@tags_using_authtype){ |
1547 |
# $tagfield=substr($tagfield,0,3); |
1548 |
# my @tags = $marcrecord->field($tagfield); |
1549 |
# foreach my $tag (@tags){ |
1550 |
# my $tagsubs=$tag->subfield("9"); |
1551 |
# #warn "$tagfield:$tagsubs:$mergefrom"; |
1552 |
# if ($tagsubs== $mergefrom) { |
1553 |
# $tag->update("9" =>$mergeto); |
1554 |
# foreach my $subfield (@record_to) { |
1555 |
# # warn "$subfield,$subfield->[0],$subfield->[1]"; |
1556 |
# $tag->update($subfield->[0] =>$subfield->[1]); |
1557 |
# }#for $subfield |
1558 |
# } |
1559 |
# $marcrecord->delete_field($tag); |
1560 |
# $marcrecord->add_fields($tag); |
1561 |
# $update=1; |
1562 |
# }#for each tag |
1563 |
# }#foreach tagfield |
1564 |
# my $authoritynumber = TransformMarcToKoha($marcrecord,"") ; |
1565 |
# if ($update==1){ |
1566 |
# &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ; |
1567 |
# } |
1568 |
# |
1569 |
# }#foreach $marc |
1570 |
}#sub |
1571 |
|
1524 |
|
1572 |
=head2 get_auth_type_location |
1525 |
=head2 get_auth_type_location |
1573 |
|
1526 |
|
1574 |
- |
|
|