1 package OpenILS::Application::Storage::Publisher::actor;
2 use base qw/OpenILS::Application::Storage/;
3 use OpenILS::Application::Storage::CDBI::actor;
4 use OpenSRF::Utils::Logger qw/:level/;
5 use OpenILS::Utils::Fieldmapper;
7 my $log = 'OpenSRF::Utils::Logger';
16 ORDER BY CASE WHEN parent_ou IS NULL THEN 0 ELSE 1 END, name;
19 my $sth = actor::org_unit->db_Main->prepare_cached($select);
23 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
27 __PACKAGE__->register_method(
28 api_name => 'open-ils.storage.actor.org_unit_list',
30 method => 'org_unit_list',
33 sub org_unit_descendants {
38 return undef unless ($id);
42 FROM connectby('actor.org_unit','id','parent_ou','name',?,'100','.')
43 as t(keyid text, parent_keyid text, level int, branch text,pos int),
49 my $sth = actor::org_unit->db_Main->prepare_cached($select);
53 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
57 __PACKAGE__->register_method(
58 api_name => 'open-ils.storage.actor.org_unit_descendants',
60 method => 'org_unit_descendants',
69 my $search_field = 'id';
70 $search_field = 'usrname' if ($self->api_name =~/userid/o);
71 $search_field = 'usrname' if ($self->api_name =~/username/o);
76 $log->debug("Searching for $id using ".$self->api_name, DEBUG);
78 my ($rec) = actor::user->fast_fieldmapper($search_field => "$id");
79 $client->respond( $rec ) if ($rec);
81 last if ($self->api_name !~ /list$/o);
85 #__PACKAGE__->register_method(
86 #method => 'get_user_record',
87 #api_name => 'open-ils.storage.actor.user.retrieve',
91 #__PACKAGE__->register_method(
92 #method => 'get_user_record',
93 #api_name => 'open-ils.storage.actor.user.search.username',
97 #__PACKAGE__->register_method(
98 #method => 'get_user_record',
99 #api_name => 'open-ils.storage.actor.user.search.userid',
103 #__PACKAGE__->register_method(
104 #method => 'get_user_record',
105 #api_name => 'open-ils.storage.actor.user.retrieve.list',
109 #__PACKAGE__->register_method(
110 #method => 'get_user_record',
111 #api_name => 'open-ils.storage.actor.user.search.username.list',
116 #__PACKAGE__->register_method(
117 #method => 'get_user_record',
118 #api_name => 'open-ils.storage.actor.user.search.userid.list',
124 sub update_user_record {
129 my $rec = actor::user->update($user);
130 return 0 unless ($rec);
133 #__PACKAGE__->register_method(
134 #method => 'update_user_record',
135 #api_name => 'open-ils.storage.actor.user.update',
140 sub delete_record_entry {
145 my $rec = actor::user->delete($user);
146 return 0 unless ($rec);
149 #__PACKAGE__->register_method(
150 #method => 'delete_user_record',
151 #api_name => 'open-ils.storage.actor.user.delete',