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

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 16 15:54:23 EDT 2009


Author: erickson
Date: 2009-04-16 15:54:19 -0400 (Thu, 16 Apr 2009)
New Revision: 12894

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
Log:
ML lineitem note CUD method

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2009-04-16 15:57:49 UTC (rev 12893)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2009-04-16 19:54:19 UTC (rev 12894)
@@ -624,4 +624,55 @@
 }
 
 
+__PACKAGE__->register_method(
+	method => 'lineitem_note_CUD_batch',
+	api_name => 'open-ils.acq.lineitem_note.cud.batch',
+    stream => 1,
+	signature => {
+        desc => q/Manage lineitem notes/,
+        params => [
+            {desc => 'Authentication token', type => 'string'},
+            {desc => 'List of lineitem_notes to manage', type => 'array'},
+        ],
+        return => {desc => 'Streaming response of current position in the array'}
+    }
+);
+
+sub lineitem_note_CUD_batch {
+    my($self, $conn, $auth, $li_notes) = @_;
+
+    my $e = new_editor(xact=>1, authtoken=>$auth);
+    return $e->die_event unless $e->checkauth;
+    # XXX perms
+
+    my $total = @$li_notes;
+    my $count = 0;
+
+    for my $note (@$li_notes) {
+
+        $note->editor($e->requestor->id);
+        $note->edit_time('now');
+
+        if($note->isnew) {
+            $note->creator($e->requestor->id);
+            $e->create_acq_lineitem_note($note) or return $e->die_event;
+
+        } elsif($note->isdeleted) {
+            $e->delete_acq_lineitem_note($note) or return $e->die_event;
+
+        } elsif($note->ischanged) {
+            $e->update_acq_lineitem_note($note) or return $e->die_event;
+        }
+
+        if(!$note->isdeleted) {
+            $note = $e->retrieve_acq_lineitem_note($note->id);
+        }
+
+        $conn->respond({maximum => $total, progress => ++$count, note => $note});
+    }
+
+    $e->commit;
+    return {complete => 1};
+}
+
 1;



More information about the open-ils-commits mailing list