1 package OpenILS::Application::Storage::Publisher::biblio;
2 use base qw/OpenILS::Application::Storage/;
4 use OpenSRF::EX qw/:try/;
5 use OpenILS::Application::Storage::CDBI::biblio;
6 use OpenILS::Application::Storage::CDBI::asset;
7 use OpenILS::Utils::Fieldmapper;
12 sub record_copy_count {
18 if ($self->api_name !~ /batch/o) {
22 throw OpenSRF::EX::InvalidArg ( "No org_unit id passed!" )
25 throw OpenSRF::EX::InvalidArg ( "No record id passed!" )
28 $org_unit_lookup ||= $self->method_lookup('open-ils.storage.direct.actor.org_unit.retrieve');
29 my ($org_unit) = $org_unit_lookup->run($oid);
31 # XXX Use descendancy tree here!!!
32 my $short_name_hack = $org_unit->shortname;
33 $short_name_hack = '' if (!$org_unit->parent_ou);
34 $short_name_hack .= '%';
35 # XXX Use descendancy tree here!!!
37 my $rec_list = join(',',@recs);
39 my $cp_table = asset::copy->table;
40 my $cn_table = asset::call_number->table;
43 SELECT cn.record as record, count(cp.*) as copies
45 JOIN $cp_table cp ON (cp.call_number = cn.id)
46 WHERE cn.owning_lib LIKE ? AND
47 cn.record IN ($rec_list)
51 my $sth = asset::copy->db_Main->prepare_cached($select);
52 $sth->execute($short_name_hack);
54 my $results = $sth->fetchall_hashref('record');
56 $client->respond($$results{$_}{copies} || 0) for (@recs);
60 __PACKAGE__->register_method(
61 method => 'record_copy_count',
62 api_name => 'open-ils.storage.direct.biblio.record_copy_count',
66 __PACKAGE__->register_method(
67 method => 'record_copy_count',
68 api_name => 'open-ils.storage.direct.biblio.record_copy_count.batch',