a bit more refactoring of Caption & Holding
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Apr 2009 00:53:52 +0000 (00:53 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Apr 2009 00:53:52 +0000 (00:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12806 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm

index a486044..5efcb8e 100755 (executable)
@@ -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;
index 5fb1bb0..e11e16f 100755 (executable)
@@ -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