From 9da1d633beafe178a0dfc4e55607ae3b1cd6dc1c Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Fri, 19 May 2006 21:39:52 +0000 Subject: [PATCH] Old authorities did not contain authid in marc record. Add it --- misc/marc_into_authority.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc/marc_into_authority.pl b/misc/marc_into_authority.pl index e900d02daa..9c679bbeda 100644 --- a/misc/marc_into_authority.pl +++ b/misc/marc_into_authority.pl @@ -9,6 +9,7 @@ use C4::Context; use MARC::Record; use MARC::File::USMARC; use MARC::File::XML; +use C4::AuthoritiesMarc; use Time::HiRes qw(gettimeofday); my $timeneeded; my $starttime = gettimeofday; @@ -41,7 +42,12 @@ my $sth2 = $dbh->prepare("UPDATE auth_header set marc=? where authid=?" ); while (my ($authid,$authtypecode)=$sth->fetchrow ){ - my $record = AUTHgetauthority($dbh,$authid); + my $record = AUTHgetauthorityold($dbh,$authid); +##Add authid and authtypecode to record. Old records did not have these fields +my ($authidfield,$authidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode); +my ($authidfield,$authtypesubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.authtypecode",$authtypecode); +##Both authid and authtypecode is expected to be in the same field. Modify if other requirements arise + $record->add_fields($authfield,'','',$authidsubfield=>$authid,$authtypesubfield=>$authtypecode); $sth2->execute($record->as_usmarc,$authid); $timeneeded = gettimeofday - $starttime unless ($i % 1000); print "$i in $timeneeded s\n" unless ($i % 1000); @@ -50,7 +56,7 @@ $timeneeded = gettimeofday - $starttime unless ($i % 1000); } $dbh->do("UNLOCK TABLES "); -sub AUTHgetauthority { +sub AUTHgetauthorityold { # Returns MARC::Record of the biblio passed in parameter. my ($dbh,$authid)=@_; my $record = MARC::Record->new(); -- 2.39.5