]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/config.pm
Make Evergreen Perl modules installable via Module::Build to match OpenSRF
[Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / Application / Storage / Publisher / config.pm
1 package OpenILS::Application::Storage::Publisher::config;
2 use base qw/OpenILS::Application::Storage/;
3 use OpenILS::Application::Storage::CDBI::config;
4
5
6 sub retrieve_all {
7         my $self = shift;
8         my $client = shift;
9
10         $self->api_name =~ /direct\.config\.(.+)\.retrieve/o;
11         
12         my $class = 'config::'.$1;
13         for my $rec ( $class->retrieve_all ) {
14                 $client->respond( $rec->to_fieldmapper );
15         }
16
17         return undef;
18 }
19
20 for my $class (
21                 qw/metabib_field standing identification_type copy_status
22                    non_cataloged_type audience_map item_form_map item_type_map
23                    language_map lit_form_map bib_source net_access_level/ ) {
24
25         __PACKAGE__->register_method(
26                 method          => 'retrieve_all',
27                 api_name        => "open-ils.storage.direct.config.$class.retrieve.all",
28                 argc            => 0,
29                 stream          => 1,
30         );
31 }
32
33
34 # XXX arg, with the descendancy SPs...
35 sub ranged_config_non_cat {
36         my $self = shift;
37         my $client = shift;
38         my @binds = @_;
39
40         my $ctable = config::non_cataloged_type->table;
41
42         my $descendants = defined($binds[1]) ?
43                 "actor.org_unit_full_path(?, ?)" :
44                 "actor.org_unit_full_path(?)" ;
45
46
47         my $sql = <<"   SQL";
48                 SELECT  DISTINCT c.*
49                   FROM  $ctable c
50                         JOIN $descendants d
51                                 ON (d.id = c.owning_lib)
52         SQL
53
54         my $sth = config::non_cataloged_type->db_Main->prepare($sql);
55         $sth->execute(@binds);
56
57         while ( my $rec = $sth->fetchrow_hashref ) {
58
59                 my $cnct = new Fieldmapper::config::non_cataloged_type;
60                 $cnct->name($rec->{name});
61                 $cnct->owning_lib($rec->{owning_lib});
62                 $cnct->id($rec->{id});
63                 $cnct->circ_duration($rec->{circ_duration});
64                 $cnct->in_house($rec->{in_house});
65
66                 $client->respond( $cnct );
67         }
68
69         return undef;
70 }
71 __PACKAGE__->register_method(
72         method          => 'ranged_config_non_cat',
73         api_name        => 'open-ils.storage.ranged.config.non_cataloged_type.retrieve',
74         argc            => 1,
75         stream          => 1,
76         notes           => <<"  NOTES",
77                 Returns 
78         NOTES
79 );
80
81 1;