hydra-collections 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c28f188d368c9473749d96c22309c56e57536633
4
- data.tar.gz: b6d1c46f2597ebae64801965633daae8f0cbe5ae
3
+ metadata.gz: ebe55db03846ed51118593543505434956f99125
4
+ data.tar.gz: db11d0ff1b2513f376e5e381eba5bf32e1bebdfb
5
5
  SHA512:
6
- metadata.gz: 6e72303ce4d2b51c69451a3c296692ca3d8db30b06ad6ee2f3754522208aac953c51938ddc7d448f4386e8f97761d0b9ef919fa653a924eb3a0aa01a981dd5f6
7
- data.tar.gz: 74652e187ce8fa1c337adfd1617be152fe49a3d9eeec3074e902dd003d38fabeba2559875d14da56f1e863c167c419a6939367ee2d62e61bc378eeb19e4e2d68
6
+ metadata.gz: 4798abcfddaaabe9bb8f63f3cc82bc214f70ead4a5f80a04a2388dc166ed1f8985e96ecb2b672c5f30d260b636e7aa8a5fdb35874b37cadf77ce4b497cf59b2d
7
+ data.tar.gz: 730fea9bd4c25e8887373e7c04b67be671c5a0d59f495f39b7a36760995471cebbcb73f4ebbaf30d1caafc294319fb9d6e2f99b155c4b7d2af4ed58bb618cf1a
@@ -57,16 +57,9 @@ module Hydra::Collections::SelectsCollections
57
57
  end
58
58
 
59
59
  def collections_search_builder(access_level = nil)
60
- collections_search_builder_class.new(collection_search_params_logic, self).tap do |builder|
60
+ collections_search_builder_class.new(self).tap do |builder|
61
61
  builder.current_ability = current_ability
62
62
  builder.discovery_perms = access_levels[access_level] if access_level
63
63
  end
64
64
  end
65
-
66
- # Defines which search_params_logic should be used when searching for Collections
67
- def collection_search_params_logic
68
- [:default_solr_parameters, :add_query_to_solr, :add_access_controls_to_solr_params,
69
- :add_collection_filter, :some_rows]
70
- end
71
-
72
65
  end
@@ -87,7 +87,7 @@ module Hydra
87
87
 
88
88
  def after_update_error
89
89
  respond_to do |format|
90
- format.html { render action: collections.edit_collection_path(@collection) }
90
+ format.html { render action: "edit" }
91
91
  format.json { render json: @collection.errors, status: :unprocessable_entity }
92
92
  end
93
93
  end
@@ -103,14 +103,14 @@ module Hydra
103
103
 
104
104
  def after_destroy (id)
105
105
  respond_to do |format|
106
- format.html { redirect_to catalog_index_path, notice: 'Collection was successfully deleted.' }
106
+ format.html { redirect_to search_catalog_path, notice: 'Collection was successfully deleted.' }
107
107
  format.json { render json: {id:id}, status: :destroyed, location: @collection }
108
108
  end
109
109
  end
110
110
 
111
111
  def after_destroy_error (id)
112
112
  respond_to do |format|
113
- format.html { redirect_to catalog_index_path, notice: 'Collection could not be deleted.' }
113
+ format.html { redirect_to search_catalog_path, notice: 'Collection could not be deleted.' }
114
114
  format.json { render json: {id:id}, status: :destroy_error, location: @collection }
115
115
  end
116
116
  end
@@ -129,11 +129,6 @@ module Hydra
129
129
 
130
130
  protected
131
131
 
132
- # Defines which search_params_logic should be used when searching for Collection members
133
- def collection_member_search_logic
134
- search_params_logic + [:include_collection_ids, :add_access_controls_to_solr_params]
135
- end
136
-
137
132
  def collection_params
