adding initial middle layer acq code
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Jan 2008 18:02:24 +0000 (18:02 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Jan 2008 18:02:24 +0000 (18:02 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8349 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq.pm [new file with mode: 0644]
Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq.pm
new file mode 100644 (file)
index 0000000..0240c24
--- /dev/null
@@ -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;
+
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
new file mode 100644 (file)
index 0000000..1137600
--- /dev/null
@@ -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;
+}
+