Properly parse holdings fields when the chronology is stored in the enumeration subfields
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Mar 2009 02:26:56 +0000 (02:26 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Mar 2009 02:26:56 +0000 (02:26 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12649 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t

index 8afba60..dbd02d0 100755 (executable)
@@ -27,16 +27,16 @@ sub new {
 
     foreach my $subfield ($self->subfields) {
        my ($key, $val) = @$subfield;
-       if ($key =~ /[a-h]/) {
+
+       if (($caption->enumeration_is_chronology && $key =~ /[a-h]/) || $key =~ /[i-m]/) {
+           # Chronology
+           $self->{_mfhdh_SUBFIELDS}->{$key} = $val;
+       } elsif ($key =~ /[a-h]/) {
            # Enumeration details of holdings
            $self->{_mfhdh_SUBFIELDS}->{$key} = {HOLDINGS => $val,
                                                 UNIT     => undef,};
            $last_enum = $key;
        } elsif ($key =~ /[i-m]/) {
-           $self->{_mfhdh_SUBFIELDS}->{$key} = $val;
-           if (!$caption->capstr($key)) {
-               warn "Holding '$seqno' specified enumeration level '$key' not included in caption $caption->{LINK}";
-           }
        } elsif ($key eq 'o') {
            warn '$o specified prior to first enumeration'
              unless defined($last_enum);
@@ -358,7 +358,7 @@ sub next_date {
 
            # I am cheating: This code assumes that only the smallest
            # time increment is combined. So, no "Apr 15/May 1" allowed.
-           @new[-1] = @new[-1] . '/' . @second_date[-1];
+           $new[-1] = $new[-1] . '/' . $second_date[-1];
        }
     }
 
@@ -478,6 +478,17 @@ sub next {
 
     # Initialize $next with current enumeration & chronology, then
     # we can just operate on $next, based on the contents of the caption
+
+    if ($caption->enumeration_is_chronology) {
+       foreach my $key ('a' .. 'h') {
+           $next->{$key} = $self->{_mfhdh_SUBFIELDS}->{$key}
+             if exists $self->{_mfhdh_SUBFIELDS}->{$key};
+       }
+       $self->next_date($next, ('a' .. 'h'));
+
+       return $next;
+    }
+
     foreach my $key ('a' .. 'h') {
        $next->{$key} = $self->{_mfhdh_SUBFIELDS}->{$key}->{HOLDINGS}
          if exists $self->{_mfhdh_SUBFIELDS}->{$key};
@@ -488,16 +499,12 @@ sub next {
          if exists $self->{_mfhdh_SUBFIELDS}->{$key};
     }
 
-    if ($caption->enumeration_is_chronology) {
-       $self->next_date($next, ('a'..'h'));
-    } else {
-       if (exists $next->{'h'}) {
-           $self->next_alt_enum($next);
-       }
-
-       $self->next_enum($next);
+    if (exists $next->{'h'}) {
+       $self->next_alt_enum($next);
     }
 
+    $self->next_enum($next);
+
     return($next);
 }
 
index 7996fb0..d7ac268 100644 (file)
@@ -182,3 +182,7 @@ __END__
 
 245 00 $aMonthly, iss no. restarts, Cal change: Jan, July issue omitted
 853 20 $815$av.$bno.$u11$vr$i(year)$j(month)$wm$x01$yom07
+
+245 00 $aQuarterly, chronology in enumeration fields
+853 20 $816$a(year)$b(season)$wq$x21$yps21,22,23,24
+863 41 $816.1$a2007$b21$x|a2007|b22$zSimple case: quarterly in mid-volume