lp834961: fix authoritative versions of callnumber retrieval calls
authorGalen Charlton <gmc@esilibrary.com>
Wed, 14 Sep 2011 16:27:45 +0000 (12:27 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 14 Sep 2011 17:01:05 +0000 (13:01 -0400)
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 <gmc@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index d21a8cc..d31bc2a 100644 (file)
@@ -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..
index 79dec4d..2bc7062 100644 (file)
@@ -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;
 }