]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/ContainerCSV.pm
Bookbag enhancements in TTOPAC
[working/Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / Application / Trigger / Reactor / ContainerCSV.pm
1 package OpenILS::Application::Trigger::Reactor::ContainerCSV;
2 use base "OpenILS::Application::Trigger::Reactor";
3 use strict;
4 use warnings;
5 use OpenSRF::Utils::Logger qw/:logger/;
6 use Data::Dumper;
7 $Data::Dumper::Indent = 0;
8 my $U = "OpenILS::Application::AppUtils";
9
10 sub ABOUT {
11     return q|
12
13 The ContainerCSV Reactor Module processes the configured template after
14 fetching the items from the bookbag refererred to in $env->{target}
15 by using the search api with the query in $env->{params}{search}.  It's
16 the event-creator's responsibility to build a correct search query and check
17 permissions and do that sort of thing.
18
19 open-ils.trigger is not a public service, so that should be ok.
20
21 The output, like all processed templates, is stored in the event_output table.
22
23 |;
24 }
25
26 sub handler {
27     my ($self, $env) = @_;
28
29     # get items for bookbags (bib containers of btype bookbag)
30     if ($env->{user_data}{item_search}) {
31         # use the search api for bib container items
32         my $items = $U->bib_container_items_via_search(
33             $env->{target}->id, $env->{user_data}{item_search}
34         ) or return 0;  # TODO build error output for db?
35
36         $env->{items} = $items;
37     } else {
38         # XXX TODO If we're going to support other types of containers here,
39         # we'll probably just want to flesh those containers' items directly,
40         # not involve the search API.
41
42         $logger->warn("ContainerCSV reactor used without item_search, doesn't know what to do."); # XXX
43     }
44
45     return 1 if $self->run_TT($env);
46     return 0;
47 }
48
49 1;