exlibris-primo 0.1.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (272) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.md +111 -0
  3. data/Rakefile +2 -1
  4. data/lib/exlibris-primo.rb +4 -14
  5. data/lib/exlibris/primo.rb +13 -0
  6. data/lib/exlibris/primo/abstract.rb +28 -0
  7. data/lib/exlibris/primo/chain_gang/README.md +9 -0
  8. data/lib/exlibris/primo/chain_gang/base.rb +121 -0
  9. data/lib/exlibris/primo/chain_gang/record.rb +18 -0
  10. data/lib/exlibris/primo/chain_gang/search.rb +319 -0
  11. data/lib/exlibris/primo/chain_gang/user.rb +18 -0
  12. data/lib/exlibris/primo/config.rb +69 -0
  13. data/lib/exlibris/primo/eshelf.rb +115 -62
  14. data/lib/exlibris/primo/facet.rb +40 -0
  15. data/lib/exlibris/primo/facet_value.rb +40 -0
  16. data/lib/exlibris/primo/holding.rb +81 -152
  17. data/lib/exlibris/primo/link.rb +32 -0
  18. data/lib/exlibris/primo/namespaces.rb +44 -0
  19. data/lib/exlibris/primo/pnx/dedup_mgr.rb +91 -0
  20. data/lib/exlibris/primo/pnx/elements.rb +79 -0
  21. data/lib/exlibris/primo/pnx/frbr.rb +24 -0
  22. data/lib/exlibris/primo/pnx/holdings.rb +36 -0
  23. data/lib/exlibris/primo/pnx/links.rb +54 -0
  24. data/lib/exlibris/primo/pnx/openurl.rb +24 -0
  25. data/lib/exlibris/primo/pnx/subfields.rb +18 -0
  26. data/lib/exlibris/primo/record.rb +20 -106
  27. data/lib/exlibris/primo/request_attributes.rb +28 -0
  28. data/lib/exlibris/primo/review.rb +46 -0
  29. data/lib/exlibris/primo/reviews.rb +81 -0
  30. data/lib/exlibris/primo/search.rb +82 -0
  31. data/lib/exlibris/primo/source/aleph.rb +77 -31
  32. data/lib/exlibris/primo/tag.rb +34 -0
  33. data/lib/exlibris/primo/tags.rb +103 -0
  34. data/lib/exlibris/primo/version.rb +1 -1
  35. data/lib/exlibris/primo/web_service/client/base.rb +30 -0
  36. data/lib/exlibris/primo/web_service/client/base/endpoint.rb +29 -0
  37. data/lib/exlibris/primo/web_service/client/base/savon_client.rb +24 -0
  38. data/lib/exlibris/primo/web_service/client/base/savon_config.rb +19 -0
  39. data/lib/exlibris/primo/web_service/client/base/soap_actions.rb +55 -0
  40. data/lib/exlibris/primo/web_service/client/base/wsdl.rb +14 -0
  41. data/lib/exlibris/primo/web_service/client/eshelf.rb +22 -0
  42. data/lib/exlibris/primo/web_service/client/reviews.rb +15 -0
  43. data/lib/exlibris/primo/web_service/client/search.rb +15 -0
  44. data/lib/exlibris/primo/web_service/client/tags.rb +14 -0
  45. data/lib/exlibris/primo/web_service/request/base.rb +77 -0
  46. data/lib/exlibris/primo/web_service/request/base/base_elements.rb +71 -0
  47. data/lib/exlibris/primo/web_service/request/base/call.rb +19 -0
  48. data/lib/exlibris/primo/web_service/request/base/client.rb +45 -0
  49. data/lib/exlibris/primo/web_service/request/base/soap_action.rb +29 -0
  50. data/lib/exlibris/primo/web_service/request/eshelf.rb +71 -0
  51. data/lib/exlibris/primo/web_service/request/reviews.rb +57 -0
  52. data/lib/exlibris/primo/web_service/request/search.rb +49 -0
  53. data/lib/exlibris/primo/web_service/request/search/display_fields.rb +30 -0
  54. data/lib/exlibris/primo/web_service/request/search/languages.rb +32 -0
  55. data/lib/exlibris/primo/web_service/request/search/location.rb +15 -0
  56. data/lib/exlibris/primo/web_service/request/search/locations.rb +33 -0
  57. data/lib/exlibris/primo/web_service/request/search/query_term.rb +43 -0
  58. data/lib/exlibris/primo/web_service/request/search/query_terms.rb +40 -0
  59. data/lib/exlibris/primo/web_service/request/search/search_elements.rb +97 -0
  60. data/lib/exlibris/primo/web_service/request/search/sort_bys.rb +32 -0
  61. data/lib/exlibris/primo/web_service/request/tags.rb +56 -0
  62. data/lib/exlibris/primo/web_service/response/base.rb +28 -0
  63. data/lib/exlibris/primo/web_service/response/base/error.rb +25 -0
  64. data/lib/exlibris/primo/web_service/response/base/util.rb +19 -0
  65. data/lib/exlibris/primo/web_service/response/did_u_mean.rb +17 -0
  66. data/lib/exlibris/primo/web_service/response/eshelf.rb +68 -0
  67. data/lib/exlibris/primo/web_service/response/facets.rb +21 -0
  68. data/lib/exlibris/primo/web_service/response/records.rb +17 -0
  69. data/lib/exlibris/primo/web_service/response/reviews.rb +49 -0
  70. data/lib/exlibris/primo/web_service/response/search.rb +36 -0
  71. data/lib/exlibris/primo/web_service/response/search_stats.rb +48 -0
  72. data/lib/exlibris/primo/web_service/response/tags.rb +54 -0
  73. data/lib/exlibris/primo/write_attributes.rb +38 -0
  74. data/lib/exlibris/primo/xml_util.rb +63 -0
  75. data/test/{unit/eshelf_test.rb → bak/eshelf_test.rb.bak} +0 -0
  76. data/test/{unit/record_test.rb → bak/record_test.rb.bak} +0 -0
  77. data/test/{unit/searcher_test.rb → bak/searcher_test.rb.bak} +0 -0
  78. data/test/{unit/web_service_test.rb → bak/web_service_test.rb.bak} +0 -0
  79. data/test/config_test.rb +72 -0
  80. data/test/eshelf_test.rb +66 -0
  81. data/test/exlibris-primo_test.rb +0 -1
  82. data/test/facet_test.rb +27 -0
  83. data/test/facet_value_test.rb +62 -0
  84. data/test/holding_test.rb +26 -0
  85. data/test/link_test.rb +42 -0
  86. data/test/pnx/dedup_mgr_test.rb +16 -0
  87. data/test/pnx/elements_test.rb +16 -0
  88. data/test/pnx/frbr_test.rb +12 -0
  89. data/test/pnx/holdings_test.rb +53 -0
  90. data/test/pnx/links_test.rb +44 -0
  91. data/test/pnx/openurl_test.rb +10 -0
  92. data/test/record_test.rb +11 -0
  93. data/test/review_test.rb +15 -0
  94. data/test/reviews_test.rb +50 -0
  95. data/test/search_test.rb +328 -0
  96. data/test/source/aleph_test.rb +52 -0
  97. data/test/support/config.yml +35 -0
  98. data/test/tag_test.rb +12 -0
  99. data/test/tags_test.rb +65 -0
  100. data/test/test_helper.rb +536 -4
  101. data/test/vcr_cassettes/client_action_no_arguments.yml +38 -0
  102. data/test/vcr_cassettes/client_get_all_my_reviews.yml +49 -0
  103. data/test/vcr_cassettes/client_get_all_my_tags.yml +49 -0
  104. data/test/vcr_cassettes/client_get_eshelf.yml +13812 -0
  105. data/test/vcr_cassettes/client_get_record.yml +222 -0
  106. data/test/vcr_cassettes/client_get_reviews.yml +39 -0
  107. data/test/vcr_cassettes/client_get_tags.yml +42 -0
  108. data/test/vcr_cassettes/client_search_brief_isbn.yml +288 -0
  109. data/test/vcr_cassettes/client_search_brief_issn.yml +282 -0
  110. data/test/vcr_cassettes/client_too_many_arguments.yml +38 -0
  111. data/test/vcr_cassettes/eshelf.yml +13845 -0
  112. data/test/vcr_cassettes/eshelf_add_folder.yml +109 -0
  113. data/test/vcr_cassettes/eshelf_add_record.yml +14237 -0
  114. data/test/vcr_cassettes/eshelf_add_records.yml +14156 -0
  115. data/test/vcr_cassettes/eshelf_basket_id.yml +36 -0
  116. data/test/vcr_cassettes/eshelf_records.yml +13460 -0
  117. data/test/vcr_cassettes/eshelf_remove_folder.yml +76 -0
  118. data/test/vcr_cassettes/eshelf_remove_record.yml +13500 -0
  119. data/test/vcr_cassettes/eshelf_remove_records.yml +13741 -0
  120. data/test/vcr_cassettes/{web_service_single_document.yml → remote_record_call.yml} +12 -23
  121. data/test/vcr_cassettes/{searcher_dedupmrg_by_id.yml → remote_record_dedupmgr.yml} +19 -31
  122. data/test/vcr_cassettes/request_add_folder_to_eshelf.yml +43 -0
  123. data/test/vcr_cassettes/request_add_to_eshelf.yml +43 -0
  124. data/test/vcr_cassettes/request_did_u_mean_enabled.yml +48 -0
  125. data/test/vcr_cassettes/request_full_view.yml +222 -0
  126. data/test/vcr_cassettes/request_get_eshelf.yml +13812 -0
  127. data/test/vcr_cassettes/request_get_eshelf_structure.yml +36 -0
  128. data/test/vcr_cassettes/request_get_reviews.yml +39 -0
  129. data/test/vcr_cassettes/request_get_tags.yml +42 -0
  130. data/test/vcr_cassettes/request_remove_folder_from_eshelf.yml +43 -0
  131. data/test/vcr_cassettes/request_remove_from_eshelf.yml +43 -0
  132. data/test/vcr_cassettes/request_search_author.yml +1258 -0
  133. data/test/vcr_cassettes/request_search_did_u_mean.yml +48 -0
  134. data/test/vcr_cassettes/request_search_genre.yml +1321 -0
  135. data/test/vcr_cassettes/request_search_isbn.yml +288 -0
  136. data/test/vcr_cassettes/request_search_issn.yml +282 -0
  137. data/test/vcr_cassettes/request_search_locations.yml +288 -0
  138. data/test/vcr_cassettes/request_search_title.yml +1024 -0
  139. data/test/vcr_cassettes/request_search_title_author_genre.yml +708 -0
  140. data/test/vcr_cassettes/response_add_folder_to_eshelf.yml +43 -0
  141. data/test/vcr_cassettes/response_add_review.yml +39 -0
  142. data/test/vcr_cassettes/response_add_tag.yml +39 -0
  143. data/test/vcr_cassettes/response_add_to_eshelf.yml +43 -0
  144. data/test/vcr_cassettes/response_did_u_mean_disabled.yml +46 -0
  145. data/test/vcr_cassettes/response_did_u_mean_enabled.yml +48 -0
  146. data/test/vcr_cassettes/response_full_view.yml +222 -0
  147. data/test/vcr_cassettes/response_get_all_my_reviews.yml +49 -0
  148. data/test/vcr_cassettes/response_get_all_my_tags.yml +49 -0
  149. data/test/vcr_cassettes/response_get_eshelf.yml +13633 -0
  150. data/test/vcr_cassettes/response_get_eshelf_structure.yml +36 -0
  151. data/test/vcr_cassettes/response_get_reviews.yml +39 -0
  152. data/test/vcr_cassettes/response_get_reviews_by_rating.yml +49 -0
  153. data/test/vcr_cassettes/response_get_reviews_for_record.yml +39 -0
  154. data/test/vcr_cassettes/response_get_tags.yml +42 -0
  155. data/test/vcr_cassettes/response_get_tags_for_record.yml +42 -0
  156. data/test/vcr_cassettes/response_remove_folder_from_eshelf.yml +43 -0
  157. data/test/vcr_cassettes/response_remove_from_eshelf.yml +43 -0
  158. data/test/vcr_cassettes/response_remove_review.yml +39 -0
  159. data/test/vcr_cassettes/response_remove_tag.yml +39 -0
  160. data/test/vcr_cassettes/response_remove_user_tags.yml +39 -0
  161. data/test/vcr_cassettes/response_search.yml +288 -0
  162. data/test/vcr_cassettes/response_search_did_u_mean.yml +48 -0
  163. data/test/vcr_cassettes/reviews.yml +49 -0
  164. data/test/vcr_cassettes/reviews_add_review.yml +39 -0
  165. data/test/vcr_cassettes/reviews_check_empty_reviews_first.yml +39 -0
  166. data/test/vcr_cassettes/reviews_check_empty_reviews_last.yml +39 -0
  167. data/test/vcr_cassettes/reviews_rating.yml +168 -0
  168. data/test/vcr_cassettes/reviews_record.yml +49 -0
  169. data/test/vcr_cassettes/reviews_remove_review.yml +39 -0
  170. data/test/vcr_cassettes/reviews_reviews.yml +49 -0
  171. data/test/vcr_cassettes/reviews_user.yml +58 -0
  172. data/test/vcr_cassettes/search_chaining_author_title.yml +938 -0
  173. data/test/vcr_cassettes/search_chaining_contains_any.yml +1453 -0
  174. data/test/vcr_cassettes/search_chaining_contains_author_starts_with_title.yml +1055 -0
  175. data/test/vcr_cassettes/search_chaining_isbn.yml +288 -0
  176. data/test/vcr_cassettes/search_chaining_page_size_author.yml +5933 -0
  177. data/test/vcr_cassettes/search_did_u_mean.yml +48 -0
  178. data/test/vcr_cassettes/search_enable_highlighting.yml +1337 -0
  179. data/test/vcr_cassettes/search_isbn.yml +288 -0
  180. data/test/vcr_cassettes/search_languages.yml +1332 -0
  181. data/test/vcr_cassettes/search_locations.yml +1440 -0
  182. data/test/vcr_cassettes/search_record_id.yml +222 -0
  183. data/test/vcr_cassettes/search_record_id_chaining.yml +222 -0
  184. data/test/vcr_cassettes/search_sort_by.yml +1289 -0
  185. data/test/vcr_cassettes/search_sort_by_locations.yml +1387 -0
  186. data/test/vcr_cassettes/tags.yml +56 -0
  187. data/test/vcr_cassettes/tags_add_extra_tag.yml +39 -0
  188. data/test/vcr_cassettes/tags_add_tag.yml +39 -0
  189. data/test/vcr_cassettes/tags_add_tags.yml +111 -0
  190. data/test/vcr_cassettes/tags_check_1_tags.yml +56 -0
  191. data/test/vcr_cassettes/tags_check_2_tags.yml +68 -0
  192. data/test/vcr_cassettes/tags_check_empty_tags_first.yml +42 -0
  193. data/test/vcr_cassettes/tags_check_empty_tags_last.yml +42 -0
  194. data/test/vcr_cassettes/tags_remove_tag.yml +39 -0
  195. data/test/vcr_cassettes/tags_remove_tags.yml +111 -0
  196. data/test/vcr_cassettes/tags_remove_user_tags.yml +39 -0
  197. data/test/vcr_cassettes/tags_tags.yml +104 -0
  198. data/test/vcr_cassettes/tags_user.yml +73 -0
  199. data/test/web_service/client/abstract_test.rb +29 -0
  200. data/test/web_service/client/eshelf_test.rb +22 -0
  201. data/test/web_service/client/reviews_test.rb +31 -0
  202. data/test/web_service/client/savon_client_test.rb +17 -0
  203. data/test/web_service/client/search_benchmarks.rb +29 -0
  204. data/test/web_service/client/search_test.rb +44 -0
  205. data/test/web_service/client/soap_actions_test.rb +45 -0
  206. data/test/web_service/client/tags_test.rb +31 -0
  207. data/test/web_service/request/abstract_test.rb +68 -0
  208. data/test/web_service/request/base_elements_test.rb +231 -0
  209. data/test/web_service/request/build_xml_test.rb +23 -0
  210. data/test/web_service/request/client_test.rb +53 -0
  211. data/test/web_service/request/eshelf_test.rb +26 -0
  212. data/test/web_service/request/location_test.rb +25 -0
  213. data/test/web_service/request/query_term_test.rb +29 -0
  214. data/test/web_service/request/reviews_test.rb +27 -0
  215. data/test/web_service/request/search_test.rb +234 -0
  216. data/test/web_service/request/soap_action_test.rb +120 -0
  217. data/test/web_service/request/tags_test.rb +27 -0
  218. data/test/web_service/response/abstract_test.rb +200 -0
  219. data/test/web_service/response/did_u_mean_test.rb +44 -0
  220. data/test/web_service/response/error_test.rb +31 -0
  221. data/test/web_service/response/eshelf_test.rb +28 -0
  222. data/test/web_service/response/facets_test.rb +42 -0
  223. data/test/web_service/response/records_test.rb +56 -0
  224. data/test/web_service/response/reviews_test.rb +28 -0
  225. data/test/web_service/response/search_stats_test.rb +75 -0
  226. data/test/web_service/response/search_test.rb +40 -0
  227. data/test/web_service/response/tags_test.rb +28 -0
  228. data/test/xml_util_test.rb +23 -0
  229. metadata +456 -114
  230. data/README.rdoc +0 -68
  231. data/lib/exlibris/primo/related_link.rb +0 -20
  232. data/lib/exlibris/primo/rsrc.rb +0 -20
  233. data/lib/exlibris/primo/searcher.rb +0 -277
  234. data/lib/exlibris/primo/toc.rb +0 -20
  235. data/lib/exlibris/primo/web_service.rb +0 -203
  236. data/test/unit/searcher_benchmarks.rb +0 -74
  237. data/test/unit/web_service_benchmarks.rb +0 -58
  238. data/test/vcr_cassettes/eshelf_add_invalid_records.yml +0 -107
  239. data/test/vcr_cassettes/eshelf_add_same_record_twice.yml +0 -159
  240. data/test/vcr_cassettes/eshelf_add_to_empty_basket.yml +0 -107
  241. data/test/vcr_cassettes/eshelf_add_to_invalid_basket.yml +0 -55
  242. data/test/vcr_cassettes/eshelf_invalid_eshelf.yml +0 -55
  243. data/test/vcr_cassettes/eshelf_invalid_institution.yml +0 -55
  244. data/test/vcr_cassettes/eshelf_valid_eshelf.yml +0 -2553
  245. data/test/vcr_cassettes/eshelf_valid_eshelf_structure.yml +0 -47
  246. data/test/vcr_cassettes/record.yml +0 -212
  247. data/test/vcr_cassettes/record_invalid_record.yml +0 -55
  248. data/test/vcr_cassettes/record_sub_record.yml +0 -212
  249. data/test/vcr_cassettes/record_valid_record.yml +0 -212
  250. data/test/vcr_cassettes/searcher_base_holdings_by_id.yml +0 -212
  251. data/test/vcr_cassettes/searcher_diacritics1_by_id.yml +0 -207
  252. data/test/vcr_cassettes/searcher_diacritics2_by_id.yml +0 -232
  253. data/test/vcr_cassettes/searcher_holdings_by_id.yml +0 -212
  254. data/test/vcr_cassettes/searcher_invalid_id.yml +0 -55
  255. data/test/vcr_cassettes/searcher_rsrcs_by_id.yml +0 -270
  256. data/test/vcr_cassettes/searcher_search_by_isbn.yml +0 -278
  257. data/test/vcr_cassettes/searcher_search_by_issn.yml +0 -297
  258. data/test/vcr_cassettes/searcher_search_by_title_author_genre.yml +0 -671
  259. data/test/vcr_cassettes/searcher_test_bug_1361.yml +0 -224
  260. data/test/vcr_cassettes/searcher_test_problem_by_id.yml +0 -194
  261. data/test/vcr_cassettes/searcher_tocs_by_id.yml +0 -217
  262. data/test/vcr_cassettes/web_service_author_search.yml +0 -1269
  263. data/test/vcr_cassettes/web_service_bogus_200.yml +0 -392
  264. data/test/vcr_cassettes/web_service_brief_search.yml +0 -299
  265. data/test/vcr_cassettes/web_service_get_eshelf.yml +0 -11823
  266. data/test/vcr_cassettes/web_service_get_eshelf_structure_search.yml +0 -47
  267. data/test/vcr_cassettes/web_service_invalid_document.yml +0 -54
  268. data/test/vcr_cassettes/web_service_isbn_search.yml +0 -299
  269. data/test/vcr_cassettes/web_service_issn_search.yml +0 -293
  270. data/test/vcr_cassettes/web_service_problem_document.yml +0 -193
  271. data/test/vcr_cassettes/web_service_title_author_genre_search.yml +0 -719
  272. data/test/vcr_cassettes/web_service_title_search.yml +0 -1035
