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 $client->respond( $card->usr->to_fieldmapper);
24 __PACKAGE__->register_method(
25 api_name => 'open-ils.storage.direct.actor.user.search.barcode',
27 method => 'user_by_barcode',
32 =comment not gonna use it...
39 return undef unless (defined $searches);
41 for my $usr ( actor::user->search( $searches ) ) {
43 $client->respond( flesh_user( $usr ) );
47 __PACKAGE__->register_method(
48 api_name => 'open-ils.storage.fleshed.actor.user.search',
50 method => 'fleshed_search',
55 sub fleshed_search_like {
60 return undef unless (defined $searches);
62 for my $usr ( actor::user->search_like( $searches ) ) {
64 $client->respond( flesh_user( $usr ) );
68 __PACKAGE__->register_method(
69 api_name => 'open-ils.storage.fleshed.actor.user.search_like',
71 method => 'user_by_barcode',
76 sub retrieve_fleshed_user {
81 return undef unless @ids;
83 @ids = ($ids[0]) unless ($self->api_name =~ /batch/o);
85 $client->respond( flesh_user( actor::user->retrieve( $_ ) ) ) for ( @ids );
89 __PACKAGE__->register_method(
90 api_name => 'open-ils.storage.fleshed.actor.user.retrieve',
92 method => 'retrieve_fleshed_user',
95 __PACKAGE__->register_method(
96 api_name => 'open-ils.storage.fleshed.actor.user.batch.retrieve',
98 method => 'retrieve_fleshed_user',
107 my $standing = $usr->standing;
108 my $profile = $usr->profile;
109 my $ident_type = $usr->ident_type;
111 my $maddress = $usr->mailing_address;
112 my $baddress = $usr->billing_address;
113 my $card = $usr->card;
115 my @addresses = $usr->addresses;
116 my @cards = $usr->cards;
118 my $usr_fm = $usr->to_fieldmapper;
119 $usr_fm->standing( $standing->to_fieldmapper );
120 $usr_fm->profile( $profile->to_fieldmapper );
121 $usr_fm->ident_type( $ident_type->to_fieldmapper );
123 $usr_fm->card( $card->to_fieldmapper );
124 $usr_fm->mailing_address( $maddress->to_fieldmapper ) if ($maddress);
125 $usr_fm->billing_address( $baddress->to_fieldmapper ) if ($baddress);
127 $usr_fm->cards( [ map { $_->to_fieldmapper } @cards ] );
128 $usr_fm->addresses( [ map { $_->to_fieldmapper } @addresses ] );
139 my $select =<<" SQL";
142 ORDER BY CASE WHEN parent_ou IS NULL THEN 0 ELSE 1 END, name;
145 my $sth = actor::org_unit->db_Main->prepare_cached($select);
149 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
153 __PACKAGE__->register_method(
154 api_name => 'open-ils.storage.direct.actor.org_unit.retrieve.all',
156 method => 'org_unit_list',
159 sub org_unit_type_list {
163 my $select =<<" SQL";
165 FROM actor.org_unit_type
166 ORDER BY depth, name;
169 my $sth = actor::org_unit_type->db_Main->prepare_cached($select);
173 push @fms, $_->to_fieldmapper for ( map { actor::org_unit_type->construct($_) } $sth->fetchall_hash );
177 __PACKAGE__->register_method(
178 api_name => 'open-ils.storage.direct.actor.org_unit_type.retrieve.all',
180 method => 'org_unit_type_list',
183 sub org_unit_descendants {
188 return undef unless ($id);
190 my $select =<<" SQL";
192 FROM connectby('actor.org_unit','id','parent_ou','name',?,'100','.')
193 as t(keyid text, parent_keyid text, level int, branch text,pos int),
199 my $sth = actor::org_unit->db_Main->prepare_cached($select);
203 push @fms, $_->to_fieldmapper for ( map { actor::org_unit->construct($_) } $sth->fetchall_hash );
207 __PACKAGE__->register_method(
208 api_name => 'open-ils.storage.actor.org_unit.descendants',
210 method => 'org_unit_descendants',