1 package OpenILS::WWW::EGCatLoader;
2 use strict; use warnings;
3 use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
4 use OpenSRF::Utils::Logger qw/$logger/;
5 use OpenILS::Utils::CStoreEditor qw/:funcs/;
6 use OpenILS::Utils::Fieldmapper;
7 use OpenILS::Application::AppUtils;
8 my $U = 'OpenILS::Application::AppUtils';
14 $self->ctx->{page} = 'record';
16 my $org = $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
17 my $depth = $self->cgi->param('depth') || 0;
18 my $copy_limit = $self->cgi->param('copy_limit');
19 my $copy_offset = $self->cgi->param('copy_offset');
21 my $rec_id = $self->ctx->{page_args}->[0]
22 or return Apache2::Const::HTTP_BAD_REQUEST;
24 # run copy retrieval in parallel to bib retrieval
25 my $copy_rec = OpenSRF::AppSession->create('open-ils.cstore')->request(
26 'open-ils.cstore.json_query.atomic',
27 $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset));
29 $self->ctx->{record} = $self->editor->retrieve_biblio_record_entry($rec_id);
30 $self->ctx->{marc_xml} = XML::LibXML->new->parse_string($self->ctx->{record}->marc);
32 $self->ctx->{copies} = $copy_rec->gather(1);
34 return Apache2::Const::OK;
42 my $copy_limit = shift || 20;
43 my $copy_offset = shift || 0;
47 acp => ['id', 'barcode', 'circ_lib'],
48 acpl => [{column => 'name', alias => 'copy_location'}],
49 ccs => [{column => 'name', alias => 'copy_status'}],
51 {column => 'label', alias => 'call_number_label'},
52 {column => 'id', alias => 'call_number'}
61 circ => {type => 'left'},
70 select => {acn => ['id']},
72 where => {record => $rec_id}
79 transform => 'actor.org_unit_descendants',
88 '+acn' => {deleted => 'f'},
89 '+circ' => {checkin_time => undef}
92 # Order is: copies with circ_lib=org, followed by circ_lib name, followed by call_number label
94 {class => 'aou', field => 'name'},
95 {class => 'acn', field => 'label'}
99 offset => $copy_offset
102 # Filter hidden items if this is the public catalog
103 unless($self->ctx->{is_staff}) {
104 $query->{where}->{'+acp'}->{opac_visible} = 't';
105 $query->{where}->{'+acpl'}->{opac_visible} = 't';
106 $query->{where}->{'+ccs'}->{opac_visible} = 't';
110 #return $self->editor->json_query($query);