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.
- data/MIT-LICENSE +1 -1
- data/README.md +111 -0
- data/Rakefile +2 -1
- data/lib/exlibris-primo.rb +4 -14
- data/lib/exlibris/primo.rb +13 -0
- data/lib/exlibris/primo/abstract.rb +28 -0
- data/lib/exlibris/primo/chain_gang/README.md +9 -0
- data/lib/exlibris/primo/chain_gang/base.rb +121 -0
- data/lib/exlibris/primo/chain_gang/record.rb +18 -0
- data/lib/exlibris/primo/chain_gang/search.rb +319 -0
- data/lib/exlibris/primo/chain_gang/user.rb +18 -0
- data/lib/exlibris/primo/config.rb +69 -0
- data/lib/exlibris/primo/eshelf.rb +115 -62
- data/lib/exlibris/primo/facet.rb +40 -0
- data/lib/exlibris/primo/facet_value.rb +40 -0
- data/lib/exlibris/primo/holding.rb +81 -152
- data/lib/exlibris/primo/link.rb +32 -0
- data/lib/exlibris/primo/namespaces.rb +44 -0
- data/lib/exlibris/primo/pnx/dedup_mgr.rb +91 -0
- data/lib/exlibris/primo/pnx/elements.rb +79 -0
- data/lib/exlibris/primo/pnx/frbr.rb +24 -0
- data/lib/exlibris/primo/pnx/holdings.rb +36 -0
- data/lib/exlibris/primo/pnx/links.rb +54 -0
- data/lib/exlibris/primo/pnx/openurl.rb +24 -0
- data/lib/exlibris/primo/pnx/subfields.rb +18 -0
- data/lib/exlibris/primo/record.rb +20 -106
- data/lib/exlibris/primo/request_attributes.rb +28 -0
- data/lib/exlibris/primo/review.rb +46 -0
- data/lib/exlibris/primo/reviews.rb +81 -0
- data/lib/exlibris/primo/search.rb +82 -0
- data/lib/exlibris/primo/source/aleph.rb +77 -31
- data/lib/exlibris/primo/tag.rb +34 -0
- data/lib/exlibris/primo/tags.rb +103 -0
- data/lib/exlibris/primo/version.rb +1 -1
- data/lib/exlibris/primo/web_service/client/base.rb +30 -0
- data/lib/exlibris/primo/web_service/client/base/endpoint.rb +29 -0
- data/lib/exlibris/primo/web_service/client/base/savon_client.rb +24 -0
- data/lib/exlibris/primo/web_service/client/base/savon_config.rb +19 -0
- data/lib/exlibris/primo/web_service/client/base/soap_actions.rb +55 -0
- data/lib/exlibris/primo/web_service/client/base/wsdl.rb +14 -0
- data/lib/exlibris/primo/web_service/client/eshelf.rb +22 -0
- data/lib/exlibris/primo/web_service/client/reviews.rb +15 -0
- data/lib/exlibris/primo/web_service/client/search.rb +15 -0
- data/lib/exlibris/primo/web_service/client/tags.rb +14 -0
- data/lib/exlibris/primo/web_service/request/base.rb +77 -0
- data/lib/exlibris/primo/web_service/request/base/base_elements.rb +71 -0
- data/lib/exlibris/primo/web_service/request/base/call.rb +19 -0
- data/lib/exlibris/primo/web_service/request/base/client.rb +45 -0
- data/lib/exlibris/primo/web_service/request/base/soap_action.rb +29 -0
- data/lib/exlibris/primo/web_service/request/eshelf.rb +71 -0
- data/lib/exlibris/primo/web_service/request/reviews.rb +57 -0
- data/lib/exlibris/primo/web_service/request/search.rb +49 -0
- data/lib/exlibris/primo/web_service/request/search/display_fields.rb +30 -0
- data/lib/exlibris/primo/web_service/request/search/languages.rb +32 -0
- data/lib/exlibris/primo/web_service/request/search/location.rb +15 -0
- data/lib/exlibris/primo/web_service/request/search/locations.rb +33 -0
- data/lib/exlibris/primo/web_service/request/search/query_term.rb +43 -0
- data/lib/exlibris/primo/web_service/request/search/query_terms.rb +40 -0
- data/lib/exlibris/primo/web_service/request/search/search_elements.rb +97 -0
- data/lib/exlibris/primo/web_service/request/search/sort_bys.rb +32 -0
- data/lib/exlibris/primo/web_service/request/tags.rb +56 -0
- data/lib/exlibris/primo/web_service/response/base.rb +28 -0
- data/lib/exlibris/primo/web_service/response/base/error.rb +25 -0
- data/lib/exlibris/primo/web_service/response/base/util.rb +19 -0
- data/lib/exlibris/primo/web_service/response/did_u_mean.rb +17 -0
- data/lib/exlibris/primo/web_service/response/eshelf.rb +68 -0
- data/lib/exlibris/primo/web_service/response/facets.rb +21 -0
- data/lib/exlibris/primo/web_service/response/records.rb +17 -0
- data/lib/exlibris/primo/web_service/response/reviews.rb +49 -0
- data/lib/exlibris/primo/web_service/response/search.rb +36 -0
- data/lib/exlibris/primo/web_service/response/search_stats.rb +48 -0
- data/lib/exlibris/primo/web_service/response/tags.rb +54 -0
- data/lib/exlibris/primo/write_attributes.rb +38 -0
- data/lib/exlibris/primo/xml_util.rb +63 -0
- data/test/{unit/eshelf_test.rb → bak/eshelf_test.rb.bak} +0 -0
- data/test/{unit/record_test.rb → bak/record_test.rb.bak} +0 -0
- data/test/{unit/searcher_test.rb → bak/searcher_test.rb.bak} +0 -0
- data/test/{unit/web_service_test.rb → bak/web_service_test.rb.bak} +0 -0
- data/test/config_test.rb +72 -0
- data/test/eshelf_test.rb +66 -0
- data/test/exlibris-primo_test.rb +0 -1
- data/test/facet_test.rb +27 -0
- data/test/facet_value_test.rb +62 -0
- data/test/holding_test.rb +26 -0
- data/test/link_test.rb +42 -0
- data/test/pnx/dedup_mgr_test.rb +16 -0
- data/test/pnx/elements_test.rb +16 -0
- data/test/pnx/frbr_test.rb +12 -0
- data/test/pnx/holdings_test.rb +53 -0
- data/test/pnx/links_test.rb +44 -0
- data/test/pnx/openurl_test.rb +10 -0
- data/test/record_test.rb +11 -0
- data/test/review_test.rb +15 -0
- data/test/reviews_test.rb +50 -0
- data/test/search_test.rb +328 -0
- data/test/source/aleph_test.rb +52 -0
- data/test/support/config.yml +35 -0
- data/test/tag_test.rb +12 -0
- data/test/tags_test.rb +65 -0
- data/test/test_helper.rb +536 -4
- data/test/vcr_cassettes/client_action_no_arguments.yml +38 -0
- data/test/vcr_cassettes/client_get_all_my_reviews.yml +49 -0
- data/test/vcr_cassettes/client_get_all_my_tags.yml +49 -0
- data/test/vcr_cassettes/client_get_eshelf.yml +13812 -0
- data/test/vcr_cassettes/client_get_record.yml +222 -0
- data/test/vcr_cassettes/client_get_reviews.yml +39 -0
- data/test/vcr_cassettes/client_get_tags.yml +42 -0
- data/test/vcr_cassettes/client_search_brief_isbn.yml +288 -0
- data/test/vcr_cassettes/client_search_brief_issn.yml +282 -0
- data/test/vcr_cassettes/client_too_many_arguments.yml +38 -0
- data/test/vcr_cassettes/eshelf.yml +13845 -0
- data/test/vcr_cassettes/eshelf_add_folder.yml +109 -0
- data/test/vcr_cassettes/eshelf_add_record.yml +14237 -0
- data/test/vcr_cassettes/eshelf_add_records.yml +14156 -0
- data/test/vcr_cassettes/eshelf_basket_id.yml +36 -0
- data/test/vcr_cassettes/eshelf_records.yml +13460 -0
- data/test/vcr_cassettes/eshelf_remove_folder.yml +76 -0
- data/test/vcr_cassettes/eshelf_remove_record.yml +13500 -0
- data/test/vcr_cassettes/eshelf_remove_records.yml +13741 -0
- data/test/vcr_cassettes/{web_service_single_document.yml → remote_record_call.yml} +12 -23
- data/test/vcr_cassettes/{searcher_dedupmrg_by_id.yml → remote_record_dedupmgr.yml} +19 -31
- data/test/vcr_cassettes/request_add_folder_to_eshelf.yml +43 -0
- data/test/vcr_cassettes/request_add_to_eshelf.yml +43 -0
- data/test/vcr_cassettes/request_did_u_mean_enabled.yml +48 -0
- data/test/vcr_cassettes/request_full_view.yml +222 -0
- data/test/vcr_cassettes/request_get_eshelf.yml +13812 -0
- data/test/vcr_cassettes/request_get_eshelf_structure.yml +36 -0
- data/test/vcr_cassettes/request_get_reviews.yml +39 -0
- data/test/vcr_cassettes/request_get_tags.yml +42 -0
- data/test/vcr_cassettes/request_remove_folder_from_eshelf.yml +43 -0
- data/test/vcr_cassettes/request_remove_from_eshelf.yml +43 -0
- data/test/vcr_cassettes/request_search_author.yml +1258 -0
- data/test/vcr_cassettes/request_search_did_u_mean.yml +48 -0
- data/test/vcr_cassettes/request_search_genre.yml +1321 -0
- data/test/vcr_cassettes/request_search_isbn.yml +288 -0
- data/test/vcr_cassettes/request_search_issn.yml +282 -0
- data/test/vcr_cassettes/request_search_locations.yml +288 -0
- data/test/vcr_cassettes/request_search_title.yml +1024 -0
- data/test/vcr_cassettes/request_search_title_author_genre.yml +708 -0
- data/test/vcr_cassettes/response_add_folder_to_eshelf.yml +43 -0
- data/test/vcr_cassettes/response_add_review.yml +39 -0
- data/test/vcr_cassettes/response_add_tag.yml +39 -0
- data/test/vcr_cassettes/response_add_to_eshelf.yml +43 -0
- data/test/vcr_cassettes/response_did_u_mean_disabled.yml +46 -0
- data/test/vcr_cassettes/response_did_u_mean_enabled.yml +48 -0
- data/test/vcr_cassettes/response_full_view.yml +222 -0
- data/test/vcr_cassettes/response_get_all_my_reviews.yml +49 -0
- data/test/vcr_cassettes/response_get_all_my_tags.yml +49 -0
- data/test/vcr_cassettes/response_get_eshelf.yml +13633 -0
- data/test/vcr_cassettes/response_get_eshelf_structure.yml +36 -0
- data/test/vcr_cassettes/response_get_reviews.yml +39 -0
- data/test/vcr_cassettes/response_get_reviews_by_rating.yml +49 -0
- data/test/vcr_cassettes/response_get_reviews_for_record.yml +39 -0
- data/test/vcr_cassettes/response_get_tags.yml +42 -0
- data/test/vcr_cassettes/response_get_tags_for_record.yml +42 -0
- data/test/vcr_cassettes/response_remove_folder_from_eshelf.yml +43 -0
- data/test/vcr_cassettes/response_remove_from_eshelf.yml +43 -0
- data/test/vcr_cassettes/response_remove_review.yml +39 -0
- data/test/vcr_cassettes/response_remove_tag.yml +39 -0
- data/test/vcr_cassettes/response_remove_user_tags.yml +39 -0
- data/test/vcr_cassettes/response_search.yml +288 -0
- data/test/vcr_cassettes/response_search_did_u_mean.yml +48 -0
- data/test/vcr_cassettes/reviews.yml +49 -0
- data/test/vcr_cassettes/reviews_add_review.yml +39 -0
- data/test/vcr_cassettes/reviews_check_empty_reviews_first.yml +39 -0
- data/test/vcr_cassettes/reviews_check_empty_reviews_last.yml +39 -0
- data/test/vcr_cassettes/reviews_rating.yml +168 -0
- data/test/vcr_cassettes/reviews_record.yml +49 -0
- data/test/vcr_cassettes/reviews_remove_review.yml +39 -0
- data/test/vcr_cassettes/reviews_reviews.yml +49 -0
- data/test/vcr_cassettes/reviews_user.yml +58 -0
- data/test/vcr_cassettes/search_chaining_author_title.yml +938 -0
- data/test/vcr_cassettes/search_chaining_contains_any.yml +1453 -0
- data/test/vcr_cassettes/search_chaining_contains_author_starts_with_title.yml +1055 -0
- data/test/vcr_cassettes/search_chaining_isbn.yml +288 -0
- data/test/vcr_cassettes/search_chaining_page_size_author.yml +5933 -0
- data/test/vcr_cassettes/search_did_u_mean.yml +48 -0
- data/test/vcr_cassettes/search_enable_highlighting.yml +1337 -0
- data/test/vcr_cassettes/search_isbn.yml +288 -0
- data/test/vcr_cassettes/search_languages.yml +1332 -0
- data/test/vcr_cassettes/search_locations.yml +1440 -0
- data/test/vcr_cassettes/search_record_id.yml +222 -0
- data/test/vcr_cassettes/search_record_id_chaining.yml +222 -0
- data/test/vcr_cassettes/search_sort_by.yml +1289 -0
- data/test/vcr_cassettes/search_sort_by_locations.yml +1387 -0
- data/test/vcr_cassettes/tags.yml +56 -0
- data/test/vcr_cassettes/tags_add_extra_tag.yml +39 -0
- data/test/vcr_cassettes/tags_add_tag.yml +39 -0
- data/test/vcr_cassettes/tags_add_tags.yml +111 -0
- data/test/vcr_cassettes/tags_check_1_tags.yml +56 -0
- data/test/vcr_cassettes/tags_check_2_tags.yml +68 -0
- data/test/vcr_cassettes/tags_check_empty_tags_first.yml +42 -0
- data/test/vcr_cassettes/tags_check_empty_tags_last.yml +42 -0
- data/test/vcr_cassettes/tags_remove_tag.yml +39 -0
- data/test/vcr_cassettes/tags_remove_tags.yml +111 -0
- data/test/vcr_cassettes/tags_remove_user_tags.yml +39 -0
- data/test/vcr_cassettes/tags_tags.yml +104 -0
- data/test/vcr_cassettes/tags_user.yml +73 -0
- data/test/web_service/client/abstract_test.rb +29 -0
- data/test/web_service/client/eshelf_test.rb +22 -0
- data/test/web_service/client/reviews_test.rb +31 -0
- data/test/web_service/client/savon_client_test.rb +17 -0
- data/test/web_service/client/search_benchmarks.rb +29 -0
- data/test/web_service/client/search_test.rb +44 -0
- data/test/web_service/client/soap_actions_test.rb +45 -0
- data/test/web_service/client/tags_test.rb +31 -0
- data/test/web_service/request/abstract_test.rb +68 -0
- data/test/web_service/request/base_elements_test.rb +231 -0
- data/test/web_service/request/build_xml_test.rb +23 -0
- data/test/web_service/request/client_test.rb +53 -0
- data/test/web_service/request/eshelf_test.rb +26 -0
- data/test/web_service/request/location_test.rb +25 -0
- data/test/web_service/request/query_term_test.rb +29 -0
- data/test/web_service/request/reviews_test.rb +27 -0
- data/test/web_service/request/search_test.rb +234 -0
- data/test/web_service/request/soap_action_test.rb +120 -0
- data/test/web_service/request/tags_test.rb +27 -0
- data/test/web_service/response/abstract_test.rb +200 -0
- data/test/web_service/response/did_u_mean_test.rb +44 -0
- data/test/web_service/response/error_test.rb +31 -0
- data/test/web_service/response/eshelf_test.rb +28 -0
- data/test/web_service/response/facets_test.rb +42 -0
- data/test/web_service/response/records_test.rb +56 -0
- data/test/web_service/response/reviews_test.rb +28 -0
- data/test/web_service/response/search_stats_test.rb +75 -0
- data/test/web_service/response/search_test.rb +40 -0
- data/test/web_service/response/tags_test.rb +28 -0
- data/test/xml_util_test.rb +23 -0
- metadata +456 -114
- data/README.rdoc +0 -68
- data/lib/exlibris/primo/related_link.rb +0 -20
- data/lib/exlibris/primo/rsrc.rb +0 -20
- data/lib/exlibris/primo/searcher.rb +0 -277
- data/lib/exlibris/primo/toc.rb +0 -20
- data/lib/exlibris/primo/web_service.rb +0 -203
- data/test/unit/searcher_benchmarks.rb +0 -74
- data/test/unit/web_service_benchmarks.rb +0 -58
- data/test/vcr_cassettes/eshelf_add_invalid_records.yml +0 -107
- data/test/vcr_cassettes/eshelf_add_same_record_twice.yml +0 -159
- data/test/vcr_cassettes/eshelf_add_to_empty_basket.yml +0 -107
- data/test/vcr_cassettes/eshelf_add_to_invalid_basket.yml +0 -55
- data/test/vcr_cassettes/eshelf_invalid_eshelf.yml +0 -55
- data/test/vcr_cassettes/eshelf_invalid_institution.yml +0 -55
- data/test/vcr_cassettes/eshelf_valid_eshelf.yml +0 -2553
- data/test/vcr_cassettes/eshelf_valid_eshelf_structure.yml +0 -47
- data/test/vcr_cassettes/record.yml +0 -212
- data/test/vcr_cassettes/record_invalid_record.yml +0 -55
- data/test/vcr_cassettes/record_sub_record.yml +0 -212
- data/test/vcr_cassettes/record_valid_record.yml +0 -212
- data/test/vcr_cassettes/searcher_base_holdings_by_id.yml +0 -212
- data/test/vcr_cassettes/searcher_diacritics1_by_id.yml +0 -207
- data/test/vcr_cassettes/searcher_diacritics2_by_id.yml +0 -232
- data/test/vcr_cassettes/searcher_holdings_by_id.yml +0 -212
- data/test/vcr_cassettes/searcher_invalid_id.yml +0 -55
- data/test/vcr_cassettes/searcher_rsrcs_by_id.yml +0 -270
- data/test/vcr_cassettes/searcher_search_by_isbn.yml +0 -278
- data/test/vcr_cassettes/searcher_search_by_issn.yml +0 -297
- data/test/vcr_cassettes/searcher_search_by_title_author_genre.yml +0 -671
- data/test/vcr_cassettes/searcher_test_bug_1361.yml +0 -224
- data/test/vcr_cassettes/searcher_test_problem_by_id.yml +0 -194
- data/test/vcr_cassettes/searcher_tocs_by_id.yml +0 -217
- data/test/vcr_cassettes/web_service_author_search.yml +0 -1269
- data/test/vcr_cassettes/web_service_bogus_200.yml +0 -392
- data/test/vcr_cassettes/web_service_brief_search.yml +0 -299
- data/test/vcr_cassettes/web_service_get_eshelf.yml +0 -11823
- data/test/vcr_cassettes/web_service_get_eshelf_structure_search.yml +0 -47
- data/test/vcr_cassettes/web_service_invalid_document.yml +0 -54
- data/test/vcr_cassettes/web_service_isbn_search.yml +0 -299
- data/test/vcr_cassettes/web_service_issn_search.yml +0 -293
- data/test/vcr_cassettes/web_service_problem_document.yml +0 -193
- data/test/vcr_cassettes/web_service_title_author_genre_search.yml +0 -719
- data/test/vcr_cassettes/web_service_title_search.yml +0 -1035
@@ -0,0 +1,29 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
module SoapAction
|
6
|
+
def self.included(klass)
|
7
|
+
klass.class_eval do
|
8
|
+
extend ClassAttributes
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassAttributes
|
13
|
+
def soap_action
|
14
|
+
@soap_action ||= name.demodulize.underscore.to_sym
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_writer :soap_action
|
18
|
+
protected :soap_action=
|
19
|
+
end
|
20
|
+
|
21
|
+
def soap_action
|
22
|
+
@soap_action ||= self.class.soap_action
|
23
|
+
end
|
24
|
+
protected :soap_action
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
#
|
6
|
+
# Abstract class for eshelf interaction
|
7
|
+
#
|
8
|
+
class Eshelf < User
|
9
|
+
self.add_base_elements :folder_id
|
10
|
+
self.abstract = true
|
11
|
+
self.has_client
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Abstract class for eshelf record interaction
|
16
|
+
#
|
17
|
+
class EshelfRecord < Eshelf
|
18
|
+
self.add_base_elements :doc_id
|
19
|
+
self.abstract = true
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Abstract class for eshelf structure interaction
|
24
|
+
#
|
25
|
+
class EshelfStructure < Eshelf
|
26
|
+
self.add_base_elements :include_basket_items
|
27
|
+
self.has_client
|
28
|
+
self.abstract = true
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Get eshelf structure from Primo for a specified user
|
33
|
+
#
|
34
|
+
class GetEshelfStructure < EshelfStructure; end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Get eshelf from Primo for a specified user
|
38
|
+
#
|
39
|
+
class GetEshelf < Eshelf
|
40
|
+
self.add_base_elements :get_delivery
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Add given record to Primo for a specified user
|
45
|
+
#
|
46
|
+
class AddToEshelf < EshelfRecord
|
47
|
+
self.add_base_elements :searchkey
|
48
|
+
self.remove_base_elements :folder_id
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Remove given record from Primo for a specified user
|
53
|
+
#
|
54
|
+
class RemoveFromEshelf < EshelfRecord; end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Add given folder name to Primo for a specified user
|
58
|
+
#
|
59
|
+
class AddFolderToEshelf < Eshelf
|
60
|
+
self.add_base_elements :folder_name, :parent_folder
|
61
|
+
self.remove_base_elements :folder_id
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Remove given folder from Primo for a specified user
|
66
|
+
#
|
67
|
+
class RemoveFolderFromEshelf < Eshelf; end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
#
|
6
|
+
# Abstract class for reviews interaction
|
7
|
+
#
|
8
|
+
class Reviews < UserRecord
|
9
|
+
self.abstract = true
|
10
|
+
self.has_client
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Get reviews from from Primo for a specified user
|
15
|
+
# and record
|
16
|
+
#
|
17
|
+
class GetReviews < Reviews; end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Get all reviews for a specified user from Primo
|
21
|
+
#
|
22
|
+
class GetAllMyReviews < Reviews
|
23
|
+
self.remove_base_elements :doc_id
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Get reviews for a specified record from Primo
|
28
|
+
#
|
29
|
+
class GetReviewsForRecord < Reviews
|
30
|
+
self.remove_base_elements :user_id
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Get reviews of a given rating for a specified user from Primo
|
35
|
+
#
|
36
|
+
class GetReviewsByRating < Reviews
|
37
|
+
self.add_base_elements :rating
|
38
|
+
self.remove_base_elements :doc_id
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Add given review to Primo for a specified record and user
|
43
|
+
#
|
44
|
+
class AddReview < Reviews
|
45
|
+
# Add review elements to the base elements
|
46
|
+
self.add_base_elements :value, :rating, :user_display_name,
|
47
|
+
:allow_user_name, :status
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Remove review from Primo for a specified record and user
|
52
|
+
#
|
53
|
+
class RemoveReview < Reviews; end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
#
|
6
|
+
# Search Primo
|
7
|
+
#
|
8
|
+
class Search < Base
|
9
|
+
self.has_client
|
10
|
+
self.soap_action = :search_brief
|
11
|
+
include DisplayFields
|
12
|
+
include Languages
|
13
|
+
include Locations
|
14
|
+
include QueryTerms
|
15
|
+
include SearchElements
|
16
|
+
include SortBys
|
17
|
+
|
18
|
+
add_default_search_elements :start_index => "1",
|
19
|
+
:bulk_size => "5", :did_u_mean_enabled => "false"
|
20
|
+
|
21
|
+
add_search_elements :start_index, :bulk_size, :did_u_mean_enabled,
|
22
|
+
:highlighting_enabled, :get_more, :inst_boost
|
23
|
+
|
24
|
+
def to_xml
|
25
|
+
super { |xml|
|
26
|
+
xml.PrimoSearchRequest("xmlns" => "http://www.exlibris.com/primo/xsd/search/request") {
|
27
|
+
query_terms_xml.call xml
|
28
|
+
search_elements_xml.call xml
|
29
|
+
languages_xml.call xml
|
30
|
+
sort_bys_xml.call xml
|
31
|
+
display_fields_xml.call xml
|
32
|
+
locations_xml.call xml
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Get a specific record from Primo.
|
40
|
+
#
|
41
|
+
class FullView < Search
|
42
|
+
# Add doc_id to the base elements
|
43
|
+
self.add_base_elements :doc_id
|
44
|
+
self.soap_action = :get_record
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
module DisplayFields
|
6
|
+
#
|
7
|
+
# Returns a lambda that takes a Nokogiri::XML::Builder as an argument
|
8
|
+
# and appends display fields XML to it.
|
9
|
+
#
|
10
|
+
def display_fields_xml
|
11
|
+
lambda { |xml|
|
12
|
+
display_fields.each do |display_field|
|
13
|
+
xml.DisplayFields display_field
|
14
|
+
end
|
15
|
+
}
|
16
|
+
end
|
17
|
+
protected :display_fields_xml
|
18
|
+
|
19
|
+
def display_fields
|
20
|
+
@display_fields ||= []
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_display_field(display_field)
|
24
|
+
display_fields << display_field
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
module Languages
|
6
|
+
#
|
7
|
+
# Returns a lambda that takes a Nokogiri::XML::Builder as an argument
|
8
|
+
# and appends languages XML to it.
|
9
|
+
#
|
10
|
+
def languages_xml
|
11
|
+
lambda { |xml|
|
12
|
+
xml.Languages {
|
13
|
+
languages.each do |language|
|
14
|
+
xml.Language language
|
15
|
+
end
|
16
|
+
} unless languages.empty?
|
17
|
+
}
|
18
|
+
end
|
19
|
+
protected :languages_xml
|
20
|
+
|
21
|
+
def languages
|
22
|
+
@languages ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_language(language)
|
26
|
+
languages << language
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
module Locations
|
6
|
+
#
|
7
|
+
# Returns a lambda that takes a Nokogiri::XML::Builder as an argument
|
8
|
+
# and appends locations XML to it.
|
9
|
+
#
|
10
|
+
def locations_xml
|
11
|
+
lambda { |xml|
|
12
|
+
# Specify the uic namespace. Not great, but adequate.
|
13
|
+
xml.Locations {
|
14
|
+
locations.each do |location|
|
15
|
+
xml['uic'].Location(:type => location.kind, :value => location.value)
|
16
|
+
end
|
17
|
+
} unless locations.empty?
|
18
|
+
}
|
19
|
+
end
|
20
|
+
protected :locations_xml
|
21
|
+
|
22
|
+
def locations
|
23
|
+
@locations ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_location(kind, value)
|
27
|
+
locations << Location.new(:kind => kind, :value => value)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
#
|
6
|
+
#
|
7
|
+
#
|
8
|
+
class QueryTerm
|
9
|
+
include WriteAttributes
|
10
|
+
include XmlUtil
|
11
|
+
attr_accessor :index, :precision, :value
|
12
|
+
attr_writer :include_values, :exclude_values
|
13
|
+
|
14
|
+
def include_values
|
15
|
+
@include_values ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def exclude_values
|
19
|
+
@exclude_values ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_xml
|
23
|
+
include_values = self.include_values
|
24
|
+
exclude_values = self.exclude_values
|
25
|
+
build_xml do |xml|
|
26
|
+
xml.QueryTerm {
|
27
|
+
xml.IndexField index
|
28
|
+
xml.PrecisionOperator precision
|
29
|
+
xml.Value value
|
30
|
+
include_values.each do |include_value|
|
31
|
+
xml.includeValue include_value
|
32
|
+
end
|
33
|
+
exclude_values.each do |exclude_value|
|
34
|
+
xml.excludeValue exclude_value
|
35
|
+
end
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
module QueryTerms
|
6
|
+
attr_writer :boolean_operator
|
7
|
+
|
8
|
+
def boolean_operator
|
9
|
+
@boolean_operator ||= "AND"
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Returns a lambda that takes a Nokogiri::XML::Builder as an argument
|
14
|
+
# and appends query terms XML to it.
|
15
|
+
#
|
16
|
+
def query_terms_xml
|
17
|
+
bool_operator = boolean_operator
|
18
|
+
lambda do |xml|
|
19
|
+
xml.QueryTerms {
|
20
|
+
xml.BoolOpeator bool_operator
|
21
|
+
query_terms.each do |query_term|
|
22
|
+
xml << query_term.to_xml
|
23
|
+
end
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
protected :query_terms_xml
|
28
|
+
|
29
|
+
def query_terms
|
30
|
+
@query_terms ||= []
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_query_term(value, index, precision="contains")
|
34
|
+
query_terms << QueryTerm.new(:value => value, :index => index, :precision => precision)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Primo
|
3
|
+
module WebService
|
4
|
+
module Request
|
5
|
+
module SearchElements
|
6
|
+
def self.included(klass)
|
7
|
+
klass.class_eval do
|
8
|
+
extend ClassAttributes
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassAttributes
|
13
|
+
def search_elements
|
14
|
+
@search_elements ||= self.superclass.respond_to?(:search_elements) ?
|
15
|
+
self.superclass.search_elements.dup : []
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_search_elements *elements
|
19
|
+
elements.each do |element|
|
20
|
+
search_elements << element unless search_elements.include? element
|
21
|
+
end
|
22
|
+
end
|
23
|
+
protected :add_search_elements
|
24
|
+
|
25
|
+
def remove_search_elements *elements
|
26
|
+
search_elements.delete_if do |element|
|
27
|
+
elements.include? element
|
28
|
+
end
|
29
|
+
end
|
30
|
+
protected :remove_search_elements
|
31
|
+
|
32
|
+
def default_search_elements
|
33
|
+
@default_search_elements ||= self.superclass.respond_to?(:default_search_elements) ?
|
34
|
+
self.superclass.default_search_elements.dup : {}
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_default_search_elements elements
|
38
|
+
default_search_elements.merge! elements
|
39
|
+
end
|
40
|
+
protected :add_default_search_elements
|
41
|
+
|
42
|
+
def remove_default_search_elements *keys
|
43
|
+
keys.each do |key|
|
44
|
+
default_search_elements.delete key
|
45
|
+
end
|
46
|
+
end
|
47
|
+
protected :remove_default_search_elements
|
48
|
+
end
|
49
|
+
|
50
|
+
def search_elements
|
51
|
+
@search_elements ||= self.class.search_elements
|
52
|
+
end
|
53
|
+
protected :search_elements
|
54
|
+
|
55
|
+
def default_search_elements
|
56
|
+
@default_search_elements ||= self.class.default_search_elements
|
57
|
+
end
|
58
|
+
protected :default_search_elements
|
59
|
+
|
60
|
+
#
|
61
|
+
# Returns a lambda that takes a Nokogiri::XML::Builder as an argument
|
62
|
+
# and appends search elements XML to it.
|
63
|
+
#
|
64
|
+
def search_elements_xml
|
65
|
+
lambda { |xml|
|
66
|
+
search_elements.each do |element|
|
67
|
+
value = (send element) ? (send element) : default_search_elements[element]
|
68
|
+
name = element.id2name.camelize
|
69
|
+
xml.send(name, value) unless value.nil?
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
protected :search_elements_xml
|
74
|
+
|
75
|
+
#
|
76
|
+
# Dynamically sets attr_accessors for search_elements
|
77
|
+
#
|
78
|
+
def method_missing(method, *args, &block)
|
79
|
+
if search_elements.include?(attributize(method))
|
80
|
+
self.class.send :attr_accessor, attributize(method)
|
81
|
+
send method, *args, &block
|
82
|
+
else
|
83
|
+
super
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Tell users that we respond to search elements accessors.
|
89
|
+
#
|
90
|
+
def respond_to?(method, include_private = false)
|
91
|
+
(search_elements.include?(attributize method)) ? true : super
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|