[open-ils-commits] r13419 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jun 19 16:50:38 EDT 2009


Author: erickson
Date: 2009-06-19 16:50:33 -0400 (Fri, 19 Jun 2009)
New Revision: 13419

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
Log:
added auth record number extractor

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm	2009-06-19 20:48:37 UTC (rev 13418)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm	2009-06-19 20:50:33 UTC (rev 13419)
@@ -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