From: djfiander Date: Tue, 7 Apr 2009 00:53:52 +0000 (+0000) Subject: a bit more refactoring of Caption & Holding X-Git-Tag: sprint4-merge-nov22~10313 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=26a7ff0e5e0b1db1891f318f858654cc7dfec216;p=working%2FEvergreen.git a bit more refactoring of Caption & Holding git-svn-id: svn://svn.open-ils.org/ILS/trunk@12806 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm index a4860444fc..5efcb8e53a 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm @@ -724,4 +724,41 @@ sub next_enum { } } +sub next { + my $self = shift; + my $holding = shift; + my $next = {}; + + # Initialize $next with current enumeration & chronology, then + # we can just operate on $next, based on the contents of the caption + + if ($self->enumeration_is_chronology) { + foreach my $key ('a' .. 'h') { + $next->{$key} = $holding->{_mfhdh_SUBFIELDS}->{$key} + if defined $holding->{_mfhdh_SUBFIELDS}->{$key}; + } + $self->next_date($next, 0, ('a' .. 'h')); + + return $next; + } + + foreach my $key ('a' .. 'h') { + $next->{$key} = $holding->{_mfhdh_SUBFIELDS}->{$key}->{HOLDINGS} + if defined $holding->{_mfhdh_SUBFIELDS}->{$key}; + } + + foreach my $key ('i'..'m') { + $next->{$key} = $holding->{_mfhdh_SUBFIELDS}->{$key} + if defined $holding->{_mfhdh_SUBFIELDS}->{$key}; + } + + if (exists $next->{'h'}) { + $self->next_alt_enum($next); + } + + $self->next_enum($next); + + return($next); +} + 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm index 5fb1bb009e..e11e16fba4 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm @@ -187,43 +187,13 @@ sub format { # next: Given a holding statement, return a hash containing the # enumeration values for the next issues, whether we hold it or not +# Just pass through to Caption::next # sub next { my $self = shift; my $caption = $self->{_mfhdh_CAPTION}; - my $next = {}; - my $carry = 0; - # 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}; - } - $caption->next_date($next, $carry, ('a' .. 'h')); - - return $next; - } - - foreach my $key ('a' .. 'h') { - $next->{$key} = $self->{_mfhdh_SUBFIELDS}->{$key}->{HOLDINGS} - if exists $self->{_mfhdh_SUBFIELDS}->{$key}; - } - - foreach my $key ('i'..'m') { - $next->{$key} = $self->{_mfhdh_SUBFIELDS}->{$key} - if exists $self->{_mfhdh_SUBFIELDS}->{$key}; - } - - if (exists $next->{'h'}) { - $caption->next_alt_enum($next); - } - - $caption->next_enum($next); - - return($next); + return $caption->next($self); } # match($pat): check to see if $self matches the enumeration passed