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';
14 return undef unless ($id);
19 ORDER BY CASE WHEN parent_ou IS NULL THEN 0 ELSE 1 END, name;
22 my $sth = actor::org_unit->db_Main->prepare_cached($select);
26 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
30 __PACKAGE__->register_method(
31 api_name => 'open-ils.storage.actor.org_unit_list',
33 method => 'org_unit_list',
36 sub org_unit_descendants {
41 return undef unless ($id);
45 FROM connectby('actor.org_unit','id','parent_ou','name',?,'100','.')
46 as t(keyid text, parent_keyid text, level int, branch text,pos int),
52 my $sth = actor::org_unit->db_Main->prepare_cached($select);
56 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
60 __PACKAGE__->register_method(
61 api_name => 'open-ils.storage.actor.org_unit_descendants',
63 method => 'org_unit_descendants',
72 my $search_field = 'id';
73 $search_field = 'usrname' if ($self->api_name =~/userid/o);
74 $search_field = 'usrname' if ($self->api_name =~/username/o);
79 $log->debug("Searching for $id using ".$self->api_name, DEBUG);
81 my ($rec) = actor::user->fast_fieldmapper($search_field => "$id");
82 $client->respond( $rec ) if ($rec);
84 last if ($self->api_name !~ /list$/o);
88 #__PACKAGE__->register_method(
89 #method => 'get_user_record',
90 #api_name => 'open-ils.storage.actor.user.retrieve',
94 #__PACKAGE__->register_method(
95 #method => 'get_user_record',
96 #api_name => 'open-ils.storage.actor.user.search.username',
100 #__PACKAGE__->register_method(
101 #method => 'get_user_record',
102 #api_name => 'open-ils.storage.actor.user.search.userid',
106 #__PACKAGE__->register_method(
107 #method => 'get_user_record',
108 #api_name => 'open-ils.storage.actor.user.retrieve.list',
112 #__PACKAGE__->register_method(
113 #method => 'get_user_record',
114 #api_name => 'open-ils.storage.actor.user.search.username.list',
119 #__PACKAGE__->register_method(
120 #method => 'get_user_record',
121 #api_name => 'open-ils.storage.actor.user.search.userid.list',
127 sub update_user_record {
132 my $rec = actor::user->update($user);
133 return 0 unless ($rec);
136 #__PACKAGE__->register_method(
137 #method => 'update_user_record',
138 #api_name => 'open-ils.storage.actor.user.update',
143 sub delete_record_entry {
148 my $rec = actor::user->delete($user);
149 return 0 unless ($rec);
152 #__PACKAGE__->register_method(
153 #method => 'delete_user_record',
154 #api_name => 'open-ils.storage.actor.user.delete',