From 57dbda297636895f2b9d715ba868c25a05c5fe9e Mon Sep 17 00:00:00 2001 From: berick Date: Fri, 18 Mar 2011 14:31:07 -0400 Subject: [PATCH] in bib attr (mra) fetcher, get the display label from the ccvm where appropriate and add to response object --- Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index e2b967fa0a..fdf5abc014 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1801,6 +1801,7 @@ sub create_circ_chain_summary { # Returns "mra" attribute key/value pairs for a set of bre's # Takes a list of bre IDs, returns a hash of hashes, # {bre1=> {key1 => value1, key2 => value2, ...}, bre2 => {...}, ...} +my $ccvm_cache; sub get_bre_attrs { my ($class, $bre_ids, $e) = @_; $e = $e || OpenILS::Utils::CStoreEditor->new; @@ -1834,8 +1835,19 @@ sub get_bre_attrs { return $attrs unless $mra; + $ccvm_cache = $ccvm_cache || $e->search_config_coded_value_map({id => {'!=' => undef}}); + for my $id (@$bre_ids) { - $attrs->{$id} = { map {$_->{key} => $_->{value}} grep { $_->{bre} eq $id } @$mra }; + $attrs->{$id} = {}; + for my $mra (grep { $_->{bre} eq $id } @$mra) { + my $ctype = $mra->{key}; + my $code = $mra->{value}; + $attrs->{$id}->{$ctype} = {code => $code}; + if($code) { + my ($ccvm) = grep { $_->ctype eq $ctype and $_->code eq $code } @$ccvm_cache; + $attrs->{$id}->{$ctype}->{label} = $ccvm->value if $ccvm; + } + } } return $attrs; -- 2.11.0