[open-ils-commits] r9801 - branches/rel_1_2_2/Open-ILS/src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jun 9 17:18:44 EDT 2008


Author: erickson
Date: 2008-06-09 17:18:41 -0400 (Mon, 09 Jun 2008)
New Revision: 9801

Modified:
   branches/rel_1_2_2/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
Log:
added biblio_record update and "undelete" methods.

Modified: branches/rel_1_2_2/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- branches/rel_1_2_2/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2008-06-09 21:18:16 UTC (rev 9800)
+++ branches/rel_1_2_2/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2008-06-09 21:18:41 UTC (rev 9801)
@@ -246,9 +246,62 @@
 	return undef;
 }
 
+__PACKAGE__->register_method(
+	method	=> "update_biblio_record_entry",
+	api_name	=> "open-ils.cat.biblio.record_entry.update",
+    signature => q/
+        Updates a biblio.record_entry
+        @param auth The authtoken
+        @param record The record with updated values
+        @return 1 on success, Event on error.
+    /
+);
 
+sub update_biblio_record_entry {
+    my($self, $conn, $auth, $record) = @_;
+    my $e = new_editor(authtoken=>$auth, xact=>1);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed('UPDATE_RECORD');
+    $e->update_biblio_record_entry($record) or return $e->die_event;
+    $e->commit;
+    return 1;
+}
 
+__PACKAGE__->register_method(
+	method	=> "undelete_biblio_record_entry",
+	api_name	=> "open-ils.cat.biblio.record_entry.undelete",
+    signature => q/
+        Un-deletes a record and sets active=true
+        @param auth The authtoken
+        @param record The record_id to ressurect
+        @return 1 on success, Event on error.
+    /
+);
+sub undelete_biblio_record_entry {
+    my($self, $conn, $auth, $record_id) = @_;
+    my $e = new_editor(authtoken=>$auth, xact=>1);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed('UPDATE_RECORD');
 
+    my $record = $e->retrieve_biblio_record_entry($record_id)
+        or return $e->die_event;
+    $record->deleted('f');
+    $record->active('t');
+
+    # no 2 non-deleted records can have the same tcn_value
+    my $existing = $e->search_biblio_record_entry(
+        {   deleted => 'f', 
+            tcn_value => $record->tcn_value, 
+            id => {'!=' => $record_id}
+        }, {idlist => 1});
+    return OpenILS::Event->new('TCN_EXISTS') if @$existing;
+
+    $e->update_biblio_record_entry($record) or return $e->die_event;
+    $e->commit;
+    return 1;
+}
+
+
 __PACKAGE__->register_method(
 	method	=> "biblio_record_xml_import",
 	api_name	=> "open-ils.cat.biblio.record.xml.import.override",



More information about the open-ils-commits mailing list