celsius-primo 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile +15 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +51 -0
  8. data/Rakefile +6 -0
  9. data/celsius-primo.gemspec +29 -0
  10. data/lib/celsius/primo/adapter/mget.rb +36 -0
  11. data/lib/celsius/primo/adapter/operation.rb +17 -0
  12. data/lib/celsius/primo/adapter/search.rb +28 -0
  13. data/lib/celsius/primo/adapter.rb +52 -0
  14. data/lib/celsius/primo/locales/de.yml +455 -0
  15. data/lib/celsius/primo/locales/en.yml +207 -0
  16. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/add_sort_by_list.rb +36 -0
  17. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/embed_inner_search_request.rb +12 -0
  18. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_ids_queries.rb +29 -0
  19. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_match_queries.rb +29 -0
  20. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_query_string_queries.rb +37 -0
  21. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/process_range_queries.rb +28 -0
  22. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/serialize_target_as_xml.rb +10 -0
  23. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/set_bulk_size.rb +12 -0
  24. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/set_institution.rb +12 -0
  25. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/set_languages.rb +14 -0
  26. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/set_locations.rb +17 -0
  27. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/set_start_index.rb +12 -0
  28. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/setup_inner_search_request.rb +32 -0
  29. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation/setup_target.rb +25 -0
  30. data/lib/celsius/primo/soap_api/searcher/search_brief/search_request_transformation.rb +59 -0
  31. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/add_missing_facets.rb +45 -0
  32. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/parse_inner_search_brief_return.rb +23 -0
  33. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_facets.rb +29 -0
  34. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/process_records.rb +80 -0
  35. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/remove_bogus_creationdate_facets.rb +15 -0
  36. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/select_only_requested_facets.rb +14 -0
  37. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/set_total_hits.rb +12 -0
  38. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/setup_target_skeleton.rb +17 -0
  39. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation/sort_facets_by_search_request.rb +21 -0
  40. data/lib/celsius/primo/soap_api/searcher/search_brief/search_result_transformation.rb +59 -0
  41. data/lib/celsius/primo/soap_api/searcher/search_brief.rb +56 -0
  42. data/lib/celsius/primo/soap_api/searcher.rb +14 -0
  43. data/lib/celsius/primo/soap_api.rb +22 -0
  44. data/lib/celsius/primo/version.rb +5 -0
  45. data/lib/celsius/primo.rb +7 -0
  46. data/spec/assets/adapter/mget/mget_request.yml +4 -0
  47. data/spec/assets/adapter/mget/mget_result.yml +407 -0
  48. data/spec/assets/adapter/search/search_request.yml +59 -0
  49. data/spec/assets/adapter/search/search_result.yml +1517 -0
  50. data/spec/cassettes/Celsius_Primo_Adapter/_mget/returns_a_normalzed_mget_result.yml +396 -0
  51. data/spec/cassettes/Celsius_Primo_Adapter/_search/returns_a_normalized_search_result.yml +1169 -0
  52. data/spec/celsius-primo/adapter_spec.rb +56 -0
  53. data/spec/celsius-primo_spec.rb +6 -0
  54. data/spec/spec_helper.rb +55 -0
  55. metadata +255 -0
