voyager_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rvmrc.07.27.2011-15:02:08 +47 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +36 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/holdings/collection.rb +44 -0
- data/lib/holdings/item.rb +253 -0
- data/lib/holdings/order.rb +68 -0
- data/lib/holdings/record.rb +229 -0
- data/lib/voyager_api.rb +10 -0
- data/lib/voyager_connection.rb +35 -0
- data/test/fixtures/fixtures_readme +65 -0
- data/test/fixtures/holdings_289196.xml +2 -0
- data/test/fixtures/holdings_4191079.xml +2 -0
- data/test/fixtures/holdings_4949188.xml +2 -0
- data/test/fixtures/holdings_4949188_2.xml +2 -0
- data/test/fixtures/holdings_526843.xml +2 -0
- data/test/fixtures/holdings_5656993.xml +2 -0
- data/test/fixtures/holdings_6269409.xml +2 -0
- data/test/fixtures/holdings_7471326.xml +2 -0
- data/test/fixtures/holdings_7658449.xml +2 -0
- data/test/fixtures/holdings_7658454.xml +2 -0
- data/test/fixtures/holdings_7784963.xml +2 -0
- data/test/fixtures/holdings_8267323.xml +2 -0
- data/test/fixtures/holdings_8615744.xml +2 -0
- data/test/fixtures/holdings_8889994.xml +2 -0
- data/test/fixtures/holdings_8891001.xml +2 -0
- data/test/fixtures/holdings_8891001_2.xml +2 -0
- data/test/fixtures/holdings_8918502.xml +2 -0
- data/test/helper.rb +29 -0
- data/test/holdings/test_collection.rb +15 -0
- data/test/holdings/test_collection_output.rb +24 -0
- data/test/holdings/test_holdings_test_case.rb +14 -0
- data/test/holdings/test_item.rb +48 -0
- data/test/holdings/test_order.rb +34 -0
- data/test/holdings/test_record.rb +147 -0
- data/test/test_voyager_api.rb +4 -0
- data/test/test_voyager_connection.rb +28 -0
- metadata +253 -0
data/.document
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ruby-1.9.2-p290@voyager_api"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment following line if you want options to be set only for given project.
|
11
|
+
#
|
12
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
13
|
+
|
14
|
+
#
|
15
|
+
# First we attempt to load the desired environment directly from the environment
|
16
|
+
# file. This is very fast and efficient compared to running through the entire
|
17
|
+
# CLI and selector. If you want feedback on which environment was used then
|
18
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
+
#
|
20
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
21
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
22
|
+
then
|
23
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
24
|
+
|
25
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
26
|
+
then
|
27
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
28
|
+
fi
|
29
|
+
else
|
30
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
31
|
+
if ! rvm --create use "$environment_id"
|
32
|
+
then
|
33
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
34
|
+
exit 1
|
35
|
+
fi
|
36
|
+
fi
|
37
|
+
|
38
|
+
#
|
39
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
40
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
41
|
+
# necessary.
|
42
|
+
#
|
43
|
+
# filename=".gems"
|
44
|
+
# if [[ -s "$filename" ]] ; then
|
45
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
46
|
+
# fi
|
47
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "httpclient"
|
7
|
+
gem "nokogiri"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "minitest", ">= 0"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.6.4"
|
15
|
+
gem "rcov", ">= 0"
|
16
|
+
gem "guard-minitest"
|
17
|
+
gem "rb-fsevent" # comment out if not on mac
|
18
|
+
gem "mocha"
|
19
|
+
gem "growl"
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
growl (1.0.3)
|
6
|
+
guard (0.5.1)
|
7
|
+
thor (~> 0.14.6)
|
8
|
+
guard-minitest (0.4.0)
|
9
|
+
guard (~> 0.4)
|
10
|
+
httpclient (2.2.1)
|
11
|
+
jeweler (1.6.4)
|
12
|
+
bundler (~> 1.0)
|
13
|
+
git (>= 1.2.5)
|
14
|
+
rake
|
15
|
+
minitest (2.3.1)
|
16
|
+
mocha (0.9.12)
|
17
|
+
nokogiri (1.5.0)
|
18
|
+
rake (0.9.2)
|
19
|
+
rb-fsevent (0.4.1)
|
20
|
+
rcov (0.9.9)
|
21
|
+
thor (0.14.6)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
bundler (~> 1.0.0)
|
28
|
+
growl
|
29
|
+
guard-minitest
|
30
|
+
httpclient
|
31
|
+
jeweler (~> 1.6.4)
|
32
|
+
minitest
|
33
|
+
mocha
|
34
|
+
nokogiri
|
35
|
+
rb-fsevent
|
36
|
+
rcov
|
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'minitest' do
|
5
|
+
watch(%r{^test/(.*)test_(.*).rb})
|
6
|
+
watch(%r{^lib/((?:(?:[^/]+)/)*)([^/]+)\.rb}) do |m|
|
7
|
+
Dir.glob("test/#{m[1]}test_#{m[2]}*.rb")
|
8
|
+
end
|
9
|
+
watch(%r{^test/helper(.*).rb}) { "test" }
|
10
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 James Stuart
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= voyager_api
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to voyager_api
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 James Stuart. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "voyager_api"
|
18
|
+
gem.homepage = "http://github.com/cul/voyager_api"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Columbia University Voyager 7 API wrapper}
|
21
|
+
gem.description = %Q{Middleware gem for Voyager 7 API calls, specificially holdings information }
|
22
|
+
gem.email = "github@jamesstuart.org"
|
23
|
+
gem.authors = ["James Stuart", "Gary Bertchume"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "voyager_api #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Voyager
|
2
|
+
module Holdings
|
3
|
+
class Collection
|
4
|
+
attr_reader :records, :xml
|
5
|
+
|
6
|
+
DEFAULT_OPAC_URL = "http://bearberry.cc.columbia.edu:7014/vxws/GetHoldingsService"
|
7
|
+
|
8
|
+
def self.new_from_opac(bibid, url = DEFAULT_OPAC_URL, httpclient = nil)
|
9
|
+
conn = Voyager::Connection.new(:http_client => httpclient)
|
10
|
+
Collection.new(conn.request(url, :bibId => bibid))
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(raw_xml)
|
14
|
+
@xml = load_and_namespace_xml(raw_xml)
|
15
|
+
parse_xml
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
output = {}
|
20
|
+
output[:records] = @records.collect do |rec|
|
21
|
+
rec.to_hash
|
22
|
+
end
|
23
|
+
output
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def load_and_namespace_xml(raw_xml)
|
29
|
+
xml = Nokogiri::XML(raw_xml)
|
30
|
+
xml.root.add_namespace_definition("hol", "http://www.endinfosys.com/Voyager/holdings")
|
31
|
+
xml.root.add_namespace_definition("mfhd", "http://www.endinfosys.com/Voyager/mfhd")
|
32
|
+
xml.root.add_namespace_definition("item", "http://www.endinfosys.com/Voyager/item")
|
33
|
+
xml.root.add_namespace_definition("slim", "http://www.loc.gov/MARC21/slim")
|
34
|
+
return xml
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_xml
|
38
|
+
@records = @xml.css("hol|mfhdCollection>mfhd|mfhdRecord").collect do |record_node|
|
39
|
+
Record.new(record_node)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
module Voyager
|
2
|
+
module Holdings
|
3
|
+
class Item
|
4
|
+
attr_reader :holding_id, :item_count, :temp_locations, :item_status
|
5
|
+
|
6
|
+
def initialize(xml_node)
|
7
|
+
|
8
|
+
@holding_id = xml_node.attributes["mfhdId"].value
|
9
|
+
|
10
|
+
item = xml_node.at_css("mfhd|itemCollection")
|
11
|
+
|
12
|
+
@item_count = item.at_css("item|itemCount").content
|
13
|
+
@temp_locations = parse_for_temp_locations(item) # array
|
14
|
+
@item_status = parse_for_circ_status(item, @item_count) # hash
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def parse_for_temp_locations(item)
|
21
|
+
|
22
|
+
# select only nodes for temp location information
|
23
|
+
itemLocation = item.css("item|itemLocation").reject { |loc| loc.at_css("item|itemLocationData[@name='tmpLoc']").content.empty? }
|
24
|
+
|
25
|
+
return [] unless itemLocation.length > 0
|
26
|
+
|
27
|
+
messages = []
|
28
|
+
|
29
|
+
itemLocation.each do |loc|
|
30
|
+
label = []
|
31
|
+
['itemEnum', 'itemChron','itemYear', 'itemCaption', 'itemFreeText'].each do |type|
|
32
|
+
loc_data = loc.at_css("item|itemLocationData[@name=#{type}]")
|
33
|
+
label << loc_data.content unless loc_data.content.empty?
|
34
|
+
end
|
35
|
+
if label.empty?
|
36
|
+
messages << "Shelved in " + loc.at_css("item|itemLocationData[@name='tempLocation']").content
|
37
|
+
else
|
38
|
+
messages << label.join(" ") + " Shelved in " + loc.at_css("item|itemLocationData[@name='tempLocation']").content
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
messages
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_for_circ_status(item,item_count)
|
47
|
+
|
48
|
+
# no items = no status available
|
49
|
+
if item_count == "0"
|
50
|
+
return {:status => 'none', :messages => ['No item status available'] }
|
51
|
+
end
|
52
|
+
|
53
|
+
itemRecord = item.css("item|itemRecord")
|
54
|
+
|
55
|
+
# collect the records into an arry of hashes for ease of handling
|
56
|
+
records = itemRecord.collect do |record|
|
57
|
+
data = {}
|
58
|
+
record.css("item|itemData").collect do |rec|
|
59
|
+
data[rec.attr("name")] = rec.content
|
60
|
+
end
|
61
|
+
data
|
62
|
+
end
|
63
|
+
|
64
|
+
status = determine_status(records,item_count)
|
65
|
+
messages = generate_messages(records)
|
66
|
+
|
67
|
+
return {:status => status, :messages => messages }
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def determine_status(records,item_count)
|
72
|
+
|
73
|
+
# this may need to be refined
|
74
|
+
# statusCode = 1 in first (and only) record seems to mean nothing is checked out
|
75
|
+
status = 'available'
|
76
|
+
if records.first['statusCode'].to_i > 1
|
77
|
+
if records.length == item_count.to_i
|
78
|
+
status = 'not_available'
|
79
|
+
else
|
80
|
+
status = 'some_available'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
status
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
def generate_messages(records)
|
89
|
+
|
90
|
+
messages = []
|
91
|
+
|
92
|
+
records.each do |record|
|
93
|
+
if record['requestCount'] == '0'
|
94
|
+
messages << generate_message_no_requests(record)
|
95
|
+
else
|
96
|
+
messages << generate_message_requests(record)
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
messages
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
def generate_message_no_requests(record)
|
106
|
+
|
107
|
+
labels = []
|
108
|
+
['enumeration', 'chronology','year', 'caption', 'text'].each do |type|
|
109
|
+
labels << record[type] unless record[type].empty?
|
110
|
+
end
|
111
|
+
labels.empty? ? label = '' : label = labels.join(' ') + ' '
|
112
|
+
|
113
|
+
datetime = record['statusDate'].split(' ') # split into date/time
|
114
|
+
|
115
|
+
message = ''
|
116
|
+
|
117
|
+
# status patron message otherwise a regular message
|
118
|
+
if record['patronGroupCode'].strip.match(/^(IND|MIS|ACO)/)
|
119
|
+
|
120
|
+
message = record['lastName'].strip + ' ' + record['firstName'].strip
|
121
|
+
|
122
|
+
else
|
123
|
+
|
124
|
+
case record['statusCode']
|
125
|
+
when '1'
|
126
|
+
message = 'Not checked out'
|
127
|
+
when '2'
|
128
|
+
message = "Checked out, due #{datetime.join(' ')} - Recall, or try Borrow Direct or ILL."
|
129
|
+
when '3'
|
130
|
+
message = "Checked out, due #{datetime.join(' ')} - Recall, or try Borrow Direct or ILL."
|
131
|
+
when '4'
|
132
|
+
message = "Overdue as of #{datetime.join(' ')} - Recall, or try Borrow Direct."
|
133
|
+
when '5'
|
134
|
+
message = "Requests: #{record['requestCount']}"
|
135
|
+
when '6'
|
136
|
+
message = "Requests: #{record['requestCount']}"
|
137
|
+
when '7'
|
138
|
+
message = "On hold at #{record['holdLocation']}. Try Borrow Direct or ILL."
|
139
|
+
when '8'
|
140
|
+
message = "In transit #{datetime[0]}. Place a hold request."
|
141
|
+
when '9'
|
142
|
+
message = "In transit to #{record['holdLocation']} #{datetime[0]}. Place a hold request."
|
143
|
+
when '10'
|
144
|
+
message = "In transit to #{record['holdLocation']} #{datetime[0]}. Place a hold request."
|
145
|
+
when '11'
|
146
|
+
message = "Returned #{datetime[0]}"
|
147
|
+
when '12'
|
148
|
+
message = "Missing #{datetime[0]}. Try Borrow Direct or ILL."
|
149
|
+
when '13'
|
150
|
+
message = "Unavailable #{datetime[0]}. Try Borrow Direct or ILL."
|
151
|
+
when '14'
|
152
|
+
message = "Unavailable #{datetime[0]}. Try Borrow Direct or ILL."
|
153
|
+
when '18'
|
154
|
+
message = "Sent to bindery for 1 month on #{datetime[0]}. Try Borrow Direct or ILL."
|
155
|
+
when '21'
|
156
|
+
message = "Scheduled"
|
157
|
+
when '22'
|
158
|
+
message = "In Process #{datetime[0]}. Place an In Process item request."
|
159
|
+
when '23'
|
160
|
+
message = "Requested"
|
161
|
+
when '24'
|
162
|
+
message = "Requested"
|
163
|
+
when '25'
|
164
|
+
message = "Requested"
|
165
|
+
else
|
166
|
+
message = "Unknown"
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
# add label
|
172
|
+
message.insert(0, label) unless label.empty?
|
173
|
+
|
174
|
+
message
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
def generate_message_requests(record)
|
179
|
+
|
180
|
+
labels = []
|
181
|
+
['enumeration', 'chronology','year', 'caption', 'text'].each do |type|
|
182
|
+
labels << record[type] unless record[type].empty?
|
183
|
+
end
|
184
|
+
labels.empty? ? label = '' : label = labels.join(' ') + ' '
|
185
|
+
|
186
|
+
datetime = record['statusDate'].split(' ') # split into date/time
|
187
|
+
|
188
|
+
message = ''
|
189
|
+
|
190
|
+
# status patron message otherwise regular message
|
191
|
+
if record['patronGroupCode'].strip.match(/^(IND|MIS|ACO)/)
|
192
|
+
|
193
|
+
message = record['lastName'].strip + ' ' + record['firstName'].strip
|
194
|
+
|
195
|
+
else
|
196
|
+
|
197
|
+
case record['statusCode']
|
198
|
+
when '1'
|
199
|
+
message = "Not checked out (Requests: #{record['requestCount']})"
|
200
|
+
when '2'
|
201
|
+
message = "Checked out, due #{datetime.join(' ')} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
202
|
+
when '3'
|
203
|
+
message = "Checked out, due #{datetime.join(' ')} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
204
|
+
when '4'
|
205
|
+
message = "Overdue as of #{datetime.join(' ')} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
206
|
+
when '5'
|
207
|
+
message = "Checked out, due #{datetime.join(' ')} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
208
|
+
when '6'
|
209
|
+
message = "Checked out, due #{datetime.join(' ')} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
210
|
+
when '7'
|
211
|
+
message = "On hold at #{record['holdLocation']} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
212
|
+
when '8'
|
213
|
+
message = "In transit #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct"
|
214
|
+
when '9'
|
215
|
+
message = "In transit to #{record['holdLocation']} #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct."
|
216
|
+
when '10'
|
217
|
+
message = "In transit to #{record['holdLocation']} #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct"
|
218
|
+
when '11'
|
219
|
+
message = "Returned #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
220
|
+
when '12'
|
221
|
+
message = "Missing #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
222
|
+
when '13'
|
223
|
+
message = "Unavailable #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
224
|
+
when '14'
|
225
|
+
message = "Unavailable #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
226
|
+
when '18'
|
227
|
+
message = "Sent to bindery for 1 month on #{datetime[0]} (Requests: #{record['requestCount']}). Try Borrow Direct or ILL."
|
228
|
+
when '21'
|
229
|
+
message = "Scheduled (Requests: #{record['requestCount']})"
|
230
|
+
when '22'
|
231
|
+
message = "In Process #{datetime[0]} (Requests: #{record['requestCount']}). Place an In Process item request."
|
232
|
+
when '23'
|
233
|
+
message = "Requests: #{record['requestCount']}"
|
234
|
+
when '24'
|
235
|
+
message = "Requests: #{record['requestCount']}"
|
236
|
+
when '25'
|
237
|
+
message = "Requests: #{record['requestCount']}"
|
238
|
+
else
|
239
|
+
message = "Unknown"
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
# add label
|
245
|
+
message.insert(0, label) unless label.empty?
|
246
|
+
|
247
|
+
message
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Voyager
|
2
|
+
module Holdings
|
3
|
+
class Order
|
4
|
+
attr_reader :orders, :current_issues
|
5
|
+
|
6
|
+
def initialize(xml_node)
|
7
|
+
|
8
|
+
serialsCheckIn = xml_node.at_css("mfhd|serialsCheckIn")
|
9
|
+
@current_issues = parse_current_issues(serialsCheckIn)
|
10
|
+
|
11
|
+
poLineItems = xml_node.at_css("mfhd|poLineItems")
|
12
|
+
@orders = parse_order(poLineItems)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def parse_current_issues(serialsCheckIn)
|
19
|
+
|
20
|
+
return [] unless serialsCheckIn
|
21
|
+
|
22
|
+
current_issues = []
|
23
|
+
|
24
|
+
# cannot verify that there can be only one mfhd:recent node
|
25
|
+
serialsCheckIn.css("mfhd|recent").each do |recent|
|
26
|
+
# there can be more than one enumChron per recent node
|
27
|
+
recent.css("mfhd|enumChron").each do |enumChron|
|
28
|
+
current_issues << enumChron.content
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
current_issues
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse_order(poLineItems)
|
37
|
+
|
38
|
+
return [] unless poLineItems
|
39
|
+
|
40
|
+
poLineItems.css("mfhd|lineItemStatus").collect { |lineItemStatus| generate_order_message(lineItemStatus) }
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def generate_order_message(lineItemStatus)
|
45
|
+
|
46
|
+
status = lineItemStatus.at_css("mfhd|status").content
|
47
|
+
date = lineItemStatus.at_css("mfhd|date").content
|
48
|
+
|
49
|
+
message = ''
|
50
|
+
|
51
|
+
case status
|
52
|
+
when "0"
|
53
|
+
message = "In the Pre-Order Process. Try Borrow Direct or ILL."
|
54
|
+
when "1"
|
55
|
+
message = "Received #{date}. Place an In Process item request."
|
56
|
+
when "4"
|
57
|
+
message = "Not yet received; claimed #{date}. Try Borrow Direct or ILL."
|
58
|
+
when "8"
|
59
|
+
message = "Copy On Order #{date}. Try Borrow Direct or ILL."
|
60
|
+
else
|
61
|
+
message = "Unknown"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|