From f44becacb7548894873b4573b8a5aad48a320dae Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 14 Sep 2011 12:27:45 -0400 Subject: [PATCH 1/1] lp834961: fix authoritative versions of callnumber retrieval calls Makes open-ils.search.callnumber[.fleshed].retrieve.authoritative actually be authoritative. Fixes bug where adding a volume could result in a false ASSET_CALL_NUMBER_NOT_FOUND error if using database replication and Slony-II. Signed-off-by: Galen Charlton Signed-off-by: Lebbeous Fogle-Weekley --- .../lib/OpenILS/Application/AppUtils.pm | 40 +++++-------------- .../lib/OpenILS/Application/Search/Biblio.pm | 8 +++- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index d21a8cc092..d31bc2a99e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -713,41 +713,21 @@ sub fetch_copy_location_by_name { } sub fetch_callnumber { - my( $self, $id, $flesh ) = @_; - my $evt = undef; + my( $self, $id, $flesh, $e ) = @_; + + $e ||= OpenILS::Utils::CStoreEditor->new; - my $e = OpenILS::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id ); - return( undef, $e ) unless $id; + my $evt = OpenILS::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id ); + return( undef, $evt ) unless $id; $logger->debug("Fetching callnumber $id"); - my $cn = $self->simplereq( - 'open-ils.cstore', - 'open-ils.cstore.direct.asset.call_number.retrieve', $id ); - $evt = $e unless $cn; - - if ($flesh && $cn) { - $cn->prefix( - $self->simplereq( - 'open-ils.cstore', - 'open-ils.cstore.direct.asset.call_number_prefix.retrieve', $cn->prefix - ) - ); - $cn->suffix( - $self->simplereq( - 'open-ils.cstore', - 'open-ils.cstore.direct.asset.call_number_suffix.retrieve', $cn->suffix - ) - ); - $cn->label_class( - $self->simplereq( - 'open-ils.cstore', - 'open-ils.cstore.direct.asset.call_number_class.retrieve', $cn->label_class - ) - ); - } + my $cn = $e->retrieve_asset_call_number([ + $id, + { flesh => $flesh, flesh_fields => { acn => [ 'prefix', 'suffix', 'label_class' ] } }, + ]); - return ( $cn, $evt ); + return ( $cn, $e->event ); } my %ORG_CACHE; # - these rarely change, so cache them.. diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 79dec4d7a6..2bc7062eeb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2373,7 +2373,9 @@ __PACKAGE__->register_method( sub fetch_cn { my( $self, $client, $id ) = @_; - my( $cn, $evt ) = $apputils->fetch_callnumber( $id ); + + my $e = new_editor(); + my( $cn, $evt ) = $apputils->fetch_callnumber( $id, 0, $e ); return $evt if $evt; return $cn; } @@ -2387,7 +2389,9 @@ __PACKAGE__->register_method( sub fetch_fleshed_cn { my( $self, $client, $id ) = @_; - my( $cn, $evt ) = $apputils->fetch_callnumber( $id, 1 ); + + my $e = new_editor(); + my( $cn, $evt ) = $apputils->fetch_callnumber( $id, 1, $e ); return $evt if $evt; return $cn; } -- 2.43.2