umlaut 3.0.0beta2 → 3.0.0beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/app/assets/javascripts/umlaut/{expand_contract_toggle.js → expand_contract_toggle.js.erb} +4 -4
  2. data/app/controllers/store_controller.rb +2 -6
  3. data/lib/service_adaptors/primo_service.rb +39 -14
  4. data/lib/service_adaptors/sfx.rb +23 -22
  5. data/lib/service_adaptors/worldcat_identities.rb +3 -3
  6. data/lib/umlaut/version.rb +1 -1
  7. data/test/integration/permalinks_test.rb +19 -0
  8. metadata +45 -132
  9. data/lib/exlibris/aleph/patron.rb +0 -64
  10. data/lib/exlibris/aleph/record.rb +0 -54
  11. data/lib/exlibris/aleph/rest_api.rb +0 -29
  12. data/lib/exlibris/primo/holding.rb +0 -186
  13. data/lib/exlibris/primo/related_link.rb +0 -17
  14. data/lib/exlibris/primo/rsrc.rb +0 -17
  15. data/lib/exlibris/primo/searcher.rb +0 -297
  16. data/lib/exlibris/primo/source/aleph.rb +0 -46
  17. data/lib/exlibris/primo/source/distribution/nyu_aleph.rb +0 -344
  18. data/lib/exlibris/primo/toc.rb +0 -17
  19. data/lib/exlibris/primo_ws.rb +0 -140
  20. data/test/dummy/tmp/cache/assets/C2A/410/sprockets%2Fd654b74912b4773a2534616863fb6565 +0 -0
  21. data/test/dummy/tmp/cache/assets/C45/A30/sprockets%2F39494895e462697b478d3d0c79298a26 +0 -0
  22. data/test/dummy/tmp/cache/assets/C5F/340/sprockets%2F99692920160b7a279b86a80415b79db7 +0 -0
  23. data/test/dummy/tmp/cache/assets/C70/4D0/sprockets%2F034ad2036e623081bd352800786dfe80 +0 -0
  24. data/test/dummy/tmp/cache/assets/C80/980/sprockets%2Fc94807409c1523d43e18d25f35d93c41 +0 -0
  25. data/test/dummy/tmp/cache/assets/CBD/730/sprockets%2F034c1086748b981c36672d5a56e7fed6 +0 -0
  26. data/test/dummy/tmp/cache/assets/CBF/B60/sprockets%2F08ca89671549936265dcb673bf02e36f +0 -0
  27. data/test/dummy/tmp/cache/assets/CC9/9F0/sprockets%2F306166316e2cafd13c15e62b51a2339d +0 -0
  28. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  29. data/test/dummy/tmp/cache/assets/CF7/2B0/sprockets%2F25a7c73655bd3598173b39d9f98bcd46 +0 -0
  30. data/test/dummy/tmp/cache/assets/CFE/080/sprockets%2F37fe9f4255baddbd549a659914929398 +0 -0
  31. data/test/dummy/tmp/cache/assets/D16/F90/sprockets%2F5fe3c021048c6f9a6086bed7736d87b1 +0 -0
  32. data/test/dummy/tmp/cache/assets/D24/360/sprockets%2F6987b047a96dc685ba3cf39b31477f6d +0 -0
  33. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  34. data/test/dummy/tmp/cache/assets/D33/FD0/sprockets%2F2ba0b4e6334a77b923e5f770381bb2bf +0 -0
  35. data/test/dummy/tmp/cache/assets/D37/2B0/sprockets%2F40834fb07d7318c1fddd5003bd9e04f6 +0 -0
  36. data/test/dummy/tmp/cache/assets/D43/0D0/sprockets%2F682843a8d0795a5fbcfeb2f0c81727d0 +0 -0
  37. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  38. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  39. data/test/dummy/tmp/cache/assets/D6C/7D0/sprockets%2F8a05d6981ec0d38c51739bef0b3a9c2b +0 -0
  40. data/test/dummy/tmp/cache/assets/D74/4C0/sprockets%2F64fdf30f75592d6e45fcfc45a48d20a2 +0 -0
  41. data/test/dummy/tmp/cache/assets/D94/FF0/sprockets%2F3b56a1aa77de0d570c38a4a9d5f4b1d6 +0 -0
  42. data/test/dummy/tmp/cache/assets/D97/6B0/sprockets%2Fb070e8c799d1a4ad5e62e0a1ae3b83e6 +0 -0
  43. data/test/dummy/tmp/cache/assets/DA6/A80/sprockets%2F92e26d8e58d5bcc8b8f6c25d1b05b9c1 +0 -0
  44. data/test/dummy/tmp/cache/assets/DC0/D20/sprockets%2F1ccf7405cd252dcec4bf23af82e2563a +0 -0
  45. data/test/dummy/tmp/cache/assets/DD2/D80/sprockets%2Fc66d103807d0f971fbbcf9aa8b8b27ee +0 -0
  46. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  47. data/test/dummy/tmp/cache/assets/DE8/790/sprockets%2Fd1333bde2b9aafcc712d11dd09ab35d8 +0 -0
  48. data/test/dummy/tmp/cache/assets/DF7/960/sprockets%2F99ac6db10b44a64fbba4ee847b35ba8b +0 -0
  49. data/test/dummy/tmp/cache/assets/DFC/040/sprockets%2F15ea81cf915c0cb1dfc9cc04c9fef364 +0 -0
  50. data/test/dummy/tmp/cache/assets/DFD/300/sprockets%2Fabac9489cf7f1db8ef00d72a1571ee1e +0 -0
  51. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  52. data/test/dummy/tmp/cache/assets/E38/FE0/sprockets%2Fe1fc875efa817cbb94a5d8de25ea4e6b +0 -0
  53. data/test/dummy/tmp/cache/assets/E5F/960/sprockets%2Fdc007b6cad5c7ef08e33ec28cfff0ef6 +0 -0
  54. data/test/unit/aleph_patron_test.rb +0 -44
  55. data/test/unit/aleph_record_benchmarks.rb +0 -32
  56. data/test/unit/aleph_record_test.rb +0 -35
  57. data/test/unit/primo_searcher_test.rb +0 -415
  58. data/test/unit/primo_ws_test.rb +0 -147
