From fe95a8ee9b9907e56bf122399f371ab7066a2e17 Mon Sep 17 00:00:00 2001 From: Brian Harrington Date: Tue, 21 Apr 2009 12:13:22 -0400 Subject: [PATCH] Patch to improve auto-generated MARC21 authorities This patch makes sure that MARC21 authorities have a minimal Leader, 008, and 040. If an authority record is created through BiblioAddsAuthority it generates a 670 based on information in the bib record. Signed-off-by: Galen Charlton --- C4/AuthoritiesMarc.pm | 34 +++++++++++++++++++++++++++++++++- cataloguing/addbiblio.pl | 9 +++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index a5102a65b0..644f53def6 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -522,11 +522,43 @@ sub AddAuthority { # pass the MARC::Record to this function, and it will create the records in the authority table my ($record,$authid,$authtypecode) = @_; my $dbh=C4::Context->dbh; - my $leader=' a ';##Fixme correct leader as this one just adds utf8 to MARC21 + my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record # if authid empty => true add, find a new authid number my $format= 'UNIMARCAUTH' if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC'); $format= 'MARC21' if (uc(C4::Context->preference('marcflavour')) ne 'UNIMARC'); + + if ($format eq "MARC21") { + if (!$record->leader) { + $record->leader($leader); + } + if (!$record->field('003')) { + $record->insert_fields_ordered( + MARC::Field->new('003',C4::Context->preference('MARCOrgCode')) + ); + } + my $time=POSIX::strftime("%Y%m%d%H%M%S",localtime); + if (!$record->field('005')) { + $record->insert_fields_ordered( + MARC::Field->new('005',$time.".0") + ); + } + my $date=POSIX::strftime("%y%m%d",localtime); + if (!$record->field('008')) { + $record->insert_fields_ordered( + MARC::Field->new('008',$date."|||a|||||| | ||| d") + ); + } + if (!$record->field('040')) { + $record->insert_fields_ordered( + MARC::Field->new('040','','', + 'a' => C4::Context->preference('MARCOrgCode'), + 'c' => C4::Context->preference('MARCOrgCode') + ) + ); + } + } + if (($format eq "UNIMARCAUTH") && (!$record->subfield('100','a'))){ $record->leader(" nx j22 "); my $date=POSIX::strftime("%Y%m%d",localtime); diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 02c2c396af..9bcf88be5e 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -793,6 +793,15 @@ AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|); SetMarcUnicodeFlag($marcrecordauth, 'MARC21'); } + if (C4::Context->preference('marcflavour') eq 'MARC21') { + $marcrecordauth->insert_fields_ordered(MARC::Field->new('667','','','a'=>"Machine generated authority record.")); + my $cite = $record->author() . ", " . $record->title_proper() . ", " . $record->publication_date() . " "; + $cite =~ s/^[\s\,]*//; + $cite =~ s/[\s\,]*$//; + $cite = "Work cat.: (" . C4::Context->preference('MARCOrgCode') . ")". $record->subfield('999','c') . ": " . $cite; + $marcrecordauth->insert_fields_ordered(MARC::Field->new('670','','','a'=>$cite)); + } + # warn "AUTH RECORD ADDED : ".$marcrecordauth->as_formatted; my $authid=AddAuthority($marcrecordauth,'',$data->{authtypecode}); -- 2.39.5