[open-ils-commits] r8349 - in
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application:
. Acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jan 8 13:26:51 EST 2008
Author: erickson
Date: 2008-01-08 13:02:24 -0500 (Tue, 08 Jan 2008)
New Revision: 8349
Added:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq.pm
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
Log:
adding initial middle layer acq code
Added: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm (rev 0)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm 2008-01-08 18:02:24 UTC (rev 8349)
@@ -0,0 +1,81 @@
+package OpenILS::Application::Acq::Picklist;
+use base qw/OpenILS::Application::Acq/;
+use strict; use warnings;
+
+use OpenSRF::Utils::Logger qw(:logger);
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Utils::CStoreEditor q/:funcs/;
+use OpenILS::Const qw/:const/;
+use OpenSRF::Utils::SettingsClient;
+use OpenILS::Event;
+
+my $BAD_PARAMS = OpenILS::Event->new('BAD_PARAMS');
+
+
+__PACKAGE__->register_method(
+ method => 'create_picklist',
+ api_name => 'open-ils.acq.picklist.create',
+ signature => q/
+ Creates a new picklist
+ @param authtoken
+ @pararm picklist
+ /
+);
+
+sub create_picklist {
+ my($self, $conn, $auth, $picklist) = @_;
+ my $e = new_editor(xact=>1, authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->allowed('CREATE_PICKLIST');
+ return $BAD_PARAMS unless $e->requestor->id == $picklist->owner;
+ $e->create_acq_picklist($picklist) or return $e->die_event;
+ $e->commit;
+ return $picklist->id;
+}
+
+sub update_picklist {
+ my($self, $conn, $auth, $picklist) = @_;
+
+ my $e = new_editor(xact=>1, authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+
+ # don't let them change the owner
+ my $o_picklist = $e->retrieve_acq_picklist($picklist->id)
+ or return $e->die_event;
+ return $BAD_PARAMS if (
+ $o_picklist->owner != $picklist->owner or
+ $picklist->owner != $e->requestor->owner );
+
+ $e->update_acq_picklist($picklist) or return $e->die_event;
+ $e->commit;
+ return 1;
+}
+
+sub retrieve_picklist {
+ my($self, $conn, $auth, $picklist_id) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+
+ my $picklist = $e->retrieve_acq_picklist($picklist_id)
+ or return $e->die_event;
+ return $BAD_PARAMS unless $e->requestor->id == $picklist->owner;
+ return $picklist;
+}
+
+
+sub delete_picklist {
+ my($self, $conn, $auth, $picklist_id) = @_;
+
+ my $e = new_editor(xact=>1, authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+
+ # don't let them change the owner
+ my $picklist = $e->retrieve_acq_picklist($picklist_id)
+ or return $e->die_event;
+ return $BAD_PARAMS if $picklist->owner != $e->requestor->owner;
+
+ $e->delete_acq_picklist($picklist) or return $e->die_event;
+ $e->commit;
+ return 1;
+}
+
Added: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq.pm (rev 0)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq.pm 2008-01-08 18:02:24 UTC (rev 8349)
@@ -0,0 +1,13 @@
+package OpenILS::Application::Acq;
+use base qw/OpenILS::Application/;
+use strict; use warnings;
+
+use OpenSRF::Utils::Logger qw(:logger);
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Utils::CStoreEditor q/:funcs/;
+use OpenILS::Const qw/:const/;
+use OpenSRF::Utils::SettingsClient;
+use OpenILS::Event;
+
+use OpenILS::Application::Acq::Picklist;
+
More information about the open-ils-commits
mailing list