@@ -0,0 +1,28 @@
1
+ module Exlibris
2
+ module Primo
3
+ #
4
+ # Common request attributes based on attr_readers.
5
+ #
6
+ module RequestAttributes
7
+ def request_attributes
8
+ @request_attributes ||= {:base_url => base_url, :institution => institution}
9
+ end
10
+ protected :request_attributes
11
+
12
+ def user_request_attributes
13
+ @user_request_attributes ||= request_attributes.merge :user_id => user_id
14
+ end
15
+ protected :user_request_attributes
16
+
17
+ def record_request_attributes
18
+ @record_request_attributes ||= request_attributes.merge :doc_id => record_id
19
+ end
20
+ protected :record_request_attributes
21
+
22
+ def user_record_request_attributes
23
+ @user_record_request_attributes ||= user_request_attributes.merge :doc_id => record_id
24
+ end
25
+ protected :user_record_request_attributes
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,46 @@
1
+ module Exlibris
2
+ module Primo
3
+ #
4
+ # Primo Review
5
+ #
6
+ class Review
7
+ include Config::Attributes
8
+ include Namespaces
9
+ include WriteAttributes
10
+ include XmlUtil
11
+
12
+ def initialize *args
13
+ @raw_xml = args.last.delete(:raw_xml)
14
+ super
15
+ end
16
+
17
+ def user_id
18
+ @user_id = xml.root.at_xpath("//userId").inner_text
19
+ end
20
+
21
+ def record_id
22
+ @record_id = xml.root.at_xpath("//docId").inner_text
23
+ end
24
+
25
+ def rating
26
+ @rating = xml.root.at_xpath("//rating").inner_text
27
+ end
28
+
29
+ def status
30
+ @status = xml.root.at_xpath("//status").inner_text
31
+ end
32
+
33
+ def value
34
+ @value = xml.root.at_xpath("//value").inner_text
35
+ end
36
+
37
+ def user_display_name
38
+ @user_display_name = xml.root.at_xpath("//userDisplayName").inner_text
39
+ end
40
+
41
+ def allow_user_name?
42
+ @allow_user_name = (xml.root.at_xpath("//allowUserName").inner_text.eql? "true")
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,81 @@
1
+ module Exlibris
2
+ module Primo
3
+ #
4
+ # Manipulate a Primo reviews using Exlibris::Primo::Reviews
5
+ #
6
+ # reviews = Reviews.new.base_url!("http://primo.library.edu").institution!("PRIMO").
7
+ # user_id!("USER_ID").record_id!("aleph0123456789")
8
+ # reviews.reviews #=> Array of Primo reviews
9
+ #
10
+ class Reviews
11
+ include Config::Attributes
12
+ include ChainGang::Base
13
+ include ChainGang::User
14
+ include ChainGang::Record
15
+ include RequestAttributes
16
+ include WriteAttributes
17
+
18
+ attr_reader :user_id, :record_id
19
+
20
+ def initialize *args
21
+ super
22
+ end
23
+
24
+ #
25
+ # Call web service to get reviews for the specified user and record
26
+ #
27
+ def reviews
28
+ @reviews ||= Exlibris::Primo::WebService::Request::GetReviews.new(
29
+ user_record_request_attributes).call.reviews
30
+ end
31
+
32
+ #
33
+ # Call web service to get all reviews for the specified user
34
+ #
35
+ def user_reviews
36
+ @user_reviews ||= Exlibris::Primo::WebService::Request::GetAllMyReviews.new(
37
+ user_request_attributes).call.reviews
38
+ end
39
+
40
+ #
41
+ # Call web service to get all reviews for the specified record
42
+ #
43
+ def record_reviews
44
+ @record_reviews ||= Exlibris::Primo::WebService::Request::GetReviewsForRecord.new(
45
+ record_request_attributes).call.reviews
46
+ end
47
+
48
+ #
49
+ # Get the reviews of a certain rating for the specified user
50
+ #
51
+ def rating_reviews(rating)
52
+ Exlibris::Primo::WebService::Request::GetReviewsByRating.new(
53
+ user_request_attributes.merge :rating => rating).call.reviews
54
+ end
55
+
56
+ #
57
+ # Call web service to add a review to Primo for the specified record
58
+ #
59
+ def add_review(value, rating, user_display_name, status=2, allow_user_name = true)
60
+ Exlibris::Primo::WebService::Request::AddReview.new(user_record_request_attributes.merge :value => value,
61
+ :rating => rating, :user_display_name => user_display_name, :status =>status, :allow_user_name => allow_user_name).call
62
+ reset_reviews
63
+ end
64
+
65
+ #
66
+ # Call web service to remove review from Primo for the specified record
67
+ #
68
+ def remove_review
69
+ Exlibris::Primo::WebService::Request::RemoveReview.new(user_record_request_attributes).call
70
+ reset_reviews
71
+ end
72
+
73
+ def reset_reviews
74
+ @reviews = nil
75
+ @record_reviews = nil
76
+ @user_reviews = nil
77
+ end
78
+ private :reset_reviews
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,82 @@
1
+ module Exlibris
2
+ module Primo
3
+ #
4
+ # Search Primo using Exlibris::Primo::Search
5
+ #
6
+ # search = Search.new.base_url!("http://primo.library.edu").
7
+ # add_query_term("Digital divide", "any", "contains")
8
+ # search.records #=> Array of Primo records
9
+ # search.facets #=> Array of Primo facets
10
+ # search.size #=> Total number of records in the search
11
+ #
12
+ # There are a several configuration setting for the search
13
+ #
14
+ # search = Search.new.base_url!("http://primo.library.edu").institution!("PRIMO").
15
+ # enable_did_u_mean.on_campus.page_size!(20).start_index!(21).add_sort_by("stitle")
16
+ # add_query_term("Digital divide", "any", "contains")
17
+ # search.records #=> Array of Primo records
18
+ # search.facets #=> Array of Primo facets
19
+ # search.size #=> Total number of records in the search
20
+ #
21
+ class Search
22
+ include Config::Attributes
23
+ include ChainGang::Base
24
+ include ChainGang::Record
25
+ include ChainGang::Search
26
+ include RequestAttributes
27
+ include WriteAttributes
28
+
29
+ #
30
+ # Returns the Response from the search.
31
+ # Not really intended for public consumption.
32
+ #
33
+ def search
34
+ request.write_attributes request_attributes
35
+ @search ||= request.call
36
+ end
37
+
38
+ #
39
+ # Returns the array of Records from the search.
40
+ #
41
+ def records
42
+ @records ||= search.records
43
+ end
44
+
45
+ #
46
+ # Returns the array of Facets from the search.
47
+ #
48
+ def facets
49
+ @facets ||= search.facets
50
+ end
51
+
52
+ #
53
+ # Returns the total number of records from the search
54
+ #
55
+ def size
56
+ @size ||= search.size
57
+ end
58
+
59
+ #
60
+ # Returns "Did U Mean" suggestion for the search.
61
+ #
62
+ def did_u_mean
63
+ @did_u_mean ||= search.did_u_mean
64
+ end
65
+
66
+ def full_view_request
67
+ @full_view_request ||= Exlibris::Primo::WebService::Request::FullView.new record_request_attributes
68
+ end
69
+ private :full_view_request
70
+
71
+ def search_request
72
+ @search_request ||= Exlibris::Primo::WebService::Request::Search.new
73
+ end
74
+ private :search_request
75
+
76
+ def request
77
+ @request ||= (record_id) ? full_view_request : search_request
78
+ end
79
+ private :request
80
+ end
81
+ end
82
+ end
@@ -3,47 +3,93 @@ module Exlibris
3
3
  module Source
