From 72d3d9a11171975ee4c4b3cf23bc99edc102eba8 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 3 Oct 2013 17:54:03 -0400 Subject: [PATCH] Relax MFHD subfield 'a' requirement for caption/patterns If going by the book, every caption/pattern field would have a subfield 'a', since the data from subfield 'i' would be moved to 'a' if 'a' was empty. Since that is arcane, and our own wizards used to bend this rule, let's make some minor adjustments to our expectations: 1) When calculating date progression, don't expect there to be an 'a' subfield which needs to be "carried" into. 2) When determining whether a field is 'open-ended', check the first availabile enum/chron subfield rather than hard-coding the check to 'a'. These changes do not affect the display formatters, so strings generated from 'a'-less caption/pattern combos are not exactly right, but they suffice. Signed-off-by: Dan Wells Signed-off-by: Lebbeous Fogle-Weekley --- Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm | 6 +++++- Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm index a873372f17..5e966d9064 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm @@ -526,7 +526,11 @@ sub next_chron { } } } - } elsif ($carry) { + } elsif ($carry and exists $next->{a}) { + # If we have only chron fields ('i' through 'm'), don't vivicate an 'a'. + # It would be more standard for the chron fields to have been moved to + # the enum fields, but imperfect patterns exist, and that's an odd + # rule anyway. $next->{a} += $carry; } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm index 37f985a38a..433596eac7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm @@ -35,10 +35,12 @@ sub new { # TODO: full support for second indicators 2, 3, and 4 $self->{_mfhdh_OPEN_ENDED} = 0; + my $first_enum_or_chron_code = ''; foreach my $subfield ($self->subfields) { my ($key, $val) = @$subfield; if ($key =~ /[a-m]/) { + $first_enum_or_chron_code = $key unless $first_enum_or_chron_code; if (exists($self->{_mfhdh_FIELDS}->{$key})) { carp("Duplicate, non-repeatable subfield '$key' found, ignoring"); next; @@ -82,7 +84,7 @@ sub new { } if ( $self->{_mfhdh_COMPRESSED} - && $self->{_mfhdh_FIELDS}{'a'}{HOLDINGS}[1] eq '') { + && $self->{_mfhdh_FIELDS}{$first_enum_or_chron_code}{HOLDINGS}[1] eq '') { $self->{_mfhdh_OPEN_ENDED} = 1; } bless($self, $class); -- 2.43.2