From: Bill Erickson Date: Wed, 23 Sep 2020 15:15:22 +0000 (-0400) Subject: LP1881607 Angular catalog located URIs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2c46e2b965e37a322fc7f0c2bf804cd8a809d572;p=evergreen%2Ftadl.git 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 Signed-off-by: Elaine Hardy Signed-off-by: Jane Sandberg --- 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 5ed26d48db..081135c37b 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 @@ -113,6 +113,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/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 06d695a807..03ae377616 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2937,6 +2937,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 => { @@ -2947,21 +2948,34 @@ __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(); for my $record_id (@$record_ids) { + + my @urls; + + # Start with scoped located URIs + my $uris = $e->json_query({ + from => ['evergreen.located_uris_as_uris', $record_id, $org_id]}); + + for my $uri (@$uris) { + push(@urls, { + href => $uri->{href}, + label => $uri->{label}, + note => $uri->{use_restriction} + }); + } + + # Logic copied from TPAC misc_utils.tts my $bib = $e->retrieve_biblio_record_entry($record_id) or return $e->event; my $marc_doc = $U->marc_xml_to_doc($bib->marc); - # Logic copied from TPAC misc_utils.tts - my @urls; - for my $node ($marc_doc->findnodes( '//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1")]')) { @@ -3064,8 +3078,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); @@ -3079,11 +3093,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}; } @@ -3091,15 +3105,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]; @@ -3124,7 +3138,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, @@ -3157,7 +3171,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) }; } diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql index 9c334c8acc..f36ddd7eed 100644 --- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql +++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql @@ -1775,6 +1775,21 @@ BEGIN END; $F$ LANGUAGE PLPGSQL STABLE; +-- note not adding a companion version which takes an int[] as +-- the first arument, similar to evergreen.located_uris(), because +-- json_query is unable to distinguish between the type of paramaters, +-- leading to 'Could not choose a best candidate function' errors. +CREATE OR REPLACE FUNCTION evergreen.located_uris_as_uris + (bibid BIGINT, ouid INT, pref_lib INT DEFAULT NULL) + RETURNS SETOF asset.uri AS $FUNK$ + /* Maps a bib directly to its scoped asset.uri's */ + + SELECT uri.* + FROM evergreen.located_uris($1, $2, $3) located_uri + JOIN asset.uri_call_number_map map ON (map.call_number = located_uri.id) + JOIN asset.uri uri ON (uri.id = map.uri) +$FUNK$ LANGUAGE SQL STABLE; + /* diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.located-uris-shortcut.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.located-uris-shortcut.sql new file mode 100644 index 0000000000..a89fa9c402 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.located-uris-shortcut.sql @@ -0,0 +1,17 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +CREATE OR REPLACE FUNCTION evergreen.located_uris_as_uris + (bibid BIGINT, ouid INT, pref_lib INT DEFAULT NULL) + RETURNS SETOF asset.uri AS $FUNK$ + /* Maps a bib directly to its scoped asset.uri's */ + + SELECT uri.* + FROM evergreen.located_uris($1, $2, $3) located_uri + JOIN asset.uri_call_number_map map ON (map.call_number = located_uri.id) + JOIN asset.uri uri ON (uri.id = map.uri) + +$FUNK$ LANGUAGE SQL STABLE; + +COMMIT;