Start getting ready to handle more complex publication patterns.
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Apr 2009 01:47:33 +0000 (01:47 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Apr 2009 01:47:33 +0000 (01:47 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12807 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 5efcb8e..7ce488f 100755 (executable)
@@ -85,14 +85,25 @@ sub new
        }
     }
 
+    my $pat = $self->{_mfhdc_PATTERN};
+
+    # Sanity check publication frequency vs publication pattern:
+    # if the frequency is a number, then the pattern better
+    # have that number of values associated with it.
+    if (exists($pat->{w}) && ($pat->{w} =~ /^\d+$/)
+       && ($pat->{w} != scalar(@{$pat->{y}}))) {
+       carp("Caption::new: publication frequency '$pat->{w}' != publication pattern @{$pat->{y}}");
+    }
+
+
     # If there's a $x subfield and a $j, then it's compressible
-    if (exists $self->{_mfhdc_PATTERN}->{x} && exists $self->{_mfhdc_CHRONS}->{'j'}) {
+    if (exists $pat->{x} && exists $self->{_mfhdc_CHRONS}->{'j'}) {
        $self->{_mfhdc_COMPRESSIBLE} = 1;
     }
 
     bless ($self, $class);
 
-    if (exists $self->{_mfhdc_PATTERN}->{y}) {
+    if (exists $pat->{y}) {
        $self->decode_pattern;
     }