From 980e0784b3644bee378418b546531c8f31771047 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 18 Jun 2010 19:40:14 +0000 Subject: [PATCH] add serials holdings to the holdings_xml data for bibs git-svn-id: svn://svn.open-ils.org/ILS/trunk@16765 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 24 +- .../src/perlmods/OpenILS/Application/SuperCat.pm | 416 ++++++++++++++++++++- 2 files changed, 437 insertions(+), 3 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index e2dffce7cf..7d6ffa8367 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3048,10 +3048,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + @@ -3068,6 +3074,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + @@ -3077,6 +3087,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + @@ -3087,9 +3101,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -3125,11 +3141,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -3175,6 +3193,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -3191,6 +3210,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -3209,6 +3229,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -3217,6 +3238,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -3230,7 +3252,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm index 144095e7cd..7aec0ad679 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm @@ -1208,7 +1208,7 @@ sub new_record_holdings { $year += 1900; $month += 1; - $client->respond("\n"); + $client->respond("\n"); for my $cn (@$cns) { next unless (@{$cn->copies} > 0 or (ref($cn->uri_maps) and @{$cn->uri_maps})); @@ -1223,7 +1223,66 @@ sub new_record_holdings { ); } - return "\n"; + $client->respond("\n"); + + $logger->info("Searching for serial holdings at orgs [".join(',',@ou_ids)."], based on $ou"); + + %subselect = ( '-or' => [ + { owning_lib => \@ou_ids }, + { '-exists' => + { from => 'sdist', + where => { holding_lib => \@ou_ids } + } + } + ]); + + my $ssubs = $_storage->request( + "open-ils.cstore.direct.serial.subscription.search.atomic", + { record_entry => $bib, + %subselect + }, + { flesh => 5, + flesh_fields => { + ssub => [qw/sdist siss sercap/], + sdist => [qw/bib_summaries sup_summaries index_summaries streams/], + sstr => [qw/items/], + sitem => [qw/notes unit/], + }, + ( $limit > -1 ? ( limit => $limit ) : () ), + ( $offset ? ( offset => $offset ) : () ), + order_by => { + ssub => { + start_date => {}, + owning_lib => {}, + id => {} + }, + sdist => { + label => {}, + owning_lib => {}, + }, + sunit => { + date_expected => {}, + } + } + } + )->gather(1); + + + for my $ssub (@$ssubs) { + next unless (@{$ssub->distributions} or @{$ssub->issuances} or @{$ssub->captions_and_patterns}); + + # We don't want O:A:S:unAPI::ssub to return the record, we've got that already + # In the context of BibTemplate, copies aren't necessary because we pull those + # in a separate call + $client->respond( + OpenILS::Application::SuperCat::unAPI::ssub + ->new( $ssub ) + ->as_xml( {no_record => 1, no_items => ($flesh ? 0 : 1)} ) + ); + } + + + return "\n"; } __PACKAGE__->register_method( method => 'new_record_holdings', @@ -2087,6 +2146,359 @@ sub as_xml { return $xml; } +package OpenILS::Application::SuperCat::unAPI::ssub; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' obj->id . '" '; + $xml .= 'start="' . $self->escape( $self->obj->start_date ) . '" '; + $xml .= 'end="' . $self->escape( $self->obj->end_date ) . '" '; + $xml .= 'expected_date_offset="' . $self->escape( $self->obj->expected_date_offset ) . '">'; + $xml .= "\n"; + + if (!$args->{no_distributions}) { + if (ref($self->obj->distributions) && @{ $self->obj->distributions }) { + $xml .= " \n" . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_subscription=>1, no_issuance=>1 }) + } @{ $self->obj->distributions } + ) . " \n"; + + } else { + $xml .= " \n"; + } + } + + if (!$args->{no_captions_and_patterns}) { + if (ref($self->obj->captions_and_patterns) && @{ $self->obj->captions_and_patterns }) { + $xml .= " \n" . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_subscription=>1 }) + } @{ $self->obj->captions_and_patterns } + ) . " \n"; + + } else { + $xml .= " \n"; + } + } + + if (!$args->{no_issuances}) { + if (ref($self->obj->issuances) && @{ $self->obj->issuances }) { + $xml .= " \n" . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_subscription=>1, no_items=>1 }) + } @{ $self->obj->issuances } + ) . " \n"; + + } else { + $xml .= " \n"; + } + } + + + $xml .= ' obj->owning_lib->id . '" '; + $xml .= 'shortname="'.$self->escape( $self->obj->owning_lib->shortname ) .'" '; + $xml .= 'name="'.$self->escape( $self->obj->owning_lib->name ) .'"/>'; + $xml .= "\n"; + + unless ($args->{no_record}) { + my $rec_tag = "tag:open-ils.org:biblio-record_entry/".$self->obj->record->id.'/'.$self->escape( $self->obj->owning_lib->shortname ) ; + + my $r_doc = $parser->parse_string($self->obj->record_entry->marc); + $r_doc->documentElement->setAttribute( id => $rec_tag ); + $xml .= $U->entityize($r_doc->documentElement->toString); + } + + $xml .= " \n"; + + return $xml; +} + +package OpenILS::Application::SuperCat::unAPI::sdist; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' obj->id . '" '; + $xml .= 'label="' . $self->escape( $self->obj->label ) . '" '; + $xml .= 'unit_label_base="' . $self->escape( $self->obj->unit_label_base ) . '" '; + $xml .= 'unit_label_suffix="' . $self->escape( $self->obj->unit_label_suffix ) . '">'; + $xml .= "\n"; + + if (!$args->{no_distributions}) { + if (ref($self->obj->distributions) && @{ $self->obj->distributions }) { + $xml .= " \n" . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_distribution=>1 }) + } @{ $self->obj->streams } + ) . " \n"; + + } else { + $xml .= " \n"; + } + } + + if (!$args->{no_summaries}) { + $xml .= " \n"; + if (ref($self->obj->bib_summaries) && @{ $self->obj->bib_summaries }) { + $xml .= join ('', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_distribution=>1 }) + } ( @{ $self->obj->bib_summaries }, @{ $self->obj->sup_summaries }, @{ $self->obj->index_summaries } ) + ); + + } + $xml .= " \n"; + } + + + $xml .= ' obj->owning_lib->id . '" '; + $xml .= 'shortname="'.$self->escape( $self->obj->owning_lib->shortname ) .'" '; + $xml .= 'name="'.$self->escape( $self->obj->owning_lib->name ) .'"/>'; + $xml .= "\n"; + + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->subscription )->as_xml({ %$args, no_distributions=>1 }) if (!$args->{no_subscription}); + + if (!$args->{no_record} && $self->obj->record_entry) { + my $rec_tag = "tag:open-ils.org:serial-record_entry/".$self->obj->record->id ; + + my $r_doc = $parser->parse_string($self->obj->record_entry->marc); + $r_doc->documentElement->setAttribute( id => $rec_tag ); + $xml .= $U->entityize($r_doc->documentElement->toString); + } + + $xml .= " \n"; + + return $xml; +} + +package OpenILS::Application::SuperCat::unAPI::sstr; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' obj->id . '" '; + $xml .= 'routing_label="' . $self->escape( $self->obj->routing_label ) . '">'; + $xml .= "\n"; + + if (!$args->{no_items}) { + if (ref($self->obj->items) && @{ $self->obj->items }) { + $xml .= " \n" . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_stream=>1 }) + } @{ $self->obj->items } + ) . " \n"; + + } else { + $xml .= " \n"; + } + } + + #XXX routing_list_user's? + + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->distribution )->as_xml({ %$args, no_streams=>1 }) if (!$args->{no_distribution}); + + $xml .= " \n"; + + return $xml; +} + +package OpenILS::Application::SuperCat::unAPI::sitem; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' obj->id . '" '; + $xml .= 'date_expected="' . $self->escape( $self->obj->date_expected ) . '"'; + $xml .= ' date_received="' . $self->escape( $self->obj->date_received ) .'"'if ($self->obj->date_received); + + if ($args->{no_issuance}) { + my $siss = ref($self->obj->issuance) ? $self->obj->issuance->id : $self->obj->issuance; + $xml .= ' issuance="tag:open-ils.org:serial-issuance/' . $siss . '"'; + } + + $xml .= ">\n"; + + if (ref($self->obj->notes) && $self->obj->notes) { + $xml .= " \n"; + for my $note ( @{$self->obj->notes} ) { + next unless ( $note->pub eq 't' ); + $xml .= sprintf(' %s',$note->create_date, $self->escape($note->title), $self->escape($note->value)); + $xml .= "\n"; + } + $xml .= " \n"; + } else { + $xml .= " \n"; + } + + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->issuance )->as_xml({ %$args, no_items=>1 }) if (!$args->{no_issuance}); + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->stream )->as_xml({ %$args, no_items=>1 }) if (!$args->{no_stream}); + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->unit )->as_xml({ %$args, no_items=>1, no_volumes=>1 }) if (!$args->{no_unit}); + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->uri )->as_xml({ %$args, no_items=>1, no_volumes=>1 }) if (!$args->{no_uri}); + + $xml .= " \n"; + + return $xml; +} + +package OpenILS::Application::SuperCat::unAPI::sunit; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' obj->status->id . '">' . $self->escape( $self->obj->status->name ) . "\n"; + $xml .= ' ' . $self->escape( $self->obj->location->name ) . "\n"; + $xml .= ' ' . $self->escape( $self->obj->circ_lib->name ) . "\n"; + + $xml .= ' obj->circ_lib->id . '" '; + $xml .= 'shortname="'.$self->escape( $self->obj->circ_lib->shortname ) .'" '; + $xml .= 'name="'.$self->escape( $self->obj->circ_lib->name ) .'"/>'; + $xml .= "\n"; + + $xml .= " \n"; + if (ref($self->obj->notes) && $self->obj->notes) { + for my $note ( @{$self->obj->notes} ) { + next unless ( $note->pub eq 't' ); + $xml .= sprintf(' %s',$note->create_date, $self->escape($note->title), $self->escape($note->value)); + $xml .= "\n"; + } + } + + $xml .= " \n"; + $xml .= " \n"; + + if (ref($self->obj->stat_cat_entries) && $self->obj->stat_cat_entries) { + for my $sce ( @{$self->obj->stat_cat_entries} ) { + next unless ( $sce->stat_cat->opac_visible eq 't' ); + $xml .= sprintf(' %s',$self->escape($sce->stat_cat->name) ,$self->escape($sce->value)); + $xml .= "\n"; + } + } + $xml .= " \n"; + + unless ($args->{no_volume}) { + if (ref($self->obj->call_number)) { + $xml .= OpenILS::Application::SuperCat::unAPI + ->new( $self->obj->call_number ) + ->as_xml({ %$args, no_copies=>1 }); + } else { + $xml .= " \n"; + } + } + + $xml .= " \n"; + + return $xml; +} + +package OpenILS::Application::SuperCat::unAPI::sercap; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' new( $self->obj->subscription )->as_xml({ %$args, no_captions_and_patterns=>1 }) if (!$args->{no_subscription}); + $xml .= " \n"; + + return $xml; +} + +package OpenILS::Application::SuperCat::unAPI::siss; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = ' {no_items}) { + if (ref($self->obj->items) && @{ $self->obj->items }) { + $xml .= " \n" . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_ ) + ->as_xml({ %$args, no_stream=>1 }) + } @{ $self->obj->items } + ) . " \n"; + + } else { + $xml .= " \n"; + } + } + + $xml .= OpenILS::Application::SuperCat::unAPI->new( $self->obj->subscription )->as_xml({ %$args, no_issuances=>1 }) if (!$args->{no_subscription}); + $xml .= " \n"; + + return $xml; +} + package OpenILS::Application::SuperCat::unAPI::acp; use base qw/OpenILS::Application::SuperCat::unAPI/; -- 2.11.0