Lines 485-497
sub _translate_query { #SRU query adjusted per server cf. srufields column
Link Here
|
485 |
|
485 |
|
486 |
ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding); |
486 |
ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding); |
487 |
|
487 |
|
488 |
ImportBreedingAuth imports MARC records in the reservoir (import_records table). |
488 |
ImportBreedingAuth imports MARC records in the reservoir (import_records table) or returns their id if they already exist. |
489 |
ImportBreedingAuth is based on the ImportBreeding subroutine. |
|
|
490 |
|
489 |
|
491 |
=cut |
490 |
=cut |
492 |
|
491 |
|
493 |
sub ImportBreedingAuth { |
492 |
sub ImportBreedingAuth { |
494 |
my ($marcrecord,$overwrite_auth,$filename,$encoding) = @_; |
493 |
my ($marcrecord,$filename,$encoding) = @_; |
495 |
my $dbh = C4::Context->dbh; |
494 |
my $dbh = C4::Context->dbh; |
496 |
|
495 |
|
497 |
my $batch_id = GetZ3950BatchId($filename); |
496 |
my $batch_id = GetZ3950BatchId($filename); |
Lines 500-555
sub ImportBreedingAuth {
Link Here
|
500 |
my $marcflavour = C4::Context->preference('marcflavour'); |
499 |
my $marcflavour = C4::Context->preference('marcflavour'); |
501 |
my $marc_type = $marcflavour eq 'UNIMARC' ? 'UNIMARCAUTH' : $marcflavour; |
500 |
my $marc_type = $marcflavour eq 'UNIMARC' ? 'UNIMARCAUTH' : $marcflavour; |
502 |
|
501 |
|
503 |
# fields used for import results |
502 |
my $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); |
504 |
my $imported=0; |
|
|
505 |
my $alreadyindb = 0; |
506 |
my $alreadyinfarm = 0; |
507 |
my $notmarcrecord = 0; |
508 |
my $breedingid; |
509 |
|
503 |
|
510 |
# Normalize the record so it doesn't have separated diacritics |
504 |
my $heading_authtype_code = GuessAuthTypeCode($marcrecord); |
511 |
SetUTF8Flag($marcrecord); |
|
|
512 |
|
513 |
if (scalar($marcrecord->fields()) == 0) { |
514 |
$notmarcrecord++; |
515 |
} else { |
516 |
my $heading; |
517 |
$heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); |
518 |
|
505 |
|
519 |
my $heading_authtype_code; |
506 |
my $controlnumber = $marcrecord->field('001')->data; |
520 |
$heading_authtype_code = GuessAuthTypeCode($marcrecord); |
507 |
my $breedingid; |
521 |
|
508 |
|
522 |
my $controlnumber; |
509 |
# Normalize the record so it doesn't have separated diacritics |
523 |
$controlnumber = $marcrecord->field('001')->data; |
510 |
SetUTF8Flag($marcrecord); |
524 |
|
511 |
|
525 |
#Check if the authority record already exists in the database... |
512 |
$searchbreeding->execute($controlnumber,$heading); |
526 |
my ($duplicateauthid,$duplicateauthvalue); |
513 |
($breedingid) = $searchbreeding->fetchrow; |
527 |
if ($marcrecord && $heading_authtype_code) { |
|
|
528 |
($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority( $marcrecord, $heading_authtype_code); |
529 |
} |
530 |
|
514 |
|
531 |
if ($duplicateauthid && $overwrite_auth ne 2) { |
515 |
return $breedingid if $breedingid; |
532 |
#If the authority record exists and $overwrite_auth doesn't equal 2, then mark it as already in the DB |
516 |
$breedingid = AddAuthToBatch($batch_id, 0, $marcrecord, $encoding); |
533 |
$alreadyindb++; |
517 |
return $breedingid; |
534 |
} else { |
|
|
535 |
if ($controlnumber && $heading) { |
536 |
$searchbreeding->execute($controlnumber,$heading); |
537 |
($breedingid) = $searchbreeding->fetchrow; |
538 |
} |
539 |
if ($breedingid && $overwrite_auth eq '0') { |
540 |
$alreadyinfarm++; |
541 |
} else { |
542 |
if ($breedingid && $overwrite_auth eq '1') { |
543 |
ModAuthorityInBatch($breedingid, $marcrecord); |
544 |
} else { |
545 |
my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding); |
546 |
$breedingid = $import_id; |
547 |
} |
548 |
$imported++; |
549 |
} |
550 |
} |
551 |
} |
552 |
return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid); |
553 |
} |
518 |
} |
554 |
|
519 |
|
555 |
=head2 Z3950SearchAuth |
520 |
=head2 Z3950SearchAuth |
Lines 649-655
sub Z3950SearchAuth {
Link Here
|
649 |
$heading_authtype_code = GuessAuthTypeCode($marcrecord); |
614 |
$heading_authtype_code = GuessAuthTypeCode($marcrecord); |
650 |
$heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); |
615 |
$heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); |
651 |
|
616 |
|
652 |
my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k]); |
617 |
my $breedingid = ImportBreedingAuth( $marcrecord, $serverhost[$k], $encoding[$k]); |
653 |
my %row_data; |
618 |
my %row_data; |
654 |
$row_data{server} = $servers[$k]->{'servername'}; |
619 |
$row_data{server} = $servers[$k]->{'servername'}; |
655 |
$row_data{breedingid} = $breedingid; |
620 |
$row_data{breedingid} = $breedingid; |
656 |
- |
|
|