exlibris-primo 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,3 +1,31 @@
1
1
  = Exlibris::Primo
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ Exlibris::Primo offers a set of libraries for interacting with the ExLibris Primo APIs.
4
+
5
+ == Exlibris::Primo::Searcher
6
+ The Exlibris::Primo::Searcher class performs a search against Primo for given parameters
7
+ and exposes the set of holdings (availibrary elements), rsrcs, tocs, and related links (addlink elements).
8
+
9
+ == Example of Exlibris::Primo::Searcher in action
10
+ setup = {
11
+ :base_url => "http://primo.institution.edu", :vid => "VID", :institution => "INSTITUTION",
12
+ :config => {
13
+ "libraries" =>
14
+ {"library_code1" => "library_display_1", "library_code2" => "library_display_1"},
15
+ "statuses" =>
16
+ {"status_code1" => "status_display_1", "status_code2" => "status_display_2"}}
17
+ }
18
+ params = {
19
+ :primo_id => primo_id,
20
+ :isbn => isbn,
21
+ :issn => issn,
22
+ :title => title,
23
+ :author => author,
24
+ :genre => genre
25
+ }
26
+ searcher = Exlibris::Primo::Searcher.new(setup, params)
27
+ count = search.count
28
+ holdings = searcher.holdings
29
+ rsrcs = searcher.rsrcs
30
+ tocs = searcher.tocs
31
+ related_links = searcher.related_links
@@ -1,40 +1,46 @@
1
- # == Overview
2
- # Exlibris::Primo::Holding represents a Primo holding.
3
- # This class should be extended to create Primo source objects for
4
- # expanding holdings information, linking to Primo sources, and storing
5
- # additional metadata based on those sources.
6
- #
7
- # == Tips on Extending
8
- # When extending the class, a few basics guidelines should be observed.
9
- # 1. A Exlibris::Primo::Holding is initialized from random Hash of parameters.
10
- # Instance variables are created from these parameters for use in the class.
11
- #
12
- # 2. A Exlibris::Primo::Holding can be initialized from an input
13
- # Exlibris::Primo::Holding by specifying the reserved
14
- # parameter name :holding, i.e. :holding => input_holding.
15
- # If the input holding has instance variables that are also specified in
16
- # the random Hash, the value in the Hash takes precedence.
17
- #
18
- # 3. The following methods are available for overriding:
19
- # expand - expand holdings information based on data source. default: [self]
20
- # dedup? - does this data source contain duplicate holdings that need to be deduped? default: false
21
- #
22
- # 4. The following instance variables will be saved in the view_data and will be available
23
- # to a local holding partial:
24
- # @record_id, @source_id, @original_source_id, @source_record_id,
25
- # @availlibrary, @institution_code, @institution, @library_code, @library,
26
- # @status_code, @status, @id_one, @id_two, @origin, @display_type, @coverage, @notes,
27
- # @url, @request_url, @source_data
28
- #
29
- # 5. Additional source data should be saved in the @source_data instance variable.
30
- # @source_data is a hash that can contain any number of string elements,
31
- # perfect for storing local source information.
32
- #
33
- # == Examples
34
- # Example of Primo source implementations are:
35
- # * Exlibris::Primo::Source::Aleph
36
1
  module Exlibris
37
2
  module Primo
