From: erickson Date: Fri, 19 Jun 2009 20:50:33 +0000 (+0000) Subject: added auth record number extractor X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5208b4c722d553441d0ac7192232648caeebd254;p=evergreen%2Fbjwebb.git added auth record number extractor git-svn-id: svn://svn.open-ils.org/ILS/trunk@13419 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm index a8ef1f0bc..a00dc5c16 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm @@ -36,6 +36,10 @@ sub import_authority_record { $rec->edit_date('now'); $rec->marc($U->entityize($marc_doc->documentElement->toString)); + my ($arn, $evt) = find_arn($e, $marc_doc); + return $evt if $evt; + $rec->arn_value($arn); + $rec = $e->create_authority_record_entry($rec) or return $e->die_event; # we don't care about the result, just fire off the request @@ -64,4 +68,24 @@ sub overlay_authority_record { return $rec; } +sub find_arn { + my($e, $marc_doc) = @_; + + my $xpath = '//marc:controlfield[@tag="001"]'; + my ($arn) = $marc_doc->documentElement->findvalue($xpath); + + if(my $existing_rec = $e->search_authority_record_entry({arn_value => $arn, deleted => 'f'})->[0]) { + # this arn is taken + return ( + undef, + OpenILS::Event->new( + 'AUTHORITY_RECORD_NUMBER_EXISTS', + payload => {existing_record => $existing_rec, arn => $arn} + ) + ); + } + + return ($arn); +} + 1;