[open-ils-commits] r12806 - trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD (djfiander)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 6 20:53:53 EDT 2009


Author: djfiander
Date: 2009-04-06 20:53:52 -0400 (Mon, 06 Apr 2009)
New Revision: 12806

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
Log:
a bit more refactoring of Caption & Holding

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-04-06 21:21:14 UTC (rev 12805)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-04-07 00:53:52 UTC (rev 12806)
@@ -724,4 +724,41 @@
     }
 }
 
+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;

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm	2009-04-06 21:21:14 UTC (rev 12805)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm	2009-04-07 00:53:52 UTC (rev 12806)
@@ -187,43 +187,13 @@
 
 # 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



More information about the open-ils-commits mailing list