[open-ils-commits] r12924 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Apr 20 15:34:49 EDT 2009
Author: erickson
Date: 2009-04-20 15:34:45 -0400 (Mon, 20 Apr 2009)
New Revision: 12924
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
Log:
moved picklist delete into order.pm. code re-use
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2009-04-20 19:34:05 UTC (rev 12923)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2009-04-20 19:34:45 UTC (rev 12924)
@@ -613,16 +613,20 @@
$picklist = $mgr->editor->retrieve_acq_picklist($picklist) unless ref $picklist;
# delete all 'new' lineitems
- my $lis = $mgr->editor->search_acq_lineitem({picklist => $picklist->id, state => 'new'}, {substream => 1});
- for my $li (@$lis) {
+ my $li_ids = $mgr->editor->search_acq_lineitem({picklist => $picklist->id, state => 'new'}, {idlist => 1});
+ for my $li_id (@$li_ids) {
+ my $li = $mgr->editor->retrieve_acq_lineitem($li_id);
return 0 unless delete_lineitem($mgr, $li);
+ $mgr->respond;
}
# detach all non-'new' lineitems
- $lis = $mgr->editor->search_acq_lineitem({picklist => $picklist->id, state => {'!=' => 'new'}, {substream => 1}});
- for my $li (@$lis) {
+ $li_ids = $mgr->editor->search_acq_lineitem({picklist => $picklist->id, state => {'!=' => 'new'}}, {idlist => 1});
+ for my $li_id (@$li_ids) {
+ my $li = $mgr->editor->retrieve_acq_lineitem($li_id);
$li->clear_picklist;
return 0 unless update_lineitem($mgr, $li);
+ $mgr->respond;
}
# remove any picklist-specific object perms
@@ -1716,5 +1720,30 @@
}
+__PACKAGE__->register_method(
+ method => 'delete_picklist_api',
+ api_name => 'open-ils.acq.picklist.delete',
+ signature => {
+ desc => q/Deletes a picklist. It also deletes any lineitems in the "new" state.
+ Other attached lineitems are detached'/,
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'Picklist ID to delete', type => 'number'}
+ ],
+ return => {desc => '1 on success, Event on error'}
+ }
+);
+sub delete_picklist_api {
+ my($self, $conn, $auth, $picklist_id) = @_;
+ my $e = new_editor(xact=>1, authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+ my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
+ my $pl = $e->retrieve_acq_picklist($picklist_id) or return $e->die_event;
+ delete_picklist($mgr, $pl) or return $e->die_event;
+ return $mgr->respond_complete;
+}
+
+
+
1;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm 2009-04-20 19:34:05 UTC (rev 12923)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm 2009-04-20 19:34:45 UTC (rev 12924)
@@ -262,60 +262,7 @@
return undef;
}
-
__PACKAGE__->register_method(
- method => 'delete_picklist',
- api_name => 'open-ils.acq.picklist.delete',
- signature => {
- desc => q/Deletes a picklist. It also deletes any lineitems in the "new" state.
- Other attached lineitems are detached'/,
- params => [
- {desc => 'Authentication token', type => 'string'},
- {desc => 'Picklist ID to delete', type => 'number'}
- ],
- return => {desc => '1 on success, Event on error'}
- }
-);
-
-sub delete_picklist {
- my($self, $conn, $auth, $picklist_id) = @_;
- my $e = new_editor(xact=>1, authtoken=>$auth);
- return $e->die_event unless $e->checkauth;
-
- my $picklist = $e->retrieve_acq_picklist($picklist_id)
- or return $e->die_event;
- # don't let anyone delete someone else's picklist
- if($picklist->owner != $e->requestor->id) {
- return $e->die_event unless
- $e->allowed('DELETE_PICKLIST', $picklist->org_unit, $picklist);
- }
-
- # delete all 'new' lineitems
- my $lis = $e->search_acq_lineitem({picklist => $picklist->id, state => 'new'});
- for my $li (@$lis) {
- $e->delete_acq_lineitem($li) or return $e->die_event;
- }
-
- # detach all non-'new' lineitems
- $lis = $e->search_acq_lineitem({picklist => $picklist->id, state => {'!=' => 'new'}});
- for my $li (@$lis) {
- $li->clear_picklist;
- $e->update_acq_lineitem($li) or return $e->die_event;
- }
-
- # remove any picklist-specific object perms
- my $ops = $e->search_permission_usr_object_perm_map({object_type => 'acqpl', object_id => "".$picklist->id});
- for my $op (@$ops) {
- $e->delete_usr_object_perm_map($op) or return $e->die_event;
- }
-
-
- $e->delete_acq_picklist($picklist) or return $e->die_event;
- $e->commit;
- return 1;
-}
-
-__PACKAGE__->register_method(
method => 'retrieve_pl_lineitem',
api_name => 'open-ils.acq.lineitem.picklist.retrieve',
stream => 1,
More information about the open-ils-commits
mailing list