qa 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/controllers/qa/linked_data_terms_controller.rb +30 -9
  4. data/app/controllers/qa/terms_controller.rb +3 -2
  5. data/app/models/qa/linked_data/config/context_property_map.rb +6 -25
  6. data/app/services/qa/iri_template_service.rb +32 -24
  7. data/app/services/qa/linked_data/authority_service.rb +8 -0
  8. data/app/services/qa/linked_data/authority_url_service.rb +27 -8
  9. data/app/services/qa/linked_data/deep_sort_service.rb +3 -2
  10. data/app/services/qa/linked_data/graph_service.rb +13 -0
  11. data/app/services/qa/linked_data/language_service.rb +12 -0
  12. data/app/services/qa/linked_data/language_sort_service.rb +7 -2
  13. data/app/services/qa/linked_data/ldpath_service.rb +40 -0
  14. data/app/services/qa/linked_data/mapper/graph_ldpath_mapper_service.rb +49 -0
  15. data/app/services/qa/linked_data/mapper/graph_mapper_service.rb +3 -11
  16. data/app/services/qa/linked_data/mapper/graph_predicate_mapper_service.rb +40 -0
  17. data/app/services/qa/linked_data/mapper/search_results_mapper_service.rb +58 -11
  18. data/app/services/qa/linked_data/mapper/term_results_mapper_service.rb +80 -0
  19. data/config/authorities/linked_data/loc.json +13 -7
  20. data/config/authorities/linked_data/oclc_fast.json +13 -8
  21. data/lib/generators/qa/discogs/USAGE +10 -0
  22. data/lib/generators/qa/discogs/discogs_generator.rb +12 -0
  23. data/lib/generators/qa/discogs/templates/config/discogs-formats.yml +346 -0
  24. data/lib/generators/qa/discogs/templates/config/discogs-genres.yml +627 -0
  25. data/lib/generators/qa/install/templates/config/initializers/qa.rb +4 -0
  26. data/lib/qa.rb +6 -0
  27. data/lib/qa/authorities.rb +2 -0
  28. data/lib/qa/authorities/discogs.rb +28 -0
  29. data/lib/qa/authorities/discogs/discogs_instance_builder.rb +145 -0
  30. data/lib/qa/authorities/discogs/discogs_translation.rb +126 -0
  31. data/lib/qa/authorities/discogs/discogs_utils.rb +89 -0
  32. data/lib/qa/authorities/discogs/discogs_works_builder.rb +153 -0
  33. data/lib/qa/authorities/discogs/generic_authority.rb +151 -0
  34. data/lib/qa/authorities/discogs_subauthority.rb +9 -0
  35. data/lib/qa/authorities/linked_data/config.rb +7 -3
  36. data/lib/qa/authorities/linked_data/config/search_config.rb +99 -11
  37. data/lib/qa/authorities/linked_data/config/term_config.rb +112 -8
  38. data/lib/qa/authorities/linked_data/find_term.rb +154 -84
  39. data/lib/qa/authorities/linked_data/search_query.rb +76 -13
  40. data/lib/qa/configuration.rb +8 -0
  41. data/lib/qa/version.rb +1 -1
  42. data/spec/controllers/linked_data_terms_controller_spec.rb +151 -30
  43. data/spec/controllers/terms_controller_spec.rb +4 -0
  44. data/spec/features/linked_data/language_spec.rb +298 -0
  45. data/spec/fixtures/authorities/linked_data/lod_full_config.json +21 -5
  46. data/spec/fixtures/authorities/linked_data/lod_lang_defaults.json +4 -4
  47. data/spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json +4 -4
  48. data/spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json +4 -5
  49. data/spec/fixtures/authorities/linked_data/lod_lang_param.json +4 -4
  50. data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +1 -1
  51. data/spec/fixtures/discogs-find-response-json.json +1 -0
  52. data/spec/fixtures/discogs-find-response-jsonld-master.json +1 -0
  53. data/spec/fixtures/discogs-find-response-jsonld-release.json +1 -0
  54. data/spec/fixtures/discogs-id-matches-master.json +1 -0
  55. data/spec/fixtures/discogs-id-matches-release.json +1 -0
  56. data/spec/fixtures/discogs-id-not-found-master.json +1 -0
  57. data/spec/fixtures/discogs-id-not-found-release.json +1 -0
  58. data/spec/fixtures/discogs-search-response-no-auth.json +1 -0
  59. data/spec/fixtures/discogs-search-response-no-subauth.json +1 -0
  60. data/spec/fixtures/discogs-search-response-subauth.json +1 -0
  61. data/spec/fixtures/lod_lang_search_enesfrde.rdf.xml +60 -0
  62. data/spec/fixtures/lod_lang_search_sv.rdf.xml +42 -0
  63. data/spec/fixtures/lod_loc_term_found.rdf.xml +5 -0
  64. data/spec/lib/authorities/discogs/generic_authority_spec.rb +235 -0
  65. data/spec/lib/authorities/discogs_spec.rb +17 -0
  66. data/spec/lib/authorities/linked_data/config_spec.rb +68 -5
  67. data/spec/lib/authorities/linked_data/find_term_spec.rb +298 -3
  68. data/spec/lib/authorities/linked_data/generic_authority_spec.rb +46 -485
  69. data/spec/lib/authorities/linked_data/search_config_spec.rb +154 -3
  70. data/spec/lib/authorities/linked_data/search_query_spec.rb +240 -3
  71. data/spec/lib/authorities/linked_data/term_config_spec.rb +193 -5
  72. data/spec/lib/configuration_spec.rb +18 -0
  73. data/spec/models/linked_data/config/context_property_map_spec.rb +3 -31
  74. data/spec/services/iri_template_service_spec.rb +54 -12
  75. data/spec/{lib/authorities → services}/linked_data/authority_service_spec.rb +47 -0
  76. data/spec/services/linked_data/language_service_spec.rb +52 -11
  77. data/spec/services/linked_data/ldpath_service_spec.rb +61 -0
  78. data/spec/services/linked_data/mapper/graph_ldpath_mapper_service_spec.rb +118 -0
  79. data/spec/services/linked_data/mapper/graph_predicate_mapper_service_spec.rb +110 -0
  80. data/spec/services/linked_data/mapper/term_results_mapper_service_spec.rb +94 -0
  81. data/spec/spec_helper.rb +1 -1
  82. data/spec/support/matchers/include_hash.rb +5 -0
  83. data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -0
  84. metadata +73 -5
  85. data/lib/qa/authorities/linked_data/rdf_helper.rb +0 -49
