From 59f96483bd784e8b3785452ba30fb907b394d57e Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Mon, 25 Mar 2024 11:36:02 -0400 Subject: [PATCH 1/7] Update reference to qa_server to use published RubyGems version --- Gemfile | 4 +- Gemfile.lock | 160 +++++++++++++++++++++++++-------------------------- 2 files changed, 79 insertions(+), 85 deletions(-) diff --git a/Gemfile b/Gemfile index f7c48d5..d540312 100644 --- a/Gemfile +++ b/Gemfile @@ -65,9 +65,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] ## Gems manually added to for qa and qa_server engines # Required gems for QA and linked data access -# NOTE: We need to update the published RubyGems version of qa_server with the 8.0 release. Until -# then, the next entry is set to use the GitHub repo and tag instead. -gem 'qa_server', git: 'https://github.com/LD4P/qa_server.git', tag: 'v8.0.1' +gem 'qa_server', '~> 8.0' gem 'qa', '~> 5.10' gem 'linkeddata' gem 'psych', '~> 5.1' diff --git a/Gemfile.lock b/Gemfile.lock index abeffe4..3bd68df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,3 @@ -GIT - remote: https://github.com/LD4P/qa_server.git - revision: e3ca6e238ec2630a5bfdd92ddc2ff2b906f964c4 - tag: v8.0.1 - specs: - qa_server (8.0.1) - gruff - rails (~> 7.0) - sass-rails (~> 5.0) - useragent - GIT remote: https://github.com/brentd/xray-rails.git revision: f121814718c9907b20058dc9357b80a53afab821 @@ -20,69 +9,69 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) activerecord-import (1.5.0) activerecord (>= 4.2) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -133,7 +122,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) connection_pool (2.4.1) coveralls (0.8.23) json (>= 1.8, < 3) @@ -178,7 +167,7 @@ GEM geocoder (1.8.2) globalid (1.2.1) activesupport (>= 6.1) - gruff (0.23.0) + gruff (0.24.0) histogram rmagick (>= 5.3) haml (6.2.3) @@ -190,14 +179,14 @@ GEM hashdiff (1.0.1) histogram (0.2.4.1) htmlentities (4.3.4) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) io-like (0.3.1) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) json (2.6.3) - json-canonicalization (0.3.2) + json-canonicalization (0.4.0) json-ld (3.3.0) htmlentities (~> 4.3) json-canonicalization (~> 0.3, >= 0.3.2) @@ -259,7 +248,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -267,36 +256,37 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.20.0) + minitest (5.22.3) msgpack (1.7.2) multi_json (1.15.0) mysql2 (0.5.5) net-http-persistent (4.0.2) connection_pool (~> 2.2) - net-imap (0.4.4) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.4-arm64-darwin) + nio4r (2.7.0) + nokogiri (1.16.3-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.4-x86_64-darwin) + nokogiri (1.16.3-x86_64-darwin) racc (~> 1.4) + observer (0.1.2) parallel (1.23.0) parser (3.2.2.4) ast (~> 2.4.1) racc parslet (2.0.0) - pkg-config (1.5.5) + pkg-config (1.5.6) psych (5.1.0) stringio public_suffix (5.0.3) @@ -311,24 +301,29 @@ GEM nokogiri (~> 1.6) rails (>= 5.0, < 7.1) rdf + qa_server (8.0.1) + gruff + rails (~> 7.0) + sass-rails (~> 5.0) + useragent racc (1.7.3) - rack (2.2.8) + rack (2.2.8.1) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.0.8.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -340,9 +335,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -420,7 +415,8 @@ GEM request_store (1.5.1) rack (>= 1.4) rexml (3.2.6) - rmagick (5.3.0) + rmagick (5.4.4) + observer (~> 0.1) pkg-config (~> 1.4) rouge (4.1.3) rspec-activemodel-mocks (1.1.0) @@ -544,7 +540,7 @@ GEM temple (0.10.3) term-ansicolor (1.7.1) tins (~> 1.0) - thor (1.3.0) + thor (1.3.1) tilt (2.3.0) timeout (0.4.1) tins (1.32.1) @@ -583,7 +579,7 @@ GEM psych (>= 3.3) rdf (~> 3.2, >= 3.2.9) rdf-xsd (~> 3.2) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS arm64-darwin-22 @@ -612,7 +608,7 @@ DEPENDENCIES psych (~> 5.1) puma (~> 6.4.0, >= 5.6.4) qa (~> 5.10) - qa_server! + qa_server (~> 8.0) rails (~> 7.0.8) rails-controller-testing rspec-activemodel-mocks (~> 1.0) From 5948a19d2df6242b4c26b72c1c9aeae0c1e601a8 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Mon, 25 Mar 2024 11:42:07 -0400 Subject: [PATCH 2/7] Add identifiers to LC cataloging vocabularies (#363) --- lib/qa/authorities/loc_subauthority.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/qa/authorities/loc_subauthority.rb b/lib/qa/authorities/loc_subauthority.rb index 76c3411..e66ce38 100644 --- a/lib/qa/authorities/loc_subauthority.rb +++ b/lib/qa/authorities/loc_subauthority.rb @@ -43,6 +43,7 @@ def vocabularies # rubocop:disable Metrics/MethodLength "frequencies", "geographicAreas", "graphicMaterials", + "identifiers", "iso639-1", "iso639-2", "iso639-5", From ed486344b594590c22f460189becca49ff18b366 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Tue, 26 Mar 2024 15:29:51 -0400 Subject: [PATCH 3/7] Add connector for LOC geographic locations (#397) --- lib/qa/authorities/loc_subauthority.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/qa/authorities/loc_subauthority.rb b/lib/qa/authorities/loc_subauthority.rb index e66ce38..9d6a955 100644 --- a/lib/qa/authorities/loc_subauthority.rb +++ b/lib/qa/authorities/loc_subauthority.rb @@ -2,10 +2,11 @@ module Qa::Authorities::LocSubauthority # rubocop:disable Metrics/ModuleLength def get_url_for_authority(authority) - if authorities.include?(authority) then authority_base_url + if authorities.include?(authority) then authority_base_url elsif vocabularies.include?(authority) then vocab_base_url elsif datatypes.include?(authority) then datatype_base_url elsif preservation.include?(authority) then vocab_preservation_base_url + elsif geography.include?(authority) then vocab_geographic_areas_base_url end end @@ -105,6 +106,10 @@ def datatypes ["edtf"] end + def geography + ['geographicAreas'] + end + def preservation # rubocop:disable Metrics/MethodLength [ "contentLocationType", @@ -159,4 +164,8 @@ def datatype_base_url def vocab_preservation_base_url "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F" end + + def vocab_geographic_areas_base_url + "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2FgeographicAreas%2F" + end end From 9f9ef112028c3acf9e519745d92c96ccc8c4add5 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Wed, 27 Mar 2024 17:24:56 -0400 Subject: [PATCH 4/7] Add lookups for LOC hubs, works, and instances (#400) --- lib/qa/authorities/loc.rb | 2 +- lib/qa/authorities/loc_subauthority.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/qa/authorities/loc.rb b/lib/qa/authorities/loc.rb index 510edd5..f9a8cc1 100644 --- a/lib/qa/authorities/loc.rb +++ b/lib/qa/authorities/loc.rb @@ -14,7 +14,7 @@ def self.subauthority_for(subauthority) extend LocSubauthority def self.subauthorities - authorities + vocabularies + datatypes + preservation + rdftypes + authorities + vocabularies + datatypes + preservation + rdftypes + resources end end end diff --git a/lib/qa/authorities/loc_subauthority.rb b/lib/qa/authorities/loc_subauthority.rb index 9d6a955..0e0cb7f 100644 --- a/lib/qa/authorities/loc_subauthority.rb +++ b/lib/qa/authorities/loc_subauthority.rb @@ -7,6 +7,9 @@ def get_url_for_authority(authority) elsif datatypes.include?(authority) then datatype_base_url elsif preservation.include?(authority) then vocab_preservation_base_url elsif geography.include?(authority) then vocab_geographic_areas_base_url + elsif resources.include?(authority) then resources_base_url + else + raise Qa::InvalidSubAuthority, "Subauthority '#{authority}' not supported by LOC" end end @@ -147,6 +150,14 @@ def rdftypes ] end + def resources + [ + 'hubs', + 'instances', + 'works' + ] + end + private def vocab_base_url @@ -161,6 +172,10 @@ def datatype_base_url "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F" end + def resources_base_url + "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fresources%2F" + end + def vocab_preservation_base_url "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F" end From a709abd4b8a1283b49a49a1fbb454aa5ed1f2997 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Fri, 29 Mar 2024 11:23:05 -0400 Subject: [PATCH 5/7] Add direct lookups for LC subject subauthorities (#369) --- lib/qa/authorities/loc.rb | 2 +- lib/qa/authorities/loc_subauthority.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/qa/authorities/loc.rb b/lib/qa/authorities/loc.rb index f9a8cc1..4322ef6 100644 --- a/lib/qa/authorities/loc.rb +++ b/lib/qa/authorities/loc.rb @@ -14,7 +14,7 @@ def self.subauthority_for(subauthority) extend LocSubauthority def self.subauthorities - authorities + vocabularies + datatypes + preservation + rdftypes + resources + authorities + vocabularies + datatypes + preservation + rdftypes + resources + subject_collections + geography end end end diff --git a/lib/qa/authorities/loc_subauthority.rb b/lib/qa/authorities/loc_subauthority.rb index 0e0cb7f..72881f8 100644 --- a/lib/qa/authorities/loc_subauthority.rb +++ b/lib/qa/authorities/loc_subauthority.rb @@ -8,6 +8,7 @@ def get_url_for_authority(authority) elsif preservation.include?(authority) then vocab_preservation_base_url elsif geography.include?(authority) then vocab_geographic_areas_base_url elsif resources.include?(authority) then resources_base_url + elsif subject_collections.include?(authority) then subject_collection_base_url else raise Qa::InvalidSubAuthority, "Subauthority '#{authority}' not supported by LOC" end @@ -158,6 +159,17 @@ def resources ] end + def subject_collections + [ + 'collection_LCSHAuthorizedHeadings', + 'collection_LCSHSubdivisions', + 'collection_LCSHTopicSubdivisions', + 'collection_LCSHGeographicSubdivisions', + 'collection_LCSHGenreFormSubdivisions', + 'collection_LCSHTemporalSubdivisions' + ] + end + private def vocab_base_url @@ -176,6 +188,10 @@ def resources_base_url "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fresources%2F" end + def subject_collection_base_url + "memberOf%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects%2F" + end + def vocab_preservation_base_url "cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F" end From f3131096723ef608afd7ac61d7ba4c1928d5dda0 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Fri, 29 Mar 2024 13:58:53 -0400 Subject: [PATCH 6/7] Use correct subject collection names --- lib/qa/authorities/loc_subauthority.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/qa/authorities/loc_subauthority.rb b/lib/qa/authorities/loc_subauthority.rb index 72881f8..c37b16a 100644 --- a/lib/qa/authorities/loc_subauthority.rb +++ b/lib/qa/authorities/loc_subauthority.rb @@ -162,11 +162,11 @@ def resources def subject_collections [ 'collection_LCSHAuthorizedHeadings', - 'collection_LCSHSubdivisions', - 'collection_LCSHTopicSubdivisions', - 'collection_LCSHGeographicSubdivisions', - 'collection_LCSHGenreFormSubdivisions', - 'collection_LCSHTemporalSubdivisions' + 'collection_Subdivisions', + 'collection_TopicSubdivisions', + 'collection_GeographicSubdivisions', + 'collection_GenreFormSubdivisions', + 'collection_TemporalSubdivisions' ] end From f9bdeb235afd42471999c0e2c3efc64f654ea865 Mon Sep 17 00:00:00 2001 From: Matthew Connolly Date: Mon, 1 Apr 2024 19:18:13 -0400 Subject: [PATCH 7/7] Enable RWO lookups (#395) --- lib/qa/authorities/loc/generic_authority.rb | 8 +++++++- lib/qa/authorities/loc_subauthority.rb | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/qa/authorities/loc/generic_authority.rb b/lib/qa/authorities/loc/generic_authority.rb index 4ce4606..977379c 100644 --- a/lib/qa/authorities/loc/generic_authority.rb +++ b/lib/qa/authorities/loc/generic_authority.rb @@ -30,7 +30,8 @@ def build_query_url(q) escaped_query = ERB::Util.url_encode(q) authority = Loc.get_authority(subauthority) rdftype = Loc.get_rdftype(subauthority) - authority_fragment = Loc.get_url_for_authority(authority) + ERB::Util.url_encode(authority) + use_authority = authority == 'agents' ? 'names' : authority + authority_fragment = Loc.get_url_for_authority(use_authority) + ERB::Util.url_encode(use_authority) rdftype_fragment = "&q=rdftype:#{ERB::Util.url_encode(rdftype)}" if rdftype "https://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}#{rdftype_fragment}&format=json" end @@ -87,6 +88,11 @@ def loc_response_to_qa(data) response["uri"] = (data.links.find { |l| l["type"].nil? } || data.links[0])["href"] if data.links.present? + if subauthority.include? 'agents' + response['id'].gsub!('authorities/names', 'rwo/agents') + response['uri'].gsub!('authorities/names', 'rwo/agents') + end + response end end diff --git a/lib/qa/authorities/loc_subauthority.rb b/lib/qa/authorities/loc_subauthority.rb index c37b16a..d568a1f 100644 --- a/lib/qa/authorities/loc_subauthority.rb +++ b/lib/qa/authorities/loc_subauthority.rb @@ -24,6 +24,7 @@ def get_rdftype(authority) def authorities [ + "agents", "classification", "childrensSubjects", "demographicTerms", @@ -143,6 +144,11 @@ def preservation # rubocop:disable Metrics/MethodLength def rdftypes [ + "agents_ConferenceName", + "agents_CorporateName", + "agents_FamilyName", + "agents_Geographic", + "agents_PersonalName", "names_ConferenceName", "names_CorporateName", "names_FamilyName",