From 6be3172ec3556969266184472fd0146a70fcce4f Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 16 Apr 2009 19:54:19 +0000 Subject: [PATCH] ML lineitem note CUD method git-svn-id: svn://svn.open-ils.org/ILS/trunk@12894 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/Lineitem.pm | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index 06b0938a82..611ec83489 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -624,4 +624,55 @@ sub get_lineitem_attr_defs { } +__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; -- 2.11.0