138
133
  params.require(:collection).permit(:part_of, :contributor, :creator, :title,
139
134
  :description, :publisher, :date_created, :subject, :language, :rights,
@@ -152,11 +147,11 @@ module Hydra
152
147
  end
153
148
 
154
149
  def collection_member_search_builder_class
155
- Hydra::Collections::SearchBuilder
150
+ Hydra::Collections::MemberSearchBuilder
156
151
  end
157
152
 
158
153
  def collection_member_search_builder
159
- @collection_member_search_builder ||= collection_member_search_builder_class.new(collection_member_search_logic, self).tap do |builder|
154
+ @collection_member_search_builder ||= collection_member_search_builder_class.new(self).tap do |builder|
160
155
  builder.current_ability = current_ability
161
156
  end
162
157
  end
@@ -7,56 +7,71 @@ module Hydra::Collections
7
7
  end
8
8
 
9
9
  property :part_of, predicate: RDF::Vocab::DC.isPartOf
10
+
10
11
  property :contributor, predicate: RDF::Vocab::DC.contributor do |index|
11
12
  index.as :stored_searchable, :facetable
12
13
  end
14
+
13
15
  property :creator, predicate: RDF::Vocab::DC.creator do |index|
14
16
  index.as :stored_searchable, :facetable
15
17
  end
18
+
16
19
  property :title, predicate: RDF::Vocab::DC.title, multiple: false do |index|
17
- index.as :stored_searchable
20
+ index.as :stored_searchable, :sortable
18
21
  end
22
+
19
23
  property :description, predicate: RDF::Vocab::DC.description, multiple: false do |index|
20
24
  index.type :text
21
25
  index.as :stored_searchable
22
26
  end
27
+
23
28
  property :publisher, predicate: RDF::Vocab::DC.publisher do |index|
24
29
  index.as :stored_searchable, :facetable
25
30
  end
31
+
26
32
  property :date_created, predicate: RDF::Vocab::DC.created do |index|
27
33
  index.as :stored_searchable
28
34
  end
35
+
29
36
  property :date_uploaded, predicate: RDF::Vocab::DC.dateSubmitted, multiple: false do |index|
30
37
  index.type :date
31
38
  index.as :stored_sortable
32
39
  end
40
+
33
41
  property :date_modified, predicate: RDF::Vocab::DC.modified, multiple: false do |index|
34
42
  index.type :date
35
43
  index.as :stored_sortable
36
44
  end
45
+
37
46
  property :subject, predicate: RDF::Vocab::DC.subject do |index|
38
47
  index.as :stored_searchable, :facetable
39
48
  end
49
+
40
50
  property :language, predicate: RDF::Vocab::DC.language do |index|
41
51
  index.as :stored_searchable, :facetable
42
52
  end
53
+
43
54
  property :rights, predicate: RDF::Vocab::DC.rights do |index|
44
55
  index.as :stored_searchable
45
56
  end
57
+
46
58
  property :resource_type, predicate: RDF::Vocab::DC.type do |index|
47
59
  index.as :stored_searchable, :facetable
48
60
  end
61
+
49
62
  property :identifier, predicate: RDF::Vocab::DC.identifier do |index|
50
63
  index.as :stored_searchable
51
64
  end
65
+
52
66
  property :based_near, predicate: RDF::Vocab::FOAF.based_near do |index|
53
67
  index.as :stored_searchable, :facetable
54
68
  end
69
+
55
70
  property :tag, predicate: RDF::Vocab::DC.relation do |index|
56
71
  index.as :stored_searchable, :facetable
57
72
  end
58
- property :related_url, predicate: RDF::RDFS.seeAlso
59
73
 
74
+ property :related_url, predicate: RDF::RDFS.seeAlso
60
75
  end
61
76
  end
62
77
  end
@@ -0,0 +1,21 @@
1
+ module Hydra::Collections
2
+ class MemberSearchBuilder < Hydra::SearchBuilder
3
+
4
+ class_attribute :from_field
5
+ self.from_field = 'member_ids_ssim'
6
+
7
+ # Defines which search_params_logic should be used when searching for Collection members
8
+ self.default_processor_chain += [:include_collection_ids]
9
+
10
+ def collection
11
+ scope.collection
12
+ end
13
+
14
+ # include filters into the query to only include the collection memebers
15
+ def include_collection_ids(solr_parameters)
16
+ solr_parameters[:fq] ||= []
17
+ solr_parameters[:fq] << "{!join from=#{from_field} to=id}id:#{collection.id}"
18
+ end
19
+
20
+ end
21
+ end
@@ -1,5 +1,35 @@
1
1
  module Hydra::Collections
2
2
  class SearchBuilder < Hydra::SearchBuilder
3
- include Hydra::Collections::SearchBehaviors
3
+ # Defines which search_params_logic should be used when searching for Collections
4
+ self.default_processor_chain = [:default_solr_parameters, :add_query_to_solr,
5
+ :add_access_controls_to_solr_params, :add_collection_filter, :some_rows, :sort_by_title]
6
+
7
+ def some_rows(solr_parameters)
8
+ solr_parameters[:rows] = '100'
9
+ end
10
+
11
+ def add_collection_filter(solr_parameters)
12
+ solr_parameters[:fq] ||= []
13
+ solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::Collection.to_class_uri)
14
+ end
15
+
16
+ # Sort results by title if no query was supplied.
17
+ # This overrides the default 'relevance' sort.
18
+ def sort_by_title(solr_parameters)
19
+ return if solr_parameters[:q]
20
+ solr_parameters[:sort] ||= "#{sort_field} asc"
21
+ end
22
+
23
+ def discovery_perms= perms
24
+ @discovery_perms = perms
25
+ end
26
+
27
+ def discovery_permissions
28
+ @discovery_perms || super
29
+ end
30
+
31
+ def sort_field
32
+ Solrizer.solr_name('title', :sortable)
33
+ end
4
34
  end
