qa 3.1.0 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +16 -548
  3. data/app/controllers/qa/linked_data_terms_controller.rb +64 -42
  4. data/app/controllers/qa/terms_controller.rb +14 -6
  5. data/app/models/qa/iri_template/url_config.rb +47 -0
  6. data/app/models/qa/iri_template/variable_map.rb +62 -0
  7. data/app/models/qa/linked_data/config/context_map.rb +77 -0
  8. data/app/models/qa/linked_data/config/context_property_map.rb +144 -0
  9. data/app/models/qa/linked_data/config/helper.rb +34 -0
  10. data/app/services/qa/iri_template_service.rb +31 -0
  11. data/{lib/qa/authorities → app/services/qa}/linked_data/authority_service.rb +3 -4
  12. data/app/services/qa/linked_data/authority_url_service.rb +48 -0
  13. data/app/services/qa/linked_data/deep_sort_service.rb +238 -0
  14. data/app/services/qa/linked_data/graph_service.rb +106 -0
  15. data/app/services/qa/linked_data/language_service.rb +30 -0
  16. data/app/services/qa/linked_data/language_sort_service.rb +81 -0
  17. data/app/services/qa/linked_data/mapper/context_mapper_service.rb +59 -0
  18. data/app/services/qa/linked_data/mapper/graph_mapper_service.rb +40 -0
  19. data/app/services/qa/linked_data/mapper/search_results_mapper_service.rb +70 -0
  20. data/config/authorities/linked_data/loc.json +5 -2
  21. data/config/authorities/linked_data/oclc_fast.json +3 -2
  22. data/config/initializers/linked_data_authorities.rb +1 -1
  23. data/config/locales/qa.en.yml +9 -0
  24. data/lib/generators/qa/install/templates/config/initializers/qa.rb +4 -0
  25. data/lib/qa.rb +8 -0
  26. data/lib/qa/authorities/assign_fast/generic_authority.rb +1 -1
  27. data/lib/qa/authorities/base.rb +0 -11
  28. data/lib/qa/authorities/crossref/generic_authority.rb +1 -1
  29. data/lib/qa/authorities/geonames.rb +1 -1
  30. data/lib/qa/authorities/getty/aat.rb +7 -2
  31. data/lib/qa/authorities/getty/tgn.rb +7 -2
  32. data/lib/qa/authorities/getty/ulan.rb +7 -2
  33. data/lib/qa/authorities/linked_data.rb +0 -1
  34. data/lib/qa/authorities/linked_data/config.rb +29 -28
  35. data/lib/qa/authorities/linked_data/config/search_config.rb +21 -79
  36. data/lib/qa/authorities/linked_data/config/term_config.rb +7 -77
  37. data/lib/qa/authorities/linked_data/find_term.rb +25 -17
  38. data/lib/qa/authorities/linked_data/generic_authority.rb +6 -5
  39. data/lib/qa/authorities/linked_data/rdf_helper.rb +6 -73
  40. data/lib/qa/authorities/linked_data/search_query.rb +54 -101
  41. data/lib/qa/authorities/loc/generic_authority.rb +4 -4
  42. data/lib/qa/authorities/web_service_base.rb +1 -8
  43. data/lib/qa/configuration.rb +7 -0
  44. data/lib/qa/version.rb +1 -1
  45. data/lib/tasks/mesh.rake +19 -18
  46. data/spec/controllers/linked_data_terms_controller_spec.rb +51 -1
  47. data/spec/controllers/terms_controller_spec.rb +15 -15
  48. data/spec/fixtures/authorities/linked_data/lod_encoding_config.json +2 -1
  49. data/spec/fixtures/authorities/linked_data/lod_full_config.json +56 -2
  50. data/spec/fixtures/authorities/linked_data/lod_full_config_1_0.json +164 -0
  51. data/spec/fixtures/authorities/linked_data/lod_lang_defaults.json +5 -4
  52. data/spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json +3 -2
  53. data/spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json +3 -2
  54. data/spec/fixtures/authorities/linked_data/lod_lang_param.json +3 -2
  55. data/spec/fixtures/authorities/linked_data/lod_min_config.json +3 -2
  56. data/spec/fixtures/authorities/linked_data/lod_search_only_config.json +2 -1
  57. data/spec/fixtures/authorities/linked_data/lod_sort.json +2 -1
  58. data/spec/fixtures/authorities/linked_data/lod_term_id_param_config.json +2 -1
  59. data/spec/fixtures/authorities/linked_data/lod_term_only_config.json +2 -1
  60. data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +2 -1
  61. data/spec/fixtures/getty-error-response.txt +10 -0
  62. data/spec/fixtures/lod_2_ranked_2_unranked.nt +17 -0
  63. data/spec/fixtures/lod_3_ranked_varying_preds.nt +16 -0
  64. data/spec/fixtures/lod_lang_search_filtering.nt +11 -0
  65. data/spec/fixtures/lod_search_with_blanknode_subjects.nt +18 -0
  66. data/spec/fixtures/lod_term_with_blanknode_objects.nt +8 -0
  67. data/spec/lib/authorities/assign_fast_spec.rb +1 -0
  68. data/spec/lib/authorities/getty/aat_spec.rb +14 -2
  69. data/spec/lib/authorities/getty/tgn_spec.rb +14 -2
  70. data/spec/lib/authorities/getty/ulan_spec.rb +14 -2
  71. data/spec/lib/authorities/linked_data/authority_service_spec.rb +2 -1
  72. data/spec/lib/authorities/linked_data/config_spec.rb +284 -5
  73. data/spec/lib/authorities/linked_data/find_term_spec.rb +3 -1
  74. data/spec/lib/authorities/linked_data/generic_authority_spec.rb +92 -42
  75. data/spec/lib/authorities/linked_data/search_config_spec.rb +67 -160
  76. data/spec/lib/authorities/linked_data/search_query_spec.rb +3 -127
  77. data/spec/lib/authorities/linked_data/term_config_spec.rb +6 -134
  78. data/spec/lib/authorities/loc_spec.rb +9 -9
  79. data/spec/lib/configuration_spec.rb +20 -7
  80. data/spec/lib/tasks/mesh.rake_spec.rb +2 -2
  81. data/spec/models/iri_template/url_config_spec.rb +102 -0
  82. data/spec/models/iri_template/variable_map_spec.rb +105 -0
  83. data/spec/models/linked_data/config/context_map_spec.rb +148 -0
  84. data/spec/models/linked_data/config/context_property_map_spec.rb +286 -0
  85. data/spec/services/iri_template_service_spec.rb +69 -0
  86. data/spec/services/linked_data/authority_url_service_spec.rb +107 -0
  87. data/spec/services/linked_data/deep_sort_service_spec.rb +260 -0
  88. data/spec/services/linked_data/graph_service_spec.rb +232 -0
  89. data/spec/services/linked_data/language_service_spec.rb +66 -0
  90. data/spec/services/linked_data/language_sort_service_spec.rb +58 -0
  91. data/spec/services/linked_data/mapper/context_mapper_service_spec.rb +137 -0
  92. data/spec/services/linked_data/mapper/graph_mapper_service_spec.rb +110 -0
  93. data/spec/services/linked_data/mapper/search_results_mapper_service_spec.rb +109 -0
  94. data/spec/spec_helper.rb +10 -2
  95. metadata +81 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: fb238fb83dfeddf175de6e3b39f7cbfd8bc8d665ef07bfbd68d540ca9d19541b
