[open-ils-commits] r12523 - in trunk/Open-ILS/src/perlmods/OpenILS/Utils: . MFHD (djfiander)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Mar 14 14:26:48 EDT 2009
Author: djfiander
Date: 2009-03-14 14:26:44 -0400 (Sat, 14 Mar 2009)
New Revision: 12523
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm
trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
Log:
minor cleanups to calculating volume numbers
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm 2009-03-14 16:15:18 UTC (rev 12522)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm 2009-03-14 18:26:44 UTC (rev 12523)
@@ -186,7 +186,7 @@
return $str;
}
-my %increments = {
+my %increments = (
a => {years => 1}, # annual
b => {months => 2}, # bimonthly
c => {days => 3}, # semiweekly
@@ -204,7 +204,7 @@
t => {months => 4}, # three times / year
w => {weeks => 1}, # weekly
# x => completely irregular
-};
+);
sub is_combined {
my $str = shift;
@@ -237,6 +237,7 @@
$new[0] += 1;
$new[1] -= 12;
}
+ $new[1] = '0' . $new[1] if ($new[1] < 10);
}
} elsif (scalar(@new) == 3) {
# Year, Month, Day: now it gets complicated.
@@ -261,19 +262,19 @@
sub next_date {
my $self = shift;
my $next = shift;
+ my $carry = shift;
my @keys = @_;
my @cur;
my @new;
my $incr;
my $caption = $self->{_mfhdh_CAPTION};
- my $reg = $caption->{REGULARITY};
- my $pattern = $caption->{PATTERN};
+ my $reg = $caption->{_mfhdc_REGULARITY};
+ my $pattern = $caption->{_mfhdc_PATTERN};
my $freq = $pattern->{w};
- foreach my $i (0.. at keys) {
- $new[$i] = $cur[$i] = $self->{_mfhdh_SUBFIELDS}->{$keys[$i]}
- if exists $self->{_mfhdh_SUBFIELDS}->{$keys[$i]};
+ foreach my $i (0..$#keys) {
+ $new[$i] = $cur[$i] = $next->{$keys[$i]} if exists $next->{$keys[$i]};
}
if (is_combined($new[-1])) {
@@ -285,14 +286,29 @@
# lists the dates of publication. Use that that list to find the next
# date following the current one.
# XXX: the code doesn't handle this case yet.
-
- if (defined $freq && exists $increments{$freq}) {
+ if (!defined($freq)) {
+ carp "Undefined frequency in next_date!";
+ } elsif (!exists $increments{$freq}) {
+ carp "Don't know how to deal with frequency '$freq'!";
+ } else {
+ #
+ # One of the standard defined issue frequencies
+ #
@new = incr_date($increments{$freq}, @new);
while ($caption->is_omitted(@new)) {
@new = incr_date($increments{$freq}, @new);
}
}
+
+ for my $i (0..$#new) {
+ $next->{$keys[$i]} = $new[$i];
+ }
+
+ # Figure out if we need to adust volume number
+ # right now just use the $carry that was passed in.
+ # in long run, need to base this on ($carry or date_change)
+ $next->{'a'} += $carry;
}
sub next_alt_enum {
@@ -338,8 +354,9 @@
# 2) it's the right time of the year.
#
$carry = 0;
- foreach my $key (reverse('b'.. 'f')) {
+ foreach my $key (reverse('b'..'f')) {
next if !exists $next->{$key};
+
if (!$caption->capstr($key)) {
# Just assume that it increments continuously and give up
warn "Holding data exists for $key, but no caption specified";
@@ -371,19 +388,19 @@
# 2) Increment the highest level of enumeration (either by date
# or because $carry is set because of the above loop
- if (!%{$caption->{_mfhdc_CHRONS}}) {
+ if (!$caption->subfield('i')) {
# The simple case: if there is no chronology specified
# then just check $carry and return
$next->{'a'} += $carry;
} else {
# Figure out date of next issue, then decide if we need
# to adjust top level enumeration based on that
- $self->next_date($next, ('i'..'m'));
+ $self->next_date($next, $carry, ('i'..'m'));
}
}
-# next: Given a holding statement, return a hash containing the
+# next: Given a holding statement, return a hash containing the
# enumeration values for the next issues, whether we hold it or not
#
sub next {
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm 2009-03-14 16:15:18 UTC (rev 12522)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm 2009-03-14 18:26:44 UTC (rev 12523)
@@ -23,7 +23,6 @@
my $cap_id;
$cap_id = $caption->subfield('8') || '0';
- print "handling caption '$cap_id'\n";
if (exists $captions->{$cap_id}) {
carp "Multiple MFHD captions with label '$cap_id'";
More information about the open-ils-commits
mailing list