Bug 10462: Followup for showing multiple ISBNs in Z3950 response
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 3 Jul 2013 12:26:56 +0000 (14:26 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 24 Jul 2013 16:32:47 +0000 (16:32 +0000)
As Jonathan correctly noted, the new Z3950 response only showed one isbn
although more isbn numbers could be in the record and would be imported.
To resolve this display problem, I traverse them all now in the updated
routine _isbn_show. There is no change in the imported records.
Note that before this patch TransformMarcToKoha did put all isbn numbers in
one field, separated by pipes (for display only). This behavior is restored
now. The three regexes on the individual isbn numbers now seem to be
overkill, but I left them there for completeness.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested this on a fresh French install under UNIMARC with BNF server.
Tested it too for MARC21.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Breeding.pm

index 7859f46..b24b0c7 100644 (file)
@@ -424,7 +424,7 @@ sub _handle_one_result {
 sub _add_rowdata {
     my ($rowref, $marcrecord)=@_;
     if(C4::Context->preference("marcflavour") ne 'UNIMARC') { #MARC21, NORMARC
-        $rowref->{isbn} = _isbn_cleanup($marcrecord->subfield('020','a')||'');
+        $rowref->{isbn}= _isbn_show($marcrecord, '020');
         $rowref->{title}= $marcrecord->subfield('245','a')||'';
         $rowref->{author}= $marcrecord->subfield('100','a')||'';
         $rowref->{date}= $marcrecord->subfield('260','c')||'';
@@ -432,7 +432,7 @@ sub _add_rowdata {
         $rowref->{lccn}= $marcrecord->subfield('050','a')||'';
     }
     else { #UNIMARC
-        $rowref->{isbn}= _isbn_cleanup($marcrecord->subfield('010','a')||'');
+        $rowref->{isbn}= _isbn_show($marcrecord, '010');
         $rowref->{title}= $marcrecord->subfield('200','a')||'';
         $rowref->{author}= $marcrecord->subfield('200','f')||'';
         $rowref->{date}= $marcrecord->subfield('210','d')||'';
@@ -442,11 +442,16 @@ sub _add_rowdata {
     return $rowref;
 }
 
-sub _isbn_cleanup {
-    my $isbn= shift;
-    $isbn=~ s/ |-|\.//g;
-    $isbn=~ s/\|/ \| /g;
-    $isbn=~ s/\(/ \(/g;
+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;
+    }
     return $isbn;
 }