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
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_default/term/{?term_id}",
7
+ "template": "http://localhost/test_default/term/{term_id}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -29,7 +30,7 @@
29
30
  "url": {
30
31
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
31
32
  "@type": "IriTemplate",
32
- "template": "http://localhost/test_default/search?query={?query}",
33
+ "template": "http://localhost/test_default/search?{?query}",
33
34
  "variableRepresentation": "BasicRepresentation",
34
35
  "mapping": [
35
36
  {
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_no_default/term/{?term_id}",
7
+ "template": "http://localhost/test_no_default/term/{term_id}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -28,7 +29,7 @@
28
29
  "url": {
29
30
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
30
31
  "@type": "IriTemplate",
31
- "template": "http://localhost/test_no_default/search?query={?query}",
32
+ "template": "http://localhost/test_no_default/search?{?query}",
32
33
  "variableRepresentation": "BasicRepresentation",
33
34
  "mapping": [
34
35
  {
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_replacement/term/{?term_id}?lang={?lang}",
7
+ "template": "http://localhost/test_replacement/term/{term_id}?{?lang}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -35,7 +36,7 @@
35
36
  "url": {
36
37
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
37
38
  "@type": "IriTemplate",
38
- "template": "http://localhost/test_replacement/search?query={?query}&lang={?lang}",
39
+ "template": "http://localhost/test_replacement/search?{?query}&{?lang}",
39
40
  "variableRepresentation": "BasicRepresentation",
40
41
  "mapping": [
41
42
  {
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_default/term/{?term_id}",
7
+ "template": "http://localhost/test_default/term/{term_id}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -27,7 +28,7 @@
27
28
  "url": {
28
29
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
29
30
  "@type": "IriTemplate",
30
- "template": "http://localhost/test_default/search?query={?query}",
31
+ "template": "http://localhost/test_default/search?{?query}",
31
32
  "variableRepresentation": "BasicRepresentation",
32
33
  "mapping": [
33
34
  {
@@ -1,10 +1,11 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {},
3
4
  "search": {
4
5
  "url": {
5
6
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
6
7
  "@type": "IriTemplate",
7
- "template": "http://localhost/test_default/search?subauth={?subauth}&query={?query}&param1={?param1}&param2={?param2}",
8
+ "template": "http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}",
8
9
  "variableRepresentation": "BasicRepresentation",
9
10
  "mapping": [
10
11
  {
@@ -1,10 +1,11 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {},
3
4
  "search": {
4
5
  "url": {
5
6
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
6
7
  "@type": "IriTemplate",
7
- "template": "http://localhost/test_sort/search?query={?query}",
8
+ "template": "http://localhost/test_sort/search?{?query}",
8
9
  "variableRepresentation": "BasicRepresentation",
9
10
  "mapping": [
10
11
  {
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_default/term/{?term_id}",
7
+ "template": "http://localhost/test_default/term/{term_id}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_default/term/{?subauth}/{?term_id}?param1={?param1}&param2={?param2}",
7
+ "template": "http://localhost/test_default/term/{subauth}/{term_id}?{?param1}&{?param2}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -1,9 +1,10 @@
1
1
  {
2
+ "QA_CONFIG_VERSION": "2.0",
2
3
  "term": {
3
4
  "url": {
4
5
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
6
  "@type": "IriTemplate",
6
- "template": "http://localhost/test_default/term?uri={?term_uri}",
7
+ "template": "http://localhost/test_default/term?uri={term_uri}",
7
8
  "variableRepresentation": "BasicRepresentation",
8
9
  "mapping": [
9
10
  {
@@ -0,0 +1,10 @@
1
+ {
2
+ "error" : {
3
+ "cause" : null,
4
+ "stackTrace" : [],
5
+ "message" : "/sparql.json?+%28regex%28%3Fname%2C+%22amphorae%22%2C+%22i%22%29%29%29+.+%7D+ORDER+BY+%3Fname&_equivalent=false&_form=%2Fsparql&_implicit=false&implicit=true&query=SELECT+%3Fs+%3Fname+%7B+%3Fs+a+skos%3AConcept%3B+luc%3Aterm+%22Panathenaic+amphorae%22%3B+skos%3AinScheme+%3Chttp%3A%2F%2Fvocab.getty.edu%2Faat%2F%3E+%3B+gvp%3AprefLabelGVP+%5Bskosxl%3AliteralForm+%3Fname%5D.+FILTER+%28%28regex%28%3Fname%2C+%22Panathenaic%22%2C+%22i%22%29%29+",
6
+ "localizedMessage" : "/sparql.json?+%28regex%28%3Fname%2C+%22amphorae%22%2C+%22i%22%29%29%29+.+%7D+ORDER+BY+%3Fname&_equivalent=false&_form=%2Fsparql&_implicit=false&implicit=true&query=SELECT+%3Fs+%3Fname+%7B+%3Fs+a+skos%3AConcept%3B+luc%3Aterm+%22Panathenaic+amphorae%22%3B+skos%3AinScheme+%3Chttp%3A%2F%2Fvocab.getty.edu%2Faat%2F%3E+%3B+gvp%3AprefLabelGVP+%5Bskosxl%3AliteralForm+%3Fname%5D.+FILTER+%28%28regex%28%3Fname%2C+%22Panathenaic%22%2C+%22i%22%29%29+",
7
+ "suppressed" : []
8
+ },
9
+ "stackTrace" : ""
10
+ }
@@ -0,0 +1,17 @@
1
+ <http://id.worldcat.org/fast/530369> <http://purl.org/dc/terms/identifier> "530369" .
2
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University" .
3
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#altLabel> "Ithaca (N.Y.). Cornell University" .
4
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#sameAs> <http://id.loc.gov/authorities/names/n79021621> .
5
+ <http://id.worldcat.org/fast/530369> <http://vivoweb.org/ontology/core#rank> "1" .
6
+ <http://id.worldcat.org/fast/510103> <http://purl.org/dc/terms/identifier> "510103" .
7
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University. Libraries" .
8
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#altLabel> "Cornell University. Central Libraries" .
9
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#altLabel> "Cornell University. John M. Olin Library" .
10
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#altLabel> "Cornell University. White Library" .
11
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#sameAs> "http://id.loc.gov/authorities/names/n50000040" .
12
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#sameAs> "https://viaf.org/viaf/147713418" .
13
+ <http://id.worldcat.org/fast/5140> <http://purl.org/dc/terms/identifier> "5140" .
14
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell, Joseph" .
15
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#altLabel> <_:b0> .
16
+ <_:b0> <http://www.w3.org/2004/02/skos/core#prefLabel> "Joseph Cornell" .
17
+ <http://id.worldcat.org/fast/5140> <http://vivoweb.org/ontology/core#rank> "3" .
@@ -0,0 +1,16 @@
1
+ <http://id.worldcat.org/fast/530369> <http://purl.org/dc/terms/identifier> "530369" .
2
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University" .
3
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#altLabel> "Ithaca (N.Y.). Cornell University" .
4
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#sameAs> <http://id.loc.gov/authorities/names/n79021621> .
5
+ <http://id.worldcat.org/fast/530369> <http://vivoweb.org/ontology/core#rank> "1" .
6
+ <http://id.worldcat.org/fast/510103> <http://purl.org/dc/terms/identifier> "510103" .
7
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University. Libraries" .
8
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#altLabel> "Cornell University. Central Libraries" .
9
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#altLabel> "Cornell University. John M. Olin Library" .
10
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#altLabel> "Cornell University. White Library" .
11
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#sameAs> <http://id.loc.gov/authorities/names/n50000040> .
12
+ <http://id.worldcat.org/fast/510103> <http://www.w3.org/2004/02/skos/core#sameAs> <https://viaf.org/viaf/147713418> .
13
+ <http://id.worldcat.org/fast/510103> <http://vivoweb.org/ontology/core#rank> "2" .
14
+ <http://id.worldcat.org/fast/5140> <http://purl.org/dc/terms/identifier> "5140" .
15
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell, Joseph" .
16
+ <http://id.worldcat.org/fast/5140> <http://vivoweb.org/ontology/core#rank> "3" .
@@ -0,0 +1,11 @@
1
+ <http://id.worldcat.org/fast/530369> <http://purl.org/dc/terms/identifier> "530369" .
2
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "buttermilk"@en
3
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Babeurre"@fr
4
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Buttermilch"
5
+ <http://id.worldcat.org/fast/5140> <http://purl.org/dc/terms/identifier> "5140" .
6
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "dried milk"@en
7
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "lait en poudre"@fr
8
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "getrocknete Milch"@de
9
+ <http://id.worldcat.org/fast/557490> <http://purl.org/dc/terms/identifier> "557490" .
10
+ <http://id.worldcat.org/fast/557490> <http://www.w3.org/2004/02/skos/core#prefLabel> "condensed milk"@en
11
+ <http://id.worldcat.org/fast/557490> <http://www.w3.org/2004/02/skos/core#prefLabel> "Kondensmilch"@de
@@ -0,0 +1,18 @@
1
+ <http://id.worldcat.org/fast/530369> <http://purl.org/dc/terms/identifier> "530369" .
2
+ <http://id.worldcat.org/fast/530369> <http://schema.org/name> "Cornell University" .
3
+ <http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University" .
4
+ <http://id.worldcat.org/fast/530369> <http://schema.org/sameAs> _:b0 .
5
+ _:b0 <http://www.w3.org/2000/01/rdf-schema#label> "Cornell University" .
6
+ _:b0 <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University" .
7
+ <http://id.worldcat.org/fast/5140> <http://purl.org/dc/terms/identifier> "5140" .
8
+ <http://id.worldcat.org/fast/5140> <http://schema.org/name> "Cornell, Joseph" .
9
+ <http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell, Joseph" .
10
+ <http://id.worldcat.org/fast/5140> <http://schema.org/sameAs> _:b1 .
11
+ _:b1 <http://www.w3.org/2000/01/rdf-schema#label> "Cornell, Joseph" .
12
+ _:b1 <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell, Joseph" .
13
+ <http://id.worldcat.org/fast/557490> <http://purl.org/dc/terms/identifier> "557490" .
14
+ <http://id.worldcat.org/fast/557490> <http://schema.org/name> "New York State School of Industrial and Labor Relations" .
15
+ <http://id.worldcat.org/fast/557490> <http://www.w3.org/2004/02/skos/core#prefLabel> "New York State School of Industrial and Labor Relations" .
16
+ <http://id.worldcat.org/fast/557490> <http://schema.org/sameAs> _:b2 .
17
+ _:b2 <http://www.w3.org/2000/01/rdf-schema#label> "New York State School of Industrial and Labor Relations" .
18
+ _:b2 <http://www.w3.org/2004/02/skos/core#prefLabel> "New York State School of Industrial and Labor Relations" .
@@ -0,0 +1,8 @@
1
+ <http://test.org/530369wbn> <http://purl.org/dc/terms/identifier> "530369" .
2
+ <http://test.org/530369wbn> <http://www.w3.org/2004/02/skos/core#inScheme> <http://id.worldcat.org/fast/ontology/1.0/#fast> .
3
+ <http://test.org/530369wbn> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .
4
+ <http://test.org/530369wbn> <http://www.w3.org/2004/02/skos/core#prefLabel> "Cornell University" .
5
+ <http://test.org/530369wbn> <http://schema.org/name> "Cornell University" .
6
+ <http://test.org/530369wbn> <http://www.w3.org/2004/02/skos/core#altLabel> "Ithaca (N.Y.). Cornell University" .
7
+ <http://test.org/530369wbn> <http://schema.org/sameAs> _:b0 .
8
+ _:b0 <http://www.w3.org/2000/01/rdf-schema#label> "Cornell University" .
@@ -48,6 +48,7 @@ describe Qa::Authorities::AssignFast do
48
48
  .to_return(status: 200, body: "", headers: {})
49
49
  end
50
50
  it "logs an info and returns an empty array" do
51
+ expect(Rails.logger).to receive(:info).with('Retrieving json for url: http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20')
51
52
  msg = "Could not parse response as JSON. Request url: " \
52
53
  "http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20"
53
54
  expect(Rails.logger).to receive(:info).with(msg)
@@ -10,7 +10,7 @@ describe Qa::Authorities::Getty::AAT do
10
10
 
11
11
  describe "#find_url" do
12
12
  subject { authority.find_url("300053264") }
13
- it { is_expected.to eq "http://vocab.getty.edu/aat/300053264.json" }
13
+ it { is_expected.to eq "http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/aat/300053264.json" }
14
14
  end
15
15
 
16
16
  describe "#search" do
@@ -27,6 +27,18 @@ describe Qa::Authorities::Getty::AAT do
27
27
  expect(subject.last).to eq("id" => 'http://vocab.getty.edu/aat/300265560', "label" => "photoscreenprints")
28
28
  expect(subject.size).to eq(10)
29
29
  end
30
+
31
+ context 'when Getty returns an error,' do
32
+ before do
33
+ stub_request(:get, /vocab\.getty\.edu.*/)
34
+ .to_return(body: webmock_fixture("getty-error-response.txt"), status: 500)
35
+ end
36
+
37
+ it 'logs error and returns empty results' do
38
+ expect(Rails.logger).to receive(:warn).with(" ERROR fetching Getty response: undefined method `[]' for nil:NilClass; cause: UNKNOWN")
39
+ expect(subject).to be {}
40
+ end
41
+ end
30
42
  end
31
43
  end
32
44
 
@@ -47,7 +59,7 @@ describe Qa::Authorities::Getty::AAT do
47
59
  describe "#find" do
48
60
  context "using a subject id" do
49
61
  before do
50
- stub_request(:get, "http://vocab.getty.edu/aat/300265560.json")
62
+ stub_request(:get, "http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/aat/300265560.json")
51
63
  .to_return(status: 200, body: webmock_fixture("getty-aat-find-response.json"))
52
64
  end
53
65
  subject { authority.find("300265560") }
@@ -10,7 +10,7 @@ describe Qa::Authorities::Getty::TGN do
10
10
 
11
11
  describe "#find_url" do
12
12
  subject { authority.find_url("1028772") }
13
- it { is_expected.to eq "http://vocab.getty.edu/tgn/1028772.json" }
13
+ it { is_expected.to eq "http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/tgn/1028772.json" }
14
14
  end
15
15
 
16
16
  describe "#search" do
@@ -27,6 +27,18 @@ describe Qa::Authorities::Getty::TGN do
27
27
  expect(subject.last).to eq("id" => 'http://vocab.getty.edu/tgn/7022503', "label" => "Cawood Branch (Kentucky, United States)")
28
28
  expect(subject.size).to eq(6)
29
29
  end
30
+
31
+ context 'when Getty returns an error,' do
32
+ before do
33
+ stub_request(:get, /vocab\.getty\.edu.*/)
34
+ .to_return(body: webmock_fixture("getty-error-response.txt"), status: 500)
35
+ end
36
+
37
+ it 'logs error and returns empty results' do
38
+ expect(Rails.logger).to receive(:warn).with(" ERROR fetching Getty response: undefined method `[]' for nil:NilClass; cause: UNKNOWN")
39
+ expect(subject).to be {}
40
+ end
41
+ end
30
42
  end
31
43
  end
32
44
 
@@ -47,7 +59,7 @@ describe Qa::Authorities::Getty::TGN do
47
59
  describe "#find" do
48
60
  context "using a subject id" do
49
61
  before do
50
- stub_request(:get, "http://vocab.getty.edu/tgn/1028772.json")
62
+ stub_request(:get, "http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/tgn/1028772.json")
51
63
  .to_return(status: 200, body: webmock_fixture("getty-tgn-find-response.json"))
52
64
  end
53
65
  subject { authority.find("1028772") }
@@ -10,7 +10,7 @@ describe Qa::Authorities::Getty::Ulan do
10
10
 
11
11
  describe "#find_url" do
12
12
  subject { authority.find_url("500026846") }
13
- it { is_expected.to eq "http://vocab.getty.edu/ulan/500026846.json" }
13
+ it { is_expected.to eq "http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/ulan/500026846.json" }
14
14
  end
15
15
 
16
16
  describe "#search" do
@@ -27,6 +27,18 @@ describe Qa::Authorities::Getty::Ulan do
27
27
  expect(subject.last).to eq("id" => 'http://vocab.getty.edu/ulan/500023812', "label" => "Warren, Charles Turner (English engraver, 1762-1823)")
28
28
  expect(subject.size).to eq(142)
29
29
  end
30
+
31
+ context 'when Getty returns an error,' do
32
+ before do
33
+ stub_request(:get, /vocab\.getty\.edu.*/)
34
+ .to_return(body: webmock_fixture("getty-error-response.txt"), status: 500)
35
+ end
36
+
37
+ it 'logs error and returns empty results' do
38
+ expect(Rails.logger).to receive(:warn).with(" ERROR fetching Getty response: undefined method `[]' for nil:NilClass; cause: UNKNOWN")
39
+ expect(subject).to be {}
40
+ end
41
+ end
30
42
  end
31
43
  end
32
44
 
@@ -47,7 +59,7 @@ describe Qa::Authorities::Getty::Ulan do
47
59
  describe "#find" do
48
60
  context "using a subject id" do
49
61
  before do
50
- stub_request(:get, "http://vocab.getty.edu/ulan/500026846.json")
62
+ stub_request(:get, "http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/ulan/500026846.json")
51
63
  .to_return(status: 200, body: webmock_fixture("getty-ulan-find-response.json"))
52
64
  end
53
65
  subject { authority.find("500026846") }
@@ -1,10 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Qa::Authorities::LinkedData::AuthorityService do
3
+ describe Qa::LinkedData::AuthorityService do
4
4
  let(:auth_names) do
5
5
  [:LOC,
6
6
  :LOD_ENCODING_CONFIG,
7
7
  :LOD_FULL_CONFIG,
8
+ :LOD_FULL_CONFIG_1_0,
8
9
  :LOD_LANG_DEFAULTS,
9
10
  :LOD_LANG_MULTI_DEFAULTS,
10
11
  :LOD_LANG_NO_DEFAULTS,
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::LinkedData::Config do
4
4
  let(:full_config) { described_class.new(:LOD_FULL_CONFIG) }
5
+ let(:full_config_1_0) { described_class.new(:LOD_FULL_CONFIG_1_0) }
5
6
 
6
7
  describe '#new' do
7
8
  context 'without an authority' do
@@ -21,14 +22,19 @@ describe Qa::Authorities::LinkedData::Config do
21
22
  end
22
23
  end
23
24
 
24
- describe '#auth_config' do
25
+ describe '#authority_config' do
25
26
  let(:full_auth_config) do
26
27
  {
28
+ QA_CONFIG_VERSION: "2.0",
29
+ prefixes: {
30
+ schema: "http://www.w3.org/2000/01/rdf-schema#",
31
+ skos: "http://www.w3.org/2004/02/skos/core#"
32
+ },
27
33
  term: {
28
34
  url: {
29
35
  :@context => 'http://www.w3.org/ns/hydra/context.jsonld',
30
36
  :@type => 'IriTemplate',
31
- template: 'http://localhost/test_default/term/{?subauth}/{?term_id}?param1={?param1}&param2={?param2}',
37
+ template: 'http://localhost/test_default/term/{subauth}/{term_id}?{?param1}&{?param2}',
32
38
  variableRepresentation: 'BasicRepresentation',
33
39
  mapping: [
34
40
  {
@@ -84,7 +90,7 @@ describe Qa::Authorities::LinkedData::Config do
84
90
  url: {
85
91
  :@context => 'http://www.w3.org/ns/hydra/context.jsonld',
86
92
  :@type => 'IriTemplate',
87
- template: 'http://localhost/test_default/search?subauth={?subauth}&query={?query}&param1={?param1}&param2={?param2}',
93
+ template: 'http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}',
88
94
  variableRepresentation: 'BasicRepresentation',
89
95
  mapping: [
90
96
  {
@@ -127,6 +133,55 @@ describe Qa::Authorities::LinkedData::Config do
127
133
  altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
128
134
  sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
129
135
  },
136
+ context: {
137
+ groups: {
138
+ dates: {
139
+ group_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.dates",
140
+ group_label_default: "Dates"
141
+ },
142
+ hierarchy: {
143
+ group_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.hierarchy",
144
+ group_label_default: "Hierarchy"
145
+ }
146
+ },
147
+ properties: [
148
+ {
149
+ property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.authoritative_label",
150
+ property_label_default: "Authoritative Label",
151
+ ldpath: "madsrdf:authoritativeLabel",
152
+ selectable: true,
153
+ drillable: false
154
+ },
155
+ {
156
+ group_id: "dates",
157
+ property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date",
158
+ property_label_default: "Birth",
159
+ ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label",
160
+ selectable: false,
161
+ drillable: false
162
+ },
163
+ {
164
+ group_id: "hierarchy",
165
+ property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.narrower",
166
+ property_label_default: "Narrower",
167
+ ldpath: "skos:narrower :: xsd:string",
168
+ selectable: true,
169
+ drillable: true,
170
+ expansion_label_ldpath: "skos:prefLabel ::xsd:string",
171
+ expansion_id_ldpath: "loc:lccn ::xsd:string"
172
+ },
173
+ {
174
+ group_id: "hierarchy",
175
+ property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.broader",
176
+ property_label_default: "Broader",
177
+ ldpath: "skos:broader :: xsd:string",
178
+ selectable: true,
179
+ drillable: true,
180
+ expansion_label_ldpath: "skos:prefLabel ::xsd:string",
181
+ expansion_id_ldpath: "loc:lccn ::xsd:string"
182
+ }
183
+ ]
184
+ },
130
185
  subauthorities: {
131
186
  search_sub1_key: 'search_sub1_name',
132
187
  search_sub2_key: 'search_sub2_name',
@@ -136,8 +191,232 @@ describe Qa::Authorities::LinkedData::Config do
136
191
  }
137
192
  end
138
193
 
139
- it 'returns hash of the full authority configuration' do
140
- expect(full_config.auth_config).to eq full_auth_config
194
+ let(:full_auth_config_1_0) do
195
+ {
196
+ prefixes: {
197
+ schema: "http://www.w3.org/2000/01/rdf-schema#",
198
+ skos: "http://www.w3.org/2004/02/skos/core#"
199
+ },
200
+ term: {
201
+ url: {
202
+ :@context => 'http://www.w3.org/ns/hydra/context.jsonld',
203
+ :@type => 'IriTemplate',
204
+ template: 'http://localhost/test_default/term/{subauth}/{term_id}?param1={param1}&param2={param2}',
205
+ variableRepresentation: 'BasicRepresentation',
206
+ mapping: [
207
+ {
208
+ :@type => 'IriTemplateMapping',
209
+ variable: 'term_id',
210
+ property: 'hydra:freetextQuery',
211
+ required: true
212
+ },
213
+ {
214
+ :@type => 'IriTemplateMapping',
215
+ variable: 'subauth',
216
+ property: 'hydra:freetextQuery',
217
+ required: false,
218
+ default: 'term_sub2_name'
219
+ },
220
+ {
221
+ :@type => 'IriTemplateMapping',
222
+ variable: 'param1',
223
+ property: 'hydra:freetextQuery',
224
+ required: false,
225
+ default: 'alpha'
226
+ },
227
+ {
228
+ :@type => 'IriTemplateMapping',
229
+ variable: 'param2',
230
+ property: 'hydra:freetextQuery',
231
+ required: false,
232
+ default: 'beta'
233
+ }
234
+ ]
235
+ },
236
+ qa_replacement_patterns: {
237
+ term_id: 'term_id',
238
+ subauth: 'subauth'
239
+ },
240
+ term_id: 'ID',
241
+ language: ['en'],
242
+ results: {
243
+ id_predicate: 'http://purl.org/dc/terms/identifier',
244
+ label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
245
+ altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
246
+ broader_predicate: 'http://www.w3.org/2004/02/skos/core#broader',
247
+ narrower_predicate: 'http://www.w3.org/2004/02/skos/core#narrower',
248
+ sameas_predicate: 'http://www.w3.org/2004/02/skos/core#exactMatch'
249
+ },
250
+ subauthorities: {
251
+ term_sub1_key: 'term_sub1_name',
252
+ term_sub2_key: 'term_sub2_name',
253
+ term_sub3_key: 'term_sub3_name'
254
+ }
255
+ },
256
+ search: {
257
+ url: {
258
+ :@context => 'http://www.w3.org/ns/hydra/context.jsonld',
259
+ :@type => 'IriTemplate',
260
+ template: 'http://localhost/test_default/search?subauth={subauth}&query={query}&param1={param1}&param2={param2}',
261
+ variableRepresentation: 'BasicRepresentation',
262
+ mapping: [
263
+ {
264
+ :@type => 'IriTemplateMapping',
265
+ variable: 'query',
266
+ property: 'hydra:freetextQuery',
267
+ required: true
268
+ },
269
+ {
270
+ :@type => 'IriTemplateMapping',
271
+ variable: 'subauth',
272
+ property: 'hydra:freetextQuery',
273
+ required: false,
274
+ default: 'search_sub1_name'
275
+ },
276
+ {
277
+ :@type => 'IriTemplateMapping',
278
+ variable: 'param1',
279
+ property: 'hydra:freetextQuery',
280
+ required: false,
281
+ default: 'delta'
282
+ },
283
+ {
284
+ :@type => 'IriTemplateMapping',
285
+ variable: 'param2',
286
+ property: 'hydra:freetextQuery',
287
+ required: false,
288
+ default: 'echo'
289
+ }
290
+ ]
291
+ },
292
+ qa_replacement_patterns: {
293
+ query: 'query',
294
+ subauth: 'subauth'
295
+ },
296
+ language: ['en', 'fr', 'de'],
297
+ results: {
298
+ id_predicate: 'http://purl.org/dc/terms/identifier',
299
+ label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
300
+ altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
301
+ sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
302
+ },
303
+ context: {
304
+ groups: {
305
+ dates: {
306
+ group_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.dates",
307
+ group_label_default: "Dates"
308
+ },
309
+ hierarchy: {
310
+ group_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.hierarchy",
311
+ group_label_default: "Hierarchy"
312
+ }
313
+ },
314
+ properties: [
315
+ {
316
+ property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.authoritative_label",
317
+ property_label_default: "Authoritative Label",
318
+ ldpath: "madsrdf:authoritativeLabel",
319
+ selectable: true,
320
+ drillable: false
321
+ },
322
+ {
323
+ group_id: "dates",
324
+ property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date",
325
+ property_label_default: "Birth",
326
+ ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label",
327
+ selectable: false,
328
+ drillable: false
329
+ },
330
+ {
331
+ group_id: "hierarchy",
332
+ property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.narrower",
333
+ property_label_default: "Narrower",
334
+ ldpath: "skos:narrower :: xsd:string",
335
+ selectable: true,
336
+ drillable: true,
337
+ expansion_label_ldpath: "skos:prefLabel ::xsd:string",
338
+ expansion_id_ldpath: "loc:lccn ::xsd:string"
339
+ },
340
+ {
341
+ group_id: "hierarchy",
342
+ property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.broader",
343
+ property_label_default: "Broader",
344
+ ldpath: "skos:broader :: xsd:string",
345
+ selectable: true,
346
+ drillable: true,
347
+ expansion_label_ldpath: "skos:prefLabel ::xsd:string",
348
+ expansion_id_ldpath: "loc:lccn ::xsd:string"
349
+ }
350
+ ]
351
+ },
352
+ subauthorities: {
353
+ search_sub1_key: 'search_sub1_name',
354
+ search_sub2_key: 'search_sub2_name',
355
+ search_sub3_key: 'search_sub3_name'
356
+ }
357
+ }
358
+ }
359
+ end
360
+
361
+ let(:authority_config) { full_config.authority_config }
362
+ let(:authority_config_1_0) { full_config_1_0.authority_config }
363
+
364
+ it 'returns hash of the full authority 2.0 configuration' do
365
+ expect(authority_config).to eq full_auth_config
366
+ end
367
+
368
+ it 'returns hash of 1.0 configuration converting all {?var} to {var}' do
369
+ expect(authority_config_1_0).to eq full_auth_config_1_0
370
+ end
371
+ end
372
+
373
+ describe '#search' do
374
+ it 'returns instance of search config class' do
375
+ expect(full_config.search).to be_kind_of Qa::Authorities::LinkedData::SearchConfig
376
+ end
377
+ end
378
+
379
+ describe '#term' do
380
+ it 'returns instance of term config class' do
381
+ expect(full_config.term).to be_kind_of Qa::Authorities::LinkedData::TermConfig
382
+ end
383
+ end
384
+
385
+ describe '#prefixes' do
386
+ let(:expected_results) do
387
+ {
388
+ schema: "http://www.w3.org/2000/01/rdf-schema#",
389
+ skos: "http://www.w3.org/2004/02/skos/core#"
390
+ }
391
+ end
392
+
393
+ it 'returns hash of prefix definitions' do
394
+ expect(full_config.prefixes).to be_kind_of Hash
395
+ expect(full_config.prefixes).to eq expected_results
396
+ end
397
+ end
398
+
399
+ describe '#config_version' do
400
+ context 'when version is NOT in the config file' do
401
+ it 'returns default as 1.0' do
402
+ expect(full_config_1_0.config_version).to eq '1.0'
403
+ end
404
+ end
405
+
406
+ context 'when version is specified in the config file' do
407
+ it 'returns the version from the config file' do
408
+ expect(full_config.config_version).to eq '2.0'
409
+ end
410
+ end
411
+ end
412
+
413
+ describe '#config_version?' do
414
+ it "returns true if the passed in version matches the authority's version" do
415
+ expect(full_config.config_version?('2.0')).to eq true
416
+ end
417
+
418
+ it "returns false if the passed in version does NOT match the authority's version" do
419
+ expect(full_config_1_0.config_version?('2.0')).to eq false
141
420
  end
142
421
  end
143
422
  end