@@ -4,12 +4,12 @@
4
4
  "url": {
5
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
6
6
  "@type": "IriTemplate",
7
- "template": "http://localhost/test_replacement/term/{term_id}?{?lang}",
7
+ "template": "{term_uri}?{?lang}",
8
8
  "variableRepresentation": "BasicRepresentation",
9
9
  "mapping": [
10
10
  {
11
11
  "@type": "IriTemplateMapping",
12
- "variable": "term_id",
12
+ "variable": "term_uri",
13
13
  "property": "hydra:freetextQuery",
14
14
  "required": true
15
15
  },
@@ -23,9 +23,9 @@
23
23
  ]
24
24
  },
25
25
  "qa_replacement_patterns": {
26
- "term_id": "term_id"
26
+ "term_id": "term_uri"
27
27
  },
28
- "term_id": "ID",
28
+ "term_id": "URI",
29
29
  "results": {
30
30
  "id_predicate": "http://id.loc.gov/vocabulary/identifiers/lccn",
31
31
  "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "term_id": "URI",
22
22
  "results": {
23
- "id_predicate": "http://id.loc.gov/vocabulary/identifiers/lccn",
23
+ "id_predicate": "http://purl.org/dc/terms/identifier",
24
24
  "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel"
25
25
  }
26
26
  },
