From efe7146a21e35ad51a7a771e8876fa7883a24c22 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 20 Jan 2014 15:45:47 -0500 Subject: [PATCH] Revert "LP#1053397 remove deprecated AC key lookup" Rolling back MR detail page for now This reverts commit 5bf50a33a02e3758ea6e2483f8dccdcc2f4dbb41. --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 49 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 2a68c0e92a..d633c6f893 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -496,6 +496,8 @@ sub added_content_stage1 { my $rec_id = shift; my $ctx = $self->ctx; my $sel_type = $self->cgi->param('ac') || ''; + my $key = $self->get_ac_key($rec_id); + ($key = $key->{value}) =~ s/^\s+//g if $key; # Connect to this machine's IP address, using the same # Host with which our caller used to connect to us. @@ -511,10 +513,10 @@ sub added_content_stage1 { for my $type (@$ac_types) { last if $ac_failed; $ctx->{added_content}->{$type} = {content => ''}; - $ctx->{added_content}->{$type}->{status} = $rec_id ? 3 : 2; + $ctx->{added_content}->{$type}->{status} = $key ? 3 : 2; - if ($rec_id) { - $logger->debug("tpac: starting added content request for $rec_id => $type"); + if ($key) { + $logger->debug("tpac: starting added content request for $key => $type"); # Net::HTTP::NB is non-blocking /after/ the initial connect() # Passing Timeout=>1 ensures we wait no longer than 1 second to @@ -525,7 +527,7 @@ sub added_content_stage1 { my $req = Net::HTTP::NB->new(Host => $ac_addr, Timeout => 1); if (!$req) { $logger->warn("Unable to connect to $ac_addr / $ac_host". - " for added content lookup for $rec_id: $@"); + " for added content lookup for $key: $@"); $ac_failed = 1; next; } @@ -533,8 +535,7 @@ sub added_content_stage1 { $req->host($self->apache->hostname); my $http_type = ($type eq $sel_type) ? 'GET' : 'HEAD'; - $req->write_request($http_type => - "/opac/extras/ac/$type/html/r/$rec_id"); + $req->write_request($http_type => "/opac/extras/ac/$type/html/" . uri_escape_utf8($key)); $ctx->{added_content}->{$type}->{request} = $req; } } @@ -581,6 +582,42 @@ sub added_content_stage2 { } } +# XXX this is copied directly from AddedContent.pm in +# working/user/jeff/ac_by_record_id_rebase. When Jeff's +# branch is merged and Evergreen gets added content +# lookup by ID, this can be removed. +# returns [{tag => $tag, value => $value}, {tag => $tag2, value => $value2}] +sub get_ac_key { + my $self = shift; + my $rec_id = shift; + my $key_data = $self->editor->json_query({ + select => {mfr => ['tag', 'value']}, + from => 'mfr', + where => { + record => $rec_id, + '-or' => [ + { + '-and' => [ + {tag => '020'}, + {subfield => 'a'} + ] + }, { + '-and' => [ + {tag => '024'}, + {subfield => 'a'}, + {ind1 => 1} + ] + } + ] + } + }); + + return ( + grep {$_->{tag} eq '020'} @$key_data, + grep {$_->{tag} eq '024'} @$key_data + )[0]; +} + sub load_metarecord { my $self = shift; my %kwargs = @_; -- 2.11.0