From 9f449a44db79cd8b362b7756f27d9eb3faf32d57 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 28 Jul 2005 19:56:15 +0000 Subject: [PATCH] * removing a useless & CPU consuming call to MARCgetbiblio * Leader management. If you create a MARC tag "000", with a subfield '@', it will be managed as the leader. Seems to work correctly. Now going to create a plugin for leader() --- C4/Biblio.pm | 31 +++++++++++++++++++++---------- acqui.simple/addbiblio.pl | 22 +++++++++++++++++----- acqui.simple/additem.pl | 5 +++-- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 25b2e77cbb..dc5dbb8fa6 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -368,6 +368,8 @@ sub MARCaddbiblio { } } } + # save leader + &MARCaddsubfield($dbh,$bibid,'000','',$fieldcount+1,'',1,$record->leader); $dbh->do("unlock tables"); return $bibid; } @@ -478,8 +480,6 @@ sub MARCgetbiblio { my ( $dbh, $bibid ) = @_; my $record = MARC::Record->new(); - #---- TODO : the leader is missing - $record->leader(' '); my $sth = $dbh->prepare( "select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink @@ -507,8 +507,11 @@ sub MARCgetbiblio { if ( $row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag ) { $previndicator .= " "; if ( $prevtag < 10 ) { - $record->add_fields( ( sprintf "%03s", $prevtag ), $prevvalue ) - unless $prevtag eq "XXX"; # ignore the 1st loop + if ($prevtag ne '000') { + $record->add_fields( ( sprintf "%03s", $prevtag ), $prevvalue ) unless $prevtag eq "XXX"; # ignore the 1st loop + } else { + $record->leader(sprintf("%24s",$prevvalue)); + } } else { $record->add_fields($field) unless $prevtag eq "XXX"; @@ -627,10 +630,6 @@ sub MARCgetitem { sub MARCmodbiblio { my ($dbh,$bibid,$record,$frameworkcode,$delete)=@_; - my $oldrecord=&MARCgetbiblio($dbh,$bibid); - if ($oldrecord eq $record) { - return; - } # 1st delete the biblio, # 2nd recreate it my $biblionumber = MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid); @@ -1033,7 +1032,11 @@ sub MARChtml2marc { if (@$rtags[$i] ne $prevtag) { if ($prevtag < 10) { if ($prevvalue) { - $record->add_fields((sprintf "%03s",$prevtag),$prevvalue); + if ($prevtag ne '000') { + $record->add_fields((sprintf "%03s",$prevtag),$prevvalue); + } else { + $record->leader($prevvalue); + } } } else { if ($field) { @@ -2429,7 +2432,7 @@ sub char_decode { # $encoding = C4::Context->preference("marcflavour") unless $encoding; if ( $encoding eq "UNIMARC" ) { - s/\xe1/Æ/gm; +# s/\xe1/Æ/gm; s/\xe2/Ð/gm; s/\xe9/Ø/gm; s/\xec/þ/gm; @@ -2721,6 +2724,14 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.115.2.16 2005/07/28 19:56:15 tipaul +# * removing a useless & CPU consuming call to MARCgetbiblio +# * Leader management. +# If you create a MARC tag "000", with a subfield '@', it will be managed as the leader. +# Seems to work correctly. +# +# Now going to create a plugin for leader() +# # Revision 1.115.2.15 2005/07/19 15:25:40 tipaul # * fixing a bug in subfield order when MARCgetbiblio # * getting rid with the limit "biblionumber & biblioitemnumber must be in the same tag". So, we can put biblionumber in 001 (field that has no subfields, so we can't put biblioitemnumber in this field), and use biblionumber as identifier in the MARC biblio too. Still to be deeply tested. diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 3ac378bc73..2c9879bae1 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -198,7 +198,7 @@ sub create_input () { # it's a standard field } else { if (length($value) >200) { - $subfield_data{marc_value}=""; + $subfield_data{marc_value}=""; } else { $subfield_data{marc_value}=""; #" } @@ -223,14 +223,26 @@ sub build_tabs ($$$$) { my $indicator; # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab. # if MARC::Record is empty => use tab as master loop. - if ($record ne -1 && $record->field($tag)) { - my @fields = $record->field($tag); + if ($record ne -1 && ($record->field($tag) || $tag eq '000')) { + my @fields; + if ($tag ne '000') { + @fields = $record->field($tag); + } else { + push @fields,$record->leader(); + } foreach my $field (@fields) { my @subfields_data; if ($tag<10) { - my $value=$field->data(); - my $subfield="@"; + my ($value,$subfield); + if ($tag ne '000') { + $value=$field->data(); + $subfield="@"; + } else { + $value = $field; + $subfield='@'; + } next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); + next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'biblio.biblionumber'); push(@subfields_data, &create_input($tag,$subfield,char_decode($value,$encoding),$i,$tabloop,$record,$authorised_values_sth)); $i++; } else { diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index a8efe44a31..3a3448d5f7 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -135,8 +135,9 @@ if ($op eq "additem") { my %indicators; $indicators{995}=' '; # now, build existiing item list -my $temp = MARCgetbiblio($dbh,$bibid); -my @fields = $temp->fields(); +# my $temp = MARCgetbiblio($dbh,$bibid); +# my @fields = $temp->fields(); +my @fields = $record->fields(); my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code my @big_array; #---- finds where items.itemnumber is stored