4
- data.tar.gz: 5a3b16d8b57dff5b3ece7fbd5dfa99be1d87879675d5e6d6764782087b2b06f4
2
+ SHA1:
3
+ metadata.gz: 5db70537500cd9a89a2a7725941bfab79ab627af
4
+ data.tar.gz: f1d64435a7113fd02e1e445e97d139b45fc41e5c
5
5
  SHA512:
6
- metadata.gz: 61d883f7a50e76e1aa0ea9d410d4251b294b81eb46355c8340af70e263ea9dddbd0f1f2407eff42dbb5ce1e04e4d04e8cb0f889a493c96885f70ea24b2a58c21
7
- data.tar.gz: f0481a189b24f742f5d1c38f2c2e3c478c1cd06b427fe7cd86604b5378c64ec601f90b41af3f9ceb1c4d4d69b672cc9e957e4f08423b74664e4151663b8200f1
6
+ metadata.gz: 624d28f29c102ec110369550d386f84bc477cf2c3c04270276986a0c85f9d38ae4d2e76d5310299e519ea8b2ac7dbd94073de3c4c563200fdf7c17af6ab9ebd4
7
+ data.tar.gz: 11b53240b97b86248349897501549bca6b5968763d0f4fcc711bf94a71e58408356493213b70f52bb9b7b01044ebb1fdb8441ec89ea408d81db5747d95b7de58
data/README.md CHANGED
@@ -20,21 +20,9 @@ You should question your authorities.
20
20
  * [How does it work?](#how-does-it-work)
21
21
  * [Sub-Authorities](#sub-authorities)
22
22
  * [How do I use this?](#how-do-i-use-this)
23
- * [Examples](#examples)
24
- * [JSON Results](#json-results)
23
+ * [Basic QA Requests](#basic-qa-requests)
24
+ * [Typical JSON Results](#typical-json-results)
25
25
  * [Authority Sources information](#authority-sources-information)
26
- * [FAST](#fast)
27
- * [Geonames](#geonames)
28
- * [Adding your own authorities](#adding-your-own-authorities)
29
- * [Local Sub-Authorities](#local-sub-authorities)
30
- * [In YAML files](#in-yaml-files)
31
- * [In database tables](#in-database-tables)
32
- * [Medical Subject Headings (Mesh)](#medical-subject-headings-mesh)
33
- * [Linked Open Data (LOD) Authorities](#linked-open-data-lod-authorities)
34
- * [Configuring a LOD Authority](#configuring-a-lod-authority)
35
- * [Query](#query)
36
- * [Find term](#find-term)
37
- * [Add javascript to support autocomplete](#add-javascript-to-support-autocomplete)
38
26
  * [Developer Notes](#developer-notes)
39
27
  * [Compatibility](#compatibility)
40
28
  * [Product Owner & Maintenance](#product-owner--maintenance)
@@ -42,6 +30,10 @@ You should question your authorities.
42
30
  * [Help](#help)
43
31
  * [Acknowledgments](#acknowledgments)
44
32
 
33
+ ## Not seeing documentation you used to find in the README?
34
+
35
+ Much of the documentation has moved to the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) to allow for better organization. We hope that you will find this easier to use.
36
+
45
37
  ----
46
38
  ## What does this do?
47
39
 
@@ -85,7 +77,9 @@ This will copy over some additional config files and add the engine's routes to
85
77
 
86
78
  Start questioning your authorities!
87
79
 
88
- ### Examples
80
+ ### Basic QA Requests
81
+
82
+ These show the basic routing patterns for connecting to authorities. See the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) documentation for detailed documentation and examples for each authority and local authorities.
89
83
 
90
84
  Return a complete list of terms:
91
85
 
@@ -102,7 +96,9 @@ Return the complete information for a specific term given its identifier
102
96
  /qa/show/:vocab/:id
103
97
  /qa/show/:vocab/:subauthority/:id
104
98
 
105
- ### JSON Results
99
+
100
+
101
+ ### Typical JSON Results
106
102
 
107
103
  Results are returned in JSON in this format:
108
104
 
@@ -113,538 +109,11 @@ Results are returned in JSON in this format:
113
109
  {"id" : "", "label" : "Neither does this"}
114
110
  ]
115
111
 
116
- Results for specific terms may vary according to the term. For example:
117
-
118
- /qa/show/mesh/D000001
119
-
120
- Might return:
121
-
122
- { "id" : "D000001",
123
- "label" : "Calcimycin",
124
- "tree_numbers" : ["D03.438.221.173"],
125
- "synonyms" : ["A-23187", "A23187", "Antibiotic A23187", "A 23187", "A23187, Antibiotic"]
126
- }
127
-
128
- This is due to the varying nature of each authority source. However, results for multiple terms, such as a search, we
129
- should always use the above id and label structure to ensure interoperability at the GUI level.
130
112
 
131
113
  # Authority Sources information
132
114
 
133
- ### Library of Congress
134
-
135
- LOC already provides a REST API to query their headings. QA provides a wrapper around this to augment its
136
- functionality and refine it so that it is congruent with the other authorities in QA. For example,
137
- searching subject headings from LOC uses the subjects sub-authority. Using QA, we'd construct the URL as:
138
-
139
- /qa/search/loc/subjects?q=History--
140
-
141
- In turn, this URL is passed to LOC as:
142
-
143
- http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects
144
-
145
- QA then presents this data to you in JSON format:
146
-
147
- [
148
- {"id":"info:lc/authorities/subjects/sh2008121753","label":"History--Philosophy--History--20th century"},
149
- {"id":"info:lc/authorities/subjects/sh2008121752","label":"History--Philosophy--History--19th century"},
150
- etc...
151
- ]
152
-
153
- ### FAST
154
-
155
- In the same manner, QA provides a wrapper around OCLC's FAST autocomplete
156
- service. The following subauthorities are available:
157
-
158
- * all
159
- * personal
160
- * corporate
161
- * event
162
- * uniform
163
- * topical
164
- * geographic
165
- * form_genre
166
-
167
- Example qa URL: /qa/search/assign_fast/all?q=periodic+table
168
-
169
- The result includes both 'label' and 'value' to help users select the correct
170
- heading, e.g.:
171
-
172
- [
173
- {
174
- "id":"fst01789629",
175
- "label":"Periodic table",
176
- "value":"Periodic table"
177
- },
178
- {
179
- "id":"fst01789629",
180
- "label":"Periodic table (Saunders, N.) USE Periodic table",
181
- "value":"Periodic table"
182
- },...
183
- ]
184
-
185
- Make sure you handle these correctly in your form.
186
-
187
- For more details on this OCLC API, see
188
- http://www.oclc.org/developer/develop/web-services/fast-api/assign-fast.en.html
189
-
190
- ### Geonames
191
- Make sure you register an account and enable it to see search results.
192
-
193
- Ensure you can run a query like this:
194
-
195
- ```
196
- http://api.geonames.org/searchJSON?q=port&&maxRows=10&username=MY_ACCOUNT_NAME
197
- ```
198
-
199
- Then you can set your username like this:
200
-
201
- ```ruby
202
- Qa::Authorities::Geonames.username = 'myAccountName'
203
-
204
- ```
205
- ### Adding your own authorities
206
-
207
- Create an authority file inside your app.
208
-
209
- ```
210
- app/authorities/qa/authorities/your_authority.rb
211
-
212
- ```
213
-
214
- Write module code with at least a search method.
215
-
216
- ```ruby
217
- module Qa::Authorities
218
- class YourAuthority < Qa::Authorities::Base
219
- # Arguments can be (query) or (query, terms_controller)
220
- def search(_q)
221
- # Should return array of hashes with ids, labels, and values(optional)
222
- { id: '123', label: 'Title', value: 'The Title' }
223
- end
224
- end
225
- end
226
- ```
227
-
228
- ### Local Sub-Authorities
229
-
230
- #### In YAML files
231
- For simple use cases when you have a few terms that don't change very often.
232
-
233
- Run the generator to install configuration files and an example authority.
234
-
235
- rails generate qa:local:files
236
-
237
- This will install a sample states authority file that lists all the states in the U.S. To query it,
238
-
239
- /qa/search/local/states?q=Nor
240
-
241
- Results are in JSON.
242
-
243
- [{"id":"NC","label":"North Carolina"},{"id":"ND","label":"North Dakota"}]
244
-
245
- The entire list can also be returned using:
246
-
247
- /qa/terms/local/states/
248
-
249
- Local authorities are stored as YAML files, one for each sub-authority. By default, local
250
- authority YAML files are located in `config/authorities/`. This location can be changed by editing
251
- the `:local_path` entry in `config/authorities.yml`. Relative paths are assumed to be relative to
252
- `Rails.root`.
253
-
254
- Local authority YAML files are named for the sub-authority they represent. The included example "states" sub-authority
255
- is named states.yml.
256
-
257
- To create your own local authority, create a .yml file, place it in the configured directory and query it
258
- using the file's name as the sub-authority. For example, if I create `foo.yml`, I would then search it using:
259
-
260
- /qa/search/local/foo?q=search_term
261
-
262
- #### Supported formats
263
-
264
- ##### List of terms
265
-
266
- terms:
267
- - Term 1
268
- - Term 2
269
-
270
- ##### List of id and term keys and, optionally, active key
271
-
272
- terms:
273
- - id: id1
274
- term: Term 1
275
- active: true
276
- - id: id2
277
- term: Term 2
278
- active: false
279
-
280
- #### Adding your own local sub-authorities
281
-
282
- If you'd like to add your own local authority that isn't necessarily backed by yaml, create an initializer and tell the local authority about your custom sub-authority:
283
-
284
- ```ruby
285
- Qa::Authorities::Local.register_subauthority('names', 'LocalNames')
286
- ```
287
-
288
- The second argument is a name of a class that represents your local authority. Then when you go to:
289
-
290
- /qa/search/local/names?q=Zoia
291
-
292
- You'll be searching with an instance of `LocalNames`
293
-
294
- ### In database tables
295
-
296
- Run the generator to install configuration files and an example authority.
297
-
298
- rails generate qa:local:tables
299
- rake db:migrate
300
-
301
- **Note: If you are using MYSQL as your database use the MSQL database generator instead**
302
-
303
- rails generate qa:local:tables:mysql
304
- rake db:migrate
305
-
306
- This will create two tables/models Qa::LocalAuthority and Qa::LocalAuthorityEntry. You can then add terms to each:
307
-
308
- language_auth = Qa::LocalAuthority.find_or_create_by(name: 'language')
309
- Qa::LocalAuthorityEntry.create(local_authority: language_auth,
310
- label: 'French',
311
- uri: 'http://id.loc.gov/vocabulary/languages/fre')
312
- Qa::LocalAuthorityEntry.create(local_authority: language_auth,
313
- label: 'Uighur',
314
- uri: 'http://id.loc.gov/vocabulary/languages/uig')
315
-
316
- Unfortunately, Rails doesn't have a mechanism for adding functional indexes to tables, so if you have a lot of rows, you'll want to add an index:
317
-
318
- CREATE INDEX "index_qa_local_authority_entries_on_lower_label" ON
319
- "qa_local_authority_entries" (local_authority_id, lower(label))
320
-
321
- **Note: If you are using MYSQL as your database and used the MSQL database gerator we tried to execute the correct SQL to create the virtual fields and indexes for you**
322
-
323
- Finall you want register your authority in an initializer:
324
-
325
- Qa::Authorities::Local.register_subauthority('languages', 'Qa::Authorities::Local::TableBasedAuthority')
326
-
327
- **Note: If you are using MYSQL as your database and used the MSQL database gerator register the MysqlTableBasedAuthority instead of the TableBasedAuthority**
328
-
329
- Then you can search for
330
-
331
- /qa/search/local/languages?q=Fre
332
-
333
- Results are in JSON.
334
-
335
- [{"id":"http://id.loc.gov/vocabulary/languages/fre","label":"French"}]
336
-
337
- The entire list (up to the first 1000 terms) can also be returned using:
338
-
339
- /qa/terms/local/languages/
340
-
341
- #### Loading RDF data into database tables
342
-
343
- You can use the Qa::Services::RDFAuthorityParser to import rdf files into your database tables. See the class file, lib/qa/services/rdf_authority_parser.rb, for examples and more information.
344
- To run the class in your local project you must include `gem 'linkeddata'` into your Gemfile and `require 'linkeddata'` into an initializer or your application.rb
345
-
346
- ### Medical Subject Headings (MeSH)
347
-
348
- Provides autocompletion of [MeSH terms](http://www.nlm.nih.gov/mesh/introduction.html). This
349
- implementation is simple, and only provides *descriptors* and does not implement *qualifiers* (in
350
- the technical MeSH sense of these terms). The terms are stored in a local database, which is then
351
- queried to provide the suggestions.
352
-
353
- To use, run the included rake task to copy over the relevant database migrations into your application:
354
-
355
- rake qa:install:migrations
356
-
357
- Then, create the tables in your database
358
-
359
- rake db:migrate
360
-
361
- Now that you've setup your application to use MeSH terms, you'll now need to load the terms into your
362
- database so you can query them locally.
363
-
364
- To import the mesh terms into the local database, first download the MeSH descriptor dump in ASCII
365
- format. You can read about doing this [here](http://www.nlm.nih.gov/mesh/filelist.html). Once you have this file, use the
366
- following rake task to load the terms into your database:
367
-
368
- MESH_FILE=path/to/mesh.txt rake mesh:import
369
-
370
- This may take a few minutes to finish.
371
-
372
- **Note:** Updating the tables with new terms is currently not supported.
373
-
374
- ### Linked Open Data (LOD) Authorities
375
-
376
- You will need to add gems that process the type of linked data returned for the authorities you use.
377
-
378
- To cover all possible formats, include the [ruby-rdf/linkeddata](https://github.com/ruby-rdf/linkeddata) gem.
115
+ See the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) for documentation on how to connect to the supported authorities, documentation on how to create new authorities, and other useful tips.
379
116
 
380
- ```
381
- gem 'linkeddata'
382
- ```
383
-
384
- This gem is included in QA for development and testing of QA, but is not automatically included in the released gem.
385
- Additionally, it is unlikely that you will need all the formats included by that gem. You may want to select only those
386
- gems that are for the formats you need supported.
387
-
388
- See all gems in [linkeddata.gemspec](https://github.com/ruby-rdf/linkeddata/blob/develop/linkeddata.gemspec).
389
-
390
- For example, if you know the authorites you are working with support rdf-xml, you can include the following gem instead of linkeddata.
391
-
392
- ```
393
- gem 'rdf-rdfxml'
394
- ```
395
-
396
- #### Configuring a LOD Authority
397
-
398
- There are a number of authority configurations that are available. See (ld4l-labs/linked_data_authorities)[https://github.com/ld4l-labs/linked_data_authorities] for configurations and instructions on how to use them. These are updated periodically, so check back from time to time to see what's new.
399
-
400
- Access to LOD authorities can be configured. Currently, a configuration exists in QA for OCLC Fast Linked Data, Library of
401
- Congress (terms only), and Agrovoc. Look for configuration files in
402
- [/config/authorities/linked_data](https://github.com/samvera/questioning_authority/tree/master/config/authorities/linked_data).
403
-
404
- Example configuration...
405
-
406
- ```json
407
- {
408
- "term": {
409
- "url": {
410
- "@context": "http://www.w3.org/ns/hydra/context.jsonld",
411
- "@type": "IriTemplate",
412
- "template": "http://id.worldcat.org/fast/{?term_id}/rdf.xml",
413
- "variableRepresentation": "BasicRepresentation",
414
- "mapping": [
415
- {
416
- "@type": "IriTemplateMapping",
417
- "variable": "term_id",
418
- "property": "hydra:freetextQuery",
419
- "required": true
420
- }
421
- ]
422
- },
423
- "qa_replacement_patterns": {
424
- "term_id": "term_id"
425
- },
426
- "language": ["en","fr"]
427
- "term_id": "ID",
428
- "results": {
429
- "id_predicate": "http://purl.org/dc/terms/identifier",
430
- "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
431
- "altlabel_predicate": "http://www.w3.org/2004/02/skos/core#altLabel",
432
- "sameas_predicate": "http://schema.org/sameAs"
433
- }
434
- },
435
- "search": {
436
- "url": {
437
- "@context": "http://www.w3.org/ns/hydra/context.jsonld",
438
- "@type": "IriTemplate",
439
- "template": "http://experimental.worldcat.org/fast/search?query={?subauth}+all+%22{?query}%22&sortKeys=usage&maximumRecords={?maximumRecords}",
440
- "variableRepresentation": "BasicRepresentation",
441
- "mapping": [
442
- {
443
- "@type": "IriTemplateMapping",
444
- "variable": "query",
445
- "property": "hydra:freetextQuery",
446
- "required": true
447
- },
448
- {
449
- "@type": "IriTemplateMapping",
450
- "variable": "subauth",
451
- "property": "hydra:freetextQuery",
452
- "required": false,
453
- "default": "cql.any"
454
- },
455
- {
456
- "@type": "IriTemplateMapping",
457
- "variable": "maximumRecords",
458
- "property": "hydra:freetextQuery",
459
- "required": false,
460
- "default": "20"
461
- }
462
- ]
463
- },
464
- "qa_replacement_patterns": {
465
- "query": "query",
466
- "subauth": "subauth"
467
- },
468
- "language": ["en"]
469
- "results": {
470
- "id_predicate": "http://purl.org/dc/terms/identifier",
471
- "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
472
- "sort_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel"
473
- },
474
- "subauthorities": {
475
- "topic": "oclc.topic",
476
- "geographic": "oclc.geographic",
477
- "event_name": "oclc.eventName",
478
- "personal_name": "oclc.personalName",
479
- "corporate_name": "oclc.corporateName",
480
- "uniform_title": "oclc.uniformTitle",
481
- "period": "oclc.period",
482
- "form": "oclc.form",
483
- "alt_lc": "oclc.altlc"
484
- }
485
- }
486
- }
487
- ```
488
-
489
- NOTES:
490
- * term: (optional) is used to define how to request term information from the authority and how to interpret results.
491
- * url: (required) templated link representation of the authority API URL and mapping of parameters for requesting term information from the authority
492
- * template: is the authority API URL with placeholders for substitution parameters in the form {?var_name}
493
- * NOTE: {?term_id} (required) and {?subauth} (optional) are expected to match to QA params (see qa_replacement_patterns to match QA params with mapping variables)
494
- * Additional substitutions can be made in the authority API if supported by the authority by adding additional mappings. Search has an example with maximumRecords.
495
- * variable: should match a replacement pattern in the template (e.g. variable: maximumRecords ==> {?maximumRecords}
496
- * required: true | false (NOTE: Not enforced at this time.)
497
- * default: provide a default value that will be used if not specified
498
- * See (documentation of templated-links)[http://www.hydra-cg.com/spec/latest/core/#templated-links] for more information.
499
- * qa_replacement_patterns: identifies which mapping variables are being used for term_id and subauth.
500
- * NOTE: The URL to make a term request via QA always uses term_id and subauth as the param names. qa_replacement_patters allows the url template to use a different variable name for pattern replacement.
501
- * language: (optional) values: array of en | fr | etc. -- identify language to use to include in results, filtering out triples of other languages
502
- * NOTE: Some authoritys' API URL allows language to be specified as a parameter. In that case, use pattern replacement to add the language to the API URL to prevent alternate languages from being returned in the results.
503
- * NOTE: At this writing, only label and altlabel are filtered.
504
- * term_id: (optional) values: ID (default) | URI - This tells apps whether `__TERM_ID__` replacement is expecting an ID or URI.
505
- * results: (required) lists predicates to select out for normalization in the hash results
506
- * id_predicate: (optional)
507
- * label_predicate: (required)
508
- * altlabel_predicate: (optional)
509
- * sameas_predicate: (optional)
510
- * narrower_predicate: (optional)
511
- * broader_predicate: (optional)
512
- * subauthorities: (optional)
513
- * subauthority name (e.g. topic:, personal_name:, corporate_name, etc.) Value for {?subauth} are limited to the values in the list of subauthorities.
514
-
515
- * search: (optional) is used to define how to send a query to the authority and how to interpret results.
516
- * url: (required) templated link representation of the authority API URL and mapping of parameters for sending a query to the authority
517
- * template: is the authority API URL with placeholders for substitution parameters in the form {?var_name}
518
- * NOTE: {?query} (required) and {?subauth} (optional) are expected to match to QA params (see qa_replacement_patterns to match QA params with mapping variables)
519
- * Additional substitutions can be made in the authority API if supported by the authority by adding additional mappings. Search has an example with maximumRecords.
520
- * variable: should match a replacement pattern in the template (e.g. variable: maximumRecords ==> {?maximumRecords}
521
- * required: true | false (NOTE: Not enforced at this time.)
522
- * default: provide a default value that will be used if not specified
523
- * See (documentation of templated-links)[http://www.hydra-cg.com/spec/latest/core/#templated-links] for more information.
524
- * qa_replacement_patterns: identifies which mapping variables are being used for term_id and subauth.
525
- * NOTE: The URL to make a term request via QA always uses term_id and subauth as the param names. qa_replacement_patters allows the url template to use a different variable name for pattern replacement.
526
- * language: (optional) values: array of en | fr | etc. -- identify language to use to include in results, filtering out triples of other languages
527
- * NOTE: Some authoritys' API URL allows language to be specified as a parameter. In that case, use pattern replacement to add the language to the API URL to prevent alternate languages from being returned in the results.
528
- * NOTE: At this writing, only label and altlabel are filtered.
529
- * results: (required) lists predicates to normalize and include in json results
530
- * id_predicate: (optional)
531
- * label_predicate: (required)
532
- * altlabel_predicate: (optional)
533
- * subauthorities: (optional)
534
- * subauthority name (e.g. topic:, personal_name:, corporate_name, etc.) Value for {?subauth} are limited to the values in the list of subauthorities.
535
-
536
-
537
- ##### Add new configuration
538
- You can add linked data authorities by adding configuration files to your rails app in `Rails.root/config/authorities/linked_data/YOUR_AUTH.json`
539
-
540
- ##### Modify existing configuration
541
- To modify one of the QA supplied configurations, copy it to your app in `Rails.root/config/authorities/linked_data/YOUR_AUTH.json`. Make your modifications to the json configuration file in your app.
542
-
543
- #### Query
544
- To query OCLC Fast Linked Data service by code...
545
-
546
- ```ruby
547
- # Search OCLC Fast all sub-authorities with default value for number of results to return
548
- lda = Qa::Authorities::LinkedData::GenericAuthority.new(:OCLC_FAST)
549
- ld_results = lda.search "Cornell University"
550
-
551
- # Search OCLC Fast all sub-authorities passing in value for number of results to return
552
- lda = Qa::Authorities::LinkedData::GenericAuthority.new(:OCLC_FAST)
553
- ld_results = lda.search "Cornell University",{"maximumRecords" => "5"}
554
-
555
- # Search OCLC Fast Corporate Name sub-authority passing in value for number of results to return
556
- lda = Qa::Authorities::LinkedData::GenericAuthority.new(:OCLC_FAST,'corporate_name')
557
- ld_results = lda.search "Cornell University",{"maximumRecords" => "3"}
558
- ```
559
-
560
- or by URL when QA is an installed gem in an app...
561
-
562
- ```
563
- http://localhost:3000/qa/search/linked_data/oclc_fast?q=Cornell&maximumRecords=3
564
- ```
565
-
566
- Returns results in the format...
567
-
568
- ```json
569
- [{"uri":"http://id.worldcat.org/fast/530369","id":"530369","label":"Cornell University"},
570
- {"uri":"http://id.worldcat.org/fast/5140","id":"5140","label":"Cornell, Joseph"},
571
- {"uri":"http://id.worldcat.org/fast/557490","id":"557490","label":"New York State School of Industrial and Labor Relations"}]
572
- ```
573
-
574
- NOTE: For some authorities, the uri and id will both be the uri.
575
-
576
- and with subauthority...
577
-
578
- ```
579
- http://localhost:3000/qa/search/linked_data/oclc_fast/personal_name?q=Cornell&maximumRecords=3
580
- ```
581
-
582
- returning results...
583
-
584
- ```json
585
- [{"uri":"http://id.worldcat.org/fast/5140","id":"5140","label":"Cornell, Joseph"},
586
- {"uri":"http://id.worldcat.org/fast/72456","id":"72456","label":"Cornell, Sarah Maria, 1802-1832"},
587
- {"uri":"http://id.worldcat.org/fast/409667","id":"409667","label":"Cornell, Ezra, 1807-1874"}]
588
- ```
589
-
590
- #### Find term
591
- To find a single term in OCLC Fast Linked Data service by code...
592
-
593
- ```ruby
594
- # Search OCLC Fast all sub-authorities with default value for number of results to return
595
- lda = Qa::Authorities::LinkedData::GenericAuthority.new(:OCLC_FAST_ALL)
596
- ld_results = lda.find 530369
597
- ```
598
-
599
- or by URL when QA is an installed gem in an app...
600
-
601
- ```
602
- http://localhost:3000/qa/show/linked_data/oclc_fast/530369
603
- ```
604
-
605
- Returns results in the format...
606
-
607
- ```json
608
- {"uri":"http://id.worldcat.org/fast/530369",
609
- "id":"530369","label":"Cornell University",
610
- "altlabel":["Ithaca (N.Y.). Cornell University","Kornelʹskii universitet","Kʻang-nai-erh ta hsüeh"],
611
- "sameas":["http://id.loc.gov/authorities/names/n79021621","https://viaf.org/viaf/126293486"],
612
- "predicates":{
613
- "http://purl.org/dc/terms/identifier":"530369",
614
- "http://www.w3.org/2004/02/skos/core#inScheme":["http://id.worldcat.org/fast/ontology/1.0/#fast","http://id.worldcat.org/fast/ontology/1.0/#facet-Corporate"],
615
- "http://www.w3.org/1999/02/22-rdf-syntax-ns#type":"http://schema.org/Organization",
616
- "http://www.w3.org/2004/02/skos/core#prefLabel":"Cornell University",
617
- "http://schema.org/name":["Cornell University","Ithaca (N.Y.). Cornell University","Kornelʹskii universitet","Kʻang-nai-erh ta hsüeh"],
618
- "http://www.w3.org/2004/02/skos/core#altLabel":["Ithaca (N.Y.). Cornell University","Kornelʹskii universitet","Kʻang-nai-erh ta hsüeh"],
619
- "http://schema.org/sameAs":["http://id.loc.gov/authorities/names/n79021621","https://viaf.org/viaf/126293486"]}}
620
- ```
621
-
622
- NOTE: All predicates with the URI as the subject will be included under "predicates" key. The selected keys are determined by the configuration file and can be one or more of id_predicate, label_predicate (required), altlabel_predicate, sameas_predicate, narrower_predicate, or broader_predicate.
623
-
624
- #### Add javascript to support autocomplete
625
-
626
- See [Using with autocomplete in Sufia](https://github.com/samvera/questioning_authority/wiki/Using-with-autocomplete-in-Sufia) in the wiki documentation for QA.
627
-
628
- If you are using jQueryUI >= 1.8 you can use the [autocomplete function](http://api.jqueryui.com/autocomplete/), for example:
629
-
630
- ```
631
- $(function(){
632
- $('#some_input').autocomplete({
633
- source: function (request, response) {
634
- $.ajax({
635
- url: "/qa/search/loc/subjects?q=" + request.term,
636
- type: 'GET',
637
- dataType: 'json',
638
- complete: function (xhr, status) {
639
- var results = $.parseJSON(xhr.responseText);
640
- response(results);
641
- }
642
- });
643
- },
644
- autoFocus: true
645
- });
646
- });
647
- ```
648
117
 
649
118
  # Developer Notes
650
119
 
@@ -665,14 +134,13 @@ Commit your features into a new branch and submit a pull request.
665
134
 
666
135
  ## Compatibility
667
136
 
668
- * Ruby 2.4 or the latest 2.3 version is recommended. Later versions may also work.
669
- * Rails 5 is required. We recommend the latest Rails 5.0 release.
137
+ * Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
138
+ * Rails 5 is required. We recommend the latest Rails 5.2 release.
670
139
 
671
140
  ## Product Owner & Maintenance
672
141
 
673
142
  Questioning Authority is a Core Component of the Samvera community. The documentation for
674
- what this means can be found
675
- [here](http://samvera.github.io/core_components.html#requirements-for-a-core-component).
143
+ what this means can be found [here](http://samvera.github.io/core_components.html#requirements-for-a-core-component).
676
144
 
677
145
  ### Product Owner
678
146