Bugzilla – Attachment 96502 Details for
Bug 24267
C4::Breeding::ImportBreedingAuth is ineffective
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24267: Improve ImportBreedingAuth
Bug-24267-Improve-ImportBreedingAuth.patch (text/plain), 4.77 KB, created by
Marcel de Rooy
on 2019-12-20 07:20:21 UTC
(
hide
)
Description:
Bug 24267: Improve ImportBreedingAuth
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-12-20 07:20:21 UTC
Size:
4.77 KB
patch
obsolete
>From bf753525c3ea9dc30fd0e4f8359c128157169e1f Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 18 Dec 2019 18:27:33 +0000 >Subject: [PATCH] Bug 24267: Improve ImportBreedingAuth >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Breeding.pm | 63 +++++++++++++--------------------------------------------- > 1 file changed, 14 insertions(+), 49 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index 8f3e4a8c69..59cad532c7 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -485,13 +485,12 @@ sub _translate_query { #SRU query adjusted per server cf. srufields column > > ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding); > >- ImportBreedingAuth imports MARC records in the reservoir (import_records table). >- ImportBreedingAuth is based on the ImportBreeding subroutine. >+ ImportBreedingAuth imports MARC records in the reservoir (import_records table) or returns their id if they already exist. > > =cut > > sub ImportBreedingAuth { >- my ($marcrecord,$overwrite_auth,$filename,$encoding) = @_; >+ my ($marcrecord,$filename,$encoding) = @_; > my $dbh = C4::Context->dbh; > > my $batch_id = GetZ3950BatchId($filename); >@@ -500,56 +499,22 @@ sub ImportBreedingAuth { > my $marcflavour = C4::Context->preference('marcflavour'); > my $marc_type = $marcflavour eq 'UNIMARC' ? 'UNIMARCAUTH' : $marcflavour; > >- # fields used for import results >- my $imported=0; >- my $alreadyindb = 0; >- my $alreadyinfarm = 0; >- my $notmarcrecord = 0; >- my $breedingid; >+ my $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); > >- # Normalize the record so it doesn't have separated diacritics >- SetUTF8Flag($marcrecord); >- >- if (scalar($marcrecord->fields()) == 0) { >- $notmarcrecord++; >- } else { >- my $heading; >- $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); >+ my $heading_authtype_code = GuessAuthTypeCode($marcrecord); > >- my $heading_authtype_code; >- $heading_authtype_code = GuessAuthTypeCode($marcrecord); >+ my $controlnumber = $marcrecord->field('001')->data; >+ my $breedingid; > >- my $controlnumber; >- $controlnumber = $marcrecord->field('001')->data; >+ # Normalize the record so it doesn't have separated diacritics >+ SetUTF8Flag($marcrecord); > >- #Check if the authority record already exists in the database... >- my ($duplicateauthid,$duplicateauthvalue); >- if ($marcrecord && $heading_authtype_code) { >- ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority( $marcrecord, $heading_authtype_code); >- } >+ $searchbreeding->execute($controlnumber,$heading); >+ ($breedingid) = $searchbreeding->fetchrow; > >- if ($duplicateauthid && $overwrite_auth ne 2) { >- #If the authority record exists and $overwrite_auth doesn't equal 2, then mark it as already in the DB >- $alreadyindb++; >- } else { >- if ($controlnumber && $heading) { >- $searchbreeding->execute($controlnumber,$heading); >- ($breedingid) = $searchbreeding->fetchrow; >- } >- if ($breedingid && $overwrite_auth eq '0') { >- $alreadyinfarm++; >- } else { >- if ($breedingid && $overwrite_auth eq '1') { >- ModAuthorityInBatch($breedingid, $marcrecord); >- } else { >- my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding); >- $breedingid = $import_id; >- } >- $imported++; >- } >- } >- } >- return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid); >+ return $breedingid if $breedingid; >+ $breedingid = AddAuthToBatch($batch_id, 0, $marcrecord, $encoding); >+ return $breedingid; > } > > =head2 Z3950SearchAuth >@@ -649,7 +614,7 @@ sub Z3950SearchAuth { > $heading_authtype_code = GuessAuthTypeCode($marcrecord); > $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); > >- my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k]); >+ my $breedingid = ImportBreedingAuth( $marcrecord, $serverhost[$k], $encoding[$k]); > my %row_data; > $row_data{server} = $servers[$k]->{'servername'}; > $row_data{breedingid} = $breedingid; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24267
:
96453
|
96482
|
96496
|
96497
|
96502
|
96503
|
96504
|
96741
|
96742
|
96743