blacklight_oai_provider 4.1.0 → 5.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -0
- data/.rubocop_todo.yml +14 -35
- data/README.md +63 -31
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight_oai_provider/oai2.xsl +19 -15
- data/app/models/concerns/blacklight_oai_provider/solr_document.rb +4 -0
- data/blacklight_oai_provider.gemspec +2 -2
- data/lib/blacklight_oai_provider.rb +3 -0
- data/lib/blacklight_oai_provider/response/list_sets.rb +34 -0
- data/lib/blacklight_oai_provider/routes.rb +3 -3
- data/lib/blacklight_oai_provider/set.rb +49 -0
- data/lib/blacklight_oai_provider/solr_document_provider.rb +4 -0
- data/lib/blacklight_oai_provider/solr_document_wrapper.rb +14 -7
- data/lib/blacklight_oai_provider/solr_set.rb +85 -0
- data/spec/controllers/catalog_controller_spec.rb +9 -5
- data/spec/features/html_rendering_spec.rb +11 -1
- data/spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb +59 -0
- data/spec/lib/blacklight_oai_provider/solr_set_spec.rb +100 -0
- data/spec/requests/get_record_spec.rb +9 -2
- data/spec/requests/identify_spec.rb +1 -1
- data/spec/requests/list_metadata_formats_spec.rb +1 -1
- data/spec/requests/list_records_spec.rb +11 -0
- data/spec/requests/list_sets_spec.rb +101 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +19 -9
- metadata +16 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac8e80d262005aef4f462074caf7bd88a504ecc
|
4
|
+
data.tar.gz: 863efffd6ba4c5804eec41824fb6419b23c197be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5edc6116f617c802dca3fd55f9d400621531aeb98fc2123c31a12d3ee3508ef0f34444e02c4c9f063180fcd2f3d4d3b1a1d1776aefed1fbfdd825090023e6a6f
|
7
|
+
data.tar.gz: f6a2457b1876bc34c3fb92a283add8284fb67d64be3776c27903062bbeac1b77346bdabf031e9df14f0e1e2f6024a5b4fe955fc8ea34b992e85de5d50d52d9c4
|
data/.rubocop.yml
CHANGED
@@ -37,3 +37,15 @@ Bundler/DuplicatedGem:
|
|
37
37
|
Bundler/OrderedGems:
|
38
38
|
Exclude:
|
39
39
|
- 'Gemfile'
|
40
|
+
|
41
|
+
RSpec/DescribeClass:
|
42
|
+
Exclude:
|
43
|
+
- 'spec/requests/**'
|
44
|
+
- 'spec/features/**'
|
45
|
+
|
46
|
+
Style/Documentation:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Lint/UnusedMethodArgument:
|
50
|
+
Exclude:
|
51
|
+
- 'lib/blacklight_oai_provider/set.rb'
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2017-
|
3
|
+
# on 2017-11-09 12:27:39 -0500 using RuboCop version 0.50.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -14,14 +14,14 @@ Layout/EmptyLinesAroundBlockBody:
|
|
14
14
|
Exclude:
|
15
15
|
- 'spec/requests/list_metadata_formats_spec.rb'
|
16
16
|
|
17
|
-
# Offense count:
|
17
|
+
# Offense count: 6
|
18
18
|
Metrics/AbcSize:
|
19
|
-
Max:
|
19
|
+
Max: 28
|
20
20
|
|
21
|
-
# Offense count:
|
21
|
+
# Offense count: 3
|
22
22
|
# Configuration parameters: CountComments.
|
23
23
|
Metrics/MethodLength:
|
24
|
-
Max:
|
24
|
+
Max: 47
|
25
25
|
|
26
26
|
# Offense count: 2
|
27
27
|
RSpec/BeforeAfterAll:
|
@@ -31,16 +31,6 @@ RSpec/BeforeAfterAll:
|
|
31
31
|
- 'spec/support/**/*.rb'
|
32
32
|
- 'spec/requests/list_identifiers_spec.rb'
|
33
33
|
|
34
|
-
# Offense count: 6
|
35
|
-
RSpec/DescribeClass:
|
36
|
-
Exclude:
|
37
|
-
- 'spec/features/html_rendering_spec.rb'
|
38
|
-
- 'spec/requests/get_record_spec.rb'
|
39
|
-
- 'spec/requests/identify_spec.rb'
|
40
|
-
- 'spec/requests/list_identifiers_spec.rb'
|
41
|
-
- 'spec/requests/list_metadata_formats_spec.rb'
|
42
|
-
- 'spec/requests/list_records_spec.rb'
|
43
|
-
|
44
34
|
# Offense count: 1
|
45
35
|
# Configuration parameters: CustomIncludeMethods.
|
46
36
|
RSpec/EmptyExampleGroup:
|
@@ -53,7 +43,13 @@ RSpec/ExampleLength:
|
|
53
43
|
Exclude:
|
54
44
|
- 'spec/controllers/catalog_controller_spec.rb'
|
55
45
|
|
56
|
-
# Offense count:
|
46
|
+
# Offense count: 1
|
47
|
+
# Configuration parameters: AssignmentOnly.
|
48
|
+
RSpec/InstanceVariable:
|
49
|
+
Exclude:
|
50
|
+
- 'spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb'
|
51
|
+
|
52
|
+
# Offense count: 9
|
57
53
|
RSpec/MultipleExpectations:
|
58
54
|
Max: 2
|
59
55
|
|
@@ -84,24 +80,7 @@ Style/BracesAroundHashParameters:
|
|
84
80
|
- 'lib/blacklight_oai_provider/solr_document_wrapper.rb'
|
85
81
|
- 'spec/models/solr_document_spec.rb'
|
86
82
|
|
87
|
-
# Offense count:
|
88
|
-
Style/Documentation:
|
89
|
-
Exclude:
|
90
|
-
- 'spec/**/*'
|
91
|
-
- 'test/**/*'
|
92
|
-
- 'app/controllers/concerns/blacklight_oai_provider/controller.rb'
|
93
|
-
- 'app/models/concerns/blacklight_oai_provider/solr_document.rb'
|
94
|
-
- 'lib/blacklight_oai_provider.rb'
|
95
|
-
- 'lib/blacklight_oai_provider/engine.rb'
|
96
|
-
- 'lib/blacklight_oai_provider/exceptions.rb'
|
97
|
-
- 'lib/blacklight_oai_provider/resumption_token.rb'
|
98
|
-
- 'lib/blacklight_oai_provider/routes.rb'
|
99
|
-
- 'lib/blacklight_oai_provider/solr_document_provider.rb'
|
100
|
-
- 'lib/blacklight_oai_provider/solr_document_wrapper.rb'
|
101
|
-
- 'lib/blacklight_oai_provider/version.rb'
|
102
|
-
- 'lib/generators/blacklight_oai_provider/install_generator.rb'
|
103
|
-
|
104
|
-
# Offense count: 24
|
83
|
+
# Offense count: 31
|
105
84
|
# Cop supports --auto-correct.
|
106
85
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
107
86
|
# SupportedStyles: when_needed, always, never
|
@@ -114,7 +93,7 @@ Style/GuardClause:
|
|
114
93
|
Exclude:
|
115
94
|
- 'lib/generators/blacklight_oai_provider/install_generator.rb'
|
116
95
|
|
117
|
-
# Offense count:
|
96
|
+
# Offense count: 2
|
118
97
|
# Cop supports --auto-correct.
|
119
98
|
# Configuration parameters: MinSize, SupportedStyles.
|
120
99
|
# SupportedStyles: percent, brackets
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ A few maintenance branches have been left in place in case there is interest to
|
|
16
16
|
## Requirements
|
17
17
|
A Rails app running Rails 4.x and Blacklight 4.x.
|
18
18
|
|
19
|
-
OAI-PMH requires a timestamp field for all records. The Solr index should include an appropriate field. This field should be able to support date range queries. By default, the name of this field is `timestamp` (more on how to configure this below).
|
19
|
+
OAI-PMH requires a timestamp field for all records. The Solr index should include an appropriate field. This field should be able to support date range queries. By default, the name of this field is `timestamp` (more on how to configure this [below](#solrdocument-configuration)).
|
20
20
|
|
21
21
|
A properly configured documentHandler in the blacklight/solr configuration.
|
22
22
|
|
@@ -25,24 +25,24 @@ A properly configured documentHandler in the blacklight/solr configuration.
|
|
25
25
|
Add
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem 'blacklight_oai_provider'
|
28
|
+
gem 'blacklight_oai_provider'
|
29
29
|
```
|
30
30
|
|
31
31
|
to your Gemfile and run `bundle install`.
|
32
32
|
|
33
33
|
Then run
|
34
34
|
```ruby
|
35
|
-
|
35
|
+
rails generate blacklight_oai_provider:install
|
36
36
|
```
|
37
37
|
to install the appropriate extensions into your `CatalogController` and `SolrDocument` classes. If you want to do customize the way this installs, instead you may:
|
38
38
|
|
39
39
|
- add this to your Solr Document model:
|
40
40
|
```ruby
|
41
|
-
|
41
|
+
include BlacklightOaiProvider::SolrDocument
|
42
42
|
```
|
43
43
|
- add this to your Controller:
|
44
44
|
```ruby
|
45
|
-
|
45
|
+
include BlacklightOaiProvider::Controller
|
46
46
|
```
|
47
47
|
|
48
48
|
## Configuration
|
@@ -53,36 +53,41 @@ While the plugin provides some sensible (albeit generic) defaults out of the box
|
|
53
53
|
You can provide OAI-PMH provider parameters by placing the following in your blacklight configuration (most likely in `app/controllers/catalog_controller.rb`)
|
54
54
|
|
55
55
|
```ruby
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
56
|
+
configure_blacklight do |config|
|
57
|
+
|
58
|
+
# ...
|
59
|
+
|
60
|
+
config.oai = {
|
61
|
+
provider: {
|
62
|
+
repository_name: 'Test',
|
63
|
+
repository_url: 'http://localhost/catalog/oai',
|
64
|
+
record_prefix: 'oai:test',
|
65
|
+
admin_email: 'root@localhost',
|
66
|
+
sample_id: '109660'
|
67
|
+
},
|
68
|
+
document: {
|
69
|
+
model: SolrDocument, # SolrDocument class being used, default: SolrDocument
|
70
|
+
limit: 25 # number of records returned with each request, default: 15
|
71
|
+
set_fields: [ # ability to define ListSets, optional, default: nil
|
72
|
+
{ label: 'language', solr_field: 'language_facet' }
|
73
|
+
]
|
71
74
|
}
|
75
|
+
}
|
72
76
|
|
73
|
-
|
74
|
-
|
75
|
-
end
|
77
|
+
# ...
|
78
|
+
end
|
76
79
|
```
|
77
80
|
|
78
81
|
The "provider" configuration is documented as part of the ruby-oai gem at http://oai.rubyforge.org/
|
79
82
|
|
83
|
+
A basic set model is included that maps Solr fields to OAI sets. Provide `set_fields` with an array of hashes defining the solr_field, and optionally a label and description. The configuration above will cause the `ListSets` verb to query Solr for unique values of the `language_facet` field and present each value as a set using a spec format of `language:value`. When the `set` parameter is supplied to the `ListRecords` verb, it will append a filter to the Solr query of the form `fq=language_facet:value`. If no label is provided, the set will use the `solr_field` name. To customize the ListSet implementation, see [customizing listsets](#customizing-listsets).
|
84
|
+
|
80
85
|
_Note:_ The document handler in your blacklight controller must be configured properly for this plugin to correctly look up records.
|
81
86
|
|
82
87
|
### SolrDocument configuration
|
83
88
|
To change the name of the timestamp solr field in your `SolrDocument` model change the following attribute:
|
84
89
|
```ruby
|
85
|
-
|
90
|
+
self.timestamp_key = 'record_creation_date' # Default: 'timestamp'
|
86
91
|
```
|
87
92
|
|
88
93
|
The metadata displayed in the xml serialization of each record is based off the `field_semantics` hash in the `SolrDocument` model. To update/change these fields add something like the following to your model:
|
@@ -97,12 +102,39 @@ The metadata displayed in the xml serialization of each record is based off the
|
|
97
102
|
format: "format"
|
98
103
|
)
|
99
104
|
```
|
100
|
-
|
101
105
|
The fields used by the dublin core serialization are:
|
102
106
|
```ruby
|
103
|
-
|
107
|
+
[:contributor, :coverage, :creator, :date, :description, :format, :identifier, :language, :publisher, :relation, :rights, :source, :subject, :title, :type]
|
108
|
+
```
|
109
|
+
|
110
|
+
### Customizing ListSets
|
111
|
+
In order to customize the default ListSets implementation, first create your own `Sets` class that subclasses `BlacklightOaiProvider::Set` or `BlacklightOaiProvider::SolrSet` and implement all required methods. Ex:
|
112
|
+
```ruby
|
113
|
+
class NewListSet < BlacklightOaiProvider::SolrSet
|
114
|
+
def description
|
115
|
+
"This is a #{label} set containing records with the value of #{value}."
|
116
|
+
end
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
Next, your `SolrDocument` model must override, `sets`, an instance method that returns an array of sets for each document. Ex:
|
121
|
+
```ruby
|
122
|
+
def sets
|
123
|
+
NewListSet.sets_for(self)
|
124
|
+
end
|
104
125
|
```
|
105
126
|
|
127
|
+
Finally, you can substitute you own Set model using the `set_model` option.
|
128
|
+
```ruby
|
129
|
+
config.oai = {
|
130
|
+
document: {
|
131
|
+
set_model: NewListSet,
|
132
|
+
set_fields: [
|
133
|
+
{ label: 'language', solr_field: 'language_facet' }
|
134
|
+
]
|
135
|
+
}
|
136
|
+
}
|
137
|
+
```
|
106
138
|
## Injection
|
107
139
|
This plugin assumes it is in a Blacklight Rails app, uses Blacklight methods, Rails methods, and standard ruby module includes to inject it's behaviors into the app.
|
108
140
|
|
@@ -110,22 +142,22 @@ You can turn off this injection if you like, although it will make the plugin le
|
|
110
142
|
|
111
143
|
In any initializer, you can set:
|
112
144
|
```ruby
|
113
|
-
|
145
|
+
BlacklightOaiProvider.omit_inject = true
|
114
146
|
```
|
115
147
|
to turn off all injection. The plugin will be completely non-functional if you do this, of course. But perhaps you could try to re-use some of it's classes in a non-Blacklight, highly hacked Blacklight, or even non-Rails application this way.
|
116
148
|
|
117
149
|
You can also turn off injection of individual components, which could be more useful:
|
118
150
|
```ruby
|
119
|
-
|
120
|
-
|
121
|
-
|
151
|
+
BlacklightOaiProvider.omit_inject = {
|
152
|
+
routes: false,
|
153
|
+
}
|
122
154
|
```
|
123
155
|
## Tests
|
124
156
|
We use `engine_cart` and `solr_wrapper` to run tests on a dummy instance of an app using this plugin.
|
125
157
|
|
126
158
|
To run the entire test suite:
|
127
159
|
```ruby
|
128
|
-
|
160
|
+
rake ci
|
129
161
|
```
|
130
162
|
|
131
163
|
You can test OAI-PMH conformance against http://www.openarchives.org/data/registerasprovider.html#Protocol_Conformance_Testing or browse the data at http://re.cs.uct.ac.za/
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
5.0.0.pre1
|
@@ -8,8 +8,8 @@
|
|
8
8
|
|
9
9
|
-->
|
10
10
|
|
11
|
-
<!--
|
12
|
-
|
11
|
+
<!--
|
12
|
+
|
13
13
|
Copyright (c) 2000-2004 University of Southampton, UK. SO17 1BJ.
|
14
14
|
|
15
15
|
EPrints 2 is free software; you can redistribute it and/or modify
|
@@ -28,9 +28,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
28
28
|
|
29
29
|
-->
|
30
30
|
|
31
|
-
|
31
|
+
|
32
32
|
<!--
|
33
|
-
|
33
|
+
|
34
34
|
All the elements really needed for EPrints are done but if
|
35
35
|
you want to use this XSL for other OAI archive you may want
|
36
36
|
to make some minor changes or additions.
|
@@ -46,7 +46,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
46
46
|
-->
|
47
47
|
<xsl:stylesheet
|
48
48
|
version="1.0"
|
49
|
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
49
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
50
50
|
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
|
51
51
|
>
|
52
52
|
|
@@ -72,7 +72,7 @@ td.key {
|
|
72
72
|
.dcdata td.key {
|
73
73
|
background-color: #ffffe0;
|
74
74
|
}
|
75
|
-
body {
|
75
|
+
body {
|
76
76
|
margin: 1em 2em 1em 2em;
|
77
77
|
}
|
78
78
|
h1, h2, h3 {
|
@@ -150,7 +150,8 @@ p.intro {
|
|
150
150
|
<xsl:call-template name='xmlstyle' />
|
151
151
|
</xsl:template>
|
152
152
|
|
153
|
-
<xsl:variable name=
|
153
|
+
<xsl:variable name="identifier" select="/oai:OAI-PMH/oai:request/@identifier" />
|
154
|
+
<xsl:variable name="verb" select="/oai:OAI-PMH/oai:request/@verb" />
|
154
155
|
|
155
156
|
<xsl:template match="/">
|
156
157
|
<html>
|
@@ -165,15 +166,15 @@ p.intro {
|
|
165
166
|
<xsl:apply-templates select="/oai:OAI-PMH" />
|
166
167
|
<xsl:call-template name="quicklinks"/>
|
167
168
|
<h2><a name="moreinfo">About the XSLT</a></h2>
|
168
|
-
<p>An XSLT file has converted the <a href="http://www.openarchives.org">OAI-PMH 2.0</a> responses into XHTML which looks nice in a browser which supports XSLT such as
|
169
|
-
|
169
|
+
<p>An XSLT file has converted the <a href="http://www.openarchives.org">OAI-PMH 2.0</a> responses into XHTML which looks nice in a browser which supports XSLT such as Firefox, Chrome, Safari, and Internet Explorer. The XSLT file was created by <a href="http://www.ecs.soton.ac.uk/people/cjg">Christopher Gutteridge</a> at the University of Southampton as part of the <a href="http://www.eprints.org/uk/index.php/eprints-software/">GNU EPrints system</a>, and is freely redistributable under the <a href="http://www.gnu.org">GPL</a>.</p>
|
170
|
+
<p>For more information or to download the XSL file please see the <a href="http://wiki.eprints.org/w/EPrints_OAI_Stylesheet">OAI to XHTML XSLT homepage</a>.</p>
|
170
171
|
</body>
|
171
172
|
</html>
|
172
173
|
</xsl:template>
|
173
174
|
|
174
175
|
<xsl:template name="quicklinks">
|
175
176
|
<ul class="quicklinks">
|
176
|
-
<li><a href="?verb=Identify">Identify</a> | </li>
|
177
|
+
<li><a href="?verb=Identify">Identify</a> | </li>
|
177
178
|
<li><a href="?verb=ListRecords&metadataPrefix=oai_dc">ListRecords</a> | </li>
|
178
179
|
<li><a href="?verb=ListSets">ListSets</a> | </li>
|
179
180
|
<li><a href="?verb=ListMetadataFormats">ListMetadataFormats</a> | </li>
|
@@ -199,7 +200,7 @@ p.intro {
|
|
199
200
|
</div>
|
200
201
|
</xsl:when>
|
201
202
|
<xsl:otherwise>
|
202
|
-
<p>Request was of type <xsl:value-of select="
|
203
|
+
<p>Request was of type <xsl:value-of select="$verb"/>.</p>
|
203
204
|
<div class="results">
|
204
205
|
<xsl:apply-templates select="oai:Identify" />
|
205
206
|
<xsl:apply-templates select="oai:GetRecord"/>
|
@@ -332,7 +333,7 @@ p.intro {
|
|
332
333
|
</xsl:template>
|
333
334
|
|
334
335
|
<xsl:template match="fr:baseURL" xmlns:fr="http://www.openarchives.org/OAI/2.0/friends/">
|
335
|
-
<li><xsl:value-of select="."/>
|
336
|
+
<li><xsl:value-of select="."/>
|
336
337
|
<xsl:text> </xsl:text>
|
337
338
|
<a class="link" href="{.}?verb=Identify">Identify</a></li>
|
338
339
|
</xsl:template>
|
@@ -433,9 +434,13 @@ p.intro {
|
|
433
434
|
<xsl:template match="oai:set">
|
434
435
|
<h2>Set</h2>
|
435
436
|
<table class="values">
|
437
|
+
<xsl:apply-templates select="oai:setSpec" />
|
436
438
|
<tr><td class="key">setName</td>
|
437
439
|
<td class="value"><xsl:value-of select="oai:setName"/></td></tr>
|
438
|
-
<xsl:
|
440
|
+
<xsl:if test="oai:setDescription">
|
441
|
+
<tr><td class="key">setDescription</td>
|
442
|
+
<td class="value"><xsl:value-of select="oai:setDescription"/></td></tr>
|
443
|
+
</xsl:if>
|
439
444
|
</table>
|
440
445
|
</xsl:template>
|
441
446
|
|
@@ -535,7 +540,7 @@ p.intro {
|
|
535
540
|
<tr><td class="key">resumptionToken:</td>
|
536
541
|
<td class="value"><xsl:value-of select="."/>
|
537
542
|
<xsl:text> </xsl:text>
|
538
|
-
<a class="link" href="?verb={
|
543
|
+
<a class="link" href="?verb={$verb}&resumptionToken={.}">Resume</a></td></tr>
|
539
544
|
</table>
|
540
545
|
</xsl:when>
|
541
546
|
<xsl:otherwise>
|
@@ -663,4 +668,3 @@ p.intro {
|
|
663
668
|
</xsl:template>
|
664
669
|
|
665
670
|
</xsl:stylesheet>
|
666
|
-
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.summary = "Blacklight Oai Provider plugin"
|
11
11
|
|
12
12
|
s.post_install_message = %q{
|
13
|
-
BlacklightOaiProvider
|
13
|
+
BlacklightOaiProvider v5.x implements configuration changes. Please visit README for more information.
|
14
14
|
|
15
15
|
}
|
16
16
|
|
@@ -22,7 +22,7 @@ BlacklightOaiProvider v4.1 implements configuration changes. Please visit README
|
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
24
|
s.add_dependency "rails", "~> 4.0"
|
25
|
-
s.add_dependency "blacklight", "~>
|
25
|
+
s.add_dependency "blacklight", "~> 5.0"
|
26
26
|
s.add_dependency "oai"
|
27
27
|
s.add_development_dependency 'rspec-rails', "~> 3.0"
|
28
28
|
s.add_development_dependency 'capybara'
|
@@ -4,6 +4,9 @@ module BlacklightOaiProvider
|
|
4
4
|
autoload :SolrDocumentWrapper, 'blacklight_oai_provider/solr_document_wrapper'
|
5
5
|
autoload :ResumptionToken, 'blacklight_oai_provider/resumption_token'
|
6
6
|
autoload :Routes, 'blacklight_oai_provider/routes'
|
7
|
+
autoload :Set, 'blacklight_oai_provider/set'
|
8
|
+
autoload :Response, 'blacklight_oai_provider/response/list_sets'
|
9
|
+
autoload :SolrSet, 'blacklight_oai_provider/solr_set'
|
7
10
|
|
8
11
|
require 'oai'
|
9
12
|
require 'blacklight_oai_provider/version'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module BlacklightOaiProvider
|
2
|
+
module Response
|
3
|
+
class ListSets < OAI::Provider::Response::Base
|
4
|
+
def to_xml
|
5
|
+
raise OAI::SetException unless provider.model.sets
|
6
|
+
|
7
|
+
response do |r|
|
8
|
+
r.ListSets do
|
9
|
+
provider.model.sets.each do |set|
|
10
|
+
r.set do
|
11
|
+
r.setSpec set.spec
|
12
|
+
r.setName set.name
|
13
|
+
|
14
|
+
if set.respond_to?(:description) && set.description
|
15
|
+
r.setDescription do
|
16
|
+
r.tag!("#{oai_dc.prefix}:#{oai_dc.element_namespace}", oai_dc.header_specification) do
|
17
|
+
r.dc :description, set.description
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def oai_dc
|
30
|
+
OAI::Provider::Metadata::DublinCore.instance
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -3,12 +3,12 @@ module BlacklightOaiProvider
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do |klass|
|
6
|
-
klass.default_route_sets.insert(klass.default_route_sets.index(:
|
6
|
+
klass.default_route_sets.insert(klass.default_route_sets.index(:export), :oai_routing)
|
7
7
|
end
|
8
8
|
|
9
|
-
def oai_routing
|
9
|
+
def oai_routing(primary_resource)
|
10
10
|
add_routes do
|
11
|
-
get "
|
11
|
+
get "#{primary_resource}/oai", to: "#{primary_resource}#oai", as: 'oai_provider'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module BlacklightOaiProvider
|
2
|
+
class Set
|
3
|
+
class << self
|
4
|
+
# The controller, used to construct solr queries
|
5
|
+
attr_accessor :controller
|
6
|
+
|
7
|
+
# Solr field configuration for each set
|
8
|
+
# Fields must be indexed
|
9
|
+
attr_accessor :fields
|
10
|
+
|
11
|
+
# Return an array of all SetSpecs, or nil if sets are not supported.
|
12
|
+
# Objects returned must be of a class that inherits from
|
13
|
+
# BlacklightOaiProvider::SetSpecs.
|
14
|
+
def all
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return a Solr filter query given a set spec. Spec will be a string in
|
19
|
+
# label:value format.
|
20
|
+
def from_spec(spec)
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns array of sets for a record, or empty array if none are available.
|
25
|
+
# Objects returned must be of a class that inherits from
|
26
|
+
# BlacklightOaiProvider::SetSpecs.
|
27
|
+
def sets_for(record)
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# OAI Set properties
|
33
|
+
attr_accessor :label, :value, :description
|
34
|
+
|
35
|
+
# Build a set object with, at minimum, a set spec string
|
36
|
+
def initialize(spec)
|
37
|
+
@label, @value = spec.split(':', 2)
|
38
|
+
raise OAI::ArgumentException if [@label, @value].any?(&:blank?)
|
39
|
+
end
|
40
|
+
|
41
|
+
def name
|
42
|
+
raise NotImplementedError
|
43
|
+
end
|
44
|
+
|
45
|
+
def spec
|
46
|
+
raise NotImplementedError
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -8,9 +8,15 @@ module BlacklightOaiProvider
|
|
8
8
|
@solr_timestamp = document_model.timestamp_key
|
9
9
|
@timestamp_field = 'timestamp' # method name used by ruby-oai
|
10
10
|
@limit = options[:limit] || 15
|
11
|
+
@set = options[:set_model] || BlacklightOaiProvider::SolrSet
|
12
|
+
|
13
|
+
@set.controller = @controller
|
14
|
+
@set.fields = options[:set_fields]
|
11
15
|
end
|
12
16
|
|
13
|
-
def sets
|
17
|
+
def sets
|
18
|
+
@set.all
|
19
|
+
end
|
14
20
|
|
15
21
|
def earliest
|
16
22
|
_response, records = @controller.get_search_results(@controller.params, { fl: solr_timestamp, sort: "#{solr_timestamp} asc", rows: 1 })
|
@@ -63,13 +69,14 @@ module BlacklightOaiProvider
|
|
63
69
|
end
|
64
70
|
|
65
71
|
def conditions(options) # conditions/query derived from options
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
)
|
70
|
-
else
|
71
|
-
base_conditions
|
72
|
+
filters = []
|
73
|
+
if options[:from].present? || options[:until].present?
|
74
|
+
filters << "#{solr_timestamp}:[#{solr_date(options[:from])} TO #{solr_date(options[:until]).gsub('Z', '.999Z')}]"
|
72
75
|
end
|
76
|
+
|
77
|
+
filters << @set.from_spec(options[:set]) if options[:set].present?
|
78
|
+
|
79
|
+
base_conditions.merge(fq: filters)
|
73
80
|
end
|
74
81
|
|
75
82
|
def solr_date(time)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module BlacklightOaiProvider
|
2
|
+
class SolrSet < BlacklightOaiProvider::Set
|
3
|
+
class << self
|
4
|
+
# Return an array of all sets, or nil if sets are not supported
|
5
|
+
def all
|
6
|
+
return if @fields.nil?
|
7
|
+
|
8
|
+
params = { rows: 0, facet: true, 'facet.field' => solr_fields }
|
9
|
+
solr_fields.each { |field| params["f.#{field}.facet.limit"] = -1 } # override any potential blacklight limits
|
10
|
+
response, _records = @controller.get_search_results(@controller.params, params)
|
11
|
+
sets_from_facets(response.facet_fields) if response.facet_fields
|
12
|
+
end
|
13
|
+
|
14
|
+
# Return a Solr filter query given a set spec
|
15
|
+
def from_spec(spec)
|
16
|
+
new(spec).solr_filter
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns array of sets for a solr document, or empty array if none are available.
|
20
|
+
def sets_for(record)
|
21
|
+
Array.wrap(@fields).map do |field|
|
22
|
+
values = record.get(field[:solr_field], sep: nil)
|
23
|
+
Array.wrap(values).map do |value|
|
24
|
+
new("#{field[:label]}:#{value}")
|
25
|
+
end
|
26
|
+
end.flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
def fields=(value) # The Solr fields to map to OAI sets. Must be indexed
|
30
|
+
if value.respond_to?(:each)
|
31
|
+
value.each do |config|
|
32
|
+
raise ArgumentException, 'OAI sets must define a solr_field' if config[:solr_field].blank?
|
33
|
+
config[:label] ||= config[:solr_field]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
super(value)
|
38
|
+
end
|
39
|
+
|
40
|
+
def field_config_for(label)
|
41
|
+
Array.wrap(@fields).find { |f| f[:label] == label } || {}
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def solr_fields
|
47
|
+
@fields.map { |f| f[:solr_field] }
|
48
|
+
end
|
49
|
+
|
50
|
+
def sets_from_facets(facet_results)
|
51
|
+
sets = Array.wrap(@fields).map do |f|
|
52
|
+
facet_results.fetch(f[:solr_field], [])
|
53
|
+
.each_slice(2)
|
54
|
+
.map { |t| new("#{f[:label]}:#{t.first}") }
|
55
|
+
end.flatten
|
56
|
+
|
57
|
+
sets.empty? ? nil : sets
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# OAI Set properties
|
62
|
+
attr_accessor :solr_field
|
63
|
+
|
64
|
+
# Build a set object with, at minimum, a set spec string
|
65
|
+
def initialize(spec)
|
66
|
+
super(spec)
|
67
|
+
config = self.class.field_config_for(label)
|
68
|
+
@solr_field = config[:solr_field]
|
69
|
+
@description = config[:description]
|
70
|
+
raise OAI::ArgumentException if @solr_field.blank?
|
71
|
+
end
|
72
|
+
|
73
|
+
def name
|
74
|
+
spec.titleize.gsub(':', ': ')
|
75
|
+
end
|
76
|
+
|
77
|
+
def spec
|
78
|
+
"#{@label}:#{@value}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def solr_filter
|
82
|
+
"#{@solr_field}:\"#{@value}\""
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -16,19 +16,23 @@ describe CatalogController do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#oai_config' do
|
19
|
-
it 'returns correct configuration' do
|
20
|
-
expect(controller.oai_config).to
|
19
|
+
it 'returns correct provider configuration' do
|
20
|
+
expect(controller.oai_config).to include(
|
21
21
|
provider: {
|
22
22
|
repository_name: "Test Repository",
|
23
|
-
repository_url: "http://localhost",
|
23
|
+
repository_url: "http://localhost/catalog/oai",
|
24
24
|
record_prefix: "oai:test",
|
25
25
|
admin_email: "root@localhost",
|
26
26
|
deletion_support: "persistent",
|
27
27
|
sample_id: "109660"
|
28
|
-
}
|
29
|
-
document: { model: SolrDocument, limit: 25 }
|
28
|
+
}
|
30
29
|
)
|
31
30
|
end
|
31
|
+
|
32
|
+
it 'return corrext document configuration' do
|
33
|
+
expect(controller.oai_config[:document][:limit]).to be 25
|
34
|
+
expect(controller.oai_config[:document][:model]).to be_a Class
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
describe '#oai_provider' do
|
@@ -18,7 +18,17 @@ describe 'HTML page rendering', js: true do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "document page" do
|
21
|
-
visit '/catalog/oai?verb=GetRecord&identifier=00282214&metadataPrefix=oai_dc'
|
21
|
+
visit '/catalog/oai?verb=GetRecord&identifier=oai:test:00282214&metadataPrefix=oai_dc'
|
22
22
|
expect(page).to have_xpath('//td[text()="Title"]/parent::*/td[@class="value"]', text: 'Fikr-i Ayāz')
|
23
23
|
end
|
24
|
+
|
25
|
+
it "lists verb on page" do
|
26
|
+
visit '/catalog/oai?verb=Identify'
|
27
|
+
expect(page).to have_content('Request was of type Identify.')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "lists metadata formats for record" do
|
31
|
+
visit '/catalog/oai?verb=ListMetadataFormats&identifier=oai:test:00282214'
|
32
|
+
expect(page).to have_content('This is a list of metadata formats available for the record "oai:test:00282214"')
|
33
|
+
end
|
24
34
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe BlacklightOaiProvider::SolrDocumentWrapper do
|
4
|
+
subject(:wrapper) { described_class.new(controller, options) }
|
5
|
+
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:controller) { CatalogController.new }
|
8
|
+
|
9
|
+
before do
|
10
|
+
allow(controller).to receive(:params).and_return({})
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
context 'with a set class provided' do
|
15
|
+
before do
|
16
|
+
stub_const 'CustomSet', Class.new(BlacklightOaiProvider::Set)
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:options) { { set_model: CustomSet, set_fields: [{ solr_field: 'language_facet' }] } }
|
20
|
+
|
21
|
+
it 'uses the Set class' do
|
22
|
+
expect(wrapper.instance_eval { @set }).to be CustomSet
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#sets' do
|
28
|
+
it 'returns nil to indicate sets are not supported' do
|
29
|
+
expect(wrapper.sets).to be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#earliest' do
|
34
|
+
it 'returns the earliest timestamp of all the records' do
|
35
|
+
expect(wrapper.earliest).to eq Time.parse('2014-02-03 18:42:53.056000000 +0000').utc
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#latest' do
|
40
|
+
it 'returns the latest timestamp of all the records' do
|
41
|
+
expect(wrapper.latest).to eq Time.parse('2014-03-03 18:42:53.056000000 +0000').utc
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#find' do
|
46
|
+
context 'when selector is :all' do
|
47
|
+
it 'returns a limited list of all records' do
|
48
|
+
expect(wrapper.find(:all)).to be_a OAI::Provider::PartialResult
|
49
|
+
expect(wrapper.find(:all).records.size).to be 15
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when selector is an individual record' do
|
54
|
+
it 'returns a single record' do
|
55
|
+
expect(wrapper.find('2005553155')).to be_a SolrDocument
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe BlacklightOaiProvider::SolrSet do
|
4
|
+
let(:controller) { CatalogController.new }
|
5
|
+
let(:fields) do
|
6
|
+
[{ label: 'language', solr_field: 'language_facet' }]
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
described_class.controller = controller
|
11
|
+
described_class.fields = fields
|
12
|
+
allow(controller).to receive(:params).and_return({})
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.all' do
|
16
|
+
subject(:all_sets) { described_class.all }
|
17
|
+
|
18
|
+
it 'returns a Set object representing each set' do
|
19
|
+
expect(all_sets.count).to be 12
|
20
|
+
expect(all_sets.first).to be_a described_class
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with multiple fields' do
|
24
|
+
let(:fields) do
|
25
|
+
[
|
26
|
+
{ label: 'language', solr_field: 'language_facet' },
|
27
|
+
{ solr_field: 'format' }
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns Sets for values in each field' do
|
32
|
+
expect(all_sets.count).to be 13
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'for a field with no values' do
|
37
|
+
let(:fields) do
|
38
|
+
[{ label: 'author', solr_field: 'author_display' }]
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns nil' do
|
42
|
+
expect(all_sets).to be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'for a field with facet config limit' do
|
47
|
+
let(:fields) do
|
48
|
+
[{ label: 'lc_alpha', solr_field: 'lc_alpha_facet' }]
|
49
|
+
end
|
50
|
+
|
51
|
+
before do
|
52
|
+
CatalogController.configure_blacklight do |config|
|
53
|
+
config.add_facet_field 'lc_alpha_facet', label: 'lc_alpha', limit: 2
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns all sets' do
|
58
|
+
expect(all_sets.count).to be 14
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '.from_spec' do
|
64
|
+
context 'with a valid spec' do
|
65
|
+
let(:spec) { 'language:Hebrew' }
|
66
|
+
|
67
|
+
it 'returns the filter query' do
|
68
|
+
expect(described_class.from_spec(spec)).to eq 'language_facet:"Hebrew"'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'with an invalid field' do
|
73
|
+
let(:spec) { 'foo:Hebrew' }
|
74
|
+
|
75
|
+
it 'raises an argument exception' do
|
76
|
+
expect { described_class.from_spec(spec) }.to raise_error(::OAI::ArgumentException)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'with an invalid spec' do
|
81
|
+
let(:spec) { 'invalid' }
|
82
|
+
|
83
|
+
it 'raises an argument exception' do
|
84
|
+
expect { described_class.from_spec(spec) }.to raise_error(::OAI::ArgumentException)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#initialize' do
|
90
|
+
let(:set) { described_class.new('language:Hebrew') }
|
91
|
+
|
92
|
+
it 'creates a friendly set name if none is provided' do
|
93
|
+
expect(set.name).to eq 'Language: Hebrew'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'gets solr field' do
|
97
|
+
expect(set.solr_field).to eql 'language_facet'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -11,14 +11,21 @@ describe 'OIA-PMH GetRecord Request' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
14
|
-
get '/catalog/oai?verb=GetRecord&identifier=2007020969&metadataPrefix=oai_dc'
|
14
|
+
get '/catalog/oai?verb=GetRecord&identifier=oai:test:2007020969&metadataPrefix=oai_dc'
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'contains
|
17
|
+
it 'contains identifier' do
|
18
18
|
expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:identifier').text).to eql 'oai:test:2007020969'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'contains datestamp' do
|
19
22
|
expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:datestamp').text).to eql '2014-02-03T18:42:53Z'
|
20
23
|
end
|
21
24
|
|
25
|
+
it 'contains sets' do
|
26
|
+
expect(xml.at_xpath('//xmlns:GetRecord/xmlns:record/xmlns:header/xmlns:setSpec').text).to eql 'language:English'
|
27
|
+
end
|
28
|
+
|
22
29
|
it 'contains creator' do
|
23
30
|
expect(xml.at_xpath('//xmlns:metadata/oai_dc:dc/dc:creator', namespaces).text).to eql 'Hearth, Amy Hill, 1958-'
|
24
31
|
end
|
@@ -16,7 +16,7 @@ describe 'OIA-PMH Identify Request' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "contains base url" do
|
19
|
-
expect(xml.at_xpath('//xmlns:baseURL').text).to eql 'http://localhost'
|
19
|
+
expect(xml.at_xpath('//xmlns:baseURL').text).to eql 'http://localhost/catalog/oai'
|
20
20
|
end
|
21
21
|
|
22
22
|
it "contains protocol version" do
|
@@ -24,7 +24,7 @@ describe 'OIA-PMH ListMetadataFormats Request' do
|
|
24
24
|
|
25
25
|
context 'with identifier parameter' do
|
26
26
|
before do
|
27
|
-
get '/catalog/oai?verb=ListMetadataFormats&identifier=2007020969'
|
27
|
+
get '/catalog/oai?verb=ListMetadataFormats&identifier=oai:test:2007020969'
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'contains oai_dc schema' do
|
@@ -95,6 +95,17 @@ describe 'OIA-PMH ListRecords Request' do
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
context 'for all documents within a set' do
|
99
|
+
let(:document_config) { { set_fields: 'language_facet' } }
|
100
|
+
|
101
|
+
it 'only records from the set are returned' do
|
102
|
+
params = { verb: 'ListRecords', metadataPrefix: 'oai_dc', set: 'language:Japanese' }
|
103
|
+
|
104
|
+
get oai_provider_path(params)
|
105
|
+
expect(xml.xpath('//xmlns:record').count).to be 2
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
98
109
|
context 'throws noRecordsMatch error' do
|
99
110
|
before do
|
100
111
|
get '/catalog/oai?verb=ListRecords&metadataPrefix=oai_dc&from=2015-01-01'
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe 'OAI-PMH ListSets Request' do
|
4
|
+
let(:xml) { Nokogiri::XML(response.body) }
|
5
|
+
let(:namespaces) do
|
6
|
+
{
|
7
|
+
dc: 'http://purl.org/dc/elements/1.1/',
|
8
|
+
xmlns: 'http://www.openarchives.org/OAI/2.0/',
|
9
|
+
oai_dc: 'http://www.openarchives.org/OAI/2.0/oai_dc/'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
let(:test_oai_config) { {} }
|
13
|
+
let(:old_config) { CatalogController.new.oai_config }
|
14
|
+
|
15
|
+
before do
|
16
|
+
old_config
|
17
|
+
CatalogController.configure_blacklight do |config|
|
18
|
+
config.oai = test_oai_config
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
CatalogController.configure_blacklight do |config|
|
24
|
+
config.oai = old_config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'without set configuration' do
|
29
|
+
it 'shows that no sets exist' do
|
30
|
+
get oai_provider_path(verb: 'ListSets')
|
31
|
+
expect(xml.xpath('//xmlns:error').text).to eql 'This repository does not support sets.'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with set configuration' do
|
36
|
+
let(:test_oai_config) { old_config }
|
37
|
+
|
38
|
+
it 'shows all sets' do
|
39
|
+
get oai_provider_path(verb: 'ListSets')
|
40
|
+
expect(xml.xpath('//xmlns:set').count).to be 12
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'contains english set' do
|
44
|
+
get oai_provider_path(verb: 'ListSets')
|
45
|
+
expect(xml.xpath('//xmlns:set//xmlns:setSpec').map(&:text)).to include 'language:English'
|
46
|
+
expect(xml.xpath('//xmlns:set//xmlns:setName').map(&:text)).to include 'Language: English'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'shows the correct verb' do
|
50
|
+
get oai_provider_path(verb: 'ListSets')
|
51
|
+
expect(xml.at_xpath('//xmlns:request').attribute('verb').value).to eql 'ListSets'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when set configuration contains description' do
|
56
|
+
let(:test_oai_config) do
|
57
|
+
{
|
58
|
+
document: {
|
59
|
+
set_fields: [
|
60
|
+
{ label: 'subject', solr_field: 'subject_topic_facet',
|
61
|
+
description: "Subject topic set using FAST subjects" }
|
62
|
+
]
|
63
|
+
}
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'shows set description' do
|
68
|
+
get oai_provider_path(verb: 'ListSets')
|
69
|
+
expect(
|
70
|
+
xml.at_xpath('//xmlns:set/xmlns:setDescription/oai_dc:dc/dc:description', namespaces).text
|
71
|
+
).to eql 'Subject topic set using FAST subjects'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when custom set model is provided' do
|
76
|
+
let(:test_oai_config) do
|
77
|
+
stub_const 'ChangeDescriptionSet', custom_set_model
|
78
|
+
|
79
|
+
{
|
80
|
+
document: {
|
81
|
+
set_model: ChangeDescriptionSet,
|
82
|
+
set_fields: [{ solr_field: 'format' }]
|
83
|
+
}
|
84
|
+
}
|
85
|
+
end
|
86
|
+
let(:custom_set_model) do
|
87
|
+
Class.new(BlacklightOaiProvider::SolrSet) do
|
88
|
+
def description
|
89
|
+
"This is a #{label} set containing records with the value of #{value}."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it "shows correct description" do
|
95
|
+
get oai_provider_path(verb: 'ListSets')
|
96
|
+
expect(
|
97
|
+
xml.at_xpath('//xmlns:set/xmlns:setDescription/oai_dc:dc/dc:description', namespaces).text
|
98
|
+
).to eql 'This is a format set containing records with the value of Book.'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -10,7 +10,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
10
10
|
def run_blacklight_generator
|
11
11
|
say_status("warning", "GENERATING BL", :yellow)
|
12
12
|
|
13
|
-
generate 'blacklight', '--devise'
|
13
|
+
generate 'blacklight:install', '--devise'
|
14
14
|
end
|
15
15
|
|
16
16
|
# Add favicon.ico to asset path
|
@@ -26,10 +26,12 @@ class TestAppGenerator < Rails::Generators::Base
|
|
26
26
|
|
27
27
|
# Override solr.yml to match settings needed for solr_wrapper.
|
28
28
|
def update_solr_config
|
29
|
-
|
29
|
+
[:solr, :blacklight].each do |key|
|
30
|
+
say_status("warning", "COPYING #{key}.YML".upcase, :yellow)
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
remove_file "config/#{key}.yml"
|
33
|
+
copy_file "config/solr.yml", "config/#{key}.yml"
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def install_engine
|
@@ -61,7 +63,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
61
63
|
config.oai = {
|
62
64
|
:provider => {
|
63
65
|
:repository_name => 'Test Repository',
|
64
|
-
:repository_url => 'http://localhost',
|
66
|
+
:repository_url => 'http://localhost/catalog/oai',
|
65
67
|
:record_prefix => 'oai:test',
|
66
68
|
:admin_email => 'root@localhost',
|
67
69
|
:deletion_support => 'persistent',
|
@@ -69,17 +71,25 @@ class TestAppGenerator < Rails::Generators::Base
|
|
69
71
|
},
|
70
72
|
:document => {
|
71
73
|
:model => SolrDocument,
|
74
|
+
:set_fields => [
|
75
|
+
{ label: 'language', solr_field: 'language_facet' }
|
76
|
+
],
|
72
77
|
:limit => 25
|
73
78
|
}
|
74
79
|
}
|
75
80
|
CONFIG
|
76
81
|
end
|
77
82
|
|
78
|
-
insert_into_file "app/models/solr_document.rb", after: "
|
83
|
+
insert_into_file "app/models/solr_document.rb", after: "include BlacklightOaiProvider::SolrDocument\n" do
|
79
84
|
<<-CONFIG
|
80
|
-
|
81
|
-
:
|
82
|
-
:
|
85
|
+
field_semantics.merge!(
|
86
|
+
title: "title_display",
|
87
|
+
creator: "author_display",
|
88
|
+
date: "pub_date",
|
89
|
+
subject: "subject_topic_facet",
|
90
|
+
format: "format",
|
91
|
+
language: "language_facet"
|
92
|
+
)
|
83
93
|
CONFIG
|
84
94
|
end
|
85
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_oai_provider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-12-
|
12
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '5.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '5.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: oai
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,10 +205,13 @@ files:
|
|
205
205
|
- lib/blacklight_oai_provider.rb
|
206
206
|
- lib/blacklight_oai_provider/engine.rb
|
207
207
|
- lib/blacklight_oai_provider/exceptions.rb
|
208
|
+
- lib/blacklight_oai_provider/response/list_sets.rb
|
208
209
|
- lib/blacklight_oai_provider/resumption_token.rb
|
209
210
|
- lib/blacklight_oai_provider/routes.rb
|
211
|
+
- lib/blacklight_oai_provider/set.rb
|
210
212
|
- lib/blacklight_oai_provider/solr_document_provider.rb
|
211
213
|
- lib/blacklight_oai_provider/solr_document_wrapper.rb
|
214
|
+
- lib/blacklight_oai_provider/solr_set.rb
|
212
215
|
- lib/blacklight_oai_provider/version.rb
|
213
216
|
- lib/generators/blacklight_oai_provider/install_generator.rb
|
214
217
|
- lib/railties/blacklight_oai_provider.rake
|
@@ -231,12 +234,15 @@ files:
|
|
231
234
|
- solr/sample_solr_documents.yml
|
232
235
|
- spec/controllers/catalog_controller_spec.rb
|
233
236
|
- spec/features/html_rendering_spec.rb
|
237
|
+
- spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
|
238
|
+
- spec/lib/blacklight_oai_provider/solr_set_spec.rb
|
234
239
|
- spec/models/solr_document_spec.rb
|
235
240
|
- spec/requests/get_record_spec.rb
|
236
241
|
- spec/requests/identify_spec.rb
|
237
242
|
- spec/requests/list_identifiers_spec.rb
|
238
243
|
- spec/requests/list_metadata_formats_spec.rb
|
239
244
|
- spec/requests/list_records_spec.rb
|
245
|
+
- spec/requests/list_sets_spec.rb
|
240
246
|
- spec/spec_helper.rb
|
241
247
|
- spec/test_app_templates/config/solr.yml
|
242
248
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
@@ -245,7 +251,7 @@ licenses: []
|
|
245
251
|
metadata: {}
|
246
252
|
post_install_message: |2+
|
247
253
|
|
248
|
-
BlacklightOaiProvider
|
254
|
+
BlacklightOaiProvider v5.x implements configuration changes. Please visit README for more information.
|
249
255
|
|
250
256
|
rdoc_options: []
|
251
257
|
require_paths:
|
@@ -257,9 +263,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
257
263
|
version: '0'
|
258
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
265
|
requirements:
|
260
|
-
- - "
|
266
|
+
- - ">"
|
261
267
|
- !ruby/object:Gem::Version
|
262
|
-
version:
|
268
|
+
version: 1.3.1
|
263
269
|
requirements: []
|
264
270
|
rubyforge_project: blacklight
|
265
271
|
rubygems_version: 2.5.2
|
@@ -269,12 +275,15 @@ summary: Blacklight Oai Provider plugin
|
|
269
275
|
test_files:
|
270
276
|
- spec/controllers/catalog_controller_spec.rb
|
271
277
|
- spec/features/html_rendering_spec.rb
|
278
|
+
- spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
|
279
|
+
- spec/lib/blacklight_oai_provider/solr_set_spec.rb
|
272
280
|
- spec/models/solr_document_spec.rb
|
273
281
|
- spec/requests/get_record_spec.rb
|
274
282
|
- spec/requests/identify_spec.rb
|
275
283
|
- spec/requests/list_identifiers_spec.rb
|
276
284
|
- spec/requests/list_metadata_formats_spec.rb
|
277
285
|
- spec/requests/list_records_spec.rb
|
286
|
+
- spec/requests/list_sets_spec.rb
|
278
287
|
- spec/spec_helper.rb
|
279
288
|
- spec/test_app_templates/config/solr.yml
|
280
289
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|