From: Dan Scott Date: Sat, 17 Jan 2015 16:05:36 +0000 (-0500) Subject: Remove vestigial (Sirsi) identifiers; order fields X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=eb29f534d76366f5989b392a86d59af6e0307f4f;p=contrib%2FConifer.git Remove vestigial (Sirsi) identifiers; order fields We might as well place any 010/024/035 that we add in numerical order. Also, remove the 035 $a (Sirsi) identifiers which are now meaningless. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql b/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql index ede6ca115c..f077a3b3f0 100644 --- a/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql +++ b/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql @@ -115,7 +115,7 @@ if ($lccn_number) { if (exists $metadata->{'list'}->[0]->{'lccn'} and !$lccn_number) { $lccn_number = $metadata->{'list'}->[0]->{'lccn'}->[0]; my $nf = MARC::Field->new('010', '', '', 'a' => "$lccn_number"); - $record->insert_grouped_field($nf); + $record->insert_fields_ordered($nf); my $response = $ua->get("http://xisbn.worldcat.org/webservices/xid/lccn/$lccn_number?method=getMetadata&format=json&fl=*"); if ($response->is_success) { my $metadata = decode_json($response->decoded_content); @@ -146,22 +146,23 @@ if ($owi_number) { } if (!$found_owinumber) { my $nf = MARC::Field->new('024', '7', '', 'a' => "http://worldcat.org/entity/work/id/$owi_number", '2' => 'uri'); - $record->insert_grouped_field($nf); + $record->insert_fields_ordered($nf); } } -if ($oclc_number) { - my @idtags = $record->field('035'); - foreach my $idtag (@idtags) { - if ($idtag->subfield('a') =~ m#^\(OCoLC\)$oclc_number#) { - $found_oclcnum = 1; - } - } - if (!$found_oclcnum) { - my $nf = MARC::Field->new('035', '', '', 'a' => "(OCoLC)$oclc_number"); - $record->insert_grouped_field($nf); +my @idtags = $record->field('035'); +foreach my $idtag (@idtags) { + # Remove meaningless old local Sirsi identifiers + if ($idtag->subfield('a') =~ m#^\(Sirsi\)#) { + $record->delete_field($idtag); + } elsif ($oclc_number && $idtag->subfield('a') =~ m#^\(OCoLC\)$oclc_number#) { + $found_oclcnum = 1; } } +if ($oclc_number && !$found_oclcnum) { + my $nf = MARC::Field->new('035', '', '', 'a' => "(OCoLC)$oclc_number"); + $record->insert_fields_ordered($nf); +} my $xml = $record->as_xml_record(); $xml =~ s/\n//sgo;