Bug 16245: [QA Follow-up] Replace typeofrecord2 by biblevel
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 14 Oct 2016 08:01:12 +0000 (10:01 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 21 Oct 2016 14:51:55 +0000 (14:51 +0000)
Position 7 of the leader is better referred to as biblevel.
(Pos 6 is record type.)
At the same time replacing some regex's by simple eq's.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
It seems that bib level in the UNIMARC leader only allows a subset of
the possible combinations for MARC21. This does not have bad side-effects
however in the new code that tests bib level to determine the type tag.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Ris.pm

index 4b2a1a1..5bf8ecc 100644 (file)
--- a/C4/Ris.pm
+++ b/C4/Ris.pm
@@ -385,10 +385,11 @@ sub print_typetag {
     ## The type of a MARC record is found at position 06 of the leader
     my $typeofrecord = defined($leader) && length $leader >=6 ?
                        substr($leader, 6, 1): undef;
-    my $typeofrecord2 = defined($leader) && length $leader >=6 ?
-                       substr($leader, 7, 1): undef;
+    ## Pos 07 == Bibliographic level
+    my $biblevel = defined($leader) && length $leader >=7 ?
+                       substr($leader, 7, 1): '';
 
-    ## ToDo: for books, field 008 positions 24-27 might have a few more
+    ## TODO: for books, field 008 positions 24-27 might have a few more
     ## hints
 
     my %typehash;
@@ -405,15 +406,15 @@ sub print_typetag {
         print "TY  - GEN\r\n"; ## most reasonable default
         warn ("no type found - assume GEN") if $marcprint;
     } elsif ( $typeofrecord =~ "a" ) {
-        if ( $typeofrecord2 =~ "a" ) {
+        if ( $biblevel eq 'a' ) {
             print "TY  - GEN\r\n"; ## monographic component part
-        } elsif ( $typeofrecord2 =~ "b" || $typeofrecord2 =~ "s" ) {
+        } elsif ( $biblevel eq 'b' || $biblevel eq 's' ) {
             print "TY  - SER\r\n"; ## serial or serial component part
-        } elsif ( $typeofrecord2 =~ "m" ) {
+        } elsif ( $biblevel eq 'm' ) {
             print "TY  - $typehash{$typeofrecord}\r\n"; ## book
-        } elsif ( $typeofrecord2 =~ "c" || $typeofrecord2 =~ "d" ) {
+        } elsif ( $biblevel eq 'c' || $biblevel eq 'd' ) {
             print "TY  - GEN\r\n"; ## collections, part of collections or made-up collections
-        } elsif ( $typeofrecord2 =~ "i" ) {
+        } elsif ( $biblevel eq 'i' ) {
             print "TY  - DATA\r\n"; ## updating loose-leafe as Dataset
         }
     } else {