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
data/README.rdoc
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
= Exlibris::Primo
|
2
|
-
{<img src="https://secure.travis-ci.org/scotdalton/exlibris-primo.png" alt="Build Status" />}[https://secure.travis-ci.org/scotdalton/exlibris-primo]
|
3
|
-
{<img src="https://gemnasium.com/scotdalton/exlibris-primo.png" alt="Dependency Status" />}[https://gemnasium.com/scotdalton/exlibris-primo]
|
4
|
-
{<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/scotdalton/exlibris-primo]
|
5
|
-
|
6
|
-
Exlibris::Primo offers a set of libraries for interacting with the ExLibris Primo APIs.
|
7
|
-
|
8
|
-
== Exlibris::Primo::Searcher
|
9
|
-
The Exlibris::Primo::Searcher class performs a search against Primo for given parameters
|
10
|
-
and exposes the set of holdings (availibrary elements), rsrcs, tocs, and related links (addlink elements).
|
11
|
-
|
12
|
-
=== Example of Exlibris::Primo::Searcher in action
|
13
|
-
setup = {
|
14
|
-
:base_url => "http://primo.institution.edu", :vid => "VID", :institution => "INSTITUTION",
|
15
|
-
:config => {
|
16
|
-
"libraries" =>
|
17
|
-
{"library_code1" => "library_display_1", "library_code2" => "library_display_1"},
|
18
|
-
"statuses" =>
|
19
|
-
{"status_code1" => "status_display_1", "status_code2" => "status_display_2"}}
|
20
|
-
}
|
21
|
-
params = {
|
22
|
-
:primo_id => primo_id,
|
23
|
-
:isbn => isbn,
|
24
|
-
:issn => issn,
|
25
|
-
:title => title,
|
26
|
-
:author => author,
|
27
|
-
:genre => genre
|
28
|
-
}
|
29
|
-
searcher = Exlibris::Primo::Searcher.new(setup, params)
|
30
|
-
count = search.count
|
31
|
-
holdings = searcher.holdings
|
32
|
-
rsrcs = searcher.rsrcs
|
33
|
-
tocs = searcher.tocs
|
34
|
-
related_links = searcher.related_links
|
35
|
-
|
36
|
-
== Exlibris::Primo::Record
|
37
|
-
The Exlibris::Primo::Record class creates an object representation of a Primo record for given parameters
|
38
|
-
and exposes the record's primary attributes (format, title, author, url, openurl) and full record Xml (raw_xml)
|
39
|
-
as instance variables.
|
40
|
-
|
41
|
-
=== Example of Exlibris::Primo::Record in action
|
42
|
-
setup = {
|
43
|
-
:base_url => "http://primo.institution.edu",
|
44
|
-
:resolver_base_url => "http://resolver.institution.edu",
|
45
|
-
:vid => "VID",
|
46
|
-
:institution => "DEFAULT",
|
47
|
-
:record_id => "PrimoRecordId"
|
48
|
-
}
|
49
|
-
record = Exlibris::Primo::Record.new(setup)
|
50
|
-
raw_xml = record.instance_variable_get(:@raw_xml)
|
51
|
-
record_hash = record.to_h
|
52
|
-
openurl = record_hash["openurl"]
|
53
|
-
|
54
|
-
== Exlibris::Primo::EShelf
|
55
|
-
The Exlibris::Primo::EShelf class provides methods for reading a given user's Primo eshelf and eshelf structure as well as adding and removing records.
|
56
|
-
|
57
|
-
=== Example of Exlibris::Primo::EShelf in action
|
58
|
-
setup = {
|
59
|
-
:base_url => "http://primo.institution.edu",
|
60
|
-
:vid => "VID",
|
61
|
-
:resolver_base_url => "http://resolver.institution.edu"
|
62
|
-
}
|
63
|
-
eshelf = Exlibris::Primo::EShelf.new(setup, "USER_ID", "PRIMO")
|
64
|
-
records = eshelf.records
|
65
|
-
p records.first.class
|
66
|
-
record_count = eshelf.count
|
67
|
-
basket_id = eshelf.basket_id
|
68
|
-
eshelf.add_records(["PrimoRecordId","PrimoRecordId2"], basket_id)
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Primo
|
3
|
-
# == Overview
|
4
|
-
# Class for handling Primo related links from links/addlink
|
5
|
-
class RelatedLink
|
6
|
-
@base_attributes = [ :record_id, :addlink, :url, :display, :notes ]
|
7
|
-
class << self; attr_reader :base_attributes end
|
8
|
-
def initialize(options={})
|
9
|
-
base_attributes = (self.class.base_attributes.nil?) ?
|
10
|
-
Exlibris::Primo::RelatedLink.base_attributes : self.class.base_attributes
|
11
|
-
base_attributes.each { |attribute|
|
12
|
-
self.class.send(:attr_reader, attribute)
|
13
|
-
}
|
14
|
-
options.each { |option, value|
|
15
|
-
self.instance_variable_set(('@'+option.to_s).to_sym, value)
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/exlibris/primo/rsrc.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Primo
|
3
|
-
# == Overview
|
4
|
-
# Class for handling Primo Rsrcs from links/linktorsrc
|
5
|
-
class Rsrc
|
6
|
-
@base_attributes = [ :record_id, :linktorsrc, :v, :url, :display, :institution_code, :origin, :notes ]
|
7
|
-
class << self; attr_reader :base_attributes end
|
8
|
-
def initialize(options={})
|
9
|
-
base_attributes = (self.class.base_attributes.nil?) ?
|
10
|
-
Exlibris::Primo::Rsrc.base_attributes : self.class.base_attributes
|
11
|
-
base_attributes.each { |attribute|
|
12
|
-
self.class.send(:attr_reader, attribute)
|
13
|
-
}
|
14
|
-
options.each { |option, value|
|
15
|
-
self.instance_variable_set(('@'+option.to_s).to_sym, value)
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,277 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Primo
|
3
|
-
# == Overview
|
4
|
-
# Exlibris::Primo::Searcher searches Primo for records.
|
5
|
-
# Exlibris::Primo::Searcher must have sufficient metadata to make
|
6
|
-
# the request. Sufficient means either:
|
7
|
-
# * We have a Primo doc id
|
8
|
-
# * We have either an isbn OR an issn
|
9
|
-
# * We have a title AND an author AND a genre
|
10
|
-
# If none of these criteria are met, Exlibris::Primo::Searcher.search
|
11
|
-
# will not perform the search.
|
12
|
-
# Exlibris::Primo::Searcher will populate the following instance variables
|
13
|
-
# accessible through readers:
|
14
|
-
# :count, :holdings, :rsrcs, :tocs, :related_links
|
15
|
-
# The reader :response makes the full xml result available as a Nokogiri::XML::Document.
|
16
|
-
class Searcher
|
17
|
-
#@required_setup = [ :base_url ]
|
18
|
-
#@setup_default_values = { :vid => "DEFAULT", :config => {} }
|
19
|
-
|
20
|
-
attr_reader :response, :count
|
21
|
-
attr_reader :cover_image, :titles, :author
|
22
|
-
attr_reader :holdings, :rsrcs, :tocs, :related_links
|
23
|
-
PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
|
24
|
-
SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
|
25
|
-
|
26
|
-
# Instantiates the object and performs the search for based on the input search criteria.
|
27
|
-
# :setup parameter requires { :base_url => http://primo.institution.edu }
|
28
|
-
# Other optional parameters are :vid => "view_id", :config => { Hash of primo config settings}
|
29
|
-
# Hash of config settings are of the form:
|
30
|
-
# {"libraries" => {"library_code1" => "library_display_1", "library_code2" => "library_display_1"}, "statuses" => {"status_code1" => "status_display_1", "status_code2" => "status_display_2"}}
|
31
|
-
# :search_params are a sufficient combination of
|
32
|
-
# { :primo_id => "primo_1", :isbn => "ISBN", :issn => "ISSN", :title => "Title", :author => "Author", :genre => "Genre" }
|
33
|
-
def initialize(setup, search_params)
|
34
|
-
@holdings = []
|
35
|
-
@rsrcs = []
|
36
|
-
@tocs = []
|
37
|
-
@related_links = []
|
38
|
-
@holding_attributes = Exlibris::Primo::Holding.base_attributes
|
39
|
-
@base_url = setup[:base_url]
|
40
|
-
raise_required_setup_parameter_error :base_url if @base_url.nil?
|
41
|
-
@institution = setup[:institution]
|
42
|
-
raise_required_setup_parameter_error :institution if @institution.nil?
|
43
|
-
@vid = setup.fetch(:vid, "DEFAULT")
|
44
|
-
raise_required_setup_parameter_error :vid if @vid.nil?
|
45
|
-
@config = setup.fetch(:config, {})
|
46
|
-
raise_required_setup_parameter_error :config if @config.nil?
|
47
|
-
search_params.each { |param, value| self.instance_variable_set("@#{param}".to_sym, value) }
|
48
|
-
# Perform the search
|
49
|
-
search
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
def self.add_attr_reader(reader)
|
54
|
-
attr_reader reader.to_sym
|
55
|
-
end
|
56
|
-
|
57
|
-
# Execute search based on instance vars
|
58
|
-
# Process Holdings based on display/availlibrary
|
59
|
-
# Process URLs based on links/linktorsrc
|
60
|
-
# Process TOCs based on links/linktotoc
|
61
|
-
def search
|
62
|
-
return if insufficient_query?
|
63
|
-
# Call Primo Web Services
|
64
|
-
unless @primo_id.nil? or @primo_id.empty?
|
65
|
-
get_record = Exlibris::Primo::WebService::GetRecord.new(@primo_id, @base_url, {:institution => @institution})
|
66
|
-
@response = get_record.response
|
67
|
-
process_record and process_search_results #since this is a search in addition to being a record call
|
68
|
-
else
|
69
|
-
brief_search = Exlibris::Primo::WebService::SearchBrief.new(search_params, @base_url, {:institution => @institution})
|
70
|
-
@response = brief_search.response
|
71
|
-
process_search_results
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Determine whether we have sufficient search criteria to search
|
76
|
-
# Sufficient means either:
|
77
|
-
# * We have a Primo doc id
|
78
|
-
# * We have either an isbn OR an issn
|
79
|
-
# * We have a title AND an author AND a genre
|
80
|
-
def insufficient_query?
|
81
|
-
return false unless (@primo_id.nil? or @primo_id.empty?)
|
82
|
-
return false unless (@issn.nil? or @issn.empty?) and (@isbn.nil? or @isbn.empty?)
|
83
|
-
return false unless (@title.nil? or @title.empty?) or (@author.nil? or @author.empty?) or (@genre.nil? or @genre.empty?)
|
84
|
-
return true
|
85
|
-
end
|
86
|
-
|
87
|
-
# Search params are determined by input to Exlibris::PrimoWS::SearchBrief
|
88
|
-
def search_params
|
89
|
-
search_params = {}
|
90
|
-
unless (@issn.nil? or @issn.empty?) and (@isbn.nil? or @isbn.empty?)
|
91
|
-
search_params[:isbn] = @isbn unless @isbn.nil?
|
92
|
-
search_params[:issn] = @issn if search_params.empty?
|
93
|
-
else
|
94
|
-
search_params[:title] = @title unless @title.nil?
|
95
|
-
search_params[:author] = @author unless @title.nil? or @author.nil?
|
96
|
-
search_params[:genre] = @genre unless @title.nil? or @author.nil? or @genre.nil?
|
97
|
-
end
|
98
|
-
return search_params
|
99
|
-
end
|
100
|
-
|
101
|
-
# Process a single record
|
102
|
-
def process_record
|
103
|
-
@count = response.at("//search:DOCSET", SEARCH_NS)["TOTALHITS"] unless response.nil? or @count
|
104
|
-
response.at("//pnx:addata", PNX_NS).children.each do |addata_child|
|
105
|
-
name = addata_child.name and value = addata_child.inner_text if addata_child.elem?
|
106
|
-
next if value.nil?
|
107
|
-
self.class.add_attr_reader name.to_sym unless name.nil?
|
108
|
-
instance_variable_set("@#{name}".to_sym, "#{value}") unless name.nil?
|
109
|
-
end
|
110
|
-
@cover_image = response.at("//pnx:addata/pnx:lad02", PNX_NS).inner_text unless response.at("//pnx:addata/pnx:lad02", PNX_NS).nil?
|
111
|
-
@titles = []
|
112
|
-
response.search("//pnx:display/pnx:title", PNX_NS).each do |title|
|
113
|
-
@titles.push(title.inner_text)
|
114
|
-
end
|
115
|
-
@authors = []
|
116
|
-
response.search("//pnx:display/pnx:creator", PNX_NS).each do |creator|
|
117
|
-
@authors.push(creator.inner_text)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Process search results
|
122
|
-
# Process Holdings based on display/availlibrary
|
123
|
-
# Process URLs based on links/linktorsrc
|
124
|
-
# Process TOCs based on links/linktotoc
|
125
|
-
def process_search_results
|
126
|
-
@count = response.at("//search:DOCSET", SEARCH_NS)["TOTALHITS"] unless response.nil? or @count
|
127
|
-
# Loop through records to set metadata for holdings, urls and tocs
|
128
|
-
response.search("//pnx:record", PNX_NS).each do |record|
|
129
|
-
# Default genre to article if necessary
|
130
|
-
record_genre = (record.xpath("pnx:addata/pnx:genre", PNX_NS).nil?) ? "article" : record.xpath("pnx:addata/pnx:genre", PNX_NS).inner_text
|
131
|
-
# Don't process if passed in genre doesn't match the record genre unless the discrepancy is only b/w journals and articles
|
132
|
-
# If we're working off id numbers, we should be good to proceed
|
133
|
-
next unless @primo_id or @isbn or @issn or
|
134
|
-
@genre == record_genre or (@genre == "journal" and record_genre == "article")
|
135
|
-
# Just take the first element for record level elements
|
136
|
-
# (should only be one, except sourceid which will be handled later)
|
137
|
-
record_id = record.xpath("pnx:control/pnx:recordid", PNX_NS).inner_text
|
138
|
-
record_title = record.xpath("pnx:display/pnx:title", PNX_NS).inner_text
|
139
|
-
record_author = record.xpath("pnx:display/pnx:creator", PNX_NS).inner_text
|
140
|
-
display_type = record.xpath("pnx:display/pnx:type", PNX_NS).inner_text
|
141
|
-
original_source_id = record.xpath("pnx:control/pnx:originalsourceid", PNX_NS).inner_text unless record.xpath("pnx:control/pnx:originalsourceid", PNX_NS).nil?
|
142
|
-
original_source_ids = process_control_hash(record, "pnx:control/pnx:originalsourceid", PNX_NS)
|
143
|
-
source_id = record.xpath("pnx:control/pnx:sourceid", PNX_NS).inner_text
|
144
|
-
source_ids = process_control_hash(record, "pnx:control/pnx:sourceid", PNX_NS)
|
145
|
-
source_record_id = record.xpath("pnx:control/pnx:sourcerecordid", PNX_NS).inner_text
|
146
|
-
# Process holdings
|
147
|
-
source_record_ids = process_control_hash(record, "pnx:control/pnx:sourcerecordid", PNX_NS)
|
148
|
-
record.xpath("pnx:display/pnx:availlibrary", PNX_NS).each do |availlibrary|
|
149
|
-
availlibrary, institution_code, library_code, id_one, id_two, status_code, origin = process_availlibrary availlibrary
|
150
|
-
holding_original_source_id = (origin.nil?) ? original_source_ids[record_id] : original_source_ids[origin] unless original_source_ids.empty?
|
151
|
-
holding_original_source_id = original_source_id if holding_original_source_id.nil?
|
152
|
-
holding_source_id = (origin.nil?) ? source_ids[record_id] : source_ids[origin] unless source_ids.empty?
|
153
|
-
holding_source_id = source_id if holding_source_id.nil?
|
154
|
-
holding_source_record_id = (origin.nil?) ? source_record_ids[record_id] : source_record_ids[origin] unless source_record_ids.empty?
|
155
|
-
holding_source_record_id = source_record_id if holding_source_record_id.nil?
|
156
|
-
holding_parameters = {
|
157
|
-
:base_url => @base_url, :vid => @vid, :config => @config,
|
158
|
-
:record_id => record_id, :title => record_title, :author => record_author,
|
159
|
-
:original_source_id => holding_original_source_id, :source_id => holding_source_id,
|
160
|
-
:source_record_id => holding_source_record_id, :origin => origin,
|
161
|
-
:availlibrary => availlibrary, :institution_code => institution_code,
|
162
|
-
:library_code => library_code, :id_one => id_one, :id_two => id_two,
|
163
|
-
:status_code => status_code, :origin => origin, :display_type => display_type, :notes => ""
|
164
|
-
}
|
165
|
-
holding = Exlibris::Primo::Holding.new(holding_parameters)
|
166
|
-
@holdings.push(holding) unless holding.nil?
|
167
|
-
end
|
168
|
-
# Process urls
|
169
|
-
record.xpath("pnx:links/pnx:linktorsrc", PNX_NS).each do |linktorsrc|
|
170
|
-
linktorsrc, v, url, display, institution_code, origin = process_linktorsrc linktorsrc
|
171
|
-
rsrc = Exlibris::Primo::Rsrc.new({
|
172
|
-
:record_id => record_id, :linktorsrc => linktorsrc,
|
173
|
-
:v => v, :url => url, :display => display,
|
174
|
-
:institution_code => institution_code, :origin => origin,
|
175
|
-
:notes => ""
|
176
|
-
}) unless linktorsrc.nil?
|
177
|
-
@rsrcs.push(rsrc) unless (rsrc.nil? or rsrc.url.nil?)
|
178
|
-
end
|
179
|
-
# Process tocs
|
180
|
-
record.xpath("pnx:links/pnx:linktotoc", PNX_NS).each do |linktotoc|
|
181
|
-
linktotoc, url, display = process_linktotoc linktotoc
|
182
|
-
toc = Exlibris::Primo::Toc.new({
|
183
|
-
:record_id => record_id, :linktotoc => linktotoc,
|
184
|
-
:url => url, :display => display,
|
185
|
-
:notes => ""
|
186
|
-
}) unless linktotoc.nil?
|
187
|
-
@tocs.push(toc) unless (toc.nil? or toc.url.nil?)
|
188
|
-
end
|
189
|
-
# Process addlinks
|
190
|
-
record.xpath("pnx:links/pnx:addlink", PNX_NS).each do |addlink|
|
191
|
-
addlink, url, display = process_addlink addlink
|
192
|
-
related_link = Exlibris::Primo::RelatedLink.new({
|
193
|
-
:record_id => record_id, :addlink => addlink,
|
194
|
-
:url => url, :display => display,
|
195
|
-
:notes => ""
|
196
|
-
}) unless addlink.nil?
|
197
|
-
@related_links.push(related_link) unless (related_link.nil? or related_link.url.nil?)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
def process_control_hash(record, xpath, ns)
|
203
|
-
h = {}
|
204
|
-
record.xpath(xpath, ns).each do |e|
|
205
|
-
str = e.inner_text unless e.nil?
|
206
|
-
a = str.split(/\$(?=\$)/) unless str.nil?
|
207
|
-
v = nil
|
208
|
-
o = nil
|
209
|
-
a.each do |s|
|
210
|
-
v = s.sub!(/^\$V/, "") unless s.match(/^\$V/).nil?
|
211
|
-
o = s.sub!(/^\$O/, "") unless s.match(/^\$O/).nil?
|
212
|
-
end
|
213
|
-
h[o] = v unless (o.nil? or v.nil?)
|
214
|
-
end
|
215
|
-
return h
|
216
|
-
end
|
217
|
-
|
218
|
-
def process_availlibrary(input)
|
219
|
-
availlibrary, institution_code, library_code, id_one, id_two, status_code, origin =
|
220
|
-
nil, nil, nil, nil, nil, nil, nil
|
221
|
-
return institution_code, library_code, id_one, id_two, status_code, origin if input.nil? or input.inner_text.nil?
|
222
|
-
availlibrary = input.inner_text
|
223
|
-
availlibrary.split(/\$(?=\$)/).each do |s|
|
224
|
-
institution_code = s.sub!(/^\$I/, "") unless s.match(/^\$I/).nil?
|
225
|
-
library_code = s.sub!(/^\$L/, "") unless s.match(/^\$L/).nil?
|
226
|
-
id_one = s.sub!(/^\$1/, "") unless s.match(/^\$1/).nil?
|
227
|
-
id_two = s.sub!(/^\$2/, "") unless s.match(/^\$2/).nil?
|
228
|
-
# Always display "Check Availability" if this is from Primo.
|
229
|
-
#@status_code = s.sub!(/^\$S/, "") unless s.match(/^\$S/).nil?
|
230
|
-
status_code = "check_holdings"
|
231
|
-
origin = s.sub!(/^\$O/, "") unless s.match(/^\$O/).nil?
|
232
|
-
end
|
233
|
-
return availlibrary, institution_code, library_code, id_one, id_two, status_code, origin
|
234
|
-
end
|
235
|
-
|
236
|
-
def process_linktorsrc(input)
|
237
|
-
linktorsrc, v, url, display, institution_code, origin = nil, nil, nil, nil, nil, nil
|
238
|
-
return linktorsrc, v, url, display, institution_code, origin if input.nil? or input.inner_text.nil?
|
239
|
-
linktorsrc = input.inner_text
|
240
|
-
linktorsrc.split(/\$(?=\$)/).each do |s|
|
241
|
-
v = s.sub!(/^\$V/, "") unless s.match(/^\$V/).nil?
|
242
|
-
url = s.sub!(/^\$U/, "") unless s.match(/^\$U/).nil?
|
243
|
-
display = s.sub!(/^\$D/, "") unless s.match(/^\$D/).nil?
|
244
|
-
institution_code = s.sub!(/^\$I/, "") unless s.match(/^\$I/).nil?
|
245
|
-
origin = s.sub!(/^\$O/, "") unless s.match(/^\$O/).nil?
|
246
|
-
end
|
247
|
-
return linktorsrc, v, url, display, institution_code, origin
|
248
|
-
end
|
249
|
-
|
250
|
-
def process_linktotoc(input)
|
251
|
-
linktotoc, url, display, = nil, nil, nil
|
252
|
-
return linktotoc, url, display if input.nil? or input.inner_text.nil?
|
253
|
-
linktotoc = input.inner_text
|
254
|
-
linktotoc.split(/\$(?=\$)/).each do |s|
|
255
|
-
url = s.sub!(/^\$U/, "") unless s.match(/^\$U/).nil?
|
256
|
-
display = s.sub!(/^\$D/, "") unless s.match(/^\$D/).nil?
|
257
|
-
end
|
258
|
-
return linktotoc, url, display
|
259
|
-
end
|
260
|
-
|
261
|
-
def process_addlink(input)
|
262
|
-
addlink, url, display, = nil, nil, nil
|
263
|
-
return addlink, url, display if input.nil? or input.inner_text.nil?
|
264
|
-
addlink = input.inner_text
|
265
|
-
addlink.split(/\$(?=\$)/).each do |s|
|
266
|
-
url = s.sub!(/^\$U/, "") unless s.match(/^\$U/).nil?
|
267
|
-
display = s.sub!(/^\$D/, "") unless s.match(/^\$D/).nil?
|
268
|
-
end
|
269
|
-
return addlink, url, display
|
270
|
-
end
|
271
|
-
|
272
|
-
def raise_required_setup_parameter_error(parameter)
|
273
|
-
raise "Initialization error in #{self.class}. Missing required setup parameter: #{parameter}."
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
data/lib/exlibris/primo/toc.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Primo
|
3
|
-
# == Overview
|
4
|
-
# Class for handling Primo TOCs from links/linktotoc
|
5
|
-
class Toc
|
6
|
-
@base_attributes = [ :record_id, :linktotoc, :url, :display, :notes ]
|
7
|
-
class << self; attr_reader :base_attributes end
|
8
|
-
def initialize(options={})
|
9
|
-
base_attributes = (self.class.base_attributes.nil?) ?
|
10
|
-
Exlibris::Primo::Toc.base_attributes : self.class.base_attributes
|
11
|
-
base_attributes.each { |attribute|
|
12
|
-
self.class.send(:attr_reader, attribute)
|
13
|
-
}
|
14
|
-
options.each { |option, value|
|
15
|
-
self.instance_variable_set(('@'+option.to_s).to_sym, value)
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,203 +0,0 @@
|
|
1
|
-
module Exlibris
|
2
|
-
module Primo
|
3
|
-
# == Overview
|
4
|
-
# Module for calling Primo Web Services
|
5
|
-
# Please note the following:
|
6
|
-
# * Be sure to configure the Primo Back Office with the relevant IPs to enable interaction via the Web Services
|
7
|
-
# * This module does not parse the response but instead stores it as an Nokogiri::XML::Document for the calling classes to parse
|
8
|
-
module WebService
|
9
|
-
require 'nokogiri'
|
10
|
-
require 'rexml/document'
|
11
|
-
|
12
|
-
# WebServiceBase is the base class for all Primo Web Services
|
13
|
-
# It can be extended but is not intended for use by itself
|
14
|
-
# To call a PrimoWebService implementing classes must explicity
|
15
|
-
# call the method make_call.
|
16
|
-
class WebServiceBase
|
17
|
-
attr_reader :response, :error
|
18
|
-
|
19
|
-
# Call to web service is made through make_call
|
20
|
-
# Raise a method not found exception if the method name is not valid
|
21
|
-
def make_call(base_url, service, method_name, param_name, input)
|
22
|
-
require 'soap/rpc/driver'
|
23
|
-
endpoint_url = base_url + "/PrimoWebServices/services/primo/" + service
|
24
|
-
soap_client = SOAP::RPC::Driver.new(endpoint_url, "http://www.exlibris.com/primo/xsd/wsRequest", "")
|
25
|
-
soap_client.add_method(method_name, param_name) unless (respond_to? method_name)
|
26
|
-
@response = Nokogiri::XML(soap_client.method(method_name).call(input.to_s))
|
27
|
-
raise "Error making call to Primo web service. Response from web service is #{@response}." if @response.nil?
|
28
|
-
@error = []
|
29
|
-
response.search("ERROR").each do |e|
|
30
|
-
# Primo Web Service calls will return an <ERROR MESSAGE="{MESSAGE}" CODE="{CODE}" />
|
31
|
-
# tag even when it succeeds. Key off CODE == 0 which is a successful call.
|
32
|
-
#debugger
|
33
|
-
@error.push(e.attributes["MESSAGE"]) unless e.nil? or e.attributes["CODE"].value.to_i == 0
|
34
|
-
end
|
35
|
-
raise "Error making call to Primo web service. #{@error.inspect}" unless @error.empty?
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
def tag!(name, value)
|
40
|
-
REXML::Element.new(name).add_text(value)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Search is the base class for Search web services
|
45
|
-
# It can be extended but is not intended for use by itself
|
46
|
-
# Two known implementations are SearchBrief and GetRecord
|
47
|
-
class Search < WebServiceBase
|
48
|
-
# Search is instantiated by calling Search.new with the following parameters
|
49
|
-
# String method_name: web service method being called
|
50
|
-
# String param_name: name of input parameter
|
51
|
-
# String input_root: input root tag name
|
52
|
-
# REXML::Element primo_search_request: REXML:Element representation of the search base on ExL Schema
|
53
|
-
# REXML:Elements[] additional_input: any additional input as an array of REXML::Elements
|
54
|
-
# String base_url: Primo URL
|
55
|
-
# Hash option: options NOT USED
|
56
|
-
def initialize(method_name, param_name, input_root, primo_search_request, additional_input, base_url, options)
|
57
|
-
input = REXML::Element.new(input_root)
|
58
|
-
input.add_namespace("http://www.exlibris.com/primo/xsd/wsRequest")
|
59
|
-
input.add_element(primo_search_request)
|
60
|
-
additional_input.each do |e|
|
61
|
-
input.add_element(e)
|
62
|
-
end
|
63
|
-
make_call(base_url, "searcher", method_name, param_name, input)
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
def primo_search_request(search_params={}, start_index="1", bulk_size="5", did_u_mean_enabled="false", highlighting_enabled="false", get_more=nil)
|
68
|
-
xml = REXML::Element.new("PrimoSearchRequest")
|
69
|
-
xml.add_namespace("http://www.exlibris.com/primo/xsd/search/request")
|
70
|
-
xml.add_element(query_terms(search_params))
|
71
|
-
xml.add_element(tag!("StartIndex", start_index)) unless start_index.nil?
|
72
|
-
xml.add_element(tag!("BulkSize", bulk_size)) unless bulk_size.nil?
|
73
|
-
xml.add_element(tag!("DidUMeanEnabled", did_u_mean_enabled)) unless did_u_mean_enabled.nil?
|
74
|
-
xml.add_element(tag!("HighlightingEnabled", highlighting_enabled)) unless highlighting_enabled.nil?
|
75
|
-
xml.add_element(tag!("GetMore", get_more)) unless get_more.nil?
|
76
|
-
return xml
|
77
|
-
end
|
78
|
-
|
79
|
-
def query_terms(search_params, bool_operator="AND")
|
80
|
-
xml = REXML::Element.new("QueryTerms")
|
81
|
-
xml.add_element(tag!("BoolOpeator", bool_operator)) unless bool_operator.nil?
|
82
|
-
search_params.each do |m, v|
|
83
|
-
begin
|
84
|
-
xml.add_element(self.method("#{m}_query_term").call(v))
|
85
|
-
rescue Exception => e
|
86
|
-
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}"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
return xml
|
90
|
-
end
|
91
|
-
|
92
|
-
def query_term(value=nil, index_field="any", precision_operator="contains")
|
93
|
-
xml = REXML::Element.new("QueryTerm")
|
94
|
-
xml.add_element(tag!("IndexField", index_field)) unless value.nil?
|
95
|
-
xml.add_element(tag!("PrecisionOperator", precision_operator)) unless value.nil?
|
96
|
-
xml.add_element(tag!("Value", value)) unless value.nil?
|
97
|
-
return xml
|
98
|
-
end
|
99
|
-
|
100
|
-
def isbn_query_term(isbn)
|
101
|
-
return query_term(isbn, "isbn", "exact")
|
102
|
-
end
|
103
|
-
|
104
|
-
def issn_query_term(issn)
|
105
|
-
return query_term(issn, "isbn", "exact")
|
106
|
-
end
|
107
|
-
|
108
|
-
def title_query_term(title)
|
109
|
-
return query_term(title, "title")
|
110
|
-
end
|
111
|
-
|
112
|
-
def author_query_term(author)
|
113
|
-
return query_term(author, "creator")
|
114
|
-
end
|
115
|
-
|
116
|
-
def genre_query_term(genre)
|
117
|
-
return query_term(genre, "any", "exact")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# SearchBrief does a brief result search through the Primo APIs
|
122
|
-
# Not all Primo API options are currently supported
|
123
|
-
# Supported search params are
|
124
|
-
# :isbn, :issn, :title :author, :genre
|
125
|
-
# e.g. {:isbn => "0143039008", :title => "Travels with My Aunt"}
|
126
|
-
# Invalid params will raise an exception
|
127
|
-
class SearchBrief < Search
|
128
|
-
def initialize(search_params, base_url, options={})
|
129
|
-
additional_input=[]
|
130
|
-
additional_input.push(tag!("institution", options.delete(:institution))) if options.has_key?(:institution)
|
131
|
-
super("searchBrief", "searchBriefRequest", "searchRequest", primo_search_request(search_params), additional_input, base_url, options)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# GetRecord get a Primo record based on doc id
|
136
|
-
# Not all Primo API options are currently supported
|
137
|
-
class GetRecord < Search
|
138
|
-
def initialize(doc_id, base_url, options={})
|
139
|
-
additional_input=[]
|
140
|
-
additional_input.push(tag!("docId", doc_id))
|
141
|
-
additional_input.push(tag!("institution", options.delete(:institution))) if options.has_key?(:institution)
|
142
|
-
super("getRecord", "getRecordRequest", "fullViewRequest", primo_search_request, additional_input, base_url, options)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# EShelf is the base class for EShelf web services
|
147
|
-
# It can be extended but is not intended for use by itself
|
148
|
-
# Known implementations are GetEShelf, AddToEShelf, RemoveFromEShelf, GetEShelfStructure
|
149
|
-
class EShelf < WebServiceBase
|
150
|
-
def initialize(method_name, param_name, input_root, user_id, institution, additional_input, base_url, options, service_name = nil)
|
151
|
-
input = REXML::Element.new(input_root)
|
152
|
-
input.add_namespace("http://www.exlibris.com/primo/xsd/wsRequest")
|
153
|
-
input.add_element(tag!("userId", user_id)) if !user_id.nil?
|
154
|
-
input.add_element(tag!("institution", institution)) if !institution.nil?
|
155
|
-
additional_input.each do |e|
|
156
|
-
input.add_element(e)
|
157
|
-
end
|
158
|
-
service_name = "eshelf" if service_name.nil?
|
159
|
-
make_call(base_url, service_name, method_name, param_name, input)
|
160
|
-
end
|
161
|
-
|
162
|
-
private
|
163
|
-
def docs(doc_ids=[], folder_id=nil, folder_name=nil)
|
164
|
-
additional_input = []
|
165
|
-
doc_ids.each { |doc_id| additional_input.push(tag!("docId", doc_id)) }
|
166
|
-
additional_input.push(tag!("folderId", folder_id)) unless folder_id.nil?
|
167
|
-
additional_input.push(tag!("folderName", folder_name)) unless folder_name.nil?
|
168
|
-
return additional_input
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
# Get EShelf based on user_id and institution
|
173
|
-
class GetEShelf < EShelf
|
174
|
-
def initialize(user_id, institution, base_url, options={})
|
175
|
-
super("getEshelf", "getEshelfRequest", "getEshelfRequest", user_id, institution, [], base_url, options)
|
176
|
-
raise "Error making call to Primo web service. #{@error.inspect}" unless @error.empty? or @error.attribe
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# Get EShelf structure based on user_id and institution
|
181
|
-
class GetEShelfStructure < EShelf
|
182
|
-
def initialize(user_id, institution, base_url, options={})
|
183
|
-
super("getEshelfStructure", "getEshelfStructureRequest", "getEshelfStructureRequest", user_id, institution, [tag!("includeBasketItems","false")], base_url, options, "eshelfstructure")
|
184
|
-
raise "Error making call to Primo web service. #{@error.inspect}" unless @error.empty? or @error.attribe
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# Add document to EShelf based on user_id and institution
|
189
|
-
class AddToEShelf < EShelf
|
190
|
-
def initialize(doc_ids, folder_id, user_id, institution, base_url, options={})
|
191
|
-
super("addToEshelf", "addToEshelfRequest", "addToEshelfRequest", user_id, institution, docs(doc_ids, folder_id), base_url, options)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
# Remove document from EShelf based on user_id and institution
|
196
|
-
class RemoveFromEShelf < EShelf
|
197
|
-
def initialize(doc_ids, folder_id, user_id, institution, base_url, options={})
|
198
|
-
super("removeFromEshelf", "removeFromEshelfRequest", "removeFromEshelfRequest", user_id, institution, docs(doc_ids, folder_id), base_url, options)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|