1 package OpenILS::Application::Search::Actor;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
4 use OpenILS::Application::AppUtils;
5 my $apputils = "OpenILS::Application::AppUtils";
9 __PACKAGE__->register_method(
10 method => "actor_user_search_username",
11 api_name => "open-ils.search.actor.user.search.username",
14 sub actor_user_search_username {
16 my($self, $client, $username) = @_;
18 my $users = OpenILS::Application::AppUtils->simple_scalar_request(
20 "open-ils.storage.direct.actor.user.search.usrname.atomic",
27 __PACKAGE__->register_method(
28 method => "actor_user_retrieve_by_barcode",
29 api_name => "open-ils.search.actor.user.barcode",
32 sub actor_user_retrieve_by_barcode {
33 my($self, $client, $barcode) = @_;
34 warn "Searching for user with barcode $barcode\n";
36 my $session = OpenSRF::AppSession->create("open-ils.storage");
38 # find the card with the given barcode
39 my $creq = $session->request(
40 "open-ils.storage.direct.actor.card.search.barcode.atomic",
42 my $card = $creq->gather(1);
44 my $user = flesh_user($card->usr(), $session);
45 $session->disconnect();
51 __PACKAGE__->register_method(
52 method => "actor_user_retrieve_by_session",
53 api_name => "open-ils.search.actor.user.session",
56 sub actor_user_retrieve_by_session {
57 my($self, $client, $user_session) = @_;
58 warn "Searching for user with user_session $user_session\n";
59 my $user_obj = $apputils->check_user_session($user_session);
60 my $session = OpenSRF::AppSession->create("open-ils.storage");
61 return flesh_user($user_obj->id);
71 $session = OpenSRF::AppSession->create("open-ils.storage");
75 # grab the user with the given card
76 my $ureq = $session->request(
77 "open-ils.storage.direct.actor.user.retrieve",
79 my $user = $ureq->gather(1);
82 my $cards_req = $session->request(
83 "open-ils.storage.direct.actor.card.search.usr.atomic",
85 $user->cards( $cards_req->gather(1) );
87 my $add_req = $session->request(
88 "open-ils.storage.direct.actor.user_address.search.usr.atomic",
90 $user->addresses( $add_req->gather(1) );
92 if($kill) { $session->disconnect(); }
99 __PACKAGE__->register_method(
100 method => "get_org_tree",
101 api_name => "open-ils.search.actor.org_tree.retrieve",
103 note => "Returns the entire org tree structure",
108 my( $self, $client, $user_session ) = @_;
111 if( $user_session ) { # keep for now for backwards compatibility
114 OpenILS::Application::AppUtils->check_user_session( $user_session ); #throws EX on error
116 my $session = OpenSRF::AppSession->create("open-ils.storage");
117 my $request = $session->request(
118 "open-ils.storage.direct.actor.org_unit.retrieve", $user_obj->home_ou );
119 my $response = $request->recv();
122 throw OpenSRF::EX::ERROR (
123 "No response from storage for org_unit retrieve");
125 if(UNIVERSAL::isa($response,"Error")) {
126 throw $response ($response->stringify);
129 my $home_ou = $response->content;
131 $session->disconnect();
137 warn "Getting ORG Tree\n";
138 my $org_tree = OpenILS::Application::AppUtils->get_org_tree();
139 warn "Returning Org Tree\n";
145 __PACKAGE__->register_method(
146 method => "get_org_tree_slim",
147 api_name => "open-ils.search.actor.org_tree.slim.retrieve",
149 note => "Returns the entire org tree structure",
152 sub get_org_tree_slim {
153 my( $self, $client, $user_session ) = @_;
154 warn "Getting ORG Tree\n";
155 warn "Call: " . $self->api_name() . "\n";
156 return OpenILS::Application::AppUtils->get_slim_org_tree();
164 __PACKAGE__->register_method(
165 method => "get_org_types",
166 api_name => "open-ils.search.actor.org_types.retrieve",
170 my($self, $client) = @_;
172 my $org_typelist = OpenILS::Application::AppUtils->simple_scalar_request(
174 "open-ils.storage.direct.actor.org_unit_type.retrieve.all.atomic" );
176 return $org_typelist;
180 __PACKAGE__->register_method(
181 method => "get_user_profiles",
182 api_name => "open-ils.search.actor.user.profiles.retrieve",
184 sub get_user_profiles {
185 return OpenILS::Application::AppUtils->simple_scalar_request(
187 "open-ils.storage.direct.actor.profile.retrieve.all.atomic",
193 __PACKAGE__->register_method(
194 method => "get_user_ident_types",
195 api_name => "open-ils.search.actor.user.ident_types.retrieve",
197 sub get_user_ident_types {
198 return OpenILS::Application::AppUtils->simple_scalar_request(
200 "open-ils.storage.direct.config.identification_type.retrieve.all.atomic" );
206 __PACKAGE__->register_method(
207 method => "get_org_unit",
208 api_name => "open-ils.search.actor.org_unit.retrieve",
210 note => "Returns the entire org tree structure",
215 my( $self, $client, $user_session ) = @_;
218 OpenILS::Application::AppUtils->check_user_session( $user_session ); #throws EX on error
220 my $home_ou = OpenILS::Application::AppUtils->simple_scalar_request(
222 "open-ils.storage.direct.actor.org_unit.retrieve",
223 $user_obj->home_ou );