From 029aa8e0c3576d6f2f77dd8dc02d1d663bf3a6f5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 23 Sep 2020 11:15:22 -0400 Subject: [PATCH] LP1881607 Angular catalog located URIs Display in-range located URIs in the staff catalog record summary pane. Also applies a fix to the staff catalog to clear cached record detail summaries on new searches to ensure the correct org-scoped version of the record summary is retrieved on each new navigation to the detail page. Signed-off-by: Bill Erickson --- .../eg2/src/app/staff/catalog/catalog.service.ts | 3 +++ .../perlmods/lib/OpenILS/Application/AppUtils.pm | 20 ++++++++++++++ .../lib/OpenILS/Application/Search/Biblio.pm | 31 ++++++++++++++-------- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts index a0652744f6..acbb78c3d9 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts @@ -97,6 +97,9 @@ export class StaffCatalogService { search(): void { if (!this.searchContext.isSearchable()) { return; } + // Clear cached detail summary for new searches. + this.currentDetailRecordSummary = null; + const params = this.catUrl.toUrlParams(this.searchContext); // Force a new search every time this method is called, even if diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 04834e20b0..7562078ab8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1533,6 +1533,26 @@ sub get_org_ancestors { return $orgs; } +# Returns an array of org unit shortnames (codes) of ancestor+me orgs. +sub get_org_ancestors_sn { + my($self, $org_id) = @_; + + my $org_list = OpenILS::Utils::CStoreEditor->new->json_query({ + select => { + aou => [{ + transform => 'actor.org_unit_ancestors', + column => 'id', + result_field => 'shortname', + params => [] + }], + }, + from => 'aou', + where => {id => $org_id} + }); + + return [ map { $_->{shortname} } @$org_list ]; +} + sub get_org_full_path { my($self, $org_id, $depth) = @_; 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 8016680154..183d1e151e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2860,6 +2860,7 @@ __PACKAGE__->register_method( signature => { desc => q/Returns bib record 856 URL content./, params => [ + {desc => 'Context org unit ID', type => 'number'}, {desc => 'Record ID or Array of Record IDs', type => 'number or array'} ], return => { @@ -2870,12 +2871,14 @@ __PACKAGE__->register_method( ); sub record_urls { - my ($self, $client, $record_ids) = @_; + my ($self, $client, $org_id, $record_ids) = @_; $record_ids = [$record_ids] unless ref $record_ids eq 'ARRAY'; my $e = new_editor(); + my %uri_orgs = map { lc($_) => 1 } @{$U->get_org_ancestors_sn($org_id)}; + for my $record_id (@$record_ids) { my $bib = $e->retrieve_biblio_record_entry($record_id) or return $e->event; @@ -2889,12 +2892,18 @@ sub record_urls { '//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1")]')) { # asset.uri's - next if $node->findnodes('./*[@code="9" or @code="w" or @code="n"]'); + next if $node->findnodes('./*[@code="w" or @code="n"]'); my $url = {}; my ($label) = $node->findnodes('./*[@code="y"]'); my ($notes) = $node->findnodes('./*[@code="z" or @code="3"]'); + # For located URIs, at least one of the $9 subfield values + # (org unit shortname) must be within our context org unit range. + if (my @orgsns = $node->findnodes('./*[@code="9"]')) { + next unless grep { $uri_orgs{lc($_->textContent)} } @orgsns; + } + my $first = 1; for my $href_node ($node->findnodes('./*[@code="u"]')) { next unless $href_node; @@ -2987,8 +2996,8 @@ sub catalog_record_summary { for my $rec_id (@$record_ids) { my $response = $is_meta ? - get_one_metarecord_summary($self, $e, $rec_id) : - get_one_record_summary($self, $e, $rec_id); + get_one_metarecord_summary($self, $e, $org_id, $rec_id) : + get_one_record_summary($self, $e, $org_id, $rec_id); ($response->{copy_counts}) = $copy_method->run($org_id, $rec_id); @@ -3002,11 +3011,11 @@ sub catalog_record_summary { } sub get_one_rec_urls { - my ($self, $e, $bib_id) = @_; + my ($self, $e, $org_id, $bib_id) = @_; my ($resp) = $self->method_lookup( 'open-ils.search.biblio.record.resource_urls.retrieve') - ->run($bib_id); + ->run($org_id, $bib_id); return $resp->{urls}; } @@ -3014,15 +3023,15 @@ sub get_one_rec_urls { # Start with a bib summary and augment the data with additional # metarecord content. sub get_one_metarecord_summary { - my ($self, $e, $rec_id) = @_; + my ($self, $e, $org_id, $rec_id) = @_; my $meta = $e->retrieve_metabib_metarecord($rec_id) or return {}; my $maps = $e->search_metabib_metarecord_source_map({metarecord => $rec_id}); my $bre_id = $meta->master_record; - my $response = get_one_record_summary($e, $bre_id); - $response->{urls} = get_one_rec_urls($self, $e, $bre_id); + my $response = get_one_record_summary($e, $org_id, $bre_id); + $response->{urls} = get_one_rec_urls($self, $e, $org_id, $bre_id); $response->{metabib_id} = $rec_id; $response->{metabib_records} = [map {$_->source} @$maps]; @@ -3047,7 +3056,7 @@ sub get_one_metarecord_summary { } sub get_one_record_summary { - my ($self, $e, $rec_id) = @_; + my ($self, $e, $org_id, $rec_id) = @_; my $bre = $e->retrieve_biblio_record_entry([$rec_id, { flesh => 1, @@ -3080,7 +3089,7 @@ sub get_one_record_summary { record => $bre, display => $display, attributes => $attributes, - urls => get_one_rec_urls($self, $e, $rec_id) + urls => get_one_rec_urls($self, $e, $org_id, $rec_id) }; } -- 2.11.0