3
+ # == Overview
4
+ # Exlibris::Primo::Holding represents a Primo availibrary entry.
5
+ # An instance of Exlibris::Primo::Holding can be created by passing
6
+ # in a set of parameters containing the data for the holding.
7
+ # Valid parameters include:
8
+ # :record_id, :title, :author, :source_id, :original_source_id, :source_record_id,
9
+ # :availlibrary,:institution_code, :library_code, :status_code, :id_one, :id_two,
10
+ # :origin, :display_type, :coverage, :notes, :url, :request_url, :source_data
11
+ # When creating an instance of Exlibris::Primo::Holding, calling
12
+ # classes may send in a :config hash that contains config mappings
13
+ # for decoding libraries and statuses. The :config hash should be
14
+ # of the form
15
+ # {"libraries" => {"library_code1" => "library_display_1", "library_code2" => "library_display_1"}, "statuses" => {"status_code1" => "status_display_1", "status_code2" => "status_display_2"}}
16
+ # The config can also include information about Primo::Source classes in the form:
17
+ # "sources" => {"source_id1" => {"class_name" => "SourceKlassName", "source_config1" => "source_config_one"}}
18
+ # Primo::Source classes can be used to represent a Primo source for expanding holdings
19
+ # information, linking to Primo sources, and storing additional metadata based on those sources.
20
+ # In order to create a source class, implementations should extend Exlibris::Primo::Holding.
21
+ #
22
+ # == Tips on Extending
23
+ # When extending the class, a few basics guidelines should be observed.
24
+ # 1. A Exlibris::Primo::Holding is initialized from random Hash of parameters.
25
+ # Instance variables are created from these parameters for use in the class.
26
+ #
27
+ # 2. A Exlibris::Primo::Holding can also be initialized from an input
28
+ # Exlibris::Primo::Holding by specifying the reserved
29
+ # parameter name :holding, i.e. :holding => input_holding.
30
+ # If the input holding has instance variables that are also specified in
31
+ # the random Hash, the value in the Hash takes precedence.
32
+ #
33
+ # 3. The following methods are available for overriding:
34
+ # expand - expand holdings information based on data source. default: [self]
35
+ # dedup? - does this data source contain duplicate holdings that need to be deduped? default: false
36
+ #
37
+ # 4. Additional source data should be saved in the @source_data instance variable.
38
+ # @source_data is a hash that can contain any number of string elements,
39
+ # perfect for storing local source information.
40
+ #
41
+ # == Examples
42
+ # Example of Primo source implementations are:
43
+ # * Exlibris::Primo::Source::Aleph
38
44
  class Holding