@@ -0,0 +1 @@
1
+ {"status":"Accepted","series":[],"labels":[{"name":"Blue Note"}],"year":1962,"artists":[{"name":"Dexter Gordon"}],"id":3380671,"genres":["Jazz"],"title":"A Swingin' Affair","styles":["Hard Bop"],"formats":[{"qty":"1","descriptions":["LP","Album","Mono"],"name":"Vinyl"}]}
@@ -0,0 +1 @@
1
+ {"genres":["Jazz"],"num_for_sale":0,"title":"Blue Moon / You Go To My Head","most_recent_release":12028368,"main_release":8035918,"main_release_url":"https://api.discogs.com/releases/8035918","year":1952,"uri":"https://www.discogs.com/Billie-Holiday-And-Her-Orchestra-Blue-Moon-You-Go-To-My-Head/master/950011","versions_url":"https://api.discogs.com/masters/950011/versions","extraartists":[{"join":"","name":"Ray Brown","anv":"","tracks":"","role":"Bass","resource_url":"https://api.discogs.com/artists/252998","id":252998},{"join":"","name":"Alvin Stoller","anv":"","tracks":"","role":"Drums","resource_url":"https://api.discogs.com/artists/258467","id":258467},{"join":"","name":"Barney Kessel","anv":"","tracks":"","role":"Guitar","resource_url":"https://api.discogs.com/artists/253476","id":253476},{"join":"","name":"Oscar Peterson","anv":"","tracks":"","role":"Piano","resource_url":"https://api.discogs.com/artists/254394","id":254394},{"join":"","name":"Flip Phillips","anv":"","tracks":"","role":"Tenor Saxophone","resource_url":"https://api.discogs.com/artists/265641","id":265641},{"join":"","name":"Charlie Shavers","anv":"","tracks":"","role":"Trumpet","resource_url":"https://api.discogs.com/artists/265683","id":265683}],"tracklist":[{"duration":"","position":"A","type_":"track","extraartists":[{"join":"","name":"Rodgers & Hart","anv":"","tracks":"","role":"Written-By","resource_url":"https://api.discogs.com/artists/604171","id":604171}],"title":"Blue Moon"},{"duration":"","position":"AA","type_":"track","extraartists":[{"join":"","name":"Haven Gillespie","anv":"Gillespie","tracks":"","role":"Written-By","resource_url":"https://api.discogs.com/artists/583502","id":583502},{"join":"","name":"J. Fred Coots","anv":"Coots","tracks":"","role":"Written-By","resource_url":"https://api.discogs.com/artists/583506","id":583506}],"title":"You Go To My Head"}],"most_recent_release_url":"https://api.discogs.com/releases/12028368","artists":[{"join":"","name":"Billie Holiday And Her Orchestra","anv":"","tracks":"","role":"","resource_url":"https://api.discogs.com/artists/312936","id":312936}],"resource_url":"https://api.discogs.com/masters/950011","lowest_price":null,"id":950011,"data_quality":"Correct"}
@@ -0,0 +1 @@
1
+ {"series":[],"labels":[{"name":"Mercury Record Corporation","entity_type":"1","catno":"89004-X45","resource_url":"https://api.discogs.com/labels/269924","id":269924,"entity_type_name":"Label"}],"year":0,"artists":[{"join":"","name":"Billie Holiday And Her Orchestra","anv":"","tracks":"","role":"","resource_url":"https://api.discogs.com/artists/312936","id":312936}],"format_quantity":1,"id":7143179,"artists_sort":"Billie Holiday And Her Orchestra","genres":["Jazz"],"thumb":"","num_for_sale":0,"title":"Blue Moon / You Go To My Head","date_changed":"2017-06-16T09:04:56-07:00","master_id":950011,"status":"Accepted","estimated_weight":60,"master_url":"https://api.discogs.com/masters/950011","date_added":"2015-06-18T19:03:08-07:00","tracklist":[{"duration":"","position":"A","type_":"track","extraartists":[{"join":"","name":"Rodgers & Hart","anv":"Rodgers - Hart","tracks":"","role":"Written-By","resource_url":"https://api.discogs.com/artists/604171","id":604171}],"title":"Blue Moon"},{"duration":"","position":"AA","type_":"track","extraartists":[{"join":"","name":"Haven Gillespie","anv":"Gillespie","tracks":"","role":"Written-By","resource_url":"https://api.discogs.com/artists/583502","id":583502},{"join":"","name":"J. Fred Coots","anv":"Coots","tracks":"","role":"Written-By","resource_url":"https://api.discogs.com/artists/583506","id":583506}],"title":"You Go To My Head"}],"extraartists":[{"join":"","name":"Ray Brown","anv":"","tracks":"","role":"Bass","resource_url":"https://api.discogs.com/artists/252998","id":252998},{"join":"","name":"Alvin Stoller","anv":"","tracks":"","role":"Drums","resource_url":"https://api.discogs.com/artists/258467","id":258467},{"join":"","name":"Barney Kessel","anv":"","tracks":"","role":"Guitar","resource_url":"https://api.discogs.com/artists/253476","id":253476},{"join":"","name":"Oscar Peterson","anv":"","tracks":"","role":"Piano","resource_url":"https://api.discogs.com/artists/254394","id":254394},{"join":"","name":"Flip Phillips","anv":"","tracks":"","role":"Tenor Saxophone","resource_url":"https://api.discogs.com/artists/265641","id":265641},{"join":"","name":"Charlie Shavers","anv":"","tracks":"","role":"Trumpet","resource_url":"https://api.discogs.com/artists/265683","id":265683}],"country":"US","identifiers":[{"type":"Matrix / Runout","description":"Side A","value":"45 YWR-765-1"},{"type":"Matrix / Runout","description":"Side AA","value":"45 YWR-766-3"}],"companies":[],"uri":"https://www.discogs.com/Billie-Holiday-And-Her-Orchestra-Blue-Moon-You-Go-To-My-Head/release/7143179","formats":[{"descriptions":["7\"","45 RPM","Single","Mono"],"name":"Vinyl","qty":"1"}],"resource_url":"https://api.discogs.com/releases/7143179","data_quality":"Complete and Correct"}
@@ -0,0 +1 @@
1
+ {"styles":["Techno","Ambient"],"genres":["Electronic"],"num_for_sale":39,"title":"Simulation","most_recent_release":10824503,"main_release":10824503,"main_release_url":"https://api.discogs.com/releases/10824503","year":2017,"uri":"https://www.discogs.com/Aleksi-Per%C3%A4l%C3%A4-Simulation/master/1234567","versions_url":"https://api.discogs.com/masters/1234567/versions","most_recent_release_url":"https://api.discogs.com/releases/10824503","artists":[{"join":"","name":"Aleksi Perälä","anv":"","tracks":"","role":"","resource_url":"https://api.discogs.com/artists/15690","id":15690}],"resource_url":"https://api.discogs.com/masters/1234567","lowest_price":22.61,"id":1234567,"data_quality":"Correct"}
@@ -0,0 +1 @@
1
+ {"series":[],"labels":[],"year":0,"format_quantity":0,"id":1234567,"artists_sort":"Asia Minor","thumb":"","extraartists":[],"title":"Longa Nova","artists":[{"join":"","name":"Asia Minor","anv":"","tracks":"","role":"","resource_url":"https://api.discogs.com/artists/1138249","id":1138249}],"date_changed":null,"lowest_price":null,"status":"Draft","date_added":null,"num_for_sale":0,"tracklist":[],"identifiers":[],"companies":[],"uri":"https://www.discogs.com/release/1234567","formats":[],"resource_url":"https://api.discogs.com/releases/1234567","data_quality":"Needs Major Changes"}
@@ -0,0 +1 @@
1
+ {"message": "Master Release not found."}
@@ -0,0 +1 @@
1
+ {"message": "Release not found."}
@@ -0,0 +1 @@
1
+ {"id": "Error", "label": "Cannot access Discogs without authentication."}
@@ -0,0 +1 @@
1
+ {"pagination": {"per_page": 50, "items": 1, "page": 1, "urls": {}, "pages": 1}, "results": [{"style": ["Smooth Jazz", "Contemporary Jazz"], "master_id": 812047, "thumb": "https://img.discogs.com/yh2qJ9upQDTqm4p-37Qxr-NLTzw=/fit-in/150x150/filters:strip_icc():format(jpeg):mode_rgb():quality(40)/discogs-images/R-1750352-1240940672.jpeg.jpg", "format": ["Vinyl", "7\"", "Promo"], "country": "Germany", "barcode": ["LC 00383", "B963180-01 A1 HL", "B963180-01 B1 HL"], "uri": "/Melody-Gardot-Who-Will-Comfort-Me-Over-The-Rainbow/release/1750352", "master_url": "https://api.discogs.com/masters/812047", "label": ["Verve Records", "Universal Music Classics & Jazz", "Universal Music Classics & Jazz"], "cover_image": "https://img.discogs.com/Vjya6pq52cXLYpDS4SI6H_2yyEA=/fit-in/600x595/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-1750352-1240940672.jpeg.jpg", "catno": "none", "community": {"have": 27, "want": 29}, "year": "2009", "genre": ["Jazz"], "title": "Melody Gardot - Who Will Comfort Me / Over The Rainbow", "resource_url": "https://api.discogs.com/releases/1750352", "type": "release", "id": 1750352}]}
@@ -0,0 +1 @@
1
+ {"pagination": {"per_page": 50, "items": 1, "page": 1, "urls": {}, "pages": 1}, "results": [{"style": ["Soul-Jazz"], "master_id": 606116, "thumb": "https://img.discogs.com/yxXxXcaRv3f92Fs7msRvDll0j9E=/fit-in/150x150/filters:strip_icc():format(jpeg):mode_rgb():quality(40)/discogs-images/R-4543663-1367897598-4591.jpeg.jpg", "format": ["Vinyl", "7\"", "45 RPM", "Single"], "country": "US", "barcode": [], "uri": "/Wes-Montgomery-Bumpin-On-Sunset-Tequila/master/606116", "master_url": "https://api.discogs.com/masters/606116", "label": ["Verve Records"], "cover_image": "https://img.discogs.com/V6ftY0lAFE9mHlzBIhGZMMos3Dg=/fit-in/593x572/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-4543663-1367897598-4591.jpeg.jpg", "catno": "VK-10432", "community": {"have": 42, "want": 118}, "year": "1966", "genre": ["Jazz", "Funk / Soul"], "title": "Wes Montgomery - Bumpin' On Sunset / Tequila", "resource_url": "https://api.discogs.com/masters/606116", "type": "master", "id": 606116}]}
@@ -0,0 +1,60 @@
1
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:coord="http://whatever/java/ORG.oclc.util.CoordToDecimal" xmlns:naco="http://whatever/java/ORG.oclc.util.NacoNormalize" xmlns:norm="http://whatever/java/ORG.oclc.util.NormalFormC" xmlns:schema="http://schema.org/" xmlns:madsrdf="http://www.loc.gov/mads/rdf/v1#" xmlns:skosxl="http://www.w3.org/2008/05/skos-xl#" xmlns:dct="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:void="http://rdfs.org/ns/void#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:mx="http://www.loc.gov/MARC21/slim" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base="http://id.worldcat.org/fast/">
2
+ <rdf:Description rdf:about="530369">
3
+ <dct:identifier>530369</dct:identifier>
4
+ <skos:prefLabel xml:lang="en">buttermilk</skos:prefLabel>
5
+ <skos:prefLabel xml:lang="fr">Babeurre</skos:prefLabel>
6
+ <skos:prefLabel xml:lang="de">Buttermilch</skos:prefLabel>
7
+ <skos:altLabel xml:lang="en">yummy</skos:altLabel>
8
+ <skos:altLabel xml:lang="fr">délicieux</skos:altLabel>
9
+ <skos:altLabel xml:lang="de">lecker</skos:altLabel>
10
+ </rdf:Description>
11
+ <rdf:Description rdf:about="fst00530369">
12
+ <rdfs:comment>This identifier is deprecated. See the rdfs:seeAlso link for the new identifier.</rdfs:comment>
13
+ <rdfs:seeAlso rdf:resource="530369"/>
14
+ </rdf:Description>
15
+ <foaf:Document rdf:about="530369/rdf.xml">
16
+ <foaf:primaryTopic rdf:resource="530369"/>
17
+ <dc:format>application/rdf+xml</dc:format>
18
+ <dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-05-13T00:00:00.0</dct:created>
19
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-07-06T14:07:21.0</dct:modified>
20
+ <dct:language rdf:resource="http://lexvo.org/id/iso639-3/eng"/>
21
+ </foaf:Document>
22
+ <rdf:Description rdf:about="5140">
23
+ <dct:identifier>5140</dct:identifier>
24
+ <skos:prefLabel xml:lang="en">dried milk</skos:prefLabel>
25
+ <skos:prefLabel xml:lang="fr">lait en poudre</skos:prefLabel>
26
+ <skos:prefLabel xml:lang="de">getrocknete Milch</skos:prefLabel>
27
+ <skos:prefLabel xml:lang="es">leche en polvo</skos:prefLabel>
28
+ <skos:altLabel xml:lang="en">powdery</skos:altLabel>
29
+ <skos:altLabel xml:lang="fr">poudreux</skos:altLabel>
30
+ <skos:altLabel xml:lang="de">Pulverförmig</skos:altLabel>
31
+ <skos:altLabel xml:lang="es">en polvo</skos:altLabel>
32
+ <skos:altLabel>pulvora</skos:altLabel>
33
+ </rdf:Description>
34
+ <rdf:Description rdf:about="fst00005140">
35
+ <rdfs:comment>This identifier is deprecated. See the rdfs:seeAlso link for the new identifier.</rdfs:comment>
36
+ <rdfs:seeAlso rdf:resource="5140"/>
37
+ </rdf:Description>
38
+ <foaf:Document rdf:about="5140/rdf.xml">
39
+ <foaf:primaryTopic rdf:resource="5140"/>
40
+ <dc:format>application/rdf+xml</dc:format>
41
+ <dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2004-09-24T00:00:00.0</dct:created>
42
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-07-06T14:07:21.0</dct:modified>
43
+ </foaf:Document>
44
+ <rdf:Description rdf:about="557490">
45
+ <dct:identifier>557490</dct:identifier>
46
+ <skos:prefLabel xml:lang="en">condensed milk</skos:prefLabel>
47
+ <skos:prefLabel xml:lang="fr">lait condensé</skos:prefLabel>
48
+ <skos:prefLabel xml:lang="de">Kondensmilch</skos:prefLabel>
49
+ <skos:prefLabel xml:lang="es">leche condensada</skos:prefLabel>
50
+ <skos:prefLabel>lakto densigita</skos:prefLabel>
51
+ <skos:altLabel xml:lang="en">creamy</skos:altLabel>
52
+ <skos:altLabel xml:lang="fr">crémeux</skos:altLabel>
53
+ <skos:altLabel xml:lang="de">cremig</skos:altLabel>
54
+ <skos:altLabel xml:lang="es">cremoso</skos:altLabel>
55
+ </rdf:Description>
56
+ <rdf:Description rdf:about="fst00557490">
57
+ <rdfs:comment>This identifier is deprecated. See the rdfs:seeAlso link for the new identifier.</rdfs:comment>
58
+ <rdfs:seeAlso rdf:resource="557490"/>
59
+ </rdf:Description>
60
+ </rdf:RDF>
@@ -0,0 +1,42 @@
1
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:coord="http://whatever/java/ORG.oclc.util.CoordToDecimal" xmlns:naco="http://whatever/java/ORG.oclc.util.NacoNormalize" xmlns:norm="http://whatever/java/ORG.oclc.util.NormalFormC" xmlns:schema="http://schema.org/" xmlns:madsrdf="http://www.loc.gov/mads/rdf/v1#" xmlns:skosxl="http://www.w3.org/2008/05/skos-xl#" xmlns:dct="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:void="http://rdfs.org/ns/void#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:mx="http://www.loc.gov/MARC21/slim" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base="http://id.worldcat.org/fast/">
2
+ <rdf:Description rdf:about="530369">
3
+ <dct:identifier>530369</dct:identifier>
4
+ <skos:prefLabel xml:lang="en">kärnmjölk</skos:prefLabel>
5
+ <skos:altLabel xml:lang="en">smaskigt</skos:altLabel>
6
+ </rdf:Description>
7
+ <rdf:Description rdf:about="fst00530369">
8
+ <rdfs:comment>This identifier is deprecated. See the rdfs:seeAlso link for the new identifier.</rdfs:comment>
9
+ <rdfs:seeAlso rdf:resource="530369"/>
10
+ </rdf:Description>
11
+ <foaf:Document rdf:about="530369/rdf.xml">
12
+ <foaf:primaryTopic rdf:resource="530369"/>
13
+ <dc:format>application/rdf+xml</dc:format>
14
+ <dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2005-05-13T00:00:00.0</dct:created>
15
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-07-06T14:07:21.0</dct:modified>
16
+ <dct:language rdf:resource="http://lexvo.org/id/iso639-3/eng"/>
17
+ </foaf:Document>
18
+ <rdf:Description rdf:about="5140">
19
+ <dct:identifier>5140</dct:identifier>
20
+ <skos:prefLabel xml:lang="en">mjölkpulver</skos:prefLabel>
21
+ <skos:altLabel xml:lang="en">pulver-</skos:altLabel>
22
+ </rdf:Description>
23
+ <rdf:Description rdf:about="fst00005140">
24
+ <rdfs:comment>This identifier is deprecated. See the rdfs:seeAlso link for the new identifier.</rdfs:comment>
25
+ <rdfs:seeAlso rdf:resource="5140"/>
26
+ </rdf:Description>
27
+ <foaf:Document rdf:about="5140/rdf.xml">
28
+ <foaf:primaryTopic rdf:resource="5140"/>
29
+ <dc:format>application/rdf+xml</dc:format>
30
+ <dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2004-09-24T00:00:00.0</dct:created>
31
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2012-07-06T14:07:21.0</dct:modified>
32
+ </foaf:Document>
33
+ <rdf:Description rdf:about="557490">
34
+ <dct:identifier>557490</dct:identifier>
35
+ <skos:prefLabel xml:lang="en">kondenserad mjölk</skos:prefLabel>
36
+ <skos:altLabel xml:lang="en">krämig</skos:altLabel>
37
+ </rdf:Description>
38
+ <rdf:Description rdf:about="fst00557490">
39
+ <rdfs:comment>This identifier is deprecated. See the rdfs:seeAlso link for the new identifier.</rdfs:comment>
40
+ <rdfs:seeAlso rdf:resource="557490"/>
41
+ </rdf:Description>
42
+ </rdf:RDF>
@@ -119,6 +119,11 @@
119
119
  <identifiers:lccn xmlns:identifiers="http://id.loc.gov/vocabulary/identifiers/">sh 85118553</identifiers:lccn>
