From b94309d9f1a4c8ff19d51a16aa5c2547f97401d8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 6 Feb 2014 15:59:40 +0100 Subject: [PATCH] Bug 11700: C4::AuthoritiesMarc::merge enhancements/fixes - Returns the list of modified biblio records - Retrieve MARC records from DB if not given in parameters - Delete source authority if source and destination records are different Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Kyle M Hall --- C4/AuthoritiesMarc.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 1d3477d..129bfe5 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1438,19 +1438,25 @@ sub AddAuthorityTrees{ =head2 merge - $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto) + my @edited_biblionumbers = merge(mergefrom, $MARCfrom, $mergeto, $MARCto); Could add some feature : Migrating from a typecode to an other for instance. Then we should add some new parameter : bibliotargettag, authtargettag +Returns a list of biblionumbers of records that were modified. + =cut sub merge { my ($mergefrom, $MARCfrom, $mergeto, $MARCto) = @_; - my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); + my @editedbiblios; my $dbh = C4::Context->dbh; my $authtypecodefrom = GetAuthTypeCode($mergefrom); my $authtypecodeto = GetAuthTypeCode($mergeto); + + $MARCfrom ||= GetAuthority($mergefrom); + $MARCto ||= GetAuthority($mergeto); + # warn "mergefrom : $authtypecodefrom $mergefrom mergeto : $authtypecodeto $mergeto "; # return if authority does not exist return "error MARCFROM not a marcrecord ".Data::Dumper::Dumper($MARCfrom) if scalar($MARCfrom->fields()) == 0; @@ -1555,11 +1561,13 @@ sub merge { } if ($update==1){ &ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; - $counteditedbiblio++; - warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); + push @editedbiblios, $biblionumber; } }#foreach $marc - return $counteditedbiblio; + + DelAuthority($mergefrom) if ($mergefrom != $mergeto); + + return @editedbiblios; } =head2 get_auth_type_location -- 1.7.10.4