[open-ils-commits] r11022 - trunk/Open-ILS/src/perlmods/OpenILS/Utils
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Nov 2 14:40:04 EST 2008
Author: djfiander
Date: 2008-11-02 14:40:01 -0500 (Sun, 02 Nov 2008)
New Revision: 11022
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm
Log:
Add support for all three caption fields (853-855) and all three
enumeration fields (863-865)
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm 2008-11-02 18:45:44 UTC (rev 11021)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD.pm 2008-11-02 19:40:01 UTC (rev 11022)
@@ -14,28 +14,41 @@
my $rec = shift;
$self->{CAPTIONS} = {};
- foreach my $caption ($rec->field('853')) {
- my $cap_id;
- $cap_id = $caption->subfield('8') || '0';
- if (exists $self->{CAPTIONS}->{$cap_id}) {
- carp "Multiple unlabelled MFHD captions";
+
+ foreach my $field ('853', '854', '855') {
+ my $captions = {};
+ foreach my $caption ($rec->field($field)) {
+ my $cap_id;
+
+ $cap_id = $caption->subfield('8') || '0';
+ if (exists $captions->{$cap_id}) {
+ carp "Multiple unlabelled MFHD captions";
+ }
+ $captions->{$cap_id} = new MFHD::Caption($caption);
}
- $self->{CAPTIONS}->{$cap_id} = new MFHD::Caption($caption);
+ $self->{CAPTIONS}->{$field} = $captions;
}
- $self->{HOLDINGS} = {};
- foreach my $holding ($rec->field('863')) {
- my $linkage;
- my ($link_id, $seqno);
+ foreach my $field ('863', '864', '865') {
+ my $holdings = {};
+ my $cap_field;
- $linkage = $holding->subfield('8');
- ($link_id, $seqno) = split(/\./, $linkage);
+ ($cap_field = $field) =~ s/6/5/;
- if (!exists $self->{HOLDINGS}->{$link_id}) {
- $self->{HOLDINGS}->{$link_id} = {};
+ foreach my $holding ($rec->field($field)) {
+ my $linkage;
+ my ($link_id, $seqno);
+
+ $linkage = $holding->subfield('8');
+ ($link_id, $seqno) = split(/\./, $linkage);
+
+ if (!exists $holdings->{$link_id}) {
+ $holdings->{$link_id} = {};
+ }
+ $holdings->{$link_id}->{$seqno} =
+ new MFHD::Holding($seqno, $holding, $self->{CAPTIONS}->{$cap_field}->{$link_id});
}
- $self->{HOLDINGS}->{$link_id}->{$seqno} =
- new MFHD::Holding($seqno, $holding, $self->{CAPTIONS}->{$link_id});
+ $self->{HOLDINGS}->{$field} = $holdings;
}
bless ($self, $class);
@@ -44,15 +57,17 @@
sub captions {
my $self = shift;
+ my $field = shift;
- return sort keys %{$self->{CAPTIONS}}
+ return sort keys %{$self->{CAPTIONS}->{$field}}
}
sub holdings {
my $self = shift;
+ my $field = shift;
my $capid = shift;
- return sort {$a->{SEQNO} <=> $b->{SEQNO}} values %{$self->{HOLDINGS}->{$capid}};
+ return sort {$a->{SEQNO} <=> $b->{SEQNO}} values %{$self->{HOLDINGS}->{$field}->{$capid}};
}
1;
More information about the open-ils-commits
mailing list