From 5d48f63a21766d67c5c8254821ae0f1cbbeeac1e Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 4 Mar 2009 02:16:38 +0000 Subject: [PATCH] indent cleanup and guarding against the no-URI-cns case git-svn-id: svn://svn.open-ils.org/ILS/trunk@12392 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Ingest.pm | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm b/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm index 193f018364..db10f1c845 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm @@ -116,39 +116,41 @@ use base qw/OpenILS::Application::Ingest/; use Unicode::Normalize; sub rw_biblio_ingest_single_object { - my $self = shift; - my $client = shift; - my $bib = shift; + my $self = shift; + my $client = shift; + my $bib = shift; - my ($blob) = $self->method_lookup("open-ils.ingest.full.biblio.object.readonly")->run($bib); - return undef unless ($blob); + my ($blob) = $self->method_lookup("open-ils.ingest.full.biblio.object.readonly")->run($bib); + return undef unless ($blob); - $bib->fingerprint( $blob->{fingerprint}->{fingerprint} ); - $bib->quality( $blob->{fingerprint}->{quality} ); + $bib->fingerprint( $blob->{fingerprint}->{fingerprint} ); + $bib->quality( $blob->{fingerprint}->{quality} ); - my $cstore = OpenSRF::AppSession->connect('open-ils.cstore'); + my $cstore = OpenSRF::AppSession->connect('open-ils.cstore'); - my $xact = $cstore->request('open-ils.cstore.transaction.begin')->gather(1); + my $xact = $cstore->request('open-ils.cstore.transaction.begin')->gather(1); my $tmp; - # update uri stuff ... + # update uri stuff ... # gather URI call numbers for this record my $uri_cns = $u->{call_number} = $cstore->request( 'open-ils.cstore.direct.asset.call_number.id_list.atomic' => { record => $bib->id, label => '##URI##' } )->gather(1); - # gather the maps for those call numbers - my $uri_maps = $u->{call_number} = $cstore->request( - 'open-ils.cstore.direct.asset.uri_call_number_map.id_list.atomic' => { call_number => $uri_cns } - )->gather(1); - - # delete the old maps - $cstore->request( 'open-ils.cstore.direct.asset.uri_call_number_map.delete' => $_ )->gather(1) for (@$uri_maps); - - # and delete the call numbers if there are no more URIs - if (!@{ $blob->{uri} }) { - $cstore->request( 'open-ils.cstore.direct.asset.call_number.delete' => $_ )->gather(1) for (@$uri_cns); + if (@$uri_cns) { + # gather the maps for those call numbers + my $uri_maps = $u->{call_number} = $cstore->request( + 'open-ils.cstore.direct.asset.uri_call_number_map.id_list.atomic' => { call_number => $uri_cns } + )->gather(1); + + # delete the old maps + $cstore->request( 'open-ils.cstore.direct.asset.uri_call_number_map.delete' => $_ )->gather(1) for (@$uri_maps); + + # and delete the call numbers if there are no more URIs + if (!@{ $blob->{uri} }) { + $cstore->request( 'open-ils.cstore.direct.asset.call_number.delete' => $_ )->gather(1) for (@$uri_cns); + } } # now, add CNs, URIs and maps -- 2.43.2