@@ -1,46 +0,0 @@
1
- module Exlibris::Primo::Source
2
- # == Overview
3
- # Aleph is an Exlibris::Primo::Holding that provides a link to Aleph
4
- # and a request button based on config settings in the primo_config file.
5
- class Aleph < Exlibris::Primo::Holding
6
- @attribute_aliases = Exlibris::Primo::Holding.attribute_aliases.merge({
7
- :aleph_doc_library => :original_source_id, :aleph_sub_library => :library,
8
- :aleph_collection => :collection, :aleph_call_number => :call_number,
9
- :aleph_doc_number => :source_record_id
10
- })
11
- @decode_variables = Exlibris::Primo::Holding.decode_variables.merge({
12
- :aleph_sub_library_code => { :code => :library_code }
13
- })
14
-
15
- # Overwrites Exlibris::Primo::Holding#new
16
- def initialize(parameters={})
17
- super(parameters)
18
- @aleph_local_base = aleph_config["local_base"] unless aleph_config.nil?
19
- # Aleph holdings page
20
- @url = "#{@source_url}/F?func=item-global&doc_library=#{aleph_doc_library}&local_base=#{@aleph_local_base}&doc_number=#{aleph_doc_number}&sub_library=#{@aleph_sub_library_code}"
21
- # Aleph doesn't work right so we have to push the patron to the Aleph holdings page!
22
- @request_url = url if requestable?
23
- @source_data.merge!({
24
- :aleph_doc_library => aleph_doc_library,
25
- :aleph_sub_library => aleph_sub_library,
26
- :aleph_sub_library_code => @aleph_sub_library_code,
27
- :aleph_collection => aleph_collection,
28
- :aleph_call_number => aleph_call_number,
29
- :aleph_doc_number => aleph_doc_number
30
- })
31
- end
32
-
33
- protected
34
- # Maps @source config to aleph_config for convenience.
35
- def aleph_config
36
- return @source_config
37
- end
38
-
39
- private
40
- def requestable?
41
- # Default to nothing is requestable
42
- return false if aleph_config.nil? or aleph_config["requestable_statuses"].nil?
43
- return aleph_config["requestable_statuses"].include?(@status_code)
44
- end
45
- end
46
- end
@@ -1,344 +0,0 @@
1
- module Exlibris::Primo::Source
2
- # == Overview
3
- # NYUAleph is an Exlibris::Primo::Source::Aleph that expands Primo availlibrary
4
- # elements based on of Aleph items return from the Aleph REST APIs.
5
- # It stores metadata from these items ub the ServiceType#view[:source_data]
6
- # element that can be used by custom controllers to extend patron services,
7
- # including request and paging functionality.
8
- # NYUAleph also provides coverage metadata based on bib and holding
9
- # information from the Aleph bib and holdings REST APIs.
10
- #
11
- # == Benchmarks
12
- # The following benchmarks were run on SunOS 5.10 Generic_141414-08 sun4u sparc SUNW,Sun-Fire-V240.
13
- # Rehearsal -----------------------------------------------------------
14
- # PrimoSource - NYUAleph: 2.120000 0.020000 2.140000 ( 3.436712)
15
- # -------------------------------------------------- total: 2.140000sec
16
- #
17
- # user system total real
18
- # PrimoSource - NYUAleph: 2.130000 0.030000 2.160000 ( 3.486879)
19
- class NYUAleph < Exlibris::Primo::Source::Aleph
20
- @attribute_aliases = Exlibris::Primo::Source::Aleph.attribute_aliases
21
- @decode_variables = Exlibris::Primo::Source::Aleph.decode_variables
22
- @source_data_elements = {
23
- :aleph_url => :source_url,
24
- :aleph_sub_library_code => :aleph_sub_library_code,
25
- :aleph_item_id => :aleph_item_id,
26
- :aleph_item_adm_library => :aleph_item_adm_library,
27
- :aleph_item_sub_library_code => :aleph_item_sub_library_code,
28
- :aleph_item_collection_code => :aleph_item_collection_code,
29
- :aleph_item_doc_number => :aleph_item_doc_number,
30
- :aleph_item_sequence_number => :aleph_item_sequence_number,
31
- :aleph_item_barcode => :aleph_item_barcode,
32
- :aleph_item_status_code => :aleph_item_status_code,
33
- :aleph_item_process_status_code => :aleph_item_process_status_code,
34
- :aleph_item_circulation_status => :aleph_item_circulation_status,
35
- :aleph_item_location => :aleph_item_location,
36
- :aleph_item_description => :aleph_item_description,
37
- :aleph_item_hol_doc_number => :aleph_item_hol_doc_number
38
- }
39
-
40
- class << self; attr_reader :source_data_elements end
41
-
42
- # Overwrites Exlibris::Primo::Source::Aleph#new
43
- def initialize(parameters={})
44
- super(parameters)
45
- @aleph_helper ||= Exlibris::Aleph::Config::Helper.instance()
46
- unless parameters[:holding].is_a?(NYUAleph)
47
- # Only process this stuff the first NYUAleph is call,
48
- # i.e. on :to_primo_source, since we don't want to
49
- # make these expensive calls twice.
50
- # Get Aleph record from REST API
51
- aleph_record = Exlibris::Aleph::Record.new(
52
- aleph_doc_library,
53
- aleph_doc_number,
54
- aleph_config["rest_url"]
55
- ) unless aleph_config.nil?
56
- begin
57
- # Exlibris::Aleph::Record :items will raise an exception if the response isn't valid XML.
58
- # We'll handle the exception, ignore the Aleph stuff and
59
- # send a message to the necessary parties that something is up.
60
- @aleph_items ||=
61
- (aleph_record.nil? or display_type.upcase == "JOURNAL") ?
62
- {} : aleph_record.items
63
- # Overwrite the current coverage.
64
- @coverage = get_coverage(aleph_record)
65
- # Don't need to exclude JOURNALS explicitly since we handled them above.
66
- @getting_aleph_holdings ||= !(@aleph_items.empty? or @aleph_items.size > @max_holdings)
67
- rescue Exception => e
68
- Rails.logger.error("Error getting data from Aleph REST APIs. #{e.message}")
69
- @aleph_items = []
70
- @coverage = []
71
- # TODO: Figure out if setting the URL to Primo is the right thing to do.
72
- # On the one hand, if Aleph REST APIs are down, Aleph may be down,
73
- # so we don't want to send users to a dead link.
74
- # On the other hand, if they just came from Primo, they don't want to
75
- # go back and Aleph may not be down, just the REST APIs.
76
- @url = primo_url
77
- @getting_aleph_holdings = false
78
- # Alert the authorities to the problem
79
- alert_the_authorities e
80
- end
81
- else
82
- # Only process this stuff after :expand is called,
83
- # because we don't have correct data before
84
- # Set library as the Aleph sub library if it exists.
85
- aleph_sub_library = @aleph_helper.sub_library_text(
86
- :sub_library_code => @aleph_item_sub_library_code
87
- ) unless @aleph_helper.nil?
88
- @library = aleph_sub_library unless aleph_sub_library.nil?
89
- # Set id_one as the Aleph collection if it exists.
90
- aleph_collection = @aleph_helper.collection_text(
91
- :adm_library_code => @aleph_item_adm_library.downcase,
92
- :sub_library_code => @aleph_item_sub_library_code,
93
- :collection_code => @aleph_item_collection_code
94
- ) unless @aleph_helper.nil? or @aleph_item_adm_library.nil?
95
- @id_one = aleph_collection unless aleph_collection.nil?
96
- # Set status and status code.
97
- @status_code, @status = get_status
98
- # Aleph doesn't work right so we have to push the patron to the Aleph holdings page!
99
- @request_url = url if requestable?
100
- # We're through a second time, so we should be alright to
101
- # to our ajax request stuff. We don't need to put this in
102
- # requestable, since ILL doesn't need a request URL.
103
- # TODO: Probably should specify the gap so it's clear.
104
- # Likely "Billed as Lost" and other circ statuses.
105
- @request_link_supports_ajax_call = true
106
- @source_data[:illiad_url] = aleph_config["illiad_url"]
107
- @source_data.merge!(item_source_data)
108
- end
109
- end
110
-
111
- # Overwrites Exlibris::Primo::Source::Aleph#expand
112
- def expand
113
- aleph_holdings = get_aleph_holdings
114
- return (aleph_holdings.empty?) ?
115
- super : aleph_holdings if getting_aleph_holdings?
116
- super
117
- end
118
-
119
- # Overwrites Exlibris::Primo::Source::Aleph#dedup?
120
- def dedup?
121
- @dedup ||= getting_aleph_holdings?
122
- end
123
-
124
- private
125
- def requestable?
126
- # If this is called by the super class, the item data hasn't been set yet
127
- # so we should just call the super class.
128
- return super if @aleph_item_adm_library.nil?
129
- return RequestHelper.item_requestable?({ :source_data => item_source_data })
130
- end
131
-
132
- def item_source_data
133
- @item_source_data ||= get_item_source_data
134
- end
135
-
136
- def get_item_source_data
137
- # Get the new source data based on class array.
138
- source_data = {} and self.class.source_data_elements.each { |element, instance_variable_name|
139
- source_data[element] = instance_variable_get("@#{instance_variable_name}")
140
- }
141
- return source_data
142
- end
143
-
144
- def get_status
145
- # Initialize status and status code.
146
- aleph_status_code, aleph_status = nil, nil
147
- # Loop through source config for statuses
148
- aleph_config["statuses"].each { |aleph_config_status_code, aleph_config_status|
149
- # Set checked out as Aleph status and code
150
- aleph_status_code = aleph_config_status_code and
151
- aleph_status = "Due: " + @aleph_item_circulation_status and
152
- break if (aleph_config_status_code == "checked_out" and
153
- aleph_config_status === @aleph_item_circulation_status)
154
- # Set circulation statuses like On Shelf, Billed as Lost, as Aleph status and code
155
- aleph_status_code = aleph_config_status_code and
156
- break if (aleph_config_status.instance_of?(Array) and
157
- aleph_config_status.include?(@aleph_item_circulation_status))
158
- } unless aleph_config.nil? or aleph_config["statuses"].nil?
159
- deferred_statuses = (aleph_config["deferred_statuses"].nil?) ? {} : aleph_config["deferred_statuses"]
160
- if (aleph_status_code.nil? or deferred_statuses.include?(aleph_status_code))
161
- # Set Aleph web text as Aleph status if we haven't already gotten the Aleph status
162
- aleph_status = @aleph_helper.item_web_text(
163
- :adm_library_code => @aleph_item_adm_library.downcase,
164
- :sub_library_code => @aleph_item_sub_library_code,
165
- :item_status_code => @aleph_item_status_code,
166
- :item_process_status_code => @aleph_item_process_status_code
167
- ) unless @aleph_helper.nil? or @aleph_item_adm_library.nil?
168
- # Set code as "overridden_by_nyu_aleph"
169
- aleph_status_code = "overridden_by_nyu_aleph" unless aleph_status.nil?
170
- end
171
- # Set status code if we have it.
172
- status_code = aleph_status_code unless aleph_status_code.nil?
173
- # Set status.
174
- status = (aleph_status.nil?) ?
175
- decode(:status, {:address => "statuses"}, true) : aleph_status
176
- return status_code, status
177
- end
178
-
179
- def get_coverage(aleph_record)
180
- require 'nokogiri'
181
- locations_seen = []
182
- coverage = []
183
- return coverage unless display_type.upcase == "JOURNAL"
184
- # Get aleph bib XML and raise exception if there is an error.
185
- aleph_bib = aleph_record.bib
186
- raise "Error getting bib from Aleph REST APIs. #{aleph_record.error}" unless aleph_record.error.nil?
187
- # Parse and process bib XML
188
- # First look at bib 866 and record sub_library and collection (through aleph config mappings)
189
- Nokogiri::XML(aleph_bib).search("//datafield[@tag='866']").each do |bib_866|
190
- bib_866_l = bib_866.at(
191
- "subfield[@code='l']"
192
- ).inner_text unless bib_866.at("subfield[@code='l']").nil?
193
- h = aleph_config["866$l_mappings"]
194
- next if h[bib_866_l].nil?
195
- bib_866_sub_library_code = h[bib_866_l]['sub_library']
196
- if @aleph_sub_library_code.upcase == bib_866_sub_library_code.upcase
197
- bib_866_collection_code = h[bib_866_l]['collection']
198
- bib_866_adm_library = @aleph_helper.sub_library_adm(
199
- :sub_library_code => bib_866_sub_library_code
200
- ) unless @aleph_helper.nil?
201
- bib_866_j = bib_866.at(
202
- "subfield[@code='j']"
203
- ).inner_text unless bib_866.at("subfield[@code='j']").nil?
204
- bib_866_k = bib_866.at(
205
- "subfield[@code='k']"
206
- ).inner_text unless bib_866.at("subfield[@code='k']").nil?
207
- bib_866_collection = @aleph_helper.collection_text(
208
- :adm_library_code => bib_866_adm_library.downcase,
209
- :sub_library_code => bib_866_sub_library_code,
210
- :collection_code => bib_866_collection_code
211
- ) unless @aleph_helper.nil? or bib_866_adm_library.nil?
212
- unless bib_866_collection.nil?
213
- unless bib_866_j.nil? and bib_866_k.nil?
214
- coverage.push(
215
- "Available in #{bib_866_collection}: #{build_coverage_string(bib_866_j, bib_866_k)}".strip
216
- )
217
- else
218
- bib_866_i = bib_866.at(
219
- "subfield[@code='i']"
220
- ).inner_text unless bib_866.at("subfield[@code='i']").nil?
221
- coverage.push(
222
- "#{bib_866_i}".strip
223
- ) unless bib_866_i.nil?
224
- end
225
- end
226
- locations_seen.push({
227
- :adm_library => bib_866_adm_library,
228
- :sub_library_code => bib_866_sub_library_code })
229
- end
230
- end
231
- # Get aleph holding XML.
232
- aleph_holdings = aleph_record.holdings
233
- # Parse and process holding XML
234
- # Now look at holding 866 and record sub_library and collection
235
- # to see if there is anything we missed
236
- Nokogiri::XML(aleph_holdings).search("//holding").each do |aleph_holding|
237
- holding_sub_library_code = aleph_holding.at(
238
- "//datafield[@tag='852']/subfield[@code='b']"
239
- ).inner_text unless aleph_holding.at("//datafield[@tag='852']/subfield[@code='b']").nil?
240
- if @aleph_sub_library_code.upcase == holding_sub_library_code.upcase
241
- holding_adm_library = @aleph_helper.sub_library_adm(
242
- :sub_library_code => holding_sub_library_code
243
- ) unless @aleph_helper.nil?
244
- holding_collection_code = aleph_holding.at(
245
- "//datafield[@tag='852']/subfield[@code='c']"
246
- ).inner_text unless aleph_holding.at("//datafield[@tag='852']/subfield[@code='c']").nil?
247
- next if locations_seen.include?({
248
- :adm_library => holding_adm_library,
249
- :sub_library_code => holding_sub_library_code })
250
- holding_852_z = aleph_holding.at(
251
- "//datafield[@tag='852']/subfield[@code='z']"
252
- ).inner_text unless aleph_holding.at("//datafield[@tag='852']/subfield[@code='z']").nil?
253
- coverage.push("Note: #{holding_852_z}") unless holding_852_z.nil?
254
- holding_collection = @aleph_helper.collection_text(
255
- :adm_library_code => holding_adm_library.downcase,
256
- :sub_library_code => holding_sub_library_code,
257
- :collection_code => holding_collection_code
258
- ) unless @aleph_helper.nil? or holding_adm_library.nil?
259
- aleph_holding.search("//datafield[@tag='866']") do |holding_866|
260
- holding_866_a = holding_866.at(
261
- "subfield[@code='a']"
262
- ).inner_text unless holding_866.at("subfield[@code='a']").nil?
263
- coverage.push(
264
- "Available in #{holding_collection}: #{holding_866_a.gsub(",", ", ")}".strip
265
- ) unless holding_collection.nil? or holding_866_a.nil?
266
- end
267
- end
268
- end
269
- return coverage
270
- end
271
-
272
- def get_aleph_holdings
273
- aleph_holdings = []
274
- return aleph_holdings if @aleph_items.nil?
275
- @aleph_items.each do |aleph_item|
276
- aleph_item_parameters = {
277
- :holding => self,
278
- :aleph_item_id => aleph_item["href"].match(/items\/(.+)$/)[1],
279
- :aleph_item_adm_library => aleph_item["z30"]["translate_change_active_library"],
280
- :aleph_sub_library_code => aleph_item["z30_sub_library_code"].strip,
281
- :aleph_item_sub_library_code => aleph_item["z30_sub_library_code"].strip,
282
- :aleph_item_collection_code => aleph_item["z30_collection_code"],
283
- :aleph_item_doc_number => aleph_item["z30"]["z30_doc_number"],
284
- :aleph_item_sequence_number => aleph_item["z30"]["z30_item_sequence"].strip,
285
- :aleph_item_barcode => aleph_item["z30"]["z30_barcode"],
286
- :aleph_item_status_code => aleph_item["z30_item_status_code"],
287
- :aleph_item_process_status_code => aleph_item["z30_item_process_status_code"],
288
- :aleph_item_circulation_status => aleph_item["status"],
289
- :aleph_item_location => aleph_item["z30"]["z30_call_no"],
290
- :aleph_item_description => aleph_item["z30"]["z30_description"],
291
- :aleph_item_hol_doc_number => aleph_item["z30"]["z30_hol_doc_number"],
292
- :library_code => aleph_item["z30_sub_library_code"].strip,
293
- :id_two => process_aleph_call_number(aleph_item).gsub("&nbsp;", " ")
294
- }
295
- aleph_holdings.push(self.class.new(aleph_item_parameters))
296
- end
297
- Rails.logger.warn(
298
- "No holdings processed from Aleph items in #{self.class}: #{self.record_id}."
299
- ) if aleph_holdings.empty? and getting_aleph_holdings?
300
- return aleph_holdings
301
- end
302
-
303
- def getting_aleph_holdings?
304
- @getting_aleph_holdings
305
- end
306
-
307
- def process_aleph_call_number(aleph_item)
308
- return "" if aleph_item.nil? or
309
- (aleph_item["z30"].fetch("z30_call_no", "").nil? and
310
- aleph_item["z30"].fetch("z30_description", "").nil?)
311
- return "("+
312
- de_marc_call_number(aleph_item["z30"].fetch("z30_call_no", ""))+
313
- ")" if aleph_item["z30"].fetch("z30_description", "").nil?
314
- return "("+
315
- aleph_item["z30"].fetch("z30_description", "").to_s +
316
- ")" if aleph_item["z30"].fetch("z30_call_no", "").nil?
317
- return "("+
318
- de_marc_call_number(aleph_item["z30"].fetch("z30_call_no", ""))+
319
- " "+ aleph_item["z30"].fetch("z30_description", "").to_s+ ")"
320
- end
321
-
322
- def de_marc_call_number(marc_call_number)
323
- call_number = marc_call_number
324
- call_number.gsub!(/\$\$h/, "") unless call_number.nil? or
325
- call_number.match(/\$\$h/).nil?
326
- call_number.gsub!(/\$\$i/, " ") unless call_number.nil? or
327
- call_number.match(/\$\$i/).nil?
328
- return call_number
329
- end
330
-
331
- def build_coverage_string(volumes, years)
332
- rv = ""
333
- rv += "VOLUMES: "+ volumes unless volumes.nil? or volumes.empty?
334
- rv += " (YEARS: "+ years+ ") " unless years.nil? or years.empty?
335
- return rv
336
- end
337
-
338
- # TODO: Implement to send mail.
339
- def alert_the_authorities(error)
340
- Rails.logger.error("Error in #{self.class}. Something is amiss with Aleph. #{error}")
341
- puts "Something is amiss with Aleph. #{error}"
342
- end
343
- end
344
- end
@@ -1,17 +0,0 @@
1
- module Exlibris::Primo
2
- # Class for handling Primo TOCs from links/linktotoc
3
- class Toc
4
- @base_attributes = [ :record_id, :linktotoc, :url, :display, :notes ]
5
- class << self; attr_reader :base_attributes end
6
- def initialize(options={})
7
- base_attributes = (self.class.base_attributes.nil?) ?
8
- Exlibris::Primo::Toc.base_attributes : self.class.base_attributes
9
- base_attributes.each { |attribute|
10
- self.class.send(:attr_reader, attribute)
11
- }
12
- options.each { |option, value|
13
- self.instance_variable_set(('@'+option.to_s).to_sym, value)
14
- }
15
- end
16
- end
17
- end
@@ -1,140 +0,0 @@
1
- # Module for calling Primo Web Services
2
- # Please note the following:
3
- # * Be sure to configure the Primo Back Office with the relevant IPs to enable interaction via the Web Services
4
- # * This module does not parse the response but instead stores it as an Nokogiri::XML::Document for the calling classes to parse
5
- module Exlibris::PrimoWS
6
- require 'nokogiri'
7
-
8
- # PrimoWebService is the base class for all PrimoWebServices
9
- # It can be extended but is not intended for use by itself
10
- # To call a PrimoWebService must explicity call the method make_call.
11
- class PrimoWebService
12
- attr_reader :response, :error
13
-
14
- # Call to web service is made through make_call
15
- # Raise a method not found exception if the method name is not valid
16
- def make_call(base_url, service, method_name, param_name, input)
17
- require 'soap/rpc/driver'
18
- endpoint_url = base_url + "/PrimoWebServices/services/primo/" + service
19
- soap_client = SOAP::RPC::Driver.new(endpoint_url, "http://www.exlibris.com/primo/xsd/wsRequest", "")
20
- soap_client.add_method(method_name, param_name) unless (respond_to? method_name)
21
- @response = Nokogiri::XML(soap_client.method(method_name).call(input.to_s))
22
- raise "Error making call to Primo web service. Response from web service is #{@response}." if @response.nil?
23
- @error = []
24
- response.search("ERROR").each do |e|
25
- @error.push(e.attributes["MESSAGE"]) unless e.nil?
26
- end
27
- raise "Error making call to Primo web service. #{@error.inspect}" unless @error.empty?
28
- end
29
- end
30
-
31
- # Search is the base class for Search web services
32
- # It can be extended but is not intended for use by itself
33
- # Two known implementations are SearchBrief and GetRecord
34
- class Search < PrimoWebService
35
- # Search is instantiated by calling Search.new with the following parameters
36
- # String method_name: web service method being called
37
- # String param_name: name of input parameter
38
- # String input_root: input root tag name
39
- # REXML::Element primo_search_request: REXML:Element representation of the search base on ExL Schema
40
- # REXML:Elements[] additional_input: any additional input as an array of REXML::Elements
41
- # String base_url: Primo URL
42
- # Hash option: options NOT USED
43
- def initialize(method_name, param_name, input_root, primo_search_request, additional_input, base_url, options)
44
- input = REXML::Element.new(input_root)
45
- input.add_namespace("http://www.exlibris.com/primo/xsd/wsRequest")
46
- input.add_element(primo_search_request)
47
- additional_input.each do |e|
48
- input.add_element(e)
49
- end
50
- make_call(base_url, "searcher", method_name, param_name, input)
51
- end
52
-
53
- private
54
- def primo_search_request(search_params={}, start_index="1", bulk_size="5", did_u_mean_enabled="false", highlighting_enabled="false", get_more=nil)
55
- xml = REXML::Element.new("PrimoSearchRequest")
56
- xml.add_namespace("http://www.exlibris.com/primo/xsd/search/request")
57
- xml.add_element(query_terms(search_params))
58
- xml.add_element(tag!("StartIndex", start_index)) unless start_index.nil?
59
- xml.add_element(tag!("BulkSize", bulk_size)) unless bulk_size.nil?
60
- xml.add_element(tag!("DidUMeanEnabled", did_u_mean_enabled)) unless did_u_mean_enabled.nil?
61
- xml.add_element(tag!("HighlightingEnabled", highlighting_enabled)) unless highlighting_enabled.nil?
62
- xml.add_element(tag!("GetMore", get_more)) unless get_more.nil?
63
- return xml
64
- end
65
-
66
- def query_terms(search_params, bool_operator="AND")
67
- xml = REXML::Element.new("QueryTerms")
68
- xml.add_element(tag!("BoolOpeator", bool_operator)) unless bool_operator.nil?
69
- search_params.each do |m, v|
70
- begin
71
- xml.add_element(self.method("#{m}_query_term").call(v))
72
- rescue Exception => e
73
- raise "Invalid search params.\nSupported search params are\n\t:isbn\n\t:issn\n\t:title\n\t:author\n\t:genre\n\nException: #{e.inspect}"
74
- end
75
- end
76
- return xml
77
- end
78
-
79
- def query_term(value=nil, index_field="any", precision_operator="contains")
80
- xml = REXML::Element.new("QueryTerm")
81
- xml.add_element(tag!("IndexField", index_field)) unless value.nil?
82
- xml.add_element(tag!("PrecisionOperator", precision_operator)) unless value.nil?
83
- xml.add_element(tag!("Value", value)) unless value.nil?
84
- return xml
85
- end
86
-
87
- def isbn_query_term(isbn)
88
- return query_term(isbn, "isbn", "exact")
89
- end
90
-
91
- def issn_query_term(issn)
92
- return query_term(issn, "isbn", "exact")
93
- end
94
-
95
- def title_query_term(title)
96
- return query_term(title, "title")
97
- end
98
-
99
- def author_query_term(author)
100
- return query_term(author, "creator")
101
- end
102
-
103
- def genre_query_term(genre)
104
- return query_term(genre, "any", "exact")
105
- end
106
-
107
- def tag!(name, value)
108
- REXML::Element.new(name).add_text(value)
109
- end
110
- end
111
-
112
- # SearchBrief does a brief result search through the Primo APIs
113
- # Not all options are currently supported
114
- # Supported search params are
115
- # :isbn
116
- # :issn
117
- # :title
118
- # :author
119
- # :genre
120
- # e.g. {:isbn => "0143039008", :title => "Travels with My Aunt"}
121
- # Invalid params will raise an exception
122
- class SearchBrief < Search
123
- def initialize(search_params, base_url, options={})
124
- additional_input=[]
125
- additional_input.push(tag!("institution", options.delete(:institution))) if options.has_key?(:institution)
126
- super("searchBrief", "searchBriefRequest", "searchRequest", primo_search_request(search_params), additional_input, base_url, options)
127
- end
128
- end
129
-
130
- # GetRecord get a primo record based on doc id
131
- # Not all options are currently supported
132
- class GetRecord < Search
133
- def initialize(doc_id, base_url, options={})
134
- additional_input=[]
135
- additional_input.push(tag!("docId", doc_id))
136
- additional_input.push(tag!("institution", options.delete(:institution))) if options.has_key?(:institution)
137
- super("getRecord", "getRecordRequest", "fullViewRequest", primo_search_request, additional_input, base_url, options)
138
- end
139
- end
140
- end