From 4bf04e423936367a488fbb7a5e9c1c763d46d073 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 24 Jul 2013 16:14:46 +0200 Subject: [PATCH] Bug 10462: QA Followup to resolve LCCN mixup and remove hardcoded marc tags This patch corrects the mixup for LC call number and control number. Further, as suggested by Galen, it would be better to not introduce hardcoded tags in the Z3950Search subs in Breeding.pm. This patch resolves that by calling TransformMarcToKohaOneField. Note that this only involves changes to _addrowdata and _isbn_show. These subs are only used in building the displayed results table. Additionally, for French UNIMARC installs publicationyear is used to fill the Date column (copyrightdate is not used in those installs). The edition statement is only used in unimarc_lecture_pub not in unimarc_complet. Test plan: Do some Z3950 searches and look for values in all result columns. For MARC21 on LOC (and/or others): Look for isbn 9780415964845 (check LCCN). Look for author Rowling. For UNIMARC on BNF2 (and/or others): On BNF2 look for isbn 2070518426: result contains date and multiple isbn's. Look for title: Guide des candidats aux emplois de commissaire de police. Third result show edition statement (if you use 205$a with pub install). Note that there are no results with LCCN here (just as before). Signed-off-by: Marcel de Rooy Tested for MARC21 and UNIMARC (French lecture_pub install). Signed-off-by: Galen Charlton --- C4/Breeding.pm | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index b24b0c73be..55069db317 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -422,36 +422,31 @@ sub _handle_one_result { } sub _add_rowdata { - my ($rowref, $marcrecord)=@_; - if(C4::Context->preference("marcflavour") ne 'UNIMARC') { #MARC21, NORMARC - $rowref->{isbn}= _isbn_show($marcrecord, '020'); - $rowref->{title}= $marcrecord->subfield('245','a')||''; - $rowref->{author}= $marcrecord->subfield('100','a')||''; - $rowref->{date}= $marcrecord->subfield('260','c')||''; - $rowref->{edition}= $marcrecord->subfield('250','a')||''; - $rowref->{lccn}= $marcrecord->subfield('050','a')||''; - } - else { #UNIMARC - $rowref->{isbn}= _isbn_show($marcrecord, '010'); - $rowref->{title}= $marcrecord->subfield('200','a')||''; - $rowref->{author}= $marcrecord->subfield('200','f')||''; - $rowref->{date}= $marcrecord->subfield('210','d')||''; - $rowref->{edition}= $marcrecord->subfield('205','a')||''; - $rowref->{lccn}= ''; + my ($row, $record)=@_; + my %fetch= ( + title => 'biblio.title', + author => 'biblio.author', + isbn =>'biblioitems.isbn', + lccn =>'biblioitems.lccn', #LC control number (not call number) + edition =>'biblioitems.editionstatement', + date => 'biblio.copyrightdate', #MARC21 + date2 => 'biblioitems.publicationyear', #UNIMARC + ); + foreach my $k (keys %fetch) { + my ($t, $f)= split '\.', $fetch{$k}; + $row= C4::Biblio::TransformMarcToKohaOneField($t, $f, $record, $row); + $row->{$k}= $row->{$f} if $k ne $f; } - return $rowref; + $row->{date}//= $row->{date2}; + $row->{isbn}=_isbn_replace($row->{isbn}); + return $row; } -sub _isbn_show { - my ($record, $fieldno)= @_; #both marc21 and unimarc possible - my $isbn= ''; - foreach my $f ( $record->field($fieldno) ) { - my $a= $f->subfield('a'); - $a =~ s/ |-|\.//g; - $a =~ s/\|/ \| /g; - $a =~ s/\(/ \(/g; - $isbn= $isbn? ($isbn.' | '. $a): $a; - } +sub _isbn_replace { + my ($isbn)= @_; + $isbn =~ s/ |-|\.//g; + $isbn =~ s/\|/ \| /g; + $isbn =~ s/\(/ \(/g; return $isbn; } -- 2.39.5