5
35
  end
@@ -4,7 +4,7 @@
4
4
  <label class="accessible-hidden">Search Collection <%=@collection.title %></label>
5
5
  <%= text_field_tag :cq, params[:cq], :class => "collection-query", :placeholder => "Search Collection", :size => '30', :type => "search", :id => "collection_search" %>
6
6
  <%= hidden_field_tag :sort, params[:sort], :id => 'collection_sort' %>
7
- <%= render_hash_as_hidden_fields(params_for_search.except(:cq, :sort, :qt, :page)).html_safe %>
7
+ <%= render_hash_as_hidden_fields(search_state.params_for_search.except(:cq, :sort, :qt, :page)) %>
8
8
  <button type="submit" class="btn btn-primary" id="collection_submit"><i class="icon-search"></i> Go</button>
9
9
  <% end %>
10
10
  </div>
@@ -20,9 +20,10 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'hydra-head', '~> 9.1'
22
22
  spec.add_dependency 'deprecation', '~> 0.1'
23
- spec.add_dependency 'blacklight', '~> 5.10'
23
+ spec.add_dependency 'blacklight', '~> 6.0'
24
24
  spec.add_dependency 'hydra-works', '~> 0.4'
25
25
  spec.add_dependency 'rdf', '~> 1.99'
26
+ spec.add_dependency 'rdf-vocab', '~> 0'
26
27
 
27
28
  spec.add_development_dependency 'engine_cart', '~> 0.8'
28
29
  spec.add_development_dependency 'rspec-rails', '~> 3.1'
@@ -8,16 +8,9 @@ module Hydra
8
8
  autoload :Collectible
9
9
  autoload :SearchService
10
10
  autoload :AcceptsBatches
11
- autoload :SelectsCollections
12
- autoload :SolrDocumentBehavior
13
- autoload :SearchBehaviors
11
+
14
12
  class Engine < ::Rails::Engine
15
13
  engine_name "collections"
16
- config.autoload_paths += %W(
17
- #{config.root}/app/controllers/concerns
18
- #{config.root}/app/models/concerns
19
- #{config.root}/app/models/datastreams
20
- )
21
14
  end
22
15
  end
23
16
  end
@@ -10,7 +10,7 @@ module Hydra
10
10
  self.class.copy_blacklight_config_from(::CatalogController)
11
11
  end
12
12
 
13
- self.search_params_logic << :apply_gated_search
13
+ # self.search_params_logic << :apply_gated_search
14
14
 
15
15
  def last_search_documents
16
16
  return [] if @session[:history].blank?
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module Collections
3
- VERSION = "6.0.0"
3
+ VERSION = "7.0.0"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ describe CollectionsController, :type => :controller do
14
14
  include Hydra::AccessControls::Permissions
15
15
  include Hydra::Works::WorkBehavior
16
16
 
17
- property :title, predicate: ::RDF::DC.title, multiple: false
17
+ property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
18
18
 
19
19
  def to_solr(solr_doc={})
20
20
  super.tap do |solr_doc|
@@ -39,15 +39,15 @@ describe CollectionsController, :type => :controller do
39
39
  end
40
40
 
41
41
  describe "#index" do