120
120
  <owl:sameAs rdf:resource="info:lc/authorities/sh85118553" xmlns:owl="http://www.w3.org/2002/07/owl#"/>
121
121
  <owl:sameAs rdf:resource="http://id.loc.gov/authorities/sh85118553#concept" xmlns:owl="http://www.w3.org/2002/07/owl#"/>
122
+ <madsrdf:hasNarrowerAuthority>
123
+ <madsrdf:Authority rdf:about="http://id.loc.gov/authorities/subjects/sh92004048">
124
+ <madsrdf:authoritativeLabel xml:lang="en">Environmental sciences</madsrdf:authoritativeLabel>
125
+ </madsrdf:Authority>
126
+ </madsrdf:hasNarrowerAuthority>
122
127
  <madsrdf:adminMetadata>
123
128
  <ri:RecordInfo xmlns:ri="http://id.loc.gov/ontologies/RecordInfo#">
124
129
  <ri:recordChangeDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2000-06-20T00:00:00</ri:recordChangeDate>
@@ -0,0 +1,235 @@
1
+ require 'spec_helper'
2
+
3
+ describe Qa::Authorities::Discogs::GenericAuthority do
4
+ before do
5
+ described_class.discogs_key = 'dummy_key'
6
+ described_class.discogs_secret = 'dummy_secret'
7
+ end
8
+
9
+ let(:authority) { described_class.new "all" }
10
+
11
+ describe "#build_query_url" do
12
+ subject { authority.build_query_url("foo", 'master') }
13
+ it { is_expected.to eq 'https://api.discogs.com/database/search?q=foo&type=master&key=dummy_key&secret=dummy_secret' }
14
+ end
15
+
16
+ describe "#find_url" do
17
+ subject { authority.find_url("10018955", "release") }
18
+ it { is_expected.to eq "https://api.discogs.com/releases/10018955" }
19
+ end
20
+
21
+ describe "#find" do
22
+ context "find variations" do
23
+ before do
24
+ stub_request(:get, "https://api.discogs.com/releases/3380671")
25
+ .to_return(status: 200, body: webmock_fixture("discogs-find-response-json.json"))
26
+
27
+ stub_request(:get, "https://api.discogs.com/masters/3380671")
28
+ .to_return(status: 200, body: webmock_fixture("discogs-id-not-found-master.json"))
29
+
30
+ stub_request(:get, "https://api.discogs.com/masters/1234567")
31
+ .to_return(status: 200, body: webmock_fixture("discogs-id-matches-master.json"))
32
+
33
+ stub_request(:get, "https://api.discogs.com/releases/1234567")
34
+ .to_return(status: 200, body: webmock_fixture("discogs-id-matches-release.json"))
35
+
36
+ stub_request(:get, "https://api.discogs.com/masters/123459876")
37
+ .to_return(status: 200, body: webmock_fixture("discogs-id-not-found-master.json"))
38
+
39
+ stub_request(:get, "https://api.discogs.com/releases/123459876")
40
+ .to_return(status: 200, body: webmock_fixture("discogs-id-not-found-release.json"))
41
+
42
+ stub_request(:get, "https://api.discogs.com/releases/7143179")
43
+ .to_return(status: 200, body: webmock_fixture("discogs-find-response-jsonld-release.json"))
44
+
45
+ stub_request(:get, "https://api.discogs.com/masters/7143179")
46
+ .to_return(status: 200, body: webmock_fixture("discogs-id-not-found-master.json"))
47
+
48
+ stub_request(:get, "https://api.discogs.com/masters/950011")
49
+ .to_return(status: 200, body: webmock_fixture("discogs-find-response-jsonld-master.json"))
50
+ end
51
+
52
+ context "json format and release subauthority" do
53
+ let(:tc) { instance_double(Qa::TermsController) }
54
+ let :results do
55
+ authority.find("3380671", tc)
56
+ end
57
+ before do
58
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
59
+ allow(tc).to receive(:params).and_return('format' => "json", 'subauthority' => "release")
60
+ end
61
+
62
+ it "returns the Discogs data for a given id" do
63
+ expect(results['title']).to eq "A Swingin' Affair"
64
+ expect(results['genres'][0]).to eq "Jazz"
65
+ end
66
+ end
67
+
68
+ context "json format and subauthority all" do
69
+ let(:tc) { instance_double(Qa::TermsController) }
70
+ let :results do
71
+ authority.find("3380671", tc)
72
+ end
73
+ before do
74
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
75
+ allow(tc).to receive(:params).and_return('format' => "json", 'subauthority' => "all")
76
+ end
77
+
78
+ it "returns the Discogs data for a given id" do
79
+ expect(results['title']).to eq "A Swingin' Affair"
80
+ expect(results['genres'][0]).to eq "Jazz"
81
+ end
82
+ end
83
+
84
+ context "id matches a Discogs release and a master" do
85
+ let(:tc) { instance_double(Qa::TermsController) }
86
+ let :results do
87
+ authority.find("1234567", tc)
88
+ end
89
+ before do
90
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
91
+ allow(tc).to receive(:params).and_return('format' => "json", 'subauthority' => "all")
92
+ end
93
+
94
+ it "returns two matches message and resource urls" do
95
+ expect(results['message']).to eq "Both a master and a release match the requested ID."
96
+ expect(results['resource_url'][0]).to eq "https://api.discogs.com/masters/1234567"
97
+ expect(results['resource_url'][1]).to eq "https://api.discogs.com/releases/1234567"
98
+ end
99
+ end
100
+
101
+ context "id matches neither a release nor a master" do
102
+ let(:tc) { instance_double(Qa::TermsController) }
103
+ let :results do
104
+ authority.find("123459876", tc)
105
+ end
106
+ before do
107
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
108
+ allow(tc).to receive(:params).and_return('format' => "json", 'subauthority' => "all")
109
+ end
110
+
111
+ it "returns two matches message and resource urls" do
112
+ expect(results['message']).to eq "Neither a master nor a release matches the requested ID."
113
+ end
114
+ end
115
+
116
+ context "json-ld format and subauthority master" do
117
+ let(:tc) { instance_double(Qa::TermsController) }
118
+ let :results do
119
+ authority.find("950011", tc)
120
+ end
121
+ before do
122
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
123
+ allow(tc).to receive(:params).and_return('format' => "jsonld", 'subauthority' => "master")
124
+ end
125
+
126
+ it "returns the Discogs data converted to json-ld for a given id" do
127
+ expect(JSON.parse(results).keys).to match_array ["@context", "@graph"]
128
+ expect(JSON.parse(results)["@context"]["bf2"]).to eq("http://id.loc.gov/ontologies/bibframe/")
129
+ expect(results).to include("Blue Moon / You Go To My Head")
130
+ expect(results).to include("Billie Holiday And Her Orchestra")
131
+ expect(results).to include("Haven Gillespie")
132
+ expect(results).to include("1952")
133
+ expect(results).to include("Jazz")
134
+ expect(results).to include("Barney Kessel")
135
+ expect(results).to include("Guitar")
136
+ end
137
+ end
138
+
139
+ context "json-ld format and subauthority all" do
140
+ let(:tc) { instance_double(Qa::TermsController) }
141
+ let :results do
142
+ authority.find("7143179", tc)
143
+ end
144
+ before do
145
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
146
+ allow(tc).to receive(:params).and_return('format' => "jsonld", 'subauthority' => "all")
147
+ end
148
+
149
+ it "returns the Discogs data converted to json-ld for a given id" do
150
+ expect(JSON.parse(results).keys).to match_array ["@context", "@graph"]
151
+ expect(JSON.parse(results)["@context"]["bf2"]).to eq("http://id.loc.gov/ontologies/bibframe/")
152
+ expect(results).to include("You Go To My Head")
153
+ expect(results).to include("Rodgers & Hart")
154
+ expect(results).to include("Ray Brown")
155
+ expect(results).to include("1952")
156
+ expect(results).to include("Single")
157
+ expect(results).to include("mono")
158
+ expect(results).to include("45 RPM")
159
+ expect(results).to include("Vinyl")
160
+ expect(results).to include("http://id.loc.gov/vocabulary/carriers/sd")
161
+ expect(results).to include("1952")
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ describe "#search" do
168
+ context "search variations" do
169
+ context "with subauthority all" do
170
+ let(:tc) { instance_double(Qa::TermsController) }
171
+ let :results do
172
+ stub_request(:get, "https://api.discogs.com/database/search?q=melody+gardot+who+will+comfort+me+over+the+rainbo&type=all&key=dummy_key&secret=dummy_secret")
173
+ .to_return(status: 200, body: webmock_fixture("discogs-search-response-no-subauth.json"))
174
+ authority.search("melody gardot who will comfort me over the rainbo", tc)
175
+ end
176
+ before do
177
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
178
+ allow(tc).to receive(:params).and_return('subauthority' => "all")
179
+ end
180
+
181
+ it "has id and label keys" do
182
+ expect(results.first["uri"]).to eq("https://api.discogs.com/releases/1750352")
183
+ expect(results.first["id"]).to eq "1750352"
184
+ expect(results.first["label"]).to eq "Melody Gardot - Who Will Comfort Me / Over The Rainbow"
185
+ expect(results.first["context"]["Year"]).to eq ['2009']
186
+ expect(results.first["context"]["Formats"][0]).to eq "Vinyl"
187
+ expect(results.first["context"]["Record Labels"][1]).to eq "Universal Music Classics & Jazz"
188
+ expect(results.first["context"]["Type"][0]).to eq "release"
189
+ end
190
+ end
191
+
192
+ context "with subauthority master" do
193
+ let(:tc) { instance_double(Qa::TermsController) }
194
+ let :results do
195
+ stub_request(:get, "https://api.discogs.com/database/search?q=wes+montgomery+tequila+bumpin'+on+sunse&type=master&key=dummy_key&secret=dummy_secret")
196
+ .to_return(status: 200, body: webmock_fixture("discogs-search-response-subauth.json"))
197
+ authority.search("wes montgomery tequila bumpin' on sunse", tc)
198
+ end
199
+ before do
200
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
201
+ allow(tc).to receive(:params).and_return('subauthority' => "master")
202
+ end
203
+
204
+ it "has id and label keys" do
205
+ expect(results.first['uri']).to eq "https://api.discogs.com/masters/606116"
206
+ expect(results.first['id']).to eq "606116"
207
+ expect(results.first['label']).to eq "Wes Montgomery - Bumpin' On Sunset / Tequila"
208
+ expect(results.first['context']["Year"]).to eq ['1966']
209
+ expect(results.first['context']["Formats"][2]).to eq "45 RPM"
210
+ expect(results.first["context"]["Type"][0]).to eq "master"
211
+ end
212
+ end
213
+
214
+ context "when authentication isn't set" do
215
+ let(:tc) { instance_double(Qa::TermsController) }
216
+ let :results do
217
+ stub_request(:get, "https://api.discogs.com/database/search?q=wes+montgomery+tequila+bumpin'+on+sunse&type=master")
218
+ .to_return(status: 200, body: webmock_fixture("discogs-search-response-no-auth.json"))
219
+ authority.search("wes montgomery tequila bumpin' on sunse", tc)
220
+ end
221
+ before do
222
+ described_class.discogs_secret = nil
223
+ described_class.discogs_key = nil
224
+ allow(Qa::TermsController).to receive(:new).and_return(tc)
225
+ allow(tc).to receive(:params).and_return('subauthority' => "master")
226
+ end
227
+
228
+ it "logs an error" do
229
+ expect(Rails.logger).to receive(:error).with('Questioning Authority tried to call Discogs, but no secret and/or key were set.')
230
+ expect(results).to be_empty
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Qa::Authorities::Discogs do
4
+ describe "#subauthority_for" do
5
+ context "with an invalid sub-authority" do
6
+ it "raises an exception" do
7
+ expect { described_class.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
8
+ end
9
+ end
10
+
11
+ context "with a valid sub-authority" do
12
+ it "creates the authority" do
13
+ expect(described_class.subauthority_for("master")).to be_kind_of Qa::Authorities::Discogs::GenericAuthority
14
+ end
15
+ end
16
+ end
17
+ end
@@ -34,7 +34,7 @@ describe Qa::Authorities::LinkedData::Config do
34
34
  url: {
35
35
  :@context => 'http://www.w3.org/ns/hydra/context.jsonld',
36
36
  :@type => 'IriTemplate',
37
- template: 'http://localhost/test_default/term/{subauth}/{term_id}?{?param1}&{?param2}',
37
+ template: 'http://localhost/test_default/term/{subauth}/{term_id}?{?param1}&{?param2}&{?lang}',
38
38
  variableRepresentation: 'BasicRepresentation',
39
39
  mapping: [
40
40
  {
@@ -63,15 +63,23 @@ describe Qa::Authorities::LinkedData::Config do
63
63
  property: 'hydra:freetextQuery',
64
64
  required: false,
65
65
  default: 'beta'
66
+ },
67
+ {
68
+ :@type => 'IriTemplateMapping',
69
+ variable: 'lang',
70
+ property: 'hydra:freetextQuery',
71
+ required: false,
72
+ default: 'de'
66
73
  }
67
74
  ]
68
75
  },
69
76
  qa_replacement_patterns: {
70
77
  term_id: 'term_id',
71
- subauth: 'subauth'
78
+ subauth: 'subauth',
79
+ lang: 'lang'
72
80
  },
73
81
  term_id: 'ID',
74
- language: ['en'],
82
+ language: ['es'],
75
83
  results: {
76
84
  id_predicate: 'http://purl.org/dc/terms/identifier',
77
85
  label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
@@ -90,7 +98,7 @@ describe Qa::Authorities::LinkedData::Config do
90
98
  url: {
91
99
  :@context => 'http://www.w3.org/ns/hydra/context.jsonld',
92
100
  :@type => 'IriTemplate',
93
- template: 'http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}',
101
+ template: 'http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}&{?lang}',
94
102
  variableRepresentation: 'BasicRepresentation',
95
103
  mapping: [
96
104
  {
@@ -119,12 +127,20 @@ describe Qa::Authorities::LinkedData::Config do
119
127
  property: 'hydra:freetextQuery',
120
128
  required: false,
121
129
  default: 'echo'
130
+ },
131
+ {
132
+ :@type => 'IriTemplateMapping',
133
+ variable: 'lang',
134
+ property: 'hydra:freetextQuery',
135
+ required: false,
136
+ default: 'fr'
122
137
  }
123
138
  ]
124
139
  },
125
140
  qa_replacement_patterns: {
126
141
  query: 'query',
127
- subauth: 'subauth'
142
+ subauth: 'subauth',
143
+ lang: 'lang'
128
144
  },
129
145
  language: ['en', 'fr', 'de'],
130
146
  results: {
@@ -396,6 +412,53 @@ describe Qa::Authorities::LinkedData::Config do
396
412
  end
397
413
  end
398
414
 
415
+ describe '#authority_info' do
416
+ let(:term_details) do
417
+ {
418
+ "label" => "oclc_fast term (QA)",
419
+ "uri" => "urn:qa:term:oclc_fast",
420
+ "authority" => "oclc_fast",
421
+ "action" => "term",
422
+ "language" => ["en"]
423
+ }
424
+ end
425
+
426
+ let(:search_details) do
427
+ {
428
+ "label" => "oclc_fast search (QA)",
429
+ "uri" => "urn:qa:search:oclc_fast",
430
+ "authority" => "oclc_fast",
431
+ "action" => "search",
432
+ "language" => ["en"]
433
+ }
434
+ end
435
+
436
+ let(:search_details_with_subauth) do
437
+ {
438
+ "label" => "oclc_fast search topic (QA)",
439
+ "uri" => "urn:qa:search:oclc_fast:topic",
440
+ "authority" => "oclc_fast",
441
+ "subauthority" => "topic",
442
+ "action" => "search",
443
+ "language" => ["en"]
444
+ }
445
+ end
446
+
447
+ let(:details) { described_class.new(:OCLC_FAST).authority_info }
448
+
449
+ it "returns a list with details for term without subauthorities" do
450
+ expect(details).to include_hash(term_details)
451
+ end
452
+
453
+ it "returns a list with details for search without subauthorities" do
454
+ expect(details).to include_hash(search_details)
455
+ end
456
+
457
+ it "returns a list with details for search with a subauthority" do
458
+ expect(details).to include_hash(search_details_with_subauth)
459
+ end
460
+ end
461
+
399
462
  describe '#config_version' do
400
463
  context 'when version is NOT in the config file' do
401
464
  it 'returns default as 1.0' do