From: djfiander Date: Tue, 24 Mar 2009 02:26:56 +0000 (+0000) Subject: Properly parse holdings fields when the chronology is stored in the enumeration subfields X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4fd4509237aba91529d8764cfb1eeb550e1539be;p=evergreen%2Fmasslnc.git Properly parse holdings fields when the chronology is stored in the enumeration subfields git-svn-id: svn://svn.open-ils.org/ILS/trunk@12649 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm index 8afba6005f..dbd02d0727 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm @@ -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); } diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t index 7996fb0970..d7ac268e26 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t @@ -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