4
4
  # == Overview
5
5
  # Exlibris::Primo::Source::Aleph is an Exlibris::Primo::Holding that provides a link to Aleph
6
- # and a request button based on config settings in the Primo config file.
6
+ # and a request link based on config settings in the Primo config file.
7
+ #
8
+ # == Example Config
9
+ # source_id:
10
+ # base_url: http://aleph.library.edu
11
+ # rest_url: http://aleph.library.edu:1891/rest-dlf
12
+ # local_base: LOCAL01
13
+ # requestable_statuses:
14
+ # - available
15
+ # - request_ill
16
+ # sub_library_codes:
17
+ # PrimoLibrary1: AlephSubLibrary1
18
+ # PrimoLibrary2: AlephSubLibrary1
19
+ # PrimoLibrary3: AlephSubLibrary2
20
+ #
7
21
  class Aleph < Exlibris::Primo::Holding
8
- @attribute_aliases = Exlibris::Primo::Holding.attribute_aliases.merge({
9
- :aleph_doc_library => :original_source_id, :aleph_sub_library => :library,
10
- :aleph_collection => :collection, :aleph_call_number => :call_number,
11
- :aleph_doc_number => :source_record_id
12
- })
13
- @decode_variables = Exlibris::Primo::Holding.decode_variables.merge({
14
- :aleph_sub_library_code => { :code => :library_code }
15
- })
16
22
 
