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 @barcodes;
16 for my $card ( actor::card->search( { barcode => @barcodes } ) ) {
20 my $usr_fm = flesh_user( $card->usr );
21 $client->respond( $usr_fm );
25 __PACKAGE__->register_method(
26 api_name => 'open-ils.storage.fleshed.actor.user.search.barcode',
28 method => 'user_by_barcode',
38 return undef unless (defined $searches);
40 for my $usr ( actor::user->search( $searches ) ) {
42 $client->respond( flesh_user( $usr ) );
46 __PACKAGE__->register_method(
47 api_name => 'open-ils.storage.fleshed.actor.user.search',
49 method => 'fleshed_search',
54 sub fleshed_search_like {
59 return undef unless (defined $searches);
61 for my $usr ( actor::user->search_like( $searches ) ) {
63 $client->respond( flesh_user( $usr ) );
67 __PACKAGE__->register_method(
68 api_name => 'open-ils.storage.fleshed.actor.user.search_like',
70 method => 'user_by_barcode',
75 sub retrieve_fleshed_user {
80 return undef unless @ids;
82 @ids = ($ids[0]) unless ($self->api_name =~ /batch/o);
84 $client->respond( flesh_user( actor::user->retrieve( $_ ) ) ) for ( @ids );
88 __PACKAGE__->register_method(
89 api_name => 'open-ils.storage.fleshed.actor.user.retrieve',
91 method => 'retrieve_fleshed_user',
94 __PACKAGE__->register_method(
95 api_name => 'open-ils.storage.fleshed.actor.user.batch.retrieve',
97 method => 'retrieve_fleshed_user',
106 my $standing = $usr->standing;
107 my $profile = $usr->profile;
108 my $ident_type = $usr->ident_type;
110 my $address = $usr->address;
111 my $card = $usr->card;
113 my @addresses = $usr->addresses;
114 my @cards = $usr->cards;
116 my $usr_fm = $usr->to_fieldmapper;
117 $usr_fm->standing( $standing->to_fieldmapper );
118 $usr_fm->profile( $profile->to_fieldmapper );
119 $usr_fm->ident_type( $ident_type->to_fieldmapper );
121 $usr_fm->card( $card->to_fieldmapper );
122 $usr_fm->address( $address->to_fieldmapper ) if ($address);
124 $usr_fm->cards( [ map { $_->to_fieldmapper } @cards ] );
125 $usr_fm->addresses( [ map { $_->to_fieldmapper } @addresses ] );
134 my $select =<<" SQL";
137 ORDER BY CASE WHEN parent_ou IS NULL THEN 0 ELSE 1 END, name;
140 my $sth = actor::org_unit->db_Main->prepare_cached($select);
144 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
148 __PACKAGE__->register_method(
149 api_name => 'open-ils.storage.direct.actor.org_unit.retrieve.all',
151 method => 'org_unit_list',
154 sub org_unit_type_list {
158 my $select =<<" SQL";
160 FROM actor.org_unit_type
161 ORDER BY depth, name;
164 my $sth = actor::org_unit_type->db_Main->prepare_cached($select);
168 push @fms, $_->to_fieldmapper for ( map { actor::org_unit_type->construct($_) } $sth->fetchall_hash );
172 __PACKAGE__->register_method(
173 api_name => 'open-ils.storage.direct.actor.org_unit_type.retrieve.all',
175 method => 'org_unit_type_list',
178 sub org_unit_descendants {
183 return undef unless ($id);
185 my $select =<<" SQL";
187 FROM connectby('actor.org_unit','id','parent_ou','name',?,'100','.')
188 as t(keyid text, parent_keyid text, level int, branch text,pos int),
194 my $sth = actor::org_unit->db_Main->prepare_cached($select);
198 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
202 __PACKAGE__->register_method(
203 api_name => 'open-ils.storage.actor.org_unit.descendants',
205 method => 'org_unit_descendants',