umlaut-primo 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +90 -2
- data/lib/umlaut-primo.rb +1 -0
- data/lib/umlaut_primo/primo_service.rb +67 -79
- data/lib/umlaut_primo/primo_source.rb +31 -1
- data/lib/umlaut_primo/railtie.rb +8 -0
- data/lib/umlaut_primo/version.rb +1 -1
- data/test/dummy/config/application.rb +0 -1
- data/test/dummy/config/umlaut_services.yml +0 -3
- data/test/dummy/log/test.log +418 -19243
- data/test/test_helper.rb +0 -2
- metadata +8 -9
- data/lib/umlaut_primo.rb +0 -2
- data/test/dummy/log/development.log +0 -4
data/README.md
CHANGED
@@ -5,6 +5,94 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/team-umlaut/umlaut-primo.png)](https://codeclimate.com/github/team-umlaut/umlaut-primo)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/team-umlaut/umlaut-primo/badge.png?branch=master)](https://coveralls.io/r/team-umlaut/umlaut-primo)
|
7
7
|
|
8
|
-
Umlaut
|
8
|
+
Umlaut services to provide full text service responses, holdings, etc. from the Primo discovery solution.
|
9
9
|
|
10
|
-
##
|
10
|
+
## Installation
|
11
|
+
In order to use the Umlaut Primo service, first
|
12
|
+
[install Umlaut](https://github.com/team-umlaut/umlaut/wiki/Installation).
|
13
|
+
Then, in your Gemfile, add in the umlaut-primo gem, `gem 'umlaut-primo', '~> 0.1.0'`.
|
14
|
+
Run `bundle intall` to get the Gem and then start your application as you normally would.
|
15
|
+
|
16
|
+
## Service Configuration
|
17
|
+
To use the Umlaut Primo services, they must be configured in `config/umlaut_service.yml`.
|
18
|
+
Two services are available for use, PrimoService and PrimoSource.
|
19
|
+
|
20
|
+
### PrimoService
|
21
|
+
The `PrimoService` is the basic Primo service for getting service data from Primo.
|
22
|
+
|
23
|
+
Several configurations parameters are available to be set in config/umlaut_services.yml.
|
24
|
+
A sample configuration is below.
|
25
|
+
|
26
|
+
Primo: # Name of your choice
|
27
|
+
type: PrimoService # Required
|
28
|
+
priority: 2 # Required. I suggest running after the SFX service so you get the SFX referent enhancements
|
29
|
+
base_url: http://primo.library.edu # Required
|
30
|
+
vid: VID # Required
|
31
|
+
institution: INST # Required
|
32
|
+
holding_search_institution: SEARCH_INST # Optional. Defaults to the institution above.
|
33
|
+
holding_search_text: Search for this title in Primo. # Optional text for holding search. Defaults to "Search for this title."
|
34
|
+
suppress_holdings: [ !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ] # Optional
|
35
|
+
ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.edu\/login\?url=/' # Optional
|
36
|
+
service_types: # Optional. Defaults to [ "fulltext", "holding", "holding_search", "table_of_contents", "referent_enhance" ]
|
37
|
+
- holding
|
38
|
+
- holding_search
|
39
|
+
- fulltext
|
40
|
+
- table_of_contents
|
41
|
+
- referent_enhance
|
42
|
+
- highlighted_link
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
### PrimoSource
|
47
|
+
The `PrimoSource` service depends on `PrimoService` and is used to expand Primo holdings based on information
|
48
|
+
from the data source.
|
49
|
+
|
50
|
+
Fi8rst, PrimoService must be configured with the `primo_source` service type instead of `holding`.
|
51
|
+
|
52
|
+
Primo: # Name of your choice
|
53
|
+
...
|
54
|
+
service_types:
|
55
|
+
- primo_source
|
56
|
+
- holding_search
|
57
|
+
...
|
58
|
+
|
59
|
+
Then you can configure the PrimoSource service in config/umlaut_services.yml
|
60
|
+
|
61
|
+
PrimoSource: # Name of your choice
|
62
|
+
type: PrimoSource # Required
|
63
|
+
priority: 3 # Required. Must be run after PrimoService
|
64
|
+
base_url: http://primo.library.edu # Required
|
65
|
+
vid: VID # Required
|
66
|
+
institution: INST # Required
|
67
|
+
source_attributes: # Optional.
|
68
|
+
- request_link_supports_ajax_call
|
69
|
+
- requestability
|
70
|
+
|
71
|
+
## Primo Configuration
|
72
|
+
Primo offers several configuration options, specified in the Primo Back Office.
|
73
|
+
Since Umlaut doesn't have access to the Primo back office, the configurations need to be set in a separate file.
|
74
|
+
Umlaut Primo leverages the [exlibris-primo](https://github.com/scotdalton/exlibris-primo) gem which can set this configuration
|
75
|
+
via a YAML file. Umlaut Primo expects this YAML file to be in `config/primo.yml`, but you can tell the PrimoService where the
|
76
|
+
YAML file is with the `primo_config` parameter.
|
77
|
+
|
78
|
+
A sample YAML config file would look like this:
|
79
|
+
|
80
|
+
institutions:
|
81
|
+
"primo_institution_code": "Primo Institution String"
|
82
|
+
libraries:
|
83
|
+
"primo_library_code": "Primo Library String"
|
84
|
+
availability_statuses:
|
85
|
+
"status1_code": "Status One"
|
86
|
+
sources:
|
87
|
+
data_source1:
|
88
|
+
base_url: "http://source1.base.url
|
89
|
+
type: source_type
|
90
|
+
class_name: Source1Implementation (in exlibris/primo/sources or exlibris/primo/sources/local)
|
91
|
+
source1_config_option1: source1_config_option1
|
92
|
+
source1_config_option2: source1_config_option2
|
93
|
+
data_source2:
|
94
|
+
base_url: "http://source2.base.url
|
95
|
+
type: source_type
|
96
|
+
class_name: Source2Implementation (in exlibris/primo/sources or exlibris/primo/sources/local)
|
97
|
+
source2_config_option1: source2_config_option1
|
98
|
+
source2_config_option2: source2_config_option2
|
data/lib/umlaut-primo.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'umlaut_primo/railtie'
|
@@ -1,10 +1,6 @@
|
|
1
1
|
# == Overview
|
2
|
-
# PrimoService is
|
3
|
-
|
4
|
-
# NOT YET:
|
5
|
-
# It first looks for rft.primo *DEPRECATED*, failing that, it parses the identifier for an id.
|
6
|
-
#++
|
7
|
-
# It first looks for rft.primo, the Primo id.
|
2
|
+
# PrimoService is an Umlaut Service that makes a call to the Primo web services based on the requested context object.
|
3
|
+
# It first looks for rft.primo *DEPRECATED*, failing that, it parses the request referrer identifier for an id.
|
8
4
|
# If the Primo id is present, the service gets the PNX record from the Primo web
|
9
5
|
# services.
|
10
6
|
# If no Primo id is found, the service searches Primo by (in order of precedence):
|
@@ -13,102 +9,100 @@
|
|
13
9
|
# * Title, Author, Genre
|
14
10
|
#
|
15
11
|
# == Available Services
|
16
|
-
# Several service types are available in the
|
12
|
+
# Several service types are available in the PrimoService. The default service types are:
|
17
13
|
# fulltext, holding, holding_search, table_of_contents, referent_enhance, cover_image
|
18
14
|
# Available service types are listed below and can be configured using the service_types parameter
|
19
|
-
# in
|
15
|
+
# in config/umlaut_services.yml:
|
20
16
|
# * fulltext - parsed from links/linktorsrc elements in the PNX record
|
21
17
|
# * holding - parsed from display/availlibrary elements in the PNX record
|
22
18
|
# * holding_search - link to an exact title search in Primo if no holdings found AND the OpenURL did not come from Primo
|
23
19
|
# * primo_source - similar to holdings but used in conjuction with the PrimoSource service to map Primo records to their original sources; a PrimoSource service must be defined in service.yml for this to work
|
24
20
|
# * table_of_contents - parsed from links/linktotoc elements in the PNX record
|
25
21
|
# * referent_enhance - metadata parsed from the addata section of the PNX record when the record was found by Primo id
|
26
|
-
# * cover_image - parsed from first addata/lad02 element in the PNX record
|
27
22
|
# * highlighted_link - parsed from links/addlink elements in the PNX record
|
28
23
|
#
|
29
24
|
# ==Available Parameters
|
30
|
-
# Several configurations parameters are available to be set in
|
31
|
-
# Primo:
|
32
|
-
# type: PrimoService
|
33
|
-
# priority: 2 #
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# holding_search_institution:
|
38
|
-
# holding_search_text: Search for this title in
|
39
|
-
# suppress_holdings: [ !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
|
40
|
-
# ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.
|
41
|
-
# service_types:
|
25
|
+
# Several configurations parameters are available to be set in config/umlaut_services.yml.
|
26
|
+
# Primo: # Name of your choice
|
27
|
+
# type: PrimoService # Required
|
28
|
+
# priority: 2 # Required. I suggest running after the SFX service so you get the SFX referent enhancements
|
29
|
+
# base_url: http://primo.library.edu # Required
|
30
|
+
# vid: VID # Required
|
31
|
+
# institution: INST # Required
|
32
|
+
# holding_search_institution: SEARCH_INST # Optional. Defaults to the institution above.
|
33
|
+
# holding_search_text: Search for this title in Primo. # Optional text for holding search. Defaults to "Search for this title."
|
34
|
+
# suppress_holdings: [ !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ] # Optional
|
35
|
+
# ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.edu\/login\?url=/' # Optional
|
36
|
+
# service_types: # Optional. Defaults to [ "fulltext", "holding", "holding_search", "table_of_contents", "referent_enhance" ]
|
42
37
|
# - holding
|
43
38
|
# - holding_search
|
44
39
|
# - fulltext
|
45
40
|
# - table_of_contents
|
46
41
|
# - referent_enhance
|
47
|
-
# - cover_image
|
48
42
|
# - highlighted_link
|
43
|
+
#
|
49
44
|
# base_url:: _required_ host and port of Primo server; used for Primo web services, deep links and holding_search
|
50
45
|
# base_path:: *DEPRECATED* previous name of base_url
|
51
46
|
# vid:: _required_ view id for Primo deep links and holding_search.
|
52
47
|
# institution:: _required_ institution id for Primo institution; used for Primo web services
|
53
48
|
# base_view_id:: *DEPRECATED* previous name of vid
|
54
|
-
# holding_search_institution::
|
49
|
+
# holding_search_institution:: if service types include holding_search_ and the holding search institution is different from
|
50
|
+
# institution to be used for the holding_search
|
55
51
|
# holding_search_text:: _optional_ text to display for the holding_search
|
56
|
-
#
|
52
|
+
# default holding search text:: "Search for this title."
|
57
53
|
# link_to_search_text:: *DEPRECATED* previous name of holding_search_text
|
58
54
|
# service_types:: _optional_ array of strings that represent the service types desired.
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
55
|
+
# options are: fulltext, holding, holding_search, table_of_contents,
|
56
|
+
# referent_enhance, cover_image, primo_source
|
57
|
+
# defaults are: fulltext, holding, holding_search, table_of_contents,
|
58
|
+
# referent_enhance, cover_image
|
59
|
+
# if no options are specified, default service types will be added.
|
64
60
|
# suppress_urls:: _optional_ array of strings or regexps to NOT use from the catalog.
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
61
|
+
# Used for linktorsrc elements that may duplicate resources from in other services.
|
62
|
+
# Regexps can be put in the services.yml like this:
|
63
|
+
# [!ruby/regexp '/sagepub.com$/']
|
68
64
|
# suppress_holdings:: _optional_ array of strings or regexps to NOT use from the catalog.
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
65
|
+
# Used for availlibrary elements that may duplicate resources from in other services.
|
66
|
+
# Regexps can be put in the services.yml like this:
|
67
|
+
# [!ruby/regexp '/\$\$LWEB$/']
|
72
68
|
# suppress_tocs:: _optional_ array of strings or regexps to NOT link to for Tables of Contents.
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
69
|
+
# Used for linktotoc elements that may duplicate resources from in other services.
|
70
|
+
# Regexps can be put in the services.yml like this:
|
71
|
+
# [!ruby/regexp '/\$\$LWEB$/']
|
76
72
|
# service_types:: _optional_ array of strings that represent the service types desired.
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
73
|
+
# options are: fulltext, holding, holding_search, table_of_contents,
|
74
|
+
# referent_enhance, cover_image, primo_source
|
75
|
+
# defaults are: fulltext, holding, holding_search, table_of_contents,
|
76
|
+
# referent_enhance
|
77
|
+
# if no options are specified, default service types will be added.
|
82
78
|
# ez_proxy:: _optional_ string or regexp of an ezproxy prefix.
|
83
79
|
# used in the case where an ezproxy prefix (on any other regexp) is hardcoded in the URL,
|
84
80
|
# and needs to be removed in order to match against SFXUrls.
|
85
81
|
# Example:
|
86
82
|
# !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
|
87
83
|
# primo_config:: _optional_ string representing the primo yaml config file in config/
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
# holding/primo_source service_data; can be used to save
|
111
|
-
# custom source implementation attributes for display by a custom holding partial
|
84
|
+
# default file name: primo.yml
|
85
|
+
# hash mappings from yaml config
|
86
|
+
# institutions:
|
87
|
+
# "primo_institution_code": "Primo Institution String"
|
88
|
+
# libraries:
|
89
|
+
# "primo_library_code": "Primo Library String"
|
90
|
+
# availability_statuses:
|
91
|
+
# "status1_code": "Status One"
|
92
|
+
# sources:
|
93
|
+
# data_source1:
|
94
|
+
# base_url: "http://source1.base.url
|
95
|
+
# type: source_type
|
96
|
+
# class_name: Source1Implementation (in exlibris/primo/sources or exlibris/primo/sources/local)
|
97
|
+
# source1_config_option1: source1_config_option1
|
98
|
+
# source1_config_option2: source1_config_option2
|
99
|
+
# data_source2:
|
100
|
+
# base_url: "http://source2.base.url
|
101
|
+
# type: source_type
|
102
|
+
# class_name: Source2Implementation (in exlibris/primo/sources or exlibris/primo/sources/local)
|
103
|
+
# source2_config_option1: source2_config_option1
|
104
|
+
# source2_config_option2: source2_config_option2
|
105
|
+
#
|
112
106
|
require 'exlibris-primo'
|
113
107
|
class PrimoService < Service
|
114
108
|
|
@@ -122,6 +116,7 @@ class PrimoService < Service
|
|
122
116
|
|
123
117
|
# Overwrites Service#new.
|
124
118
|
def initialize(config)
|
119
|
+
@holding_search_text = "Search for this title."
|
125
120
|
# Configure Primo
|
126
121
|
configure_primo
|
127
122
|
# Attributes for holding service data.
|
@@ -153,18 +148,11 @@ class PrimoService < Service
|
|
153
148
|
@suppress_related_links = []
|
154
149
|
@suppress_holdings = []
|
155
150
|
@service_types = [ "fulltext", "holding", "holding_search",
|
156
|
-
"table_of_contents", "referent_enhance"
|
151
|
+
"table_of_contents", "referent_enhance" ] if @service_types.nil?
|
157
152
|
backward_compatibility(config)
|
158
153
|
super(config)
|
159
|
-
#
|
160
|
-
|
161
|
-
if @service_types.include?("holding_search") and @holding_search_institution.nil?
|
162
|
-
@holding_search_institution = @institution
|
163
|
-
Rails.logger.warn("Required parameter 'holding_search_institution' was not set. Please set the appropriate value in umlaut_services.yml. Defaulting institution to view id, #{@vid}.")
|
164
|
-
end # End backward compatibility maintenance
|
165
|
-
raise ArgumentError.new(
|
166
|
-
"Missing Service configuration parameter. Service type #{self.class} (id: #{self.id}) requires a config parameter named 'holding_search_institution'. Check your config/umlaut_services.yml file."
|
167
|
-
) if @service_types.include?("holding_search") and @holding_search_institution.nil?
|
154
|
+
# Handle the case where holding_search_institution is the same as institution.
|
155
|
+
@holding_search_institution = @institution if @service_types.include?("holding_search") and @holding_search_institution.nil?
|
168
156
|
end
|
169
157
|
|
170
158
|
# Overwrites Service#service_types_generated.
|
@@ -368,7 +356,7 @@ class PrimoService < Service
|
|
368
356
|
def add_holding_search_service(request)
|
369
357
|
service_data = {}
|
370
358
|
service_data[:type] = "link_to_search"
|
371
|
-
service_data[:display_text] =
|
359
|
+
service_data[:display_text] = @holding_search_text
|
372
360
|
service_data[:note] = ""
|
373
361
|
service_data[:url] = deep_link_search_url
|
374
362
|
request.add_service_response(
|
@@ -466,7 +454,7 @@ class PrimoService < Service
|
|
466
454
|
|
467
455
|
def config_file
|
468
456
|
config_file = @primo_config.nil? ? default_config_file : "#{Rails.root}/config/"+ @primo_config
|
469
|
-
Rails.logger.
|
457
|
+
Rails.logger.info("Primo config file not found: #{config_file}.") and return "" unless File.exists?(config_file)
|
470
458
|
config_file
|
471
459
|
end
|
472
460
|
private :config_file
|
@@ -4,7 +4,37 @@
|
|
4
4
|
# based on the given Primo sources and can be implemented per source.
|
5
5
|
#
|
6
6
|
# PrimoSources are not necessary to use the Primo service andthey require programming.
|
7
|
-
#
|
7
|
+
# They do, however, allow further customization and functionality.
|
8
|
+
#
|
9
|
+
# == Prerequisites
|
10
|
+
# First, the PrimoService must be configured with the primo_source service type instead of holding.
|
11
|
+
#
|
12
|
+
# Primo: # Name of your choice
|
13
|
+
# type: PrimoService
|
14
|
+
# ...
|
15
|
+
# service_types:
|
16
|
+
# - primo_source
|
17
|
+
# - holding_search
|
18
|
+
# ...
|
19
|
+
#
|
20
|
+
# ==Available Parameters
|
21
|
+
# Several configurations parameters are available to be set in config/umlaut_services.yml.
|
22
|
+
# PrimoSource: # Name of your choice
|
23
|
+
# type: PrimoSource # Required
|
24
|
+
# priority: 3 # Required. Must be run after PrimoService
|
25
|
+
# base_url: http://primo.library.edu # Required
|
26
|
+
# vid: VID # Required
|
27
|
+
# institution: INST # Required
|
28
|
+
# source_attributes: # Optional.
|
29
|
+
# - request_link_supports_ajax_call
|
30
|
+
# - requestability
|
31
|
+
#
|
32
|
+
# base_url:: _required_ host and port of Primo server for Primo display deep link
|
33
|
+
# vid:: _required_ view id for Primo display deep link
|
34
|
+
# institution:: _required_ institution id for Primo display deep link
|
35
|
+
# source_attributes:: _optional_ Array of Holding attribute readers to persist to
|
36
|
+
# holding service_data; can be used to save custom source implementation attributes
|
37
|
+
# for display by a custom holding partial
|
8
38
|
#
|
9
39
|
class PrimoSource < PrimoService
|
10
40
|
|
data/lib/umlaut_primo/version.rb
CHANGED