]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
fixing pure-virtual fieldmapper classes and adding retrieve_all for copy_locations
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage / Publisher / asset.pm
1 package OpenILS::Application::Storage::Publisher::asset;
2 use base qw/OpenILS::Application::Storage/;
3 #use OpenILS::Application::Storage::CDBI::asset;
4 #use OpenSRF::Utils::Logger qw/:level/;
5 #use OpenILS::Utils::Fieldmapper;
6 #
7 #my $log = 'OpenSRF::Utils::Logger';
8
9 sub asset_copy_location_all {
10         my $self = shift;
11         my $client = shift;
12
13         for my $rec ( asset::copy_location->retrieve_all ) {
14                 $client->respond( $rec->to_fieldmapper );
15         }
16
17         return undef;
18 }
19 __PACKAGE__->register_method(
20         method          => 'asset_copy_location_all',
21         api_name        => 'open-ils.storage.direct.asset.copy_location.retrieve.all',
22         argc            => 0,
23         stream          => 1,
24 );
25
26 sub fleshed_copy {
27         my $self = shift;
28         my $client = shift;
29         my $id = ''.shift;
30
31         my $cp = asset::copy->retrieve($id);
32
33         my $cp_fm = $cp->to_fieldmapper;
34         $cp_fm->circ_lib( $cp->circ_lib->to_fieldmapper );
35         $cp_fm->location( $cp->location->to_fieldmapper );
36         return $cp_fm;
37 }
38 __PACKAGE__->register_method(
39         api_name        => 'open-ils.storage.fleshed.asset.copy.retrieve',
40         method          => 'fleshed_copy',
41         argc            => 1,
42 );
43
44 sub fleshed_copy_by_barcode {
45         my $self = shift;
46         my $client = shift;
47         my $bc = ''.shift;
48
49         my ($cp) = asset::copy->search( { barcode => $bc } );
50
51         my $cp_fm = $cp->to_fieldmapper;
52         $cp_fm->circ_lib( $cp->circ_lib->to_fieldmapper );
53         $cp_fm->location( $cp->location->to_fieldmapper );
54         $cp_fm->status( $cp->status->to_fieldmapper );
55
56         return [ $cp_fm ];
57 }       
58 __PACKAGE__->register_method(
59         api_name        => 'open-ils.storage.fleshed.asset.copy.search.barcode',
60         method          => 'fleshed_copy_by_barcode',
61         argc            => 1,
62         stream          => 1,
63 );
64
65
66 1;