Test for chronology stored in enumeration subfields of holdings data.
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 25 Nov 2008 02:44:00 +0000 (02:44 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 25 Nov 2008 02:44:00 +0000 (02:44 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11325 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index ccc9fc7..5b4561d 100755 (executable)
@@ -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;
index a713c50..e0927ee 100755 (executable)
@@ -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