1 package OpenILS::Application::Search::Actor;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
4 use OpenILS::Application::AppUtils;
8 __PACKAGE__->register_method(
9 method => "actor_user_search_username",
10 api_name => "open-ils.search.actor.user.search.username",
13 sub actor_user_search_username {
15 my($self, $client, $username) = @_;
17 my $users = OpenILS::Application::AppUtils->simple_scalar_request(
19 "open-ils.storage.direct.actor.user.search.usrname",
26 __PACKAGE__->register_method(
27 method => "actor_user_retrieve_by_barcode",
28 api_name => "open-ils.search.actor.user.barcode",
31 sub actor_user_retrieve_by_barcode {
32 my($self, $client, $barcode) = @_;
33 warn "Searching for user with barcode $barcode\n";
35 my $session = OpenSRF::AppSession->create("open-ils.storage");
37 # find the card with the given barcode
38 my $creq = $session->request(
39 "open-ils.storage.direct.actor.card.search.barcode",
41 my $card = $creq->gather(1);
44 # grab the user with the given card
45 my $ureq = $session->request(
46 "open-ils.storage.direct.actor.user.retrieve",
48 my $user = $ureq->gather(1);
51 my $cards_req = $session->request(
52 "open-ils.storage.direct.actor.card.search.usr",
54 $user->cards( $cards_req->gather(1) );
56 my $add_req = $session->request(
57 "open-ils.storage.direct.actor.user_address.search.usr",
59 $user->addresses( $add_req->gather(1) );
66 __PACKAGE__->register_method(
67 method => "get_org_tree",
68 api_name => "open-ils.search.actor.org_tree.retrieve",
70 note => "Returns the entire org tree structure",
75 my( $self, $client, $user_session ) = @_;
77 if( $user_session ) { # keep for now for backwards compatibility
80 OpenILS::Application::AppUtils->check_user_session( $user_session ); #throws EX on error
82 my $session = OpenSRF::AppSession->create("open-ils.storage");
83 my $request = $session->request(
84 "open-ils.storage.direct.actor.org_unit.retrieve", $user_obj->home_ou );
85 my $response = $request->recv();
88 throw OpenSRF::EX::ERROR (
89 "No response from storage for org_unit retrieve");
91 if(UNIVERSAL::isa($response,"Error")) {
92 throw $response ($response->stringify);
95 my $home_ou = $response->content;
97 $session->disconnect();
102 warn "Getting ORG Tree\n";
103 my $org_tree = OpenILS::Application::AppUtils->get_org_tree();
104 warn "Returning Org Tree\n";
110 __PACKAGE__->register_method(
111 method => "get_org_tree_slim",
112 api_name => "open-ils.search.actor.org_tree.slim.retrieve",
114 note => "Returns the entire org tree structure",
117 sub get_org_tree_slim {
119 my( $self, $client, $user_session ) = @_;
121 warn "Getting ORG Tree\n";
122 my $org_tree = OpenILS::Application::AppUtils->get_slim_org_tree();
123 warn "Returning Org Tree\n";
133 __PACKAGE__->register_method(
134 method => "get_org_types",
135 api_name => "open-ils.search.actor.org_types.retrieve",
139 my($self, $client) = @_;
141 my $org_typelist = OpenILS::Application::AppUtils->simple_scalar_request(
143 "open-ils.storage.direct.actor.org_unit_type.retrieve.all" );
145 return $org_typelist;
149 __PACKAGE__->register_method(
150 method => "get_user_profiles",
151 api_name => "open-ils.search.actor.user.profiles",
154 sub get_user_profiles {
155 return OpenILS::Application::AppUtils->simple_scalar_request(
157 "open-ils.storage.direct.actor.profile.batch.retrieve.atomic",