42
- let!(:collection1) { Collection.create { |c| c.apply_depositor_metadata(user.user_key) } }
43
- let!(:collection2) { Collection.create { |c| c.apply_depositor_metadata(user.user_key) } }
42
+ let!(:collection1) { Collection.create(title: 'Beta') { |c| c.apply_depositor_metadata(user.user_key) } }
43
+ let!(:collection2) { Collection.create(title: 'Alpha') { |c| c.apply_depositor_metadata(user.user_key) } }
44
44
  let!(:generic_file) { GenericWork.create }
45
45
 
46
- it "should show a list of collections" do
46
+ it "shows a list of collections sorted alphabetically" do
47
47
  get :index
48
48
  expect(response).to be_successful
49
49
  expect(assigns[:document_list].map(&:id)).not_to include generic_file.id
50
- expect(assigns[:document_list].map(&:id)).to eq [collection1.id, collection2.id]
50
+ expect(assigns[:document_list].map(&:id)).to eq [collection2.id, collection1.id]
51
51
  end
52
52
  end
53
53
 
@@ -126,6 +126,16 @@ describe CollectionsController, :type => :controller do
126
126
  put :update, id: @collection.id, collection: { title: "New Title", description: "New Description" }
127
127
  end
128
128
 
129
+ context "when updating fails" do
130
+ before do
131
+ allow_any_instance_of(Collection).to receive(:save).and_return(false)
132
+ end
133
+ it "should render edit succesfully" do
134
+ put :update, id: @collection.id, collection: { title: "New Title" }
135
+ expect(response).to render_template "edit"
136
+ end
137
+ end
138
+
129
139
  context "when there are existing members in the collection" do
130
140
  it "should support adding batches of members" do
131
141
  @collection.members << @asset1
@@ -189,7 +199,7 @@ describe CollectionsController, :type => :controller do
189
199
 
190
200
  it "deletes the collection" do
191
201
  delete :destroy, id: @collection
192
- expect(response).to redirect_to Rails.application.routes.url_helpers.catalog_index_path
202
+ expect(response).to redirect_to Rails.application.routes.url_helpers.search_catalog_path
193
203
  expect(flash[:notice]).to eq("Collection was successfully deleted.")
194
204
  end
195
205
 
@@ -5,15 +5,15 @@ class SelectsCollectionsController < ApplicationController
5
5
  include Hydra::Controller::ControllerBehavior
6
6
  include Hydra::Collections::SelectsCollections
7
7
 
8
- SelectsCollectionsController.search_params_logic += [:add_access_controls_to_solr_params]
8
+ #SelectsCollectionsController.search_params_logic += [:add_access_controls_to_solr_params]
9
9
  end
10
10
 
11
11
  describe SelectsCollectionsController, :type => :controller do
12
12
 
13
13
  describe "#find_collections" do
14
- it "should use collection_search_params_logic" do
15
- expect(subject.collection_search_params_logic).to eq([:default_solr_parameters, :add_query_to_solr, :add_access_controls_to_solr_params, :add_collection_filter, :some_rows])
16
- expect(Hydra::Collections::SearchBuilder).to receive(:new).with(subject.collection_search_params_logic, subject).and_call_original
14
+ it "uses the search builder" do
15
+ expect(subject.collections_search_builder_class.default_processor_chain).to eq [:default_solr_parameters, :add_query_to_solr, :add_access_controls_to_solr_params, :add_collection_filter, :some_rows, :sort_by_title]
16
+ expect(Hydra::Collections::SearchBuilder).to receive(:new).with(subject).and_call_original
17
17
  subject.find_collections
18
18
  end
19
19
  end
@@ -23,8 +23,9 @@ describe Collection, :type => :model do
23
23
 
24
24
  subject { collection.to_solr }
25
25
 
26
- it "should have title and depositor information" do
26
+ it "has title and depositor information" do
27
27
  expect(subject['title_tesim']).to eq ['A good title']
28
+ expect(subject['title_si']).to eq 'A good title'
28
29
  expect(subject['depositor_tesim']).to eq [user.user_key]
29
30
  expect(subject['depositor_ssim']).to eq [user.user_key]
30
31
  end
@@ -1 +1,2 @@
1
1
  gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
2
+
@@ -8,14 +8,19 @@ describe 'collections/_thumbnail_default.html.erb' do
8
8
  end
9
9
  end
10
10
 
11
+ let(:blacklight_configuration_context) do
12
+ Blacklight::Configuration::Context.new(controller)
13
+ end
14
+ let(:search_state) { double('SearchState', url_for_document: '/foo') }
15
+
11
16
  before do