39
45
  @base_attributes = [ :record_id, :title, :author, :source_id, :original_source_id,
40
46
  :source_record_id, :availlibrary, :institution_code, :institution, :library_code,
@@ -149,12 +155,14 @@ module Exlibris
149
155
  end
150
156
  end
151
157
 
158
+ # Convenience method for making base attributes accessible via Hash-like syntax.
152
159
  def [](key)
153
160
  raise "Error in #{self.class}. #{key} doesn't exist or is restricted." unless self.class.base_attributes.include?(key)
154
161
  method(key).call
155
162
  end
156
163
 
157
164
  protected
165
+ # Decode based on the pased in config
158
166
  def decode(var, decode_params={}, refresh=false)
159
167
  return instance_variable_get("@#{var}") unless (not instance_variable_defined?("@#{var}")) or refresh
160
168
  code_sym = (decode_params[:code].nil?) ? "#{var}_code".to_sym : decode_params[:code]
@@ -178,4 +186,4 @@ module Exlibris
178
186
  end
179
187
  end
180
188
  end
181
- end
189
+ end
@@ -1,5 +1,6 @@
1
1
  module Exlibris
2
2
  module Primo
3
+ # == Overview
3
4
  # Class for handling Primo related links from links/addlink
4
5
  class RelatedLink
5
6
  @base_attributes = [ :record_id, :addlink, :url, :display, :notes ]
@@ -1,5 +1,6 @@
1
1
  module Exlibris
2
2
  module Primo
3
+ # == Overview
3
4
  # Class for handling Primo Rsrcs from links/linktorsrc
4
5
  class Rsrc
5
6
  @base_attributes = [ :record_id, :linktorsrc, :v, :url, :display, :institution_code, :origin, :notes ]
@@ -1,15 +1,18 @@
1
- # == Overview
2
- # Searcher searches Primo for records.
3
- # Searcher must have sufficient metadata to make
4
- # the request. Sufficient means either:
5
- # * We have a Primo doc id
6
- # * We have either an isbn OR an issn
7
- # * We have a title AND an author AND a genre
8
- # If none of these criteria are met, Searcher.search
9
- # will raise a RuntimeException.
10
-
11
1
  module Exlibris
12
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 log a warning in the Rails log.
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.
13
16
  class Searcher
14
17
  #@required_setup = [ :base_url ]
15
18
  #@setup_default_values = { :vid => "DEFAULT", :config => {} }
@@ -21,11 +24,12 @@ module Exlibris
21
24
  SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
22
25
 
23
26
  # Instantiates the object and performs the search for based on the input search criteria.
24
- # setup parameter requires { :base_url => http://primo.server.institution.edu }
27
+ # :setup parameter requires { :base_url => http://primo.institution.edu }
25
28
  # Other optional parameters are :vid => "view_id", :config => { Hash of primo config settings}
26
- # search_params are a sufficient combination of
27
- # { :primo_id => "primo_1", :isbn => "ISBN", :issn => "ISSN",
28
- # :title => "=Title", :author => "Author", :genre => "Genre" }
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" }
29
33
  def initialize(setup, search_params)
30
34
  @holdings = []
31
35
  @rsrcs = []
@@ -1,9 +1,9 @@
1
- # == Overview
2
- # Aleph is an Exlibris::Primo::Holding that provides a link to Aleph
3
- # and a request button based on config settings in the primo_config file.
4
1
  module Exlibris
5
2
  module Primo
6
3
  module Source
4
+ # == Overview
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.
7
7
  class Aleph < Exlibris::Primo::Holding
8
8
  @attribute_aliases = Exlibris::Primo::Holding.attribute_aliases.merge({
9
9
  :aleph_doc_library => :original_source_id, :aleph_sub_library => :library,
@@ -1,5 +1,6 @@
1
1
  module Exlibris
2
2
  module Primo
3
+ # == Overview
3
4
  # Class for handling Primo TOCs from links/linktotoc
4
5
  class Toc
5
6
  @base_attributes = [ :record_id, :linktotoc, :url, :display, :notes ]
@@ -1,5 +1,5 @@
1
1
  module Exlibris
2
2
  module Primo
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,16 +1,18 @@
1
- # Module for calling Primo Web Services
2
- # Please note the following:
3
- # * Be sure to configure the Primo Back Office with the relevant IPs to enable interaction via the Web Services
4
- # * This module does not parse the response but instead stores it as an Nokogiri::XML::Document for the calling classes to parse
5
1
  module Exlibris
6
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
7
8
  module WebService
8
9
  require 'nokogiri'
9
10
  require 'rexml/document'
10
11
 
11
12
  # WebServiceBase is the base class for all Primo Web Services
12
13
  # It can be extended but is not intended for use by itself
13
- # To call a PrimoWebService must explicity call the method make_call.
14
+ # To call a PrimoWebService implementing classes must explicity
15
+ # call the method make_call.
14
16
  class WebServiceBase
15
17
  attr_reader :response, :error
16
18
 
@@ -113,14 +115,10 @@ module Exlibris
113
115
  end
114
116
 
115
117
  # SearchBrief does a brief result search through the Primo APIs
116
- # Not all options are currently supported
118
+ # Not all Primo API options are currently supported
117
119
  # Supported search params are
118
- # :isbn
119
- # :issn
120
- # :title
121
- # :author
122
- # :genre
123
- # e.g. {:isbn => "0143039008", :title => "Travels with My Aunt"}
120
+ # :isbn, :issn, :title :author, :genre
121
+ # e.g. {:isbn => "0143039008", :title => "Travels with My Aunt"}
124
122
  # Invalid params will raise an exception
125
123
  class SearchBrief < Search
126
124
  def initialize(search_params, base_url, options={})
@@ -130,8 +128,8 @@ module Exlibris
130
128
  end
131
129
  end
132
130
 
133
- # GetRecord get a primo record based on doc id
134
- # Not all options are currently supported
131
+ # GetRecord get a Primo record based on doc id
132
+ # Not all Primo API options are currently supported
135
133
  class GetRecord < Search
136
134
  def initialize(doc_id, base_url, options={})
137
135
  additional_input=[]
@@ -1646,3 +1646,59 @@
1646
1646
   (0.1ms) rollback transaction
1647
1647
   (0.0ms) begin transaction
1648
1648
   (0.1ms) rollback transaction
1649
+  (1.5ms) begin transaction
1650
+  (0.0ms) rollback transaction
1651
+  (0.0ms) begin transaction
1652
+  (0.1ms) rollback transaction
1653
+  (0.0ms) begin transaction
1654
+  (0.1ms) rollback transaction
1655
+  (0.0ms) begin transaction
1656
+  (0.1ms) rollback transaction
1657
+  (0.0ms) begin transaction
1658
+  (0.1ms) rollback transaction
1659
+  (0.0ms) begin transaction
1660
+  (0.1ms) rollback transaction
1661
+  (0.0ms) begin transaction
1662
+  (0.1ms) rollback transaction
1663
+  (0.0ms) begin transaction
1664
+  (0.1ms) rollback transaction
1665
+  (0.0ms) begin transaction
1666
+  (0.1ms) rollback transaction
1667
+  (0.0ms) begin transaction
1668
+  (0.1ms) rollback transaction
1669
+  (0.0ms) begin transaction
1670
+  (0.1ms) rollback transaction
1671
+  (0.0ms) begin transaction
1672
+  (0.0ms) rollback transaction
1673
+  (0.0ms) begin transaction
1674
+  (0.0ms) rollback transaction
1675
+  (0.0ms) begin transaction
1676
+  (0.1ms) rollback transaction
1677
+  (0.0ms) begin transaction
1678
+  (0.1ms) rollback transaction
1679
+  (0.0ms) begin transaction
1680
+  (0.1ms) rollback transaction
1681
+  (0.0ms) begin transaction
1682
+  (0.1ms) rollback transaction
1683
+  (0.0ms) begin transaction
1684
+  (0.1ms) rollback transaction
1685
+  (0.0ms) begin transaction
1686
+  (0.1ms) rollback transaction
1687
+  (0.0ms) begin transaction
1688
+  (0.1ms) rollback transaction
1689
+  (0.0ms) begin transaction
1690
+  (0.1ms) rollback transaction
1691
+  (0.0ms) begin transaction
1692
+  (0.1ms) rollback transaction
1693
+  (0.0ms) begin transaction
1694
+  (0.1ms) rollback transaction
1695
+  (0.0ms) begin transaction
1696
+  (0.1ms) rollback transaction
1697
+  (0.0ms) begin transaction
1698
+  (0.1ms) rollback transaction
1699
+  (0.0ms) begin transaction
1700
+  (0.1ms) rollback transaction
1701
+  (0.0ms) begin transaction
1702
+  (0.1ms) rollback transaction
1703
+  (0.0ms) begin transaction
1704
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exlibris-primo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-29 00:00:00.000000000 Z
12
+ date: 2012-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2160416640 !ruby/object:Gem::Requirement
16
+ requirement: &2152708140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2160416640
24
+ version_requirements: *2152708140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2160416180 !ruby/object:Gem::Requirement
27
+ requirement: &2152707580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2160416180
35
+ version_requirements: *2152707580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: soap4r-ruby1.9
38
- requirement: &2160415640 !ruby/object:Gem::Requirement
38
+ requirement: &2152706900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2160415640
46
+ version_requirements: *2152706900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &2160415060 !ruby/object:Gem::Requirement
49
+ requirement: &2152706260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2160415060
57
+ version_requirements: *2152706260
58
58
  description: Library to work with Exlibris' Primo discovery system.
59
59
  email:
60
60
  - scotdalton@gmail.com