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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/qa/linked_data_terms_controller.rb +30 -9
- data/app/controllers/qa/terms_controller.rb +3 -2
- data/app/models/qa/linked_data/config/context_property_map.rb +6 -25
- data/app/services/qa/iri_template_service.rb +32 -24
- data/app/services/qa/linked_data/authority_service.rb +8 -0
- data/app/services/qa/linked_data/authority_url_service.rb +27 -8
- data/app/services/qa/linked_data/deep_sort_service.rb +3 -2
- data/app/services/qa/linked_data/graph_service.rb +13 -0
- data/app/services/qa/linked_data/language_service.rb +12 -0
- data/app/services/qa/linked_data/language_sort_service.rb +7 -2
- data/app/services/qa/linked_data/ldpath_service.rb +40 -0
- data/app/services/qa/linked_data/mapper/graph_ldpath_mapper_service.rb +49 -0
- data/app/services/qa/linked_data/mapper/graph_mapper_service.rb +3 -11
- data/app/services/qa/linked_data/mapper/graph_predicate_mapper_service.rb +40 -0
- data/app/services/qa/linked_data/mapper/search_results_mapper_service.rb +58 -11
- data/app/services/qa/linked_data/mapper/term_results_mapper_service.rb +80 -0
- data/config/authorities/linked_data/loc.json +13 -7
- data/config/authorities/linked_data/oclc_fast.json +13 -8
- data/lib/generators/qa/discogs/USAGE +10 -0
- data/lib/generators/qa/discogs/discogs_generator.rb +12 -0
- data/lib/generators/qa/discogs/templates/config/discogs-formats.yml +346 -0
- data/lib/generators/qa/discogs/templates/config/discogs-genres.yml +627 -0
- data/lib/generators/qa/install/templates/config/initializers/qa.rb +4 -0
- data/lib/qa.rb +6 -0
- data/lib/qa/authorities.rb +2 -0
- data/lib/qa/authorities/discogs.rb +28 -0
- data/lib/qa/authorities/discogs/discogs_instance_builder.rb +145 -0
- data/lib/qa/authorities/discogs/discogs_translation.rb +126 -0
- data/lib/qa/authorities/discogs/discogs_utils.rb +89 -0
- data/lib/qa/authorities/discogs/discogs_works_builder.rb +153 -0
- data/lib/qa/authorities/discogs/generic_authority.rb +151 -0
- data/lib/qa/authorities/discogs_subauthority.rb +9 -0
- data/lib/qa/authorities/linked_data/config.rb +7 -3
- data/lib/qa/authorities/linked_data/config/search_config.rb +99 -11
- data/lib/qa/authorities/linked_data/config/term_config.rb +112 -8
- data/lib/qa/authorities/linked_data/find_term.rb +154 -84
- data/lib/qa/authorities/linked_data/search_query.rb +76 -13
- data/lib/qa/configuration.rb +8 -0
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/linked_data_terms_controller_spec.rb +151 -30
- data/spec/controllers/terms_controller_spec.rb +4 -0
- data/spec/features/linked_data/language_spec.rb +298 -0
- data/spec/fixtures/authorities/linked_data/lod_full_config.json +21 -5
- data/spec/fixtures/authorities/linked_data/lod_lang_defaults.json +4 -4
- data/spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json +4 -4
- data/spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json +4 -5
- data/spec/fixtures/authorities/linked_data/lod_lang_param.json +4 -4
- data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +1 -1
- data/spec/fixtures/discogs-find-response-json.json +1 -0
- data/spec/fixtures/discogs-find-response-jsonld-master.json +1 -0
- data/spec/fixtures/discogs-find-response-jsonld-release.json +1 -0
- data/spec/fixtures/discogs-id-matches-master.json +1 -0
- data/spec/fixtures/discogs-id-matches-release.json +1 -0
- data/spec/fixtures/discogs-id-not-found-master.json +1 -0
- data/spec/fixtures/discogs-id-not-found-release.json +1 -0
- data/spec/fixtures/discogs-search-response-no-auth.json +1 -0
- data/spec/fixtures/discogs-search-response-no-subauth.json +1 -0
- data/spec/fixtures/discogs-search-response-subauth.json +1 -0
- data/spec/fixtures/lod_lang_search_enesfrde.rdf.xml +60 -0
- data/spec/fixtures/lod_lang_search_sv.rdf.xml +42 -0
- data/spec/fixtures/lod_loc_term_found.rdf.xml +5 -0
- data/spec/lib/authorities/discogs/generic_authority_spec.rb +235 -0
- data/spec/lib/authorities/discogs_spec.rb +17 -0
- data/spec/lib/authorities/linked_data/config_spec.rb +68 -5
- data/spec/lib/authorities/linked_data/find_term_spec.rb +298 -3
- data/spec/lib/authorities/linked_data/generic_authority_spec.rb +46 -485
- data/spec/lib/authorities/linked_data/search_config_spec.rb +154 -3
- data/spec/lib/authorities/linked_data/search_query_spec.rb +240 -3
- data/spec/lib/authorities/linked_data/term_config_spec.rb +193 -5
- data/spec/lib/configuration_spec.rb +18 -0
- data/spec/models/linked_data/config/context_property_map_spec.rb +3 -31
- data/spec/services/iri_template_service_spec.rb +54 -12
- data/spec/{lib/authorities → services}/linked_data/authority_service_spec.rb +47 -0
- data/spec/services/linked_data/language_service_spec.rb +52 -11
- data/spec/services/linked_data/ldpath_service_spec.rb +61 -0
- data/spec/services/linked_data/mapper/graph_ldpath_mapper_service_spec.rb +118 -0
- data/spec/services/linked_data/mapper/graph_predicate_mapper_service_spec.rb +110 -0
- data/spec/services/linked_data/mapper/term_results_mapper_service_spec.rb +94 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/matchers/include_hash.rb +5 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -0
- metadata +73 -5
- data/lib/qa/authorities/linked_data/rdf_helper.rb +0 -49
|
@@ -52,6 +52,10 @@ describe Qa::TermsController, type: :controller do
|
|
|
52
52
|
get :search, params: { q: "a query", vocab: "oclcts" }
|
|
53
53
|
expect(response.code).to eq("400")
|
|
54
54
|
end
|
|
55
|
+
it "returns 400 for discogs" do
|
|
56
|
+
get :search, params: { q: "a query", vocab: "discogs" }
|
|
57
|
+
expect(response.code).to eq("400")
|
|
58
|
+
end
|
|
55
59
|
end
|
|
56
60
|
end
|
|
57
61
|
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'qa/authorities/linked_data/config/search_config'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'language processing', type: :controller do # rubocop:disable RSpec/DescribeClass
|
|
6
|
+
before do
|
|
7
|
+
@controller = Qa::LinkedDataTermsController.new
|
|
8
|
+
@routes = Qa::Engine.routes
|
|
9
|
+
stub_request(:get, "http://localhost/test_default/search?query=my_query")
|
|
10
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enesfrde.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let(:de_expected_results) do
|
|
14
|
+
[
|
|
15
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "http://id.worldcat.org/fast/530369", "label" => "Buttermilch" }, # de only b/c all tagged
|
|
16
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "http://id.worldcat.org/fast/557490", "label" => "[Kondensmilch, lakto densigita]" }, # de + untagged
|
|
17
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "http://id.worldcat.org/fast/5140", "label" => "getrocknete Milch" } # de only b/c all tagged
|
|
18
|
+
]
|
|
19
|
+
end
|
|
20
|
+
let(:en_expected_results) do
|
|
21
|
+
[
|
|
22
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "http://id.worldcat.org/fast/530369", "label" => "buttermilk" }, # en only b/c all tagged
|
|
23
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "http://id.worldcat.org/fast/557490", "label" => "[condensed milk, lakto densigita]" }, # en + untagged
|
|
24
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "http://id.worldcat.org/fast/5140", "label" => "dried milk" } # en only b/c all tagged
|
|
25
|
+
]
|
|
26
|
+
end
|
|
27
|
+
let(:es_expected_results) do
|
|
28
|
+
[
|
|
29
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "http://id.worldcat.org/fast/530369", "label" => "[Buttermilch, buttermilk, Babeurre]" }, # all matches b/c no matching tag
|
|
30
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "http://id.worldcat.org/fast/557490", "label" => "[leche condensada, lakto densigita]" }, # es + untagged
|
|
31
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "http://id.worldcat.org/fast/5140", "label" => "leche en polvo" } # es only b/c all tagged
|
|
32
|
+
]
|
|
33
|
+
end
|
|
34
|
+
let(:fr_expected_results) do
|
|
35
|
+
[
|
|
36
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "http://id.worldcat.org/fast/530369", "label" => "Babeurre" }, # fr only b/c all tagged
|
|
37
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "http://id.worldcat.org/fast/557490", "label" => "[lait condensé, lakto densigita]" }, # fr + untagged
|
|
38
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "http://id.worldcat.org/fast/5140", "label" => "lait en poudre" } # fr only b/c all tagged
|
|
39
|
+
]
|
|
40
|
+
end
|
|
41
|
+
let(:fr_alt_expected_results) do
|
|
42
|
+
[
|
|
43
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "530369", "label" => "Babeurre (délicieux)" }, # fr only in results + (alt label)
|
|
44
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "557490", "label" => "lait condensé (crémeux)" }, # fr only in results + (alt label)
|
|
45
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "5140", "label" => "lait en poudre (poudreux)" } # fr only in results + (alt label)
|
|
46
|
+
]
|
|
47
|
+
end
|
|
48
|
+
let(:sv_alt_expected_results) do
|
|
49
|
+
[
|
|
50
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "530369", "label" => "kärnmjölk (smaskigt)" }, # sv only in results + (alt label)
|
|
51
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "557490", "label" => "kondenserad mjölk (krämig)" }, # sv only in results + (alt label)
|
|
52
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "5140", "label" => "mjölkpulver (pulver-)" } # sv only in results + (alt label)
|
|
53
|
+
]
|
|
54
|
+
end
|
|
55
|
+
let(:nil_expected_results) do
|
|
56
|
+
# returns values for all language when requested lang is nil
|
|
57
|
+
[
|
|
58
|
+
{ "uri" => "http://id.worldcat.org/fast/530369", "id" => "http://id.worldcat.org/fast/530369", "label" => "[Buttermilch, buttermilk, Babeurre]" },
|
|
59
|
+
{ "uri" => "http://id.worldcat.org/fast/557490", "id" => "http://id.worldcat.org/fast/557490", "label" => "[Kondensmilch, condensed milk, leche condensada, lait condensé, lakto densigita]" },
|
|
60
|
+
{ "uri" => "http://id.worldcat.org/fast/5140", "id" => "http://id.worldcat.org/fast/5140", "label" => "[getrocknete Milch, dried milk, leche en polvo, lait en poudre]" }
|
|
61
|
+
]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'when configured authority URL includes a language parameter' do
|
|
65
|
+
before do
|
|
66
|
+
stub_request(:get, "http://localhost/test_default/search?lang=sv¶m1=delta¶m2=echo&query=my_query&subauth=search_sub1_name")
|
|
67
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_search_sv.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'passes language to authority for filtering based on user specified language' do
|
|
71
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_FULL_CONFIG', maximumRecords: '3', lang: 'sv' }
|
|
72
|
+
expect(response).to be_successful
|
|
73
|
+
results = JSON.parse(response.body)
|
|
74
|
+
expect(results).to match_array sv_alt_expected_results
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context 'when language includes a WILDCARD (i.e. *)' do
|
|
79
|
+
before do
|
|
80
|
+
stub_request(:get, "http://localhost/test_default/search?subauth=search_sub1_name&query=my_query¶m1=delta¶m2=echo&lang=fr")
|
|
81
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_search_fr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'does not filter languages through graph service' do
|
|
85
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: '*' }
|
|
86
|
+
expect(response).to be_successful
|
|
87
|
+
results = JSON.parse(response.body)
|
|
88
|
+
expect(results).to match_array nil_expected_results
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'reverts to parameter default when passing to the authority' do
|
|
92
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_FULL_CONFIG', maximumRecords: '3', lang: '*' }
|
|
93
|
+
expect(response).to be_successful
|
|
94
|
+
results = JSON.parse(response.body)
|
|
95
|
+
expect(results).to match_array fr_alt_expected_results
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context 'when site defined default language' do
|
|
100
|
+
before do
|
|
101
|
+
allow(Qa.config).to receive(:default_language).and_return('en')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'and authority defined default language' do
|
|
105
|
+
before do
|
|
106
|
+
allow_any_instance_of(Qa::Authorities::LinkedData::SearchConfig).to receive(:language).and_return('de') # rubocop:disable RSpec/AnyInstance
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context 'and language is passed via access_language in the http request header' do
|
|
110
|
+
context 'and user passes language as parameter' do
|
|
111
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
112
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
113
|
+
expect(response).to be_successful
|
|
114
|
+
results = JSON.parse(response.body)
|
|
115
|
+
expect(results).to match_array es_expected_results
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
120
|
+
it 'filters results to the http request access_language (e.g. fr + untagged)' do
|
|
121
|
+
request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr'
|
|
122
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
123
|
+
expect(response).to be_successful
|
|
124
|
+
results = JSON.parse(response.body)
|
|
125
|
+
expect(results).to match_array fr_expected_results
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
context 'and language is NOT passed via access_language in the http request header' do
|
|
131
|
+
context 'and user passes language as parameter' do
|
|
132
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
133
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
134
|
+
expect(response).to be_successful
|
|
135
|
+
results = JSON.parse(response.body)
|
|
136
|
+
expect(results).to match_array es_expected_results
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
141
|
+
it 'filters results to the authority defined language (e.g. de + untagged)' do
|
|
142
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
143
|
+
expect(response).to be_successful
|
|
144
|
+
results = JSON.parse(response.body)
|
|
145
|
+
expect(results).to match_array de_expected_results
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
context 'and authority does NOT define default language' do
|
|
152
|
+
before do
|
|
153
|
+
allow_any_instance_of(Qa::Authorities::LinkedData::SearchConfig).to receive(:language).and_return(nil) # rubocop:disable RSpec/AnyInstance
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
context 'and language is passed via access_language in the http request header' do
|
|
157
|
+
context 'and user passes language as parameter' do
|
|
158
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
159
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
160
|
+
expect(response).to be_successful
|
|
161
|
+
results = JSON.parse(response.body)
|
|
162
|
+
expect(results).to match_array es_expected_results
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
167
|
+
it 'filters results to the http request access_language (e.g. fr + untagged)' do
|
|
168
|
+
request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr'
|
|
169
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
170
|
+
expect(response).to be_successful
|
|
171
|
+
results = JSON.parse(response.body)
|
|
172
|
+
expect(results).to match_array fr_expected_results
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
context 'and language is NOT passed via access_language in the http request header' do
|
|
178
|
+
context 'and user passes language as parameter' do
|
|
179
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
180
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
181
|
+
expect(response).to be_successful
|
|
182
|
+
results = JSON.parse(response.body)
|
|
183
|
+
expect(results).to match_array es_expected_results
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
188
|
+
it 'filters results to the site defined language (e.g. en + untagged)' do
|
|
189
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
190
|
+
expect(response).to be_successful
|
|
191
|
+
results = JSON.parse(response.body)
|
|
192
|
+
expect(results).to match_array en_expected_results
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
context 'when site does NOT define default language' do
|
|
200
|
+
before do
|
|
201
|
+
allow(Qa.config).to receive(:default_language).and_return(nil)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
context 'and authority defined default language' do
|
|
205
|
+
before do
|
|
206
|
+
allow_any_instance_of(Qa::Authorities::LinkedData::SearchConfig).to receive(:language).and_return('de') # rubocop:disable RSpec/AnyInstance
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
context 'and language is passed via access_language in the http request header' do
|
|
210
|
+
context 'and user passes language as parameter' do
|
|
211
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
212
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
213
|
+
expect(response).to be_successful
|
|
214
|
+
results = JSON.parse(response.body)
|
|
215
|
+
expect(results).to match_array es_expected_results
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
220
|
+
it 'filters results to the http request access_language (e.g. fr + untagged)' do
|
|
221
|
+
request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr'
|
|
222
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
223
|
+
expect(response).to be_successful
|
|
224
|
+
results = JSON.parse(response.body)
|
|
225
|
+
expect(results).to match_array fr_expected_results
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
context 'and language is NOT passed via access_language in the http request header' do
|
|
231
|
+
context 'and user passes language as parameter' do
|
|
232
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
233
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
234
|
+
expect(response).to be_successful
|
|
235
|
+
results = JSON.parse(response.body)
|
|
236
|
+
expect(results).to match_array es_expected_results
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
241
|
+
it 'filters results to the authority defined language (e.g. de + untagged)' do
|
|
242
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
243
|
+
expect(response).to be_successful
|
|
244
|
+
results = JSON.parse(response.body)
|
|
245
|
+
expect(results).to match_array de_expected_results
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
context 'and authority does NOT define default language' do
|
|
252
|
+
before do
|
|
253
|
+
allow_any_instance_of(Qa::Authorities::LinkedData::SearchConfig).to receive(:language).and_return(nil) # rubocop:disable RSpec/AnyInstance
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
context 'and language is passed via access_language in the http request header' do
|
|
257
|
+
context 'and user passes language as parameter' do
|
|
258
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
259
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
260
|
+
expect(response).to be_successful
|
|
261
|
+
results = JSON.parse(response.body)
|
|
262
|
+
expect(results).to match_array es_expected_results
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
267
|
+
it 'filters results to the http request access_language (e.g. fr + untagged)' do
|
|
268
|
+
request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr'
|
|
269
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
270
|
+
expect(response).to be_successful
|
|
271
|
+
results = JSON.parse(response.body)
|
|
272
|
+
expect(results).to match_array fr_expected_results
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
context 'and language is NOT passed via access_language in the http request header' do
|
|
278
|
+
context 'and user passes language as parameter' do
|
|
279
|
+
it 'filters results to the user passed in language (e.g. es + untagged)' do
|
|
280
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3', lang: 'es' }
|
|
281
|
+
expect(response).to be_successful
|
|
282
|
+
results = JSON.parse(response.body)
|
|
283
|
+
expect(results).to match_array es_expected_results
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
context 'and user does NOT pass in language as a parameter' do
|
|
288
|
+
it 'does not filter results' do
|
|
289
|
+
get :search, params: { q: 'my_query', vocab: 'LOD_MIN_CONFIG', maximumRecords: '3' }
|
|
290
|
+
expect(response).to be_successful
|
|
291
|
+
results = JSON.parse(response.body)
|
|
292
|
+
expect(results).to match_array nil_expected_results
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
end
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"url": {
|
|
9
9
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
|
10
10
|
"@type": "IriTemplate",
|
|
11
|
-
"template": "http://localhost/test_default/term/{subauth}/{term_id}?{?param1}&{?param2}",
|
|
11
|
+
"template": "http://localhost/test_default/term/{subauth}/{term_id}?{?param1}&{?param2}&{?lang}",
|
|
12
12
|
"variableRepresentation": "BasicRepresentation",
|
|
13
13
|
"mapping": [
|
|
14
14
|
{
|
|
@@ -37,15 +37,23 @@
|
|
|
37
37
|
"property": "hydra:freetextQuery",
|
|
38
38
|
"required": false,
|
|
39
39
|
"default": "beta"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"@type": "IriTemplateMapping",
|
|
43
|
+
"variable": "lang",
|
|
44
|
+
"property": "hydra:freetextQuery",
|
|
45
|
+
"required": false,
|
|
46
|
+
"default": "de"
|
|
40
47
|
}
|
|
41
48
|
]
|
|
42
49
|
},
|
|
43
50
|
"qa_replacement_patterns": {
|
|
44
51
|
"term_id": "term_id",
|
|
45
|
-
"subauth": "subauth"
|
|
52
|
+
"subauth": "subauth",
|
|
53
|
+
"lang": "lang"
|
|
46
54
|
},
|
|
47
55
|
"term_id": "ID",
|
|
48
|
-
"language": [ "
|
|
56
|
+
"language": [ "es" ],
|
|
49
57
|
"results": {
|
|
50
58
|
"id_predicate": "http://purl.org/dc/terms/identifier",
|
|
51
59
|
"label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
|
|
@@ -64,7 +72,7 @@
|
|
|
64
72
|
"url": {
|
|
65
73
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
|
66
74
|
"@type": "IriTemplate",
|
|
67
|
-
"template": "http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}",
|
|
75
|
+
"template": "http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}&{?lang}",
|
|
68
76
|
"variableRepresentation": "BasicRepresentation",
|
|
69
77
|
"mapping": [
|
|
70
78
|
{
|
|
@@ -93,12 +101,20 @@
|
|
|
93
101
|
"property": "hydra:freetextQuery",
|
|
94
102
|
"required": false,
|
|
95
103
|
"default": "echo"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"@type": "IriTemplateMapping",
|
|
107
|
+
"variable": "lang",
|
|
108
|
+
"property": "hydra:freetextQuery",
|
|
109
|
+
"required": false,
|
|
110
|
+
"default": "fr"
|
|
96
111
|
}
|
|
97
112
|
]
|
|
98
113
|
},
|
|
99
114
|
"qa_replacement_patterns": {
|
|
100
115
|
"query": "query",
|
|
101
|
-
"subauth": "subauth"
|
|
116
|
+
"subauth": "subauth",
|
|
117
|
+
"lang": "lang"
|
|
102
118
|
},
|
|
103
119
|
"language": [ "en", "fr", "de" ],
|
|
104
120
|
"results": {
|
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
"url": {
|
|
5
5
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
|
6
6
|
"@type": "IriTemplate",
|
|
7
|
-
"template": "
|
|
7
|
+
"template": "{term_uri}",
|
|
8
8
|
"variableRepresentation": "BasicRepresentation",
|
|
9
9
|
"mapping": [
|
|
10
10
|
{
|
|
11
11
|
"@type": "IriTemplateMapping",
|
|
12
|
-
"variable": "
|
|
12
|
+
"variable": "term_uri",
|
|
13
13
|
"property": "hydra:freetextQuery",
|
|
14
14
|
"required": true
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"qa_replacement_patterns": {
|
|
19
|
-
"term_id": "
|
|
19
|
+
"term_id": "term_uri"
|
|
20
20
|
},
|
|
21
|
-
"term_id": "
|
|
21
|
+
"term_id": "URI",
|
|
22
22
|
"language": [ "fr" ],
|
|
23
23
|
"results": {
|
|
24
24
|
"id_predicate": "http://id.loc.gov/vocabulary/identifiers/lccn",
|
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
"url": {
|
|
5
5
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
|
6
6
|
"@type": "IriTemplate",
|
|
7
|
-
"template": "
|
|
7
|
+
"template": "{term_uri}",
|
|
8
8
|
"variableRepresentation": "BasicRepresentation",
|
|
9
9
|
"mapping": [
|
|
10
10
|
{
|
|
11
11
|
"@type": "IriTemplateMapping",
|
|
12
|
-
"variable": "
|
|
12
|
+
"variable": "term_uri",
|
|
13
13
|
"property": "hydra:freetextQuery",
|
|
14
14
|
"required": true
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"qa_replacement_patterns": {
|
|
19
|
-
"term_id": "
|
|
19
|
+
"term_id": "term_uri"
|
|
20
20
|
},
|
|
21
|
-
"term_id": "
|
|
21
|
+
"term_id": "URI",
|
|
22
22
|
"language": [ "en", "fr" ],
|
|
23
23
|
"results": {
|
|
24
24
|
"id_predicate": "http://purl.org/dc/terms/identifier",
|
|
@@ -4,23 +4,22 @@
|
|
|
4
4
|
"url": {
|
|
5
5
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
|
6
6
|
"@type": "IriTemplate",
|
|
7
|
-
"template": "
|
|
7
|
+
"template": "{term_uri}",
|
|
8
8
|
"variableRepresentation": "BasicRepresentation",
|
|
9
9
|
"mapping": [
|
|
10
10
|
{
|
|
11
11
|
"@type": "IriTemplateMapping",
|
|
12
|
-
"variable": "
|
|
12
|
+
"variable": "term_uri",
|
|
13
13
|
"property": "hydra:freetextQuery",
|
|
14
14
|
"required": true
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"qa_replacement_patterns": {
|
|
19
|
-
"term_id": "
|
|
19
|
+
"term_id": "term_uri"
|
|
20
20
|
},
|
|
21
|
-
"term_id": "
|
|
21
|
+
"term_id": "URI",
|
|
22
22
|
"results": {
|
|
23
|
-
"id_predicate": "http://id.loc.gov/vocabulary/identifiers/lccn",
|
|
24
23
|
"label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
|
|
25
24
|
"altlabel_predicate": "http://www.w3.org/2004/02/skos/core#altLabel"
|
|
26
25
|
}
|