Bugzilla – Attachment 13786 Details for
Bug 9171
Vendor sent us a file with holdings in 952 which has repeated subfields and no home or holding branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch for master
0001-Fixing-MARC-import-with-holding-in-952-and-repeated-.patch (text/plain), 3.39 KB, created by
Michael Hafen
on 2012-11-29 18:49:14 UTC
(
hide
)
Description:
Proposed patch for master
Filename:
MIME Type:
Creator:
Michael Hafen
Created:
2012-11-29 18:49:14 UTC
Size:
3.39 KB
patch
obsolete
>From 3e7ecf2fd6187182fea83ba7b322b8be0c592ff8 Mon Sep 17 00:00:00 2001 >From: Michael Hafen <mdhafen@tech.washk12.org> >Date: Thu, 29 Nov 2012 11:25:15 -0700 >Subject: [PATCH] Fixing MARC import with holding in 952 and repeated > subfields >Content-Type: text/plain; charset="utf-8" > >Found a marc record from a vendor which has holdings in the 952, like Koha >does. The vendor tried to have a repeating 'z' subfield (public notes), but >Koha failed to parse it, and instead created seperate item records for the >repeated subfields. > >Also adding the home and holding branch if they aren't set, like they weren't >in this file. >--- > C4/ImportBatch.pm | 42 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 15f1acb..8b6de32 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -424,6 +424,48 @@ sub AddItemsToImportBiblio { > my $dbh = C4::Context->dbh; > my ($item_tag,$item_subfield) = &GetMarcFromKohaField("items.itemnumber",''); > foreach my $item_field ($marc_record->field($item_tag)) { >+ my ($b_tag,$b_sub) = &GetMarcFromKohaField("items.barcode",''); >+ my ($c_tag,$c_sub) = &GetMarcFromKohaField("items.itemcallnumber",''); >+ unless ( $item_field->subfield( $item_subfield ) || $item_field->subfield( $b_sub ) || $item_field->subfield( $c_sub ) ) { >+ # No itemnumber, barcode, or call number. >+ # This is probably a repeated subfield stuffed into it's own >+ # field. The best action would be to join it to the previous >+ # item record so we don't loose any data. >+ # Yes, I have actually seen records like this from a vendor >+ my $import_id = $import_items_ids[ $#import_items_ids ]; >+ my $sth = $dbh->prepare("SELECT marcxml FROM import_items WHERE import_items_id = ?"); >+ $sth->bind_param(1, $import_id); >+ $sth->execute(); >+ my ( $xml ) = $sth->fetchrow_array; >+ my $item_marc = MARC::Record->new_from_xml( $xml ); >+ foreach my $subfield ( $item_field->subfields() ) { >+ my $data = $item_marc->subfield( $item_tag, $subfield->[0] ); >+ $data .= " | " if ( $data ); >+ $data .= $subfield->[1]; >+ for my $field ( $item_marc->field( $item_tag ) ) { >+ $field->update( $subfield->[0] => $data ); >+ } >+ } >+ >+ $sth = $dbh->prepare("UPDATE import_items SET marcxml = ? WHERE import_items_id = ?"); >+ $sth->bind_param(1, $item_marc->as_xml()); >+ $sth->bind_param(2, $import_id); >+ $sth->execute(); >+ >+ next; >+ } >+ >+ # make sure home and holding branch are set >+ my $branch = C4::Context::userenv->{branch}; >+ my ($h_tag,$h_sub) = &GetMarcFromKohaField("items.homebranch",''); >+ my ($h2_tag,$h2_sub) = &GetMarcFromKohaField("items.holdingbranch",''); >+ unless ( $item_field->subfield( $h_sub ) ) { >+ $item_field->add_subfields( $h_sub, $branch ) if ( $branch ); >+ } >+ unless ( $item_field->subfield( $h2_sub ) ) { >+ $item_field->add_subfields( $h2_sub, $branch ) if ( $branch ); >+ } >+ > my $item_marc = MARC::Record->new(); > $item_marc->leader("00000 a "); # must set Leader/09 to 'a' > $item_marc->append_fields($item_field); >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9171
:
13785
| 13786