17
23
  # Overwrites Exlibris::Primo::Holding#new
18
- def initialize(parameters={})
19
- super(parameters)
20
- @aleph_local_base = aleph_config["local_base"] unless aleph_config.nil?
21
- # Aleph holdings page
22
- @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}"
23
- # Aleph doesn't work right so we have to push the patron to the Aleph holdings page!
24
- @request_url = url if requestable?
24
+ def initialize(attributes={})
25
+ super attributes
25
26
  @source_data.merge!({
26
- :aleph_doc_library => aleph_doc_library,
27
- :aleph_sub_library => aleph_sub_library,
28
- :aleph_sub_library_code => @aleph_sub_library_code,
29
- :aleph_collection => aleph_collection,
30
- :aleph_call_number => aleph_call_number,
31
- :aleph_doc_number => aleph_doc_number
32
- })
27
+ :doc_library => original_source_id,
28
+ :sub_library_code => sub_library_code,
29
+ :sub_library => sub_library,
30
+ :collection => collection,
31
+ :call_number => call_number,
32
+ :doc_number => source_record_id,
33
+ :rest_api_id => ils_api_id })
34
+ end
35
+
36
+ # Aleph base url from config.
37
+ def aleph_url
38
+ @aleph_url ||= source_config["base_url"] unless source_config.nil?
39
+ end
40
+
41
+ # Aleph base rest url from config.
42
+ def aleph_rest_url
43
+ @aleph_rest_url ||= source_config["rest_url"] unless source_config.nil?
44
+ end
45
+
46
+ # Aleph local base from config.
47
+ def local_base
48
+ @local_base ||= source_config["local_base"] unless source_config.nil?
49
+ end
50
+
51
+ # Aleph holdings screen
52
+ def url
53
+ @url ||= "#{aleph_url}/F?func=item-global&doc_library=#{original_source_id}&local_base=#{local_base}&doc_number=#{source_record_id}&sub_library=#{sub_library_code}"
54
+ end
55
+
56
+ # Aleph doesn't work right so we have to push the patron to the Aleph holdings page!
57
+ def request_url
58
+ @request_url = url if requestable?
59
+ end
60
+
61
+ # Aleph record rest url
62
+ def rest_url
63
+ @rest_url ||= "#{aleph_rest_url}/record/#{ils_api_id}"
64
+ end
65
+
66
+ # Aleph sub library code from config based on library code
67
+ def sub_library_code
68
+ @sub_library_code ||= sub_library_codes[library_code] unless sub_library_codes.nil?
69
+ end
70
+
71
+ # Aleph sub library
72
+ def sub_library
73
+ library
74
+ end
75
+
76
+ # Aleph sub library codes from config to map from Primo libraries to Aleph sub libraries
77
+ def sub_library_codes
78
+ @sub_library_codes ||= source_config["sub_library_codes"] unless source_config.nil?
33
79
  end
