From: djfiander Date: Tue, 25 Nov 2008 02:44:00 +0000 (+0000) Subject: Test for chronology stored in enumeration subfields of holdings data. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1df351759efbac9d6a747938e17e2c0cc35a6b2c;p=Evergreen.git Test for chronology stored in enumeration subfields of holdings data. git-svn-id: svn://svn.open-ils.org/ILS/trunk@11325 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 ccc9fc79ac..5b4561d437 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm @@ -109,4 +109,30 @@ sub caption { } } +# If items are identified by chronology only, with no separate +# enumeration (eg, a newspaper issue), then the chronology is +# recorded in the enumeration subfields $a - $f. We can tell +# that this is the case if there are $a - $f subfields and no +# chronology subfields ($i-$k), and none of the $a-$f subfields +# have associated $u or $v subfields, but there are $w and $y +# subfields. + +sub enumeration_is_chronology { + my $self = shift; + + # There is always a '$a' subfield in well-formed fields. + return 0 if exists $self->{CHRONS}->{i}; + + foreach my $key ('a' .. 'f') { + my $enum; + + last if !exists $self->{ENUMS}->{$key}; + + $enum = $self->{ENUMS}->{$key}; + return 0 if defined $enum->{COUNT} || defined $enum->{RESTART}; + } + + return (exists $self->{PATTERN}->{w} && exists $self->{PATTERN}->{y}); +} + 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm index a713c507b4..e0927eeb5e 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm @@ -74,10 +74,18 @@ sub format { # Enumerations foreach my $key ('a'..'f') { + my $capstr; + last if !defined $caption->caption($key); + # printf("fmt %s: '%s'\n", $key, $caption->caption($key)); - $str .= ($key eq 'a' ? "" : ':') . $caption->caption($key) . $self->{ENUMS}->{$key}->{HOLDINGS}; + $capstr = $caption->caption($key); + if (substr($capstr, 0, 1) eq '(') { + # a caption enclosed in parentheses is not displayed + $capstr = ''; + } + $str .= ($key eq 'a' ? "" : ':') . $capstr . $self->{ENUMS}->{$key}->{HOLDINGS}; } # Chronology @@ -175,6 +183,9 @@ sub next { } } + if ($caption->enumeration_is_chronology) { + # do something + } # $carry keeps track of whether we need to carry into the next # higher level of enumeration. It's not actually necessary except