12
17
  assign :response, double(start: 0)
13
18
  allow(view).to receive(:blacklight_config).and_return(blacklight_config)
14
19
  allow(view).to receive(:render_grouped_response?).and_return(false)
15
20
  allow(view).to receive(:current_search_session).and_return nil
16
21
  allow(view).to receive(:search_session).and_return({})
17
- allow(view).to receive(:url_for_document).and_return('/foo')
18
- allow(view).to receive(:session_tracking_params).and_return({})
22
+ allow(view).to receive(:search_state).and_return(search_state)
23
+ allow(view).to receive(:blacklight_configuration_context).and_return(blacklight_configuration_context)
19
24
  render 'collections/thumbnail_default', document: document, document_counter: 1
20
25
  end
21
26
 
@@ -6,11 +6,15 @@ describe 'collections/show.html.erb' do
6
6
 
7
7
  let(:blacklight_config) { CatalogController.blacklight_config }
8
8
  let(:member_docs) { [ SolrDocument.new(id: '234'), SolrDocument.new(id: '456') ] }
9
+ let(:search_state) { double('SearchState', params_for_search: {}) }
10
+ let(:blacklight_configuration_context) do
11
+ Blacklight::Configuration::Context.new(controller)
12
+ end
13
+
9
14
  before do
10
15
  allow(view).to receive(:blacklight_config).and_return(blacklight_config)
11
- allow(view).to receive(:search_session).and_return({})
12
- allow(view).to receive(:current_search_session).and_return nil
13
- allow(view).to receive(:render_index_doc_actions).and_return nil
16
+ allow(view).to receive(:search_state).and_return(search_state)
17
+ allow(view).to receive(:blacklight_configuration_context).and_return(blacklight_configuration_context)
14
18
  view.lookup_context.prefixes += ['catalog']
15
19
  assign(:response, response)
16
20
  assign(:collection, collection)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-collections
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carolyn Cole
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hydra-head
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.10'
47
+ version: '6.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.10'
54
+ version: '6.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hydra-works
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.99'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rdf-vocab
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: engine_cart
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +152,9 @@ files:
138
152
  - app/models/concerns/hydra/collection.rb
139
153
  - app/models/concerns/hydra/collections/actions.rb
140
154
  - app/models/concerns/hydra/collections/metadata.rb
155
+ - app/models/concerns/hydra/collections/solr_document_behavior.rb
141
156
  - app/models/solr_document.rb
157
+ - app/search_builders/hydra/collections/member_search_builder.rb
142
158
  - app/search_builders/hydra/collections/search_builder.rb
143
159
  - app/views/batch_select/_add_button.html.erb
144
160
  - app/views/batch_select/_check_all.html.erb
@@ -175,9 +191,7 @@ files:
175
191
  - lib/hydra-collections.rb
176
192
  - lib/hydra/collections/accepts_batches.rb
177
193
  - lib/hydra/collections/collectible.rb
178
- - lib/hydra/collections/search_behaviors.rb
179
194
  - lib/hydra/collections/search_service.rb
180
- - lib/hydra/collections/solr_document_behavior.rb
181
195
  - lib/hydra/collections/version.rb
182
196
  - solr_conf/conf/schema.xml
183
197
  - solr_conf/conf/solrconfig.xml
@@ -1,36 +0,0 @@
1
- module Hydra::Collections::SearchBehaviors
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- class_attribute :from_field
6
- self.from_field = 'member_ids_ssim'
7
- end
8
-
9
- def collection
10
- scope.collection
11
- end
12
-
13
- # include filters into the query to only include the collection memebers
14
- def include_collection_ids(solr_parameters)
15
- solr_parameters[:fq] ||= []
16
- solr_parameters[:fq] << "{!join from=#{from_field} to=id}id:#{collection.id}"
17
- end
18
-
19
- def some_rows(solr_parameters)
20
- solr_parameters[:rows] = '100'
21
- end
22
-
23
- def add_collection_filter(solr_parameters)
24
- solr_parameters[:fq] ||= []
25
- solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::Collection.to_class_uri)
26
- end
27
-
28
- def discovery_perms= perms
29
- @discovery_perms = perms
30
- end
31
-
32
- def discovery_permissions
33
- @discovery_perms || super
34
- end
35
-
36
- end