[open-ils-commits] r13420 - branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Cat (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jun 19 16:51:21 EDT 2009
Author: erickson
Date: 2009-06-19 16:51:16 -0400 (Fri, 19 Jun 2009)
New Revision: 13420
Modified:
branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
Log:
added auth record number extractor
Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm 2009-06-19 20:50:33 UTC (rev 13419)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm 2009-06-19 20:51:16 UTC (rev 13420)
@@ -36,6 +36,10 @@
$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 @@
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;
More information about the open-ils-commits
mailing list