exlibris-aleph 0.1.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +89 -0
- data/Rakefile +2 -4
- data/lib/exlibris-aleph.rb +8 -21
- data/lib/exlibris/aleph.rb +13 -0
- data/lib/exlibris/aleph/abstract.rb +28 -0
- data/lib/exlibris/aleph/config.rb +78 -0
- data/lib/exlibris/aleph/patron.rb +71 -56
- data/lib/exlibris/aleph/record.rb +34 -40
- data/lib/exlibris/aleph/rest/base.rb +56 -0
- data/lib/exlibris/aleph/tab_helper.rb +84 -99
- data/lib/exlibris/aleph/{config/config_base.rb → tabs_parser/base.rb} +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/pc_tab_exp_field_extended.rb +2 -2
- data/lib/exlibris/aleph/{config/config_by_sub_library.rb → tabs_parser/sub_library.rb} +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab15_by_item_process_status.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab15_by_item_status.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab31.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab37.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab40.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab_sub_library.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab_www_item_desc.rb +2 -2
- data/lib/exlibris/aleph/task_installer.rb +23 -0
- data/lib/exlibris/aleph/version.rb +1 -1
- data/lib/exlibris/aleph/write_attributes.rb +38 -0
- data/lib/exlibris/aleph/xml_util.rb +50 -0
- data/lib/exlibris/aleph/xservice/bor_auth.rb +47 -0
- data/lib/tasks/exlibris-aleph_tasks.rake +1 -8
- data/test/{dummy/config → config}/aleph/alephe/sub_libraries.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/collections.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/item_permissions_by_item_process_status.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/item_permissions_by_item_status.yml +104 -105
- data/test/{dummy/config → config}/aleph/nyu50/items.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/patron_permissions.yml +27 -28
- data/test/{dummy/config → config}/aleph/nyu50/patrons.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/pickup_locations.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/collections.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/item_permissions_by_item_process_status.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/item_permissions_by_item_status.yml +6 -7
- data/test/{dummy/config → config}/aleph/nyu51/items.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/patron_permissions.yml +27 -28
- data/test/{dummy/config → config}/aleph/nyu51/patrons.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/pickup_locations.yml +0 -1
- data/test/config_test.rb +24 -0
- data/test/patron_test.rb +98 -0
- data/test/{unit/record_benchmarks.rb → record_benchmarks.rb} +0 -0
- data/test/record_test.rb +64 -0
- data/test/support/config.yml +2 -0
- data/test/{unit/tab_helper_benchmarks.rb → tab_helper_benchmarks.rb} +5 -20
- data/test/tab_helper_test.rb +178 -0
- data/test/test_helper.rb +26 -22
- data/test/vcr_cassettes/bor_auth.yml +8 -10
- data/test/vcr_cassettes/patron.yml +77 -18
- data/test/vcr_cassettes/patron_address.yml +45 -0
- data/test/vcr_cassettes/patron_bogus_url.yml +731 -0
- data/test/vcr_cassettes/patron_error.yml +93 -0
- data/test/vcr_cassettes/record.yml +18 -17
- data/test/vcr_cassettes/record_bogus_url.yml +690 -0
- data/test/{unit → xservice}/bor_auth_test.rb +4 -4
- metadata +160 -150
- data/README.rdoc +0 -67
- data/lib/exlibris/aleph/bor_auth.rb +0 -45
- data/lib/exlibris/aleph/railtie.rb +0 -9
- data/lib/exlibris/aleph/rest.rb +0 -43
- data/lib/exlibris/aleph/tasks.rb +0 -25
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -56
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -37
- data/test/dummy/config/initializers/aleph.rb +0 -1
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/README +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/aleph/aleph_tab_helper.log +0 -1
- data/test/dummy/log/aleph/tab_helper.log +0 -109
- data/test/dummy/log/tab_helper.log +0 -16
- data/test/dummy/log/test.log +0 -5160
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/unit/patron_test.rb +0 -41
- data/test/unit/record_test.rb +0 -32
- data/test/unit/tab_helper_test.rb +0 -222
@@ -0,0 +1,56 @@
|
|
1
|
+
module Exlibris
|
2
|
+
module Aleph
|
3
|
+
module Rest
|
4
|
+
require 'httparty'
|
5
|
+
# ==Overview
|
6
|
+
# Base implementation for Aleph REST APIs.
|
7
|
+
# Not intended for use on its own, but should
|
8
|
+
# instead be extended by implementing classes.
|
9
|
+
class Base
|
10
|
+
include HTTParty
|
11
|
+
include Abstract
|
12
|
+
include Config::Attributes
|
13
|
+
include XmlUtil
|
14
|
+
include WriteAttributes
|
15
|
+
self.format :xml
|
16
|
+
self.abstract = true
|
17
|
+
|
18
|
+
attr_writer :rest_url
|
19
|
+
attr_accessor :response
|
20
|
+
protected :response=
|
21
|
+
|
22
|
+
# Returns the error associated with the request.
|
23
|
+
# Returns nil if no error.
|
24
|
+
def error
|
25
|
+
return nil if reply_code == "0000"
|
26
|
+
return "#{reply_text}"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the reply code associate with the request.
|
30
|
+
def reply_code
|
31
|
+
return "No response." if response.nil?
|
32
|
+
return (not response.first.last.kind_of?(Hash) or response.first.last["reply_code"].nil?) ? "Unexpected response hash." : response.first.last["reply_code"] if response.instance_of?(Hash)
|
33
|
+
response_match = response.match(/\<reply-code\>(.+)\<\/reply-code\>/) if response.instance_of?(String)
|
34
|
+
return (response_match.nil?) ? "Unexpected response string." : response_match[1] if response.instance_of?(String)
|
35
|
+
return "Unexpected response type."
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the reply text associate with the request.
|
39
|
+
def reply_text
|
40
|
+
return "No response." if response.nil?
|
41
|
+
return (not response.first.last.kind_of?(Hash) or response.first.last["reply_text"].nil?) ? "Unexpected response hash." : response.first.last["reply_text"] if response.instance_of?(Hash)
|
42
|
+
response_match = response.match(/\<reply-text\>(.+)\<\/reply-text\>/) if response.instance_of?(String)
|
43
|
+
return (response_match.nil?) ? "Unexpected response string." : response_match[1] if response.instance_of?(String)
|
44
|
+
return "Unexpected response type."
|
45
|
+
end
|
46
|
+
|
47
|
+
def raise_error_if *args, &block
|
48
|
+
message = (args.shift || "Error in the Aleph REST APIs.")
|
49
|
+
block_value = (block_given?) ? yield : false
|
50
|
+
raise "#{message} #{error}" if error or block_value
|
51
|
+
end
|
52
|
+
protected :raise_error_if
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -2,98 +2,62 @@ module Exlibris
|
|
2
2
|
module Aleph
|
3
3
|
require 'singleton'
|
4
4
|
require 'yaml'
|
5
|
-
require 'rails'
|
6
5
|
# ==Overview
|
7
6
|
# Exlibris::Aleph::TabHelper assumes a mount of Aleph tab files and provides
|
8
7
|
# a way to access the various tab settings for patrons, patron_permissions,
|
9
|
-
# items, item_permission (both by item status and by item processing status),
|
8
|
+
# items, item_permission (both by item status and by item processing status),
|
10
9
|
# collections and pickup locations.
|
11
|
-
# It also provides convenience methods for common tasks like getting the
|
10
|
+
# It also provides convenience methods for common tasks like getting the
|
12
11
|
# pickup location for a given combination of item status, item process status
|
13
12
|
# and borrower status or getting an item's web text.
|
14
13
|
# To initialize Exlibris::Aleph::TabHelper call Exlibris::Aleph::TabHelper.init
|
15
14
|
# in an initializer.
|
16
15
|
class TabHelper
|
16
|
+
extend Config::Attributes
|
17
17
|
include Singleton
|
18
18
|
attr_reader :updated_at
|
19
19
|
@@alephe_tabs = {
|
20
20
|
:sub_libraries => :TabSubLibrary
|
21
21
|
}
|
22
|
-
@@adm_tabs = {
|
23
|
-
:patrons => :PcTabExpFieldExtended,
|
24
|
-
:patron_permissions => :Tab31,
|
25
|
-
:items => :TabWwwItemDesc,
|
26
|
-
:item_permissions_by_item_status => :Tab15ByItemStatus,
|
27
|
-
:item_permissions_by_item_process_status => :Tab15ByItemProcessStatus,
|
28
|
-
:collections => :Tab40,
|
22
|
+
@@adm_tabs = {
|
23
|
+
:patrons => :PcTabExpFieldExtended,
|
24
|
+
:patron_permissions => :Tab31,
|
25
|
+
:items => :TabWwwItemDesc,
|
26
|
+
:item_permissions_by_item_status => :Tab15ByItemStatus,
|
27
|
+
:item_permissions_by_item_process_status => :Tab15ByItemProcessStatus,
|
28
|
+
:collections => :Tab40,
|
29
29
|
:pickup_locations => :Tab37 }
|
30
30
|
@@tabs = @@alephe_tabs.keys + @@adm_tabs.keys
|
31
|
-
|
32
|
-
@@tab_path = nil
|
33
|
-
@@yml_path = nil
|
34
|
-
@@log_path = nil
|
35
|
-
@@irrelevant_sub_libraries = ["USR00", "HOME", "BOX", "ILLDT", "NYU51", "ALEPH", "USM50",
|
36
|
-
"MED", "HYL", "HIL", "LAM", "LAW", "LIT", "MUS", "WID", "EXL", "CIRC", "HILR", "HIL01",
|
37
|
-
"HYL01", "HYL02", "HYL03", "HYL04", "HYL05", "HYL06", "LAM01", "LAM02", "LAM03", "LAW01",
|
38
|
-
"LAW02", "LAW03", "LIT01", "LIT02", "MED01", "MED02", "MUS01", "MUS02", "WID01", "WID02",
|
39
|
-
"WID03", "WID04", "WID05", "U60WD", "U60HL", "U60LA", "U70WD", "CBAB", "BCU", "MBAZU", "USM51",
|
40
|
-
"ELEC5", "GDOC5", "EDUC5", "LINC5", "RRLIN", "OU511", "OR512", "OR513", "OR514", "OR515", "U61ED",
|
41
|
-
"U61EL", "U61LN", "S61GD", "USM53", "ELEC7", "GDOC7", "EDUC7", "LINC7", "USM54", "ELEC4", "USM55",
|
42
|
-
"CUN50", "CLEC5", "CDOC5", "CDUC5", "CINC5", "UNI50", "NARCV", "NELEC", "NRLEC", "NGDOC", "NRDOC",
|
43
|
-
"NEDUC", "NHLTH", "NLINC", "NLAW", "NMUSI", "NSCI", "NUPTN"]
|
44
|
-
|
45
|
-
# Initialize TabHelper based on path to tabs, path to store yml configs,
|
46
|
-
# path for log file, and the ADMs for the Aleph implementation
|
47
|
-
# Exlibris::Aleph::TabHelper.init("/mnt/aleph_tab", ["ADM50", "ADM51"])
|
48
|
-
def self.init(tab_path, adms, refresh_time = lambda{1.day.ago})
|
49
|
-
@@tab_path, @@refresh_time = tab_path, refresh_time
|
50
|
-
@@adms = adms.collect{|adm| adm.downcase} unless adms.nil?
|
51
|
-
# Set yml path and log path and make directories.
|
52
|
-
@@yml_path, @@log_path = File.join(Rails.root, "config/aleph"), File.join(Rails.root, "log")
|
53
|
-
Dir.mkdir(@@yml_path) unless @@yml_path.nil? or File.directory?(@@yml_path)
|
54
|
-
Dir.mkdir(File.join(@@yml_path, "alephe")) unless @@yml_path.nil? or File.directory?(File.join(@@yml_path, "alephe"))
|
55
|
-
@@adms.each { |adm|
|
56
|
-
Dir.mkdir(File.join(@@yml_path, adm)) unless @@yml_path.nil? or File.directory?(File.join(@@yml_path, adm))
|
57
|
-
} unless @@adms.nil?
|
58
|
-
Dir.mkdir(@@log_path) unless @@log_path.nil? or File.directory?(@@log_path)
|
59
|
-
# Make readers for each class variable
|
60
|
-
class_variables.each do |class_variable|
|
61
|
-
define_method "#{class_variable}".sub('@@', '') do
|
62
|
-
self.class.send(:class_variable_get, "#{class_variable}")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# Sets class variable of irrelevant sub libraries to be ignored when building sub_libraries YAML
|
68
|
-
def self.set_irrelevant_sub_libraries(irrelevant_sub_libraries, replace = true)
|
69
|
-
@@irrelevant_sub_libraries |= irrelevant_sub_libraries if replace
|
70
|
-
@@irrelevant_sub_libraries = irrelevant_sub_libraries unless replace
|
71
|
-
end
|
72
|
-
|
31
|
+
|
73
32
|
# Refreshes the yml files that are used to parse the tables.
|
74
33
|
def self.refresh_yml
|
34
|
+
mkdirs
|
75
35
|
@@alephe_tabs.each do |key, klass|
|
76
|
-
tab = Exlibris::Aleph::
|
77
|
-
File.open( File.join(
|
36
|
+
tab = Exlibris::Aleph::TabParser.const_get(klass).new(:aleph_library => "ALEPHE", :aleph_mnt_path => tab_path).to_h
|
37
|
+
File.open( File.join(yml_path, "alephe", "#{key}.yml"), 'w' ) { |out| YAML.dump( tab, out ) } unless tab.empty?
|
78
38
|
end
|
79
39
|
@@adm_tabs.each do |key, klass|
|
80
|
-
|
81
|
-
tab = Exlibris::Aleph::
|
82
|
-
File.open( File.join(
|
40
|
+
adms.each do |adm|
|
41
|
+
tab = Exlibris::Aleph::TabParser.const_get(klass).new(:aleph_library => adm, :aleph_mnt_path => tab_path).to_h
|
42
|
+
File.open( File.join(yml_path, adm, "#{key}.yml"), 'w' ) { |out| YAML.dump( tab, out ) } unless tab.empty?
|
83
43
|
end
|
84
44
|
end
|
85
45
|
end
|
86
|
-
|
46
|
+
|
47
|
+
# Make the necessary directories
|
48
|
+
def self.mkdirs
|
49
|
+
FileUtils.mkdir_p File.join(yml_path, "alephe")
|
50
|
+
adms.each do |adm|
|
51
|
+
FileUtils.mkdir_p File.join(yml_path, adm)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
87
55
|
# Private initialzize method for the singleton.
|
88
56
|
def initialize
|
89
|
-
raise ArgumentError.new("No tab path was specified.") if
|
90
|
-
raise ArgumentError.new("No yml path was specified.") if
|
91
|
-
raise ArgumentError.new("No
|
92
|
-
raise ArgumentError.new("No ADMs were specified.") if @@adms.nil? or @@adms.empty?
|
93
|
-
raise ArgumentError.new("No refresh time was specified.") if @@refresh_time.nil?
|
57
|
+
raise ArgumentError.new("No tab path was specified.") if self.class.tab_path.nil?
|
58
|
+
raise ArgumentError.new("No yml path was specified.") if self.class.yml_path.nil?
|
59
|
+
raise ArgumentError.new("No refresh time was specified.") if self.class.refresh_time.nil?
|
94
60
|
self.class.refresh_yml
|
95
|
-
@helper_log = Logger.new(File.join(@@log_path, "tab_helper.log"))
|
96
|
-
@helper_log.level = Logger::WARN
|
97
61
|
@@tabs.each { |tab|
|
98
62
|
# Default to empty hash
|
99
63
|
instance_variable_set("@#{tab}".to_sym, {})
|
@@ -111,13 +75,13 @@ module Exlibris
|
|
111
75
|
sub_library = @sub_libraries[code]
|
112
76
|
return sub_library[:text] unless sub_library.nil?
|
113
77
|
end
|
114
|
-
|
78
|
+
|
115
79
|
# Returns the ADM associated with the given sub library code
|
116
80
|
def sub_library_adm(code)
|
117
81
|
sub_library = @sub_libraries[code]
|
118
82
|
return sub_library[:library] unless sub_library.nil?
|
119
83
|
end
|
120
|
-
|
84
|
+
|
121
85
|
# Returns an array of pickup locations based on the given params.
|
122
86
|
# Available param keys are:
|
123
87
|
# :adm_library_code, :sub_library_code, :item_status_code,
|
@@ -131,16 +95,16 @@ module Exlibris
|
|
131
95
|
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
132
96
|
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
133
97
|
availability_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
134
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
98
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
135
99
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
136
100
|
return locations[:pickup_locations] unless locations.nil?
|
137
|
-
|
101
|
+
|
138
102
|
# Wild card item status
|
139
103
|
item_locations, item_procesing_locations, borrower_locations = nil, nil, nil
|
140
104
|
item_locations = sub_locations["##"] unless sub_locations.nil?
|
141
105
|
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
142
106
|
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
143
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
107
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
144
108
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
145
109
|
return locations[:pickup_locations] unless locations.nil?
|
146
110
|
|
@@ -149,7 +113,7 @@ module Exlibris
|
|
149
113
|
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
150
114
|
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
151
115
|
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
152
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
116
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
153
117
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
154
118
|
return locations[:pickup_locations] unless locations.nil?
|
155
119
|
|
@@ -158,7 +122,7 @@ module Exlibris
|
|
158
122
|
item_locations = sub_locations["##"] unless sub_locations.nil?
|
159
123
|
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
160
124
|
borrower_locations = item_procesing_locations[params[:bor_status]] unless item_procesing_locations.nil?
|
161
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
125
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
162
126
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
163
127
|
return locations[:pickup_locations] unless locations.nil?
|
164
128
|
|
@@ -167,7 +131,7 @@ module Exlibris
|
|
167
131
|
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
168
132
|
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
169
133
|
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
170
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
134
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
171
135
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
172
136
|
return locations[:pickup_locations] unless locations.nil?
|
173
137
|
|
@@ -176,7 +140,7 @@ module Exlibris
|
|
176
140
|
item_locations = sub_locations["##"] unless sub_locations.nil?
|
177
141
|
item_procesing_locations = item_locations[params[:item_process_status_code]] unless item_locations.nil?
|
178
142
|
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
179
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
143
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
180
144
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
181
145
|
return locations[:pickup_locations] unless locations.nil?
|
182
146
|
|
@@ -185,7 +149,7 @@ module Exlibris
|
|
185
149
|
item_locations = sub_locations[params[:item_status_code]] unless sub_locations.nil?
|
186
150
|
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
187
151
|
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
188
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
152
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
189
153
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
190
154
|
return locations[:pickup_locations] unless locations.nil?
|
191
155
|
|
@@ -194,16 +158,16 @@ module Exlibris
|
|
194
158
|
item_locations = sub_locations["##"] unless sub_locations.nil?
|
195
159
|
item_procesing_locations = item_locations["##"] unless item_locations.nil?
|
196
160
|
borrower_locations = item_procesing_locations["##"] unless item_procesing_locations.nil?
|
197
|
-
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
161
|
+
locations = (borrower_locations.has_key?(params[:availability_status])) ?
|
198
162
|
borrower_locations[:availability_status] : borrower_locations["#"] unless borrower_locations.nil?
|
199
163
|
return locations[:pickup_locations] unless locations.nil?
|
200
|
-
|
164
|
+
|
201
165
|
# Set the pickup location to default to the passed in sub library
|
202
|
-
|
166
|
+
logger.warn(
|
203
167
|
"Warning in #{self.class}. "+
|
204
168
|
"Pickup locations not found. "+
|
205
169
|
"Defaulting to Aleph item sub library, #{params[:sub_library_code]}.\n"+
|
206
|
-
"Additional parameters:\n"+
|
170
|
+
"Additional parameters:\n"+
|
207
171
|
"\tADM library: #{params[:adm_library_code]}\n"+
|
208
172
|
"\tSub library: #{params[:sub_library_code]}\n"+
|
209
173
|
"\tItem status: #{params[:item_status_code]}\n"+
|
@@ -213,7 +177,7 @@ module Exlibris
|
|
213
177
|
)
|
214
178
|
return [params[:sub_library_code]]
|
215
179
|
end
|
216
|
-
|
180
|
+
|
217
181
|
# Returns collection text for the given params.
|
218
182
|
# Available param keys are:
|
219
183
|
# :adm_library_code, :sub_library_code, :collection_code
|
@@ -223,7 +187,7 @@ module Exlibris
|
|
223
187
|
coll = sub[params[:collection_code]] unless sub.nil?
|
224
188
|
return coll[:text] unless coll.nil?
|
225
189
|
end
|
226
|
-
|
190
|
+
|
227
191
|
# Returns web display text for the given params.
|
228
192
|
# Available param keys are:
|
229
193
|
# :adm_library_code, :sub_library_code, :item_status_code, :item_process_status_code, :item_status, :item_process_status
|
@@ -235,32 +199,32 @@ module Exlibris
|
|
235
199
|
return item[:web_text] unless item.nil?
|
236
200
|
return permissions[:text] unless permissions.nil?
|
237
201
|
end
|
238
|
-
|
202
|
+
|
239
203
|
# Returns item permissions for the given params.
|
240
204
|
# Available param keys are:
|
241
205
|
# :adm_library_code, :sub_library_code, :item_status_code, :item_process_status_code
|
242
206
|
def item_permissions(params)
|
243
207
|
unless params[:item_process_status_code].nil?
|
244
|
-
adm_permissions =
|
208
|
+
adm_permissions =
|
245
209
|
item_permissions_by_item_process_status[params[:adm_library_code]]
|
246
|
-
sublibrary_permissions =
|
210
|
+
sublibrary_permissions =
|
247
211
|
adm_permissions[params[:sub_library_code]] unless adm_permissions.nil?
|
248
|
-
item_process_status_permissions =
|
212
|
+
item_process_status_permissions =
|
249
213
|
sublibrary_permissions[params[:item_process_status_code]] unless sublibrary_permissions.nil?
|
250
214
|
return item_process_status_permissions unless item_process_status_permissions.nil?
|
251
215
|
end
|
252
216
|
unless params[:item_status_code].nil?
|
253
217
|
adm_permissions = item_permissions_by_item_status[params[:adm_library_code]]
|
254
|
-
sublibrary_permissions =
|
218
|
+
sublibrary_permissions =
|
255
219
|
adm_permissions[params[:sub_library_code]] unless adm_permissions.nil?
|
256
|
-
item_status_permissions =
|
220
|
+
item_status_permissions =
|
257
221
|
sublibrary_permissions[params[:item_status_code]] unless sublibrary_permissions.nil?
|
258
222
|
return item_status_permissions unless item_status_permissions.nil?
|
259
223
|
end
|
260
|
-
|
224
|
+
logger.warn(
|
261
225
|
"Warning in #{self.class}. "+
|
262
226
|
"Item permissions not found. "+
|
263
|
-
"Additional parameters:\n"+
|
227
|
+
"Additional parameters:\n"+
|
264
228
|
"\tADM library: #{params[:adm_library_code]}\n"+
|
265
229
|
"\tSub library: #{params[:sub_library_code]}\n"+
|
266
230
|
"\tItem status: #{params[:item_status_code]}\n"+
|
@@ -268,31 +232,52 @@ module Exlibris
|
|
268
232
|
)
|
269
233
|
return {}
|
270
234
|
end
|
271
|
-
|
272
|
-
private
|
235
|
+
|
273
236
|
def refresh?
|
274
|
-
return (@updated_at.nil? or @updated_at <
|
275
|
-
end
|
237
|
+
return (@updated_at.nil? or @updated_at < refresh_time.call)
|
238
|
+
end
|
239
|
+
private :refresh?
|
276
240
|
|
277
241
|
def refresh
|
278
242
|
@@alephe_tabs.each_key do |key|
|
279
|
-
instance_variable_set("@#{key}".to_sym, YAML.load_file(File.join(
|
243
|
+
instance_variable_set("@#{key}".to_sym, YAML.load_file(File.join(yml_path, "alephe", "#{key}.yml")))
|
280
244
|
end
|
281
245
|
@@adm_tabs.each_key do |key|
|
282
|
-
|
246
|
+
adms.each do |adm|
|
283
247
|
tab = instance_variable_get("@#{key}".to_sym)
|
284
|
-
tab[adm] = YAML.load_file(File.join(
|
248
|
+
tab[adm] = YAML.load_file(File.join(yml_path, adm, "#{key}.yml"))
|
285
249
|
instance_variable_set("@#{key}".to_sym, tab)
|
286
250
|
end
|
287
251
|
end
|
288
252
|
# Delete irrelevant sub libraries from @sub_library
|
289
|
-
@sub_libraries.delete_if {|key,value|
|
253
|
+
@sub_libraries.delete_if {|key,value| irrelevant_sub_libraries.include? key }
|
290
254
|
@updated_at = Time.now()
|
291
255
|
end
|
256
|
+
private :refresh?
|
257
|
+
|
258
|
+
def adms
|
259
|
+
@adms ||= self.class.adms
|
260
|
+
end
|
261
|
+
|
262
|
+
def yml_path
|
263
|
+
@yml_path ||= self.class.yml_path
|
264
|
+
end
|
265
|
+
private :yml_path
|
266
|
+
|
267
|
+
def refresh_time
|
268
|
+
@refresh_time ||= self.class.refresh_time
|
269
|
+
end
|
270
|
+
private :refresh_time
|
271
|
+
|
272
|
+
def logger
|
273
|
+
@logger ||= self.class.logger
|
274
|
+
end
|
275
|
+
private :logger
|
292
276
|
|
293
|
-
def
|
294
|
-
|
277
|
+
def irrelevant_sub_libraries
|
278
|
+
@irrelevant_sub_libraries ||= self.class.irrelevant_sub_libraries
|
295
279
|
end
|
280
|
+
private :irrelevant_sub_libraries
|
296
281
|
end
|
297
282
|
end
|
298
283
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Exlibris
|
2
2
|
module Aleph
|
3
|
-
module
|
4
|
-
class PcTabExpFieldExtended < Exlibris::Aleph::
|
3
|
+
module TabParser
|
4
|
+
class PcTabExpFieldExtended < Exlibris::Aleph::TabParser::Base
|
5
5
|
|
6
6
|
def initialize(args)
|
7
7
|
args[:aleph_file_name] = "pc_tab_exp_field_extended.eng"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Exlibris
|
2
2
|
module Aleph
|
3
|
-
module
|
4
|
-
class Tab15ByItemProcessStatus < Exlibris::Aleph::
|
3
|
+
module TabParser
|
4
|
+
class Tab15ByItemProcessStatus < Exlibris::Aleph::TabParser::SubLibrary
|
5
5
|
|
6
6
|
def initialize(args)
|
7
7
|
args[:aleph_file_name] = "tab15.eng"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Exlibris
|
2
2
|
module Aleph
|
3
|
-
module
|
4
|
-
class Tab15ByItemStatus < Exlibris::Aleph::
|
3
|
+
module TabParser
|
4
|
+
class Tab15ByItemStatus < Exlibris::Aleph::TabParser::SubLibrary
|
5
5
|
|
6
6
|
def initialize(args)
|
7
7
|
args[:aleph_file_name] = "tab15.eng"
|