From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 4 Aug 2010 19:46:59 +0000 (+0000)
Subject: a glue method used to apply a template to a set of records
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ba9404628ed78181be5912aa48f6636152bef6b3;p=evergreen%2Ftadl.git

a glue method used to apply a template to a set of records

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17077 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
index 7164a9ef41..5bf04ad00e 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
@@ -175,6 +175,46 @@ sub biblio_record_replace_marc  {
 }
 
 __PACKAGE__->register_method(
+	method	=> "template_overlay_biblio_record_entry",
+	api_name	=> "open-ils.cat.biblio.record_entry.template_overlay",
+    stream  => 1,
+    signature => q#
+        Overlays biblio.record_entry MARC values
+        @param auth The authtoken
+        @param records The record ids to be updated by the template
+        @param template The overlay template
+        @return Stream of hashes record id in the key "record" and t or f for the success of the overlay operation in key "success"
+    #
+);
+
+sub template_overlay_biblio_record_entry {
+    my($self, $conn, $auth, $records, $template) = @_;
+    my $e = new_editor(authtoken=>$auth, xact=>1);
+    return $e->die_event unless $e->checkauth;
+
+    $records = [$records] if (!ref($records));
+
+    for my $rid ( @$records ) {
+        my $rec = $e->retrieve_biblio_record_entry($rid);
+        next unless $rec;
+
+        unless ($e->allowed('UPDATE_RECORD', $rec->owner, $rec)) {
+            $conn->respond({ record => $rid, success => 'f' });
+            next;
+        }
+
+        my $success = $e->json_query(
+            { from => [ 'vandelay.template_overlay_bib_record', $template, $rid ] }
+        )->[0]->{'vandelay.template_overlay_bib_record'};
+
+        $conn->respond({ record => $rid, success => $success });
+    }
+
+    $e->commit;
+    return undef;
+}
+
+__PACKAGE__->register_method(
 	method	=> "update_biblio_record_entry",
 	api_name	=> "open-ils.cat.biblio.record_entry.update",
     signature => q/