@@ -0,0 +1,207 @@
1
+ en:
2
+ facet_name:
3
+ facet_creator: Creator
4
+ facet_lang: Language
5
+ facet_rtype: Resource type
6
+ facet_topic: Subject
7
+ facet_jtitle: Journal
8
+ facet_tlevel: Only show
9
+ facet_domain: Domain
10
+ facet_creationdate: Creation date
11
+
12
+ facet_value:
13
+ facet_lang:
14
+ aar: Afar
15
+ abk: Abkhaz
16
+ afr: Afrikaans
17
+ aka: Akan
18
+ alb: Albanian
19
+ amh: Amharic
20
+ ara: Arabic
21
+ arg: Aragonese
22
+ arm: Armenian
23
+ asm: Assamese
24
+ ava: Avaric
25
+ ave: Avestan
26
+ aym: Aymara
27
+ aze: Azerbaijani
28
+ bak: Bashkir
29
+ bam: Bambara
30
+ baq: Basque
31
+ bel: Belarusian
32
+ ben: Bengali
33
+ bih: Bihari
34
+ bis: Bislama
35
+ bos: Bosnian
36
+ bre: Breton
37
+ bul: Bulgarian
38
+ bur: Burmese
39
+ cat: Catalan
40
+ cha: Chamorro
41
+ che: Chechen
42
+ chi: Chinese
43
+ chu: Old Bulgarian
44
+ chv: Chuvash
45
+ cor: Cornish
46
+ cos: Corsican
47
+ cre: Cree
48
+ cze: Czech
49
+ dan: Danish
50
+ div: Divehi
51
+ dut: Dutch
52
+ dzo: Dzongkha
53
+ eng: English
54
+ epo: Esperanto
55
+ est: Estonian
56
+ ewe: Ewe
57
+ fao: Faroese
58
+ fij: Fijian
59
+ fin: Finnish
60
+ fre: French
61
+ fry: Western Frisian
62
+ ful: Fula
63
+ geo: Georgian
64
+ ger: German
65
+ gla: Gaelic
66
+ gle: Irish
67
+ glg: Galician
68
+ glv: Manx
69
+ gre: Greek (modern)
70
+ grn: Guaraní
71
+ guj: Gujarati
72
+ hat: Haitian
73
+ hau: Hausa
74
+ heb: Hebrew (modern)
75
+ her: Herero
76
+ hin: Hindi
77
+ hmo: Hiri Motu
78
+ hrv: Croatian
79
+ hun: Hungarian
80
+ ibo: Igbo
81
+ ice: Icelandic
82
+ ido: Ido
83
+ iii: Nuosu
84
+ iku: Inuktitut
85
+ ile: Interlingue
86
+ ina: Interlingua
87
+ ind: Indonesian
88
+ ipk: Inupiaq
89
+ ita: Italian
90
+ jav: Javanese
91
+ jpn: Japanese
92
+ kal: Greenlandic
93
+ kan: Kannada
94
+ kas: Kashmiri
95
+ kau: Kanuri
96
+ kaz: Kazakh
97
+ khm: Khmer
98
+ kik: Kikuyu
99
+ kin: Kinyarwanda
100
+ kir: Kyrgyz
101
+ kom: Komi
102
+ kon: Kongo
103
+ kor: Korean
104
+ kua: Kwanyama
105
+ kur: Kurdish
106
+ lao: Lao
107
+ lat: Latin
108
+ lav: Latvian
109
+ lim: Limburgish
110
+ lin: Lingala
111
+ lit: Lithuanian
112
+ ltz: Luxembourgish
113
+ lub: Luba-Katanga
114
+ lug: Ganda
115
+ mac: Macedonian
116
+ mah: Marshallese
117
+ mal: Malayalam
118
+ mao: Maori
119
+ mar: Marathi
120
+ may: Malay
121
+ mlg: Malagasy
122
+ mlt: Maltese
123
+ mon: Mongolian
124
+ nau: Nauru
125
+ nav: Navajo
126
+ nbl: Southern Ndebele
127
+ nde: Northern Ndebele
128
+ ndo: Ndonga
129
+ nep: Nepali
130
+ nno: Norwegian Nynorsk
131
+ nob: Norwegian Bokmål
132
+ nor: Norwegian
133
+ nya: Nyanja
134
+ oci: Occitan
135
+ oji: Ojibwe
136
+ ori: Oriya
137
+ orm: Oromo
138
+ oss: Ossetian
139
+ pan: Panjabi
140
+ per: Persian (Farsi)
141
+ pli: Pali
142
+ pol: Polish
143
+ por: Portuguese
144
+ pus: Pushto
145
+ que: Quechua
146
+ roh: Romansh
147
+ rum: Romanian
148
+ run: Kirundi
149
+ rus: Russian
150
+ sag: Sango
151
+ san: Sanskrit
152
+ sin: Sinhala
153
+ slo: Slovak
154
+ slv: Slovene
155
+ sme: Northern Sami
156
+ smo: Samoan
157
+ sna: Shona
158
+ snd: Sindhi
159
+ som: Somali
160
+ sot: Southern Sotho
161
+ spa: Spanish
162
+ srd: Sardinian
163
+ srp: Serbian
164
+ ssw: Swati
165
+ sun: Sundanese
166
+ swa: Swahili
167
+ swe: Swedish
168
+ tah: Tahitian
169
+ tam: Tamil
170
+ tat: Tatar
171
+ tel: Telugu
172
+ tgk: Tajik
173
+ tgl: Tagalog
174
+ tha: Thai
175
+ tib: Tibetan
176
+ tir: Tigrinya
177
+ ton: Tonga
178
+ tsn: Tswana
179
+ tso: Tsonga
180
+ tuk: Turkmen
181
+ tur: Turkish
182
+ twi: Twi
183
+ uig: Uighur
184
+ ukr: Ukrainian
185
+ urd: Urdu
186
+ uzb: Uzbek
187
+ ven: Venda
188
+ vie: Vietnamese
189
+ vol: Volapük
190
+ wel: Welsh
191
+ wln: Walloon
192
+ wol: Wolof
193
+ xho: Xhosa
194
+ yid: Yiddish
195
+ yor: Yoruba
196
+ zha: Zhuang
197
+ zul: Zulu
198
+
199
+ facet_tlevel:
200
+ printmedia: Print media
201
+ online_resources: Online resource
202
+ audiovisual: Audio visual
203
+ peer_reviewed: Peer reviewed
204
+ cited_articles: Cited article
205
+ microform: Microform
206
+ data_storage: Data storage
207
+ other: Other
@@ -0,0 +1,36 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ AddSortByList < Celsius::Transformation::Step
6
+
7
+ #
8
+ # SortField is optional, so we have to add it on the fly if necessary
9
+ #
10
+ def call
11
+ if sort_fields = (Celsius::Hash.deep_find_key(source, :sort) || []).first
12
+ # map sort field values to primo equivalents
13
+ primo_sort_fields = sort_fields.map(&transformation.method(:sort_field_mapping))
14
+
15
+ # memoize this node to shorten further lines
16
+ primo_search_request = transformation.inner_search_request.locate("PrimoSearchRequest").first
17
+
18
+ # Order matters, SortField *must* be inserted after <Languages>
19
+ index_of_languages = primo_search_request.nodes.index do |node|
20
+ node.value == "Languages"
21
+ end
22
+
23
+ # primo can only handle *one* sort field
24
+ sort_by_list = Ox.parse(
25
+ <<-xml
26
+ <SortByList>
27
+ <SortField>#{primo_sort_fields.first}</SortField>
28
+ </SortByList>
29
+ xml
30
+ )
31
+
32
+ # insert the SortByList at the appropriate position
33
+ primo_search_request.nodes.insert(index_of_languages + 1, sort_by_list)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,12 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ EmbedInnerSearchRequest < Celsius::Transformation::Step
6
+
7
+ def call
8
+ target.locate("*/searchRequestStr").first.tap do |searchRequestStr|
9
+ searchRequestStr << Ox::CData.new(Ox.dump(transformation.inner_search_request))
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ ProcessIdsQueries < Celsius::Transformation::Step
6
+
7
+ def call
8
+ if ids_queries = Celsius::Hash.deep_find_key(source, :ids)
9
+ # memoize the QueryTerms node
10
+ query_terms_node = transformation.inner_search_request.locate("PrimoSearchRequest/QueryTerms").first
11
+
12
+ # for an ids search, "OR" is the appropriate operator
13
+ query_terms_node.locate("BoolOpeator").first << "OR"
14
+
15
+ # for each id, add a seperate QueryTerm
16
+ ids_queries.first.each do |id|
17
+ query_terms_node << Ox.parse(
18
+ <<-xml
19
+ <QueryTerm>
20
+ <IndexField>rid</IndexField>
21
+ <PrecisionOperator>exact</PrecisionOperator>
22
+ <Value>#{id}</Value>
23
+ </QueryTerm>
24
+ xml
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ ProcessMatchQueries < Celsius::Transformation::Step
6
+
7
+ def call
8
+ if match_queries = Celsius::Hash.deep_find_key(source, :match)
9
+ binding.pry
10
+ raise "unimplemented!"
11
+ end
12
+ end
13
+
14
+ =begin
15
+ process "//match" do |match|
16
+ index_field = index_field_mapping(match.nodes.first.value)
17
+
18
+ find(@search_request, "PrimoSearchRequest/QueryTerms") << element_from_xml(
19
+ <<-xml
20
+ <QueryTerm>
21
+ <IndexField>#{index_field}</IndexField>
22
+ <PrecisionOperator>exact</PrecisionOperator>
23
+ <Value>#{match.nodes.first.text}</Value>
24
+ </QueryTerm>
25
+ xml
26
+ )
27
+ end
28
+ =end
29
+ end
@@ -0,0 +1,37 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ ProcessQueryStringQueries < Celsius::Transformation::Step
6
+
7
+ def call
8
+ if query_string_queries = Celsius::Hash.deep_find_key(source, :query_string)
9
+ # memoize the QueryTerms node
10
+ query_terms_node = transformation.inner_search_request.locate("PrimoSearchRequest/QueryTerms").first
11
+
12
+ # if multiple queries strings are given, they all have to match
13
+ query_terms_node.locate("BoolOpeator").first << "AND"
14
+
15
+ # for each query_string query, add a QueryTerm node
16
+ query_string_queries.each do |query_string_query|
17
+ value = query_string_query[:query] || query_string_query["query"]
18
+
19
+ # primo can only handle one (index_)field
20
+ index_field = (query_string_query[:fields] || query_string_query["fields"]).first
21
+
22
+ # translate the index field to a known primo index field
23
+ index_field = index_field_mapping(index_field)
24
+
25
+ query_terms_node << Ox.parse(
26
+ <<-xml
27
+ <QueryTerm>
28
+ <IndexField>#{index_field}</IndexField>
29
+ <PrecisionOperator>contains</PrecisionOperator>
30
+ <Value>#{value}</Value>
31
+ </QueryTerm>
32
+ xml
33
+ )
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,28 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ ProcessRangeQueries < Celsius::Transformation::Step
6
+
7
+ def call
8
+ if range_queries = Celsius::Hash.deep_find_key(source, :range)
9
+ binding.pry
10
+ end
11
+ end
12
+
13
+ =begin
14
+ process "//range" do |range|
15
+ index_field = index_field_mapping(range.nodes.first.value)
16
+
17
+ find(@search_request, "PrimoSearchRequest/QueryTerms") << element_from_xml(
18
+ <<-xml
19
+ <QueryTerm>
20
+ <IndexField>#{index_field}</IndexField>
21
+ <PrecisionOperator>contains</PrecisionOperator>
22
+ <Value>[#{find(range, "/gte").text} TO #{find(range, "/lte").text}]</Value>
23
+ </QueryTerm>
24
+ xml
25
+ )
26
+ end
27
+ =end
28
+ end
@@ -0,0 +1,10 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ SerializeTargetAsXml < Celsius::Transformation::Step
6
+
7
+ def call
8
+ transformation.target = Ox.dump(target, with_xml: true)
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ SetBulkSize < Celsius::Transformation::Step
6
+
7
+ def call
8
+ transformation.inner_search_request.locate("PrimoSearchRequest/BulkSize").first.tap do |node|
9
+ node << Celsius::Hash.deep_find_key(source, :size).first.to_s
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ SetInstitution < Celsius::Transformation::Step
6
+
7
+ def call
8
+ transformation.inner_search_request.locate("institution").first.tap do |node|
9
+ node << transformation.institution
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ SetLanguages < Celsius::Transformation::Step
6
+
7
+ def call
8
+ (transformation.languages || []).each do |language|
9
+ transformation.inner_search_request.locate("PrimoSearchRequest/Languages").first.tap do |node|
10
+ node << Ox.parse("<Language>#{language}</Language>")
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ require "celsius/transformation/step"
2
+ require "ox"
3
+
4
+ class Celsius::Primo::SoapApi::Searcher::SearchBrief::SearchRequestTransformation::
5
+ SetLocations < Celsius::Transformation::Step
6
+
7
+ def call
8
+ (transformation.locations || []).each do |location|
9
+ type = location[:type] || location["type"]
10
+ value = location[:value] || location["value"]
11
+
12
+ transformation.inner_search_request.locate("PrimoSearchRequest/Locations").first.tap do |node|
13
+ node << Ox.parse("<uic:Location type=\"#{type}\" value=\"#{value}\"/>")
14
+ end
15
+ end
16
+ end
17
+ end