From 5255c177b00bddfa09fb2d8166ca705f917ee284 Mon Sep 17 00:00:00 2001 From: Shawn Boyette Date: Wed, 27 May 2009 15:35:12 +0000 Subject: [PATCH] multi hash now uses just code for key --- Equinox-Migration/Changes | 5 +++++ .../lib/Equinox/Migration/MapDrivenMARCXMLProc.pm | 14 ++++++-------- Equinox-Migration/t/03-MapDrivenMARCXMLProc.t | 6 +++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Equinox-Migration/Changes b/Equinox-Migration/Changes index e29d599..327c1d7 100644 --- a/Equinox-Migration/Changes +++ b/Equinox-Migration/Changes @@ -1,5 +1,10 @@ Revision history for Equinox-Migration +2009-05-27 MDMP 1.001 + + * The multi hash no longer uses tag+code for keys. Just code + (e.g. '999a' is now just 'a') + 2009-05-07 MDMP 1.000 & MS 1.000 2009-04-30 SM 1.004 diff --git a/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm b/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm index 2b90a03..75424ff 100644 --- a/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm +++ b/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm @@ -13,11 +13,11 @@ Equinox::Migration::MapDrivenMARCXMLProc =head1 VERSION -Version 1.000 +Version 1.001 =cut -our $VERSION = '1.000'; +our $VERSION = '1.001'; =head1 SYNOPSIS @@ -169,8 +169,7 @@ sub process_subs { # handle multi modifier if (my $mods = $map->mods($field)) { if ($mods->{multi}) { - my $name = $tag . $code; - push @{$dataf->{multi}{$name}}, $sub->text; + push @{$dataf->{multi}{$code}}, $sub->text; return; } } @@ -261,7 +260,7 @@ Then C<$rec> will look like: tags => [ { tag => tag_id, - multi => { (tag_id . sub_code) => [ val1, val2, ... ] }, + multi => { code => [ val1, val2, ... ] }, uni => { code => value, code2 => value2, ... }, }, ... @@ -282,9 +281,8 @@ Each tag hash holds its own id (e.g. C<998>), and two references to two more hashrefs, C and C. The C hash holds the extracted data for tag/sub mappings which -have the C modifier on them. The keys in C are -composed of the tag id and subfield code, catenated -(e.g. C<901c>). The values are arrayrefs containing the content of all +have the C modifier on them. The keys in C subfield +codes. The values are arrayrefs containing the content of all instances of that subfield in that instance of that tag. If no tags are defined as C, it will be C. diff --git a/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t b/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t index 6e19df4..ddd8c85 100644 --- a/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t +++ b/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t @@ -88,7 +88,7 @@ is ($rec->{tags}[0]{tag}, 250, 'should be 250'); is ($rec->{tags}[0]{uni}{a}, "1st ed.", '999$a'); is ($rec->{tags}[1]{tag}, 999, 'should be 999'); is ($rec->{tags}[1]{uni}{a}, "MYS DEM", '999$a'); -is_deeply ($rec->{tags}[1]{multi}{'999x'}, ['MYSTERY'], '999$x - multi'); +is_deeply ($rec->{tags}[1]{multi}{'x'}, ['MYSTERY'], '999$x - multi'); is_deeply ($rec->{tmap}{250}, [0], 'tag map test 1a'); is_deeply ($rec->{tmap}{999}, [1], 'tag map test 1b'); $rec = $mp->parse_record; @@ -96,7 +96,7 @@ $rec = $mp->parse_record; $rec = $mp->parse_record; is ($rec->{tags}[0]{tag}, 999, '250 doesnt exist in this record'); is ($rec->{tags}[0]{uni}{a}, "FIC DEV", 'subfield value 4'); -is_deeply ($rec->{tags}[0]{multi}{'999x'}, ['FICTION','FICTION2','FICTION3','FICTION4'], +is_deeply ($rec->{tags}[0]{multi}{'x'}, ['FICTION','FICTION2','FICTION3','FICTION4'], '999$x - multi'); is ($rec->{tmap}{250}, undef, 'tag map test 2a'); is_deeply ($rec->{tmap}{999}, [0], 'tag map test 2b'); @@ -109,4 +109,4 @@ $rec = $mp->parse_record; $rec = $mp->parse_record; $rec = $mp->parse_record; $rec = $mp->parse_record; -is_deeply ($rec->{tags}[0]{multi}{'999x'}, ['FICTION'], '999$x - multi no digits'); +is_deeply ($rec->{tags}[0]{multi}{'x'}, ['FICTION'], '999$x - multi no digits'); -- 1.7.2.5