80
+ private :sub_library_codes
34
81
 
35
- protected
36
- # Maps @source config to aleph_config for convenience.
37
- def aleph_config
38
- return @source_config
82
+ # Aleph requestable statuses from config
83
+ def requestable_statuses
84
+ source_config["requestable_statuses"] unless source_config.nil?
39
85
  end
86
+ private :requestable_statuses
40
87
 
41
- private
88
+ # Is this holding requestable?
42
89
  def requestable?
43
- # Default to nothing is requestable
44
- return false if aleph_config.nil? or aleph_config["requestable_statuses"].nil?
45
- return aleph_config["requestable_statuses"].include?(@status_code)
90
+ (requestable_statuses.nil?) ? false : requestable_statuses.include?(@availability_status_code)
46
91
  end
92
+ private :requestable?
47
93
  end
48
94
  end
49
95
  end
@@ -0,0 +1,34 @@
1
+ module Exlibris
2
+ module Primo
3
+ #
4
+ # Primo Tag
5
+ #
6
+ class Tag
7
+ include Config::Attributes
8
+ include Namespaces
9
+ include WriteAttributes
10
+ include XmlUtil
11
+
12
+ def initialize *args
13
+ @raw_xml = args.last.delete(:raw_xml)
14
+ super
15
+ end
16
+
17
+ def user_id
18
+ @user_id = xml.root.at_xpath("//userId").inner_text
19
+ end
20
+
21
+ def record_id
22
+ @record_id = xml.root.at_xpath("//docId").inner_text
23
+ end
24
+
25
+ def status
26
+ @status = xml.root.at_xpath("//status").inner_text
27
+ end
28
+
29
+ def value
30
+ @value = xml.root.at_xpath("//value").inner_text
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,103 @@
1
+ module Exlibris
2
+ module Primo
3
+ #
4
+ # Manipulate a Primo tags using Exlibris::Primo::Tags
5
+ #
6
+ # tags = Tags.new.base_url!("http://primo.library.edu").institution!("PRIMO").
7
+ # user_id!("USER_ID").record_id!("aleph0123456789")
8
+ # tag.my_tags #=> Array of Primo tags
9
+ #
10
+ class Tags
11
+ include Config::Attributes
12
+ include ChainGang::Base
13
+ include ChainGang::User
14
+ include ChainGang::Record
15
+ include RequestAttributes
16
+ include WriteAttributes
17
+
18
+ attr_reader :user_id, :record_id
19
+
20
+ def initialize *args
21
+ super
22
+ end
23
+
24
+ #
25
+ # Get tags for the specified user and record
26
+ #
27
+ def tags
28
+ @tags ||= get_tags.my_tags
29
+ end
30
+
31
+ #
32
+ # Get all tags for the specified user
33
+ #
34
+ def record_tags
35
+ @record_tags ||= get_tags.everybody_tags
36
+ end
37
+
38
+ #
39
+ # Get all tags for the specified user
40
+ #
41
+ def user_tags
42
+ @user_tags ||=
43
+ Exlibris::Primo::WebService::Request::GetAllMyTags.new(user_request_attributes).call.my_tags
44
+ end
45
+
46
+ #
47
+ # Call web service to add tags to Primo for the specified record
48
+ #
49
+ def add_tags(tags)
50
+ tags.each do |tag|
51
+ add_tag tag
52
+ end
53
+ end
54
+
55
+ #
56
+ # Call web service to add a tag to Primo for the specified record
57
+ #
58
+ def add_tag(tag)
59
+ Exlibris::Primo::WebService::Request::AddTag.new(user_record_request_attributes.merge :value => tag).call
60
+ reset_tags
61
+ end
62
+
63
+ #
64
+ # Call web service to remove tags from Primo for the specified record
65
+ #
66
+ def remove_tags(tags)
67
+ tags.each do |tag|
68
+ remove_tag tag
69
+ end
70
+ end
71
+
72
+ #
73
+ # Call web service to remove tag from Primo for the specified record
74
+ #
75
+ def remove_tag(tag)
76
+ Exlibris::Primo::WebService::Request::RemoveTag.new(user_record_request_attributes.merge :value => tag).call
77
+ reset_tags
78
+ end
79
+
80
+ #
81
+ # Remove all users tags
82
+ #
83
+ def remove_user_tags
84
+ Exlibris::Primo::WebService::Request::RemoveUserTags.new(user_request_attributes).call
85
+ reset_tags
86
+ end
87
+
88
+ def get_tags
89
+ @get_tags ||=
90
+ Exlibris::Primo::WebService::Request::GetTags.new(user_record_request_attributes).call
91
+ end
92
+ private :get_tags
93
+
94
+ def reset_tags
95
+ @tags = nil
96
+ @record_tags = nil
97
+ @user_tags = nil
98
+ @get_tags = nil
99
+ end
100
+ private :reset_tags
101
+ end
102
+ end
103
+ end