From 52809f02b4738b4291ad783ec646ac8ed777f6cb Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 1 Jun 2020 12:32:21 -0400 Subject: [PATCH] LP1881607 Angular catalog e-resource links display Display electronic resource links (MARC 856's) in the Angular staff catalog. The extraction logic, which matches the TPAC, has been put into its own API. To test in concerto, navigate to: /eg2/staff/catalog/record/208 Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/catalog/bib-record.service.ts | 7 +++++++ .../staff/share/bib-summary/bib-summary.component.html | 13 +++++++++++++ Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm | 15 ++++++++++++++- .../src/perlmods/lib/OpenILS/Application/Cat/Authority.pm | 8 +------- .../src/perlmods/lib/OpenILS/Application/Search/Biblio.pm | 3 +++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts index 7510fe0d0b..ce352c7868 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts @@ -17,6 +17,11 @@ export const NAMESPACE_MAPS = { export const HOLDINGS_XPATH = '/holdings:holdings/holdings:counts/holdings:count'; +interface EResourceUrl { + href: string; + note: string; + label: string; +} export class BibRecordSummary { id: number; // == record.id() for convenience @@ -32,6 +37,7 @@ export class BibRecordSummary { bibCallNumber: string; net: NetService; displayHighlights: {[name: string]: string | string[]} = {}; + eResourceUrls: EResourceUrl[] = []; constructor(record: IdlObject, orgId: number, orgDepth?: number) { this.id = Number(record.id()); @@ -106,6 +112,7 @@ export class BibRecordService { summary.attributes = bibSummary.attributes; summary.holdCount = bibSummary.hold_count; summary.holdingsSummary = bibSummary.copy_counts; + summary.eResourceUrls = bibSummary.urls; return summary; })); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html index e91a4e4393..042394aa12 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html @@ -119,6 +119,19 @@ + +
  • +
    +
    + Electronic Resource: +
    + +
    {{url.note}}
    +
    +
  • +
    diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 9bf9285617..e062363d75 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1,5 +1,7 @@ package OpenILS::Application::AppUtils; use strict; use warnings; +use MARC::Record; +use MARC::File::XML (BinaryEncoding => 'utf8', RecordFormat => 'USMARC'); use OpenILS::Application; use base qw/OpenILS::Application/; use OpenSRF::Utils::Cache; @@ -23,7 +25,7 @@ use Digest::MD5 qw(md5_hex); # Pile of utilty methods used accross applications. # --------------------------------------------------------------------------- my $cache_client = "OpenSRF::Utils::Cache"; - +my $MARC_NAMESPACE = 'http://www.loc.gov/MARC21/slim'; # --------------------------------------------------------------------------- # on sucess, returns the created session, on failure throws ERROR exception @@ -2429,5 +2431,16 @@ sub verify_migrated_user_password { } +# generate a MARC XML document from a MARC XML string +sub marc_xml_to_doc { + my ($class, $xml) = @_; + my $marc_doc = XML::LibXML->new->parse_string($xml); + $marc_doc->documentElement->setNamespace($MARC_NAMESPACE, 'marc', 1); + $marc_doc->documentElement->setNamespace($MARC_NAMESPACE); + return $marc_doc; +} + + + 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm index 82d04f56e9..746f528150 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/Authority.pm @@ -11,19 +11,13 @@ use OpenILS::Utils::Fieldmapper; use OpenILS::Const qw/:const/; use OpenILS::Event; my $U = 'OpenILS::Application::AppUtils'; -my $MARC_NAMESPACE = 'http://www.loc.gov/MARC21/slim'; - # generate a MARC XML document from a MARC XML string sub marc_xml_to_doc { my $xml = shift; - my $marc_doc = XML::LibXML->new->parse_string($xml); - $marc_doc->documentElement->setNamespace($MARC_NAMESPACE, 'marc', 1); - $marc_doc->documentElement->setNamespace($MARC_NAMESPACE); - return $marc_doc; + return $U->marc_xml_to_doc($xml); } - __PACKAGE__->register_method( method => 'import_authority_record', api_name => 'open-ils.cat.authority.record.import', 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 64d92cf361..db8914510d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2899,6 +2899,9 @@ sub record_urls { 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")]')) { -- 2.11.0