blacklight_oai_provider 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/VERSION +1 -1
- data/app/models/concerns/blacklight_oai_provider/solr_document.rb +1 -1
- data/blacklight_oai_provider.gemspec +1 -1
- data/lib/blacklight_oai_provider/solr_document_wrapper.rb +18 -18
- data/lib/blacklight_oai_provider/solr_set.rb +5 -3
- data/lib/railties/blacklight_oai_provider.rake +1 -1
- data/spec/controllers/catalog_controller_spec.rb +0 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +15 -16
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a928d521835ccd466eb70eaed91ac54a0680c60b
|
4
|
+
data.tar.gz: 923dbe6d7ec7c741fe4b63418a3b3ca51e8ed000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36e1822ae96de49092998f5e02bba8ed43f3811e905f324be337b398af8d758b9bc9cc56183c0fcdb1884c37b4cc34c07c12504be62a13ef16a6e66074e82a51
|
7
|
+
data.tar.gz: 56fbfd912c0a969f35609f61e997151bb5f7b96d41d254c785e9397d4603b628fb0a9f2d0c7a86bcfaf0e0a08f623c8c26962ddc16bb1756061944ff935f409f
|
data/README.md
CHANGED
@@ -66,7 +66,6 @@ configure_blacklight do |config|
|
|
66
66
|
sample_id: '109660'
|
67
67
|
},
|
68
68
|
document: {
|
69
|
-
model: SolrDocument, # SolrDocument class being used, default: SolrDocument
|
70
69
|
limit: 25 # number of records returned with each request, default: 15
|
71
70
|
set_fields: [ # ability to define ListSets, optional, default: nil
|
72
71
|
{ label: 'language', solr_field: 'language_facet' }
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.1.0
|
@@ -3,7 +3,7 @@ module BlacklightOaiProvider
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def timestamp
|
6
|
-
timestamp =
|
6
|
+
timestamp = fetch(self.class.timestamp_key, nil)
|
7
7
|
raise BlacklightOaiProvider::Exceptions::MissingTimestamp if timestamp.blank?
|
8
8
|
Time.zone.parse(timestamp) # Solr timestamps are all in UTC.
|
9
9
|
end
|
@@ -22,7 +22,7 @@ BlacklightOaiProvider v5.x 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", "~> 5.
|
25
|
+
s.add_dependency "blacklight", "~> 5.13"
|
26
26
|
s.add_dependency "oai", "~> 0.4"
|
27
27
|
s.add_development_dependency 'rspec-rails', "~> 3.0"
|
28
28
|
s.add_development_dependency 'capybara'
|
@@ -4,7 +4,7 @@ module BlacklightOaiProvider
|
|
4
4
|
|
5
5
|
def initialize(controller, options = {})
|
6
6
|
@controller = controller
|
7
|
-
@document_model =
|
7
|
+
@document_model = @controller.blacklight_config.document_model
|
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
|
@@ -19,32 +19,34 @@ module BlacklightOaiProvider
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def earliest
|
22
|
-
|
23
|
-
|
22
|
+
builder = @controller.search_builder.merge(fl: solr_timestamp, sort: "#{solr_timestamp} asc", rows: 1)
|
23
|
+
response = @controller.repository.search(builder)
|
24
|
+
response.documents.first.timestamp
|
24
25
|
end
|
25
26
|
|
26
27
|
def latest
|
27
|
-
|
28
|
-
|
28
|
+
builder = @controller.search_builder.merge(fl: solr_timestamp, sort: "#{solr_timestamp} desc", rows: 1)
|
29
|
+
response = @controller.repository.search(builder)
|
30
|
+
response.documents.first.timestamp
|
29
31
|
end
|
30
32
|
|
31
33
|
def find(selector, options = {})
|
32
34
|
return next_set(options[:resumption_token]) if options[:resumption_token]
|
33
35
|
|
34
36
|
if selector == :all
|
35
|
-
response
|
37
|
+
response = @controller.repository.search(conditions(options))
|
36
38
|
|
37
39
|
if limit && response.total > limit
|
38
40
|
return select_partial(BlacklightOaiProvider::ResumptionToken.new(options.merge(last: 0), nil, response.total))
|
39
41
|
end
|
42
|
+
response.documents
|
40
43
|
else
|
41
|
-
|
44
|
+
@controller.fetch(selector.split('/', 2).last).first.documents.first
|
42
45
|
end
|
43
|
-
records
|
44
46
|
end
|
45
47
|
|
46
48
|
def select_partial(token)
|
47
|
-
|
49
|
+
records = @controller.repository.search(token_conditions(token)).documents
|
48
50
|
|
49
51
|
raise ::OAI::ResumptionTokenException unless records
|
50
52
|
|
@@ -60,23 +62,21 @@ module BlacklightOaiProvider
|
|
60
62
|
|
61
63
|
private
|
62
64
|
|
63
|
-
def base_conditions
|
64
|
-
{ sort: "#{solr_timestamp} asc", rows: limit }
|
65
|
-
end
|
66
|
-
|
67
65
|
def token_conditions(token)
|
68
66
|
conditions(token.to_conditions_hash).merge(start: token.last)
|
69
67
|
end
|
70
68
|
|
71
69
|
def conditions(options) # conditions/query derived from options
|
72
|
-
|
70
|
+
query = @controller.search_builder.merge(sort: "#{solr_timestamp} asc", rows: limit).query
|
71
|
+
|
73
72
|
if options[:from].present? || options[:until].present?
|
74
|
-
|
73
|
+
query.append_filter_query(
|
74
|
+
"#{solr_timestamp}:[#{solr_date(options[:from])} TO #{solr_date(options[:until]).gsub('Z', '.999Z')}]"
|
75
|
+
)
|
75
76
|
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
base_conditions.merge(fq: filters)
|
78
|
+
query.append_filter_query(@set.from_spec(options[:set])) if options[:set].present?
|
79
|
+
query
|
80
80
|
end
|
81
81
|
|
82
82
|
def solr_date(time)
|
@@ -7,7 +7,10 @@ module BlacklightOaiProvider
|
|
7
7
|
|
8
8
|
params = { rows: 0, facet: true, 'facet.field' => solr_fields }
|
9
9
|
solr_fields.each { |field| params["f.#{field}.facet.limit"] = -1 } # override any potential blacklight limits
|
10
|
-
|
10
|
+
|
11
|
+
builder = @controller.search_builder.merge(params)
|
12
|
+
response = @controller.repository.search(builder)
|
13
|
+
|
11
14
|
sets_from_facets(response.facet_fields) if response.facet_fields
|
12
15
|
end
|
13
16
|
|
@@ -19,8 +22,7 @@ module BlacklightOaiProvider
|
|
19
22
|
# Returns array of sets for a solr document, or empty array if none are available.
|
20
23
|
def sets_for(record)
|
21
24
|
Array.wrap(@fields).map do |field|
|
22
|
-
|
23
|
-
Array.wrap(values).map do |value|
|
25
|
+
record.fetch(field[:solr_field], []).map do |value|
|
24
26
|
new("#{field[:label]}:#{value}")
|
25
27
|
end
|
26
28
|
end.flatten
|
@@ -6,7 +6,7 @@ namespace :blacklight_oai_provider do
|
|
6
6
|
require 'yaml'
|
7
7
|
|
8
8
|
docs = YAML.safe_load(File.open(File.join(BlacklightOaiProvider.root, 'solr', 'sample_solr_documents.yml')))
|
9
|
-
conn = RSolr.connect(Blacklight.
|
9
|
+
conn = RSolr.connect(Blacklight.connection_config)
|
10
10
|
conn.add docs
|
11
11
|
conn.commit
|
12
12
|
end
|
@@ -44,16 +44,16 @@ class TestAppGenerator < Rails::Generators::Base
|
|
44
44
|
say_status("warning", "ADDING BL OIA-PMH CONFIG")
|
45
45
|
|
46
46
|
insert_into_file "app/controllers/catalog_controller.rb", after: " config.default_solr_params = { \n" do
|
47
|
-
" :
|
47
|
+
" fl: '*',\n"
|
48
48
|
end
|
49
49
|
|
50
50
|
insert_into_file "app/controllers/catalog_controller.rb", after: " configure_blacklight do |config|\n" do
|
51
51
|
<<-CONFIG
|
52
52
|
config.default_document_solr_params = {
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
53
|
+
qt: 'search',
|
54
|
+
fl: '*',
|
55
|
+
rows: 1,
|
56
|
+
q: '{!raw f=id v=$id}'
|
57
57
|
}
|
58
58
|
CONFIG
|
59
59
|
end
|
@@ -61,20 +61,19 @@ class TestAppGenerator < Rails::Generators::Base
|
|
61
61
|
insert_into_file "app/controllers/catalog_controller.rb", after: "configure_blacklight do |config|\n" do
|
62
62
|
<<-CONFIG
|
63
63
|
config.oai = {
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
64
|
+
provider: {
|
65
|
+
repository_name: 'Test Repository',
|
66
|
+
repository_url: 'http://localhost/catalog/oai',
|
67
|
+
record_prefix: 'oai:test',
|
68
|
+
admin_email: 'root@localhost',
|
69
|
+
deletion_support: 'persistent',
|
70
|
+
sample_id: '109660'
|
71
71
|
},
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:set_fields => [
|
72
|
+
document: {
|
73
|
+
set_fields: [
|
75
74
|
{ label: 'language', solr_field: 'language_facet' }
|
76
75
|
],
|
77
|
-
:
|
76
|
+
limit: 25
|
78
77
|
}
|
79
78
|
}
|
80
79
|
CONFIG
|
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: 5.
|
4
|
+
version: 5.1.0
|
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-27 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: '5.
|
34
|
+
version: '5.13'
|
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: '5.
|
41
|
+
version: '5.13'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: oai
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|