ranged non-cat types; depth aware full-path (my_orgs)
[Evergreen.git] / Open-ILS / src / perlmods / 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 metabib_field_all {
7         my $self = shift;
8         my $client = shift;
9
10         for my $rec ( config::metabib_field->retrieve_all ) {
11                 $client->respond( $rec->to_fieldmapper );
12         }
13
14         return undef;
15 }
16 __PACKAGE__->register_method(
17         method          => 'metabib_field_all',
18         api_name        => 'open-ils.storage.direct.config.metabib_field.retrieve.all',
19         argc            => 0,
20         stream          => 1,
21 );
22
23 sub standing_all {
24         my $self = shift;
25         my $client = shift;
26
27         for my $rec ( config::standing->retrieve_all ) {
28                 $client->respond( $rec->to_fieldmapper );
29         }
30
31         return undef;
32 }
33 __PACKAGE__->register_method(
34         method          => 'standing_all',
35         api_name        => 'open-ils.storage.direct.config.standing.retrieve.all',
36         argc            => 0,
37         stream          => 1,
38 );
39
40 sub ident_type_all {
41         my $self = shift;
42         my $client = shift;
43
44         for my $rec ( config::identification_type->retrieve_all ) {
45                 $client->respond( $rec->to_fieldmapper );
46         }
47
48         return undef;
49 }
50 __PACKAGE__->register_method(
51         method          => 'ident_type_all',
52         api_name        => 'open-ils.storage.direct.config.identification_type.retrieve.all',
53         argc            => 0,
54         stream          => 1,
55 );
56
57 sub config_status_all {
58         my $self = shift;
59         my $client = shift;
60
61         for my $rec ( config::copy_status->retrieve_all ) {
62                 $client->respond( $rec->to_fieldmapper );
63         }
64
65         return undef;
66 }
67 __PACKAGE__->register_method(
68         method          => 'config_status_all',
69         api_name        => 'open-ils.storage.direct.config.copy_status.retrieve.all',
70         argc            => 0,
71         stream          => 1,
72 );
73
74 sub config_non_cat {
75         my $self = shift;
76         my $client = shift;
77
78         for my $rec ( config::non_cataloged_type->retrieve_all ) {
79                 $client->respond( $rec->to_fieldmapper );
80         }
81
82         return undef;
83 }
84 __PACKAGE__->register_method(
85         method          => 'config_non_cat',
86         api_name        => 'open-ils.storage.direct.config.non_cataloged_type.retrieve.all',
87         argc            => 0,
88         stream          => 1,
89 );
90
91
92 # XXX arg, with the descendancy SPs...
93 sub ranged_config_non_cat {
94         my $self = shift;
95         my $client = shift;
96         my @binds = @_;
97
98         my $ctable = config::non_cataloged_type->table;
99
100         my $descendants = defined($binds[1]) ?
101                 "actor.org_unit_full_path(?, ?)" :
102                 "actor.org_unit_full_path(?)" ;
103
104
105         my $sql = <<"   SQL";
106                 SELECT  DISTINCT c.*
107                   FROM  $ctable c
108                         JOIN $descendants d
109                                 ON (d.id = c.owning_lib)
110         SQL
111
112         my $sth = config::non_cataloged_type->db_Main->prepare($sql);
113         $sth->execute(@binds);
114
115         while ( my $rec = $sth->fetchrow_hashref ) {
116
117                 my $cnct = new Fieldmapper::config::non_cataloged_type;
118                 $cnct->name($rec->{name});
119                 $cnct->owning_lib($rec->{owning_lib});
120                 $cnct->id($rec->{id});
121
122                 $client->respond( $cnct );
123         }
124
125         return undef;
126 }
127 __PACKAGE__->register_method(
128         method          => 'ranged_config_non_cat',
129         api_name        => 'open-ils.storage.ranged.config.non_cataloged_type.retrieve',
130         argc            => 1,
131         stream          => 1,
132         notes           => <<"  NOTES",
133                 Returns 
134         NOTES
135 );
136
137 1;