From 89148e82c1fca4c2d9dba383d44af3c2f0c22676 Mon Sep 17 00:00:00 2001 From: kados Date: Mon, 10 Apr 2006 20:06:15 +0000 Subject: [PATCH] Adding support for bulkauthimport of records where authid already exists. This commit should be tested with other uses of AUTHaddauthority to ensure it works. --- C4/AuthoritiesMarc.pm | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index b52990e28d..602af8e4a2 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -223,7 +223,7 @@ sub authoritysearch { } elsif ($record->field('148')) { $heading.= $field->as_string('abvxyz68'); } elsif ($record->field('150')) { - $heading.= $field->as_string('abvxyz68'); + $heading.= $field->as_string('abvxyz68'); } elsif ($record->field('151')) { $heading.= $field->as_string('avxyz68'); } elsif ($record->field('155')) { @@ -239,16 +239,17 @@ sub authoritysearch { } else { $heading.= $field->as_string(); } - } + } #See From foreach my $field ($record->field('4..')) { - $summary.= "   ".$field->as_string()."
"; - $summary.= "      see: ".$heading."
"; - } + $seeheading.= "   ".$field->as_string()."
"; + $seeheading.= "      see: ".$seeheading."
"; + } #See Also foreach my $field ($record->field('5..')) { - $seeheading.= "      see also: ".$field->as_string()."
"; + $altheading.= "      see also: ".$field->as_string()."
"; $altheading.= "   ".$field->as_string()."
"; - $altheading.= "      see also: ".$heading."
"; + $altheading.= "      see also: ".$altheading."
"; } + $summary.=$heading.$seeheading.$altheading; } } # then add a line for the template loop @@ -484,15 +485,22 @@ sub AUTHaddauthority { my @fields=$record->fields(); # adding main table, and retrieving authid # if authid is sent, then it's not a true add, it's only a re-add, after a delete (ie, a mod) -# if authid empty => true add, find a new authid number - unless ($authid) { +# In fact, it could still be a true add, in the case of a bulkauthimort for instance with previously +# existing authids in the records. I've adjusted below to account for this instance --JF. + if ($authid) { $dbh->do("lock tables auth_header WRITE,auth_subfield_table WRITE, auth_word WRITE, stopwords READ"); - my $sth=$dbh->prepare("insert into auth_header (datecreated,authtypecode) values (now(),?)"); - $sth->execute($authtypecode); - $sth=$dbh->prepare("select max(authid) from auth_header"); - $sth->execute; - ($authid)=$sth->fetchrow; + my $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode) values (?,now(),?)"); + $sth->execute($authid,$authtypecode); $sth->finish; +# if authid empty => true add, find a new authid number + } else { + $dbh->do("lock tables auth_header WRITE,auth_subfield_table WRITE, auth_word WRITE, stopwords READ"); + my $sth=$dbh->prepare("insert into auth_header (datecreated,authtypecode) values (now(),?)"); + $sth->execute($authtypecode); + $sth=$dbh->prepare("select max(authid) from auth_header"); + $sth->execute; + ($authid)=$sth->fetchrow; + $sth->finish; } my $fieldcount=0; # now, add subfields... @@ -1071,6 +1079,11 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.9.2.17 2006/04/10 20:06:15 kados +# Adding support for bulkauthimport of records where authid already exists. +# This commit should be tested with other uses of AUTHaddauthority to ensure +# it works. +# # Revision 1.9.2.16 2006/04/03 12:52:50 tipaul # oups, sorry kados, I had removed something you wrote for MARC21 authorities... # -- 2.39.5