curation_concerns 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Gemfile +0 -4
  4. data/app/actors/curation_concerns/actors/file_actor.rb +19 -3
  5. data/app/assets/javascripts/curation_concerns/curation_concerns.js +1 -0
  6. data/app/assets/javascripts/curation_concerns/file_manager/sorting.es6 +44 -5
  7. data/app/assets/javascripts/curation_concerns/file_manager.es6 +9 -2
  8. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +57 -18
  9. data/app/controllers/concerns/curation_concerns/permissions_controller_behavior.rb +23 -0
  10. data/app/controllers/concerns/curation_concerns/selects_collections.rb +2 -0
  11. data/app/controllers/curation_concerns/permissions_controller.rb +1 -16
  12. data/app/forms/curation_concerns/forms/work_form.rb +0 -7
  13. data/app/helpers/batch_select_helper.rb +0 -15
  14. data/app/helpers/curation_concerns/collections_helper.rb +40 -6
  15. data/app/helpers/curation_concerns/main_app_helpers.rb +0 -2
  16. data/app/jobs/characterize_job.rb +5 -3
  17. data/app/jobs/create_derivatives_job.rb +3 -2
  18. data/app/jobs/ingest_file_job.rb +16 -16
  19. data/app/models/concerns/curation_concerns/admin_set_behavior.rb +5 -0
  20. data/app/models/concerns/curation_concerns/basic_metadata.rb +8 -0
  21. data/app/models/concerns/curation_concerns/collection_behavior.rb +2 -3
  22. data/app/models/concerns/curation_concerns/serializers.rb +2 -2
  23. data/app/models/concerns/curation_concerns/solr_document_behavior.rb +3 -2
  24. data/app/models/concerns/curation_concerns/work_behavior.rb +1 -1
  25. data/app/presenters/curation_concerns/work_show_presenter.rb +2 -1
  26. data/app/renderers/curation_concerns/renderers/external_link_attribute_renderer.rb +13 -0
  27. data/app/renderers/{renderers.rb → curation_concerns/renderers.rb} +0 -0
  28. data/app/search_builders/curation_concerns/admin_set_search_builder.rb +3 -3
  29. data/app/search_builders/curation_concerns/collection_search_builder.rb +6 -4
  30. data/app/search_builders/curation_concerns/file_set_search_builder.rb +3 -3
  31. data/app/search_builders/curation_concerns/filter_by_type.rb +17 -5
  32. data/app/search_builders/curation_concerns/member_search_builder.rb +7 -3
  33. data/app/search_builders/curation_concerns/single_result.rb +1 -1
  34. data/app/services/curation_concerns/admin_set_service.rb +6 -8
  35. data/app/services/curation_concerns/indexes_thumbnails.rb +0 -1
  36. data/app/services/curation_concerns/license_service.rb +8 -0
  37. data/app/services/curation_concerns/working_directory.rb +4 -2
  38. data/app/views/collections/_search_form.html.erb +2 -2
  39. data/app/views/curation_concerns/base/_file_manager_actions.html.erb +1 -0
  40. data/app/views/curation_concerns/base/_file_manager_member_resource_options.html.erb +4 -0
  41. data/app/views/curation_concerns/base/_file_manager_resource_form.html.erb +1 -0
  42. data/app/views/curation_concerns/base/_form_rights.html.erb +3 -2
  43. data/config/locales/curation_concerns.en.yml +4 -0
  44. data/curation_concerns.gemspec +3 -3
  45. data/lib/curation_concerns/version.rb +1 -1
  46. data/lib/generators/curation_concerns/models_generator.rb +8 -0
  47. data/lib/generators/curation_concerns/templates/spec/models/collection_spec.rb +7 -0
  48. data/lib/generators/curation_concerns/templates/spec/models/file_set_spec.rb +7 -0
  49. data/spec/actors/curation_concerns/file_actor_spec.rb +17 -3
  50. data/spec/actors/curation_concerns/file_set_actor_spec.rb +34 -8
  51. data/spec/controllers/curation_concerns/collections_controller_spec.rb +3 -4
  52. data/spec/controllers/selects_collections_controller_spec.rb +7 -2
  53. data/spec/factories/generic_works.rb +3 -1
  54. data/spec/features/collection_spec.rb +2 -0
  55. data/spec/helpers/curation_concerns/collections_helper_spec.rb +87 -3
  56. data/spec/indexers/file_set_indexer_spec.rb +3 -0
  57. data/spec/indexers/work_indexer_spec.rb +2 -1
  58. data/spec/javascripts/file_manager_member_spec.coffee +2 -1
  59. data/spec/javascripts/file_manager_sorting_spec.coffee +23 -0
  60. data/spec/javascripts/fixtures/sortable.html +182 -0
  61. data/spec/javascripts/save_manager_spec.coffee +2 -1
  62. data/spec/jobs/characterize_job_spec.rb +18 -1
  63. data/spec/jobs/ingest_file_job_spec.rb +18 -13
  64. data/spec/models/admin_set_spec.rb +5 -3
  65. data/spec/models/file_set_spec.rb +2 -4
  66. data/spec/models/solr_document_spec.rb +17 -3
  67. data/spec/presenters/curation_concerns/collection_presenter_spec.rb +5 -0
  68. data/spec/renderers/curation_concerns/renderers/external_link_attribute_renderer_spec.rb +22 -0
  69. data/spec/search_builders/curation_concerns/admin_set_search_builder_spec.rb +8 -5
  70. data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +2 -2
  71. data/spec/services/curation_concerns/admin_set_service_spec.rb +53 -22
  72. data/spec/spec_helper.rb +1 -2
  73. data/spec/test_app_templates/Gemfile.extra +4 -0
  74. data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +10 -4
  75. data/spec/views/curation_concerns/base/file_manager.html.erb_spec.rb +8 -0
  76. data/spec/views/curation_concerns/base/show.json.jbuilder_spec.rb +1 -1
  77. data/spec/views/curation_concerns/file_sets/show.json.jbuilder_spec.rb +1 -1
  78. metadata +19 -22
  79. data/app/helpers/collections_helper.rb +0 -4
  80. data/app/helpers/curation_concerns/collections_helper_behavior.rb +0 -41
  81. data/app/helpers/curation_concerns/permissions_helper.rb +0 -19
  82. data/app/helpers/curation_concerns/rights_helper.rb +0 -9
  83. data/app/models/collection.rb +0 -6
  84. data/spec/helpers/collections_helper_spec.rb +0 -88
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3c778b10ded8ecbde18b513c114091bd5db0f03
4
- data.tar.gz: 7665059aa1ca3e90ac806048ec6e5d05d9336514
3
+ metadata.gz: a18cbc58262bda78bbccb7fcc5e263e09675b574
4
+ data.tar.gz: fb6ff7b4b9ad80ff9f2ccb26dbfa2ce93b35b585
5
5
  SHA512:
6
- metadata.gz: ce3acb4259faa827a4c98563a10f13d492388ae5815f5160a5505a053b8a18ed655928dacbb298a8b2e4cf701ec9280c41efd1d28d05a9a0abc57fb78f65751e
7
- data.tar.gz: 7d4ccf6d0e886559560ffc178cba90eeb27d6654d6871905f5bdd79128b688d6a3eff8c1414bf8c89d138d8ecc90e1c34a435c3770c39e540a0c31c4d7382696
6
+ metadata.gz: df0282909989ce292b1dbaa07ae83497e0bb7a8cd253120c5dc3d6d5d9d085a539aefacb701fd13e8fa70bef726b008fd2e5937faad7a6cc96b1808af0bb6695
7
+ data.tar.gz: 7bc806d8693440c4e17958531be96a56af544878796081521339bfa7ae261672f537900337035a29ae79b1a7385693b0f5403f82ae37a29fd0e8f493d8f94ad5
data/.rubocop.yml CHANGED
@@ -107,7 +107,7 @@ Style/HashSyntax:
107
107
 
108
108
  Style/PredicateName:
109
109
  Exclude:
110
- - 'app/helpers/curation_concerns/collections_helper_behavior.rb'
110
+ - 'app/helpers/curation_concerns/collections_helper.rb'
111
111
 
112
112
  Style/GlobalVars:
113
113
  Exclude:
data/Gemfile CHANGED
@@ -3,10 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in curation_concerns.gemspec
4
4
  gemspec
5
5
 
6
- if ENV['RDF_VERSION']
7
- gem 'rdf', ENV['RDF_VERSION']
8
- end
9
-
10
6
  group :development, :test do
11
7
  gem 'simplecov', '~> 0.9', require: false
12
8
  gem 'coveralls', require: false
@@ -20,9 +20,11 @@ module CurationConcerns
20
20
  # have made it to the repo
21
21
  # @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file to save in the repository
22
22
  def ingest_file(file)
23
- working_file = WorkingDirectory.copy_file_to_working_directory(file, file_set.id)
24
- mime_type = file.respond_to?(:content_type) ? file.content_type : nil
25
- IngestFileJob.perform_later(file_set, working_file, mime_type, user, relation)
23
+ IngestFileJob.perform_later(
24
+ file_set,
25
+ working_file(file),
26
+ user,
27
+ ingest_options(file))
26
28
  true
27
29
  end
28
30
 
@@ -38,6 +40,20 @@ module CurationConcerns
38
40
  CharacterizeJob.perform_later(file_set, repository_file.id)
39
41
  true
40
42
  end
43
+
44
+ private
45
+
46
+ def working_file(file)
47
+ path = file.path
48
+ return path if File.exist?(path)
49
+ CurationConcerns::WorkingDirectory.copy_file_to_working_directory(file, file_set.id)
50
+ end
51
+
52
+ def ingest_options(file, opts = {})
53
+ opts.merge!(mime_type: file.content_type) if file.respond_to?(:content_type)
54
+ opts.merge!(filename: file.original_filename) if file.respond_to?(:original_filename)
55
+ opts.merge!(relation: relation)
56
+ end
41
57
  end
42
58
  end
43
59
  end
@@ -10,6 +10,7 @@
10
10
  //= require curation_concerns/collections
11
11
  //= require curation_concerns/file_manager
12
12
  //= require curation_concerns/boot
13
+ //= require babel/polyfill
13
14
 
14
15
  // Initialize plugins and Bootstrap dropdowns on jQuery's ready event as well as
15
16
  // Turbolinks's page change event.
@@ -5,6 +5,7 @@ export default class SortManager {
5
5
  this.initialize_sort()
6
6
  this.element.data("current-order", this.order)
7
7
  this.save_manager = save_manager
8
+ this.initialize_alpha_sort_button()
8
9
  }
9
10
 
10
11
  initialize_sort() {
@@ -42,17 +43,21 @@ export default class SortManager {
42
43
  return this.element.children().index(item)
43
44
  }
44
45
 
46
+ register_order_change() {
47
+ if(this.order.toString() != this.element.data("current-order").toString()) {
48
+ this.save_manager.push_changed(this)
49
+ } else {
50
+ this.save_manager.mark_unchanged(this)
51
+ }
52
+ }
53
+
45
54
  get stopped_sorting() {
46
55
  return (event, ui) => {
47
56
  this.sorting_info.end = this.get_sort_position($(ui.item))
48
57
  if(this.sorting_info.end == this.sorting_info.start) {
49
58
  return
50
59
  }
51
- if(this.order.toString() != this.element.data("current-order").toString()) {
52
- this.save_manager.push_changed(this)
53
- } else {
54
- this.save_manager.mark_unchanged(this)
55
- }
60
+ this.register_order_change()
56
61
  }
57
62
  }
58
63
 
@@ -82,4 +87,38 @@ export default class SortManager {
82
87
  }
83
88
  ).toArray()
84
89
  }
90
+
91
+ get alpha_sort_button() {
92
+ return $("*[data-action='alpha-sort-action']")
93
+ }
94
+
95
+ initialize_alpha_sort_button() {
96
+ let that = this
97
+ this.alpha_sort_button.click(function() { that.sort_alpha() } )
98
+ }
99
+
100
+ sort_alpha() {
101
+ // create array of { title, element } objects
102
+ let array = []
103
+ let children = this.element.children().get()
104
+ children.forEach(function(child) {
105
+ let title = $(child).find("input.title").val()
106
+ array.push(
107
+ { title: title,
108
+ element: child }
109
+ )
110
+ })
111
+ // sort array by title of each object
112
+ array.sort(function(o1, o2) {
113
+ let a = o1.title.toLowerCase()
114
+ let b = o2.title.toLowerCase()
115
+ return a < b ? -1 : (a > b ? 1 : 0);
116
+ });
117
+ // replace contents of #sortable with elements from the array
118
+ this.element.empty()
119
+ for (let child of array) {
120
+ this.element.append(child.element)
121
+ }
122
+ this.register_order_change()
123
+ }
85
124
  }
@@ -42,8 +42,9 @@ export default class FileManager {
42
42
  }
43
43
 
44
44
  // Initialize a form that represents the parent resource as a whole.
45
- // For the purpose of CC, this only comes with a thumbnail_id hidden field
46
- // which is synchronized with the radio buttons on each member and then
45
+ // For the purpose of CC, this comes with hidden fields for
46
+ // thumbnail_id and representative_id
47
+ // which are synchronized with the radio buttons on each member and then
47
48
  // submitted with the SaveManager.
48
49
  resource_form() {
49
50
  let manager = new FileManagerMember($("#resource-form").parent(), this.save_manager)
@@ -55,6 +56,12 @@ export default class FileManager {
55
56
  $("*[data-member-link=thumbnail_id]").val(val)
56
57
  $("*[data-member-link=thumbnail_id]").change()
57
58
  })
59
+ new InputTracker($("*[data-member-link=representative_id]"), manager)
60
+ $("#sortable *[name=representative_id]").change(function() {
61
+ let val = $("#sortable *[name=representative_id]:checked").val()
62
+ $("*[data-member-link=representative_id]").val(val)
63
+ $("*[data-member-link=representative_id]").change()
64
+ })
58
65
  }
59
66
 
60
67
  // Keep the ui/sortable placeholder the right size.
@@ -2,9 +2,7 @@ module CurationConcerns
2
2
  module CollectionsControllerBehavior
3
3
  extend ActiveSupport::Concern
4
4
  include Blacklight::AccessControls::Catalog
5
-
6
5
  include Blacklight::Base
7
- include CurationConcerns::SelectsCollections
8
6
 
9
7
  included do
10
8
  before_action :filter_docs_with_read_access!, except: :show
@@ -29,17 +27,38 @@ module CurationConcerns
29
27
  end
30
28
 
31
29
  # actions: audit, index, create, new, edit, show, update, destroy, permissions, citation
32
- before_action :authenticate_user!, except: [:show]
30
+ before_action :authenticate_user!, except: [:show, :index]
33
31
  load_and_authorize_resource except: [:index, :show], instance_name: :collection
34
32
 
35
- class_attribute :presenter_class, :form_class
33
+ class_attribute :presenter_class,
34
+ :form_class,
35
+ :list_search_builder_class,
36
+ :single_item_search_builder_class,
37
+ :member_search_builder_class
38
+
39
+ alias_method :collection_search_builder_class, :single_item_search_builder_class
40
+ deprecation_deprecate collection_search_builder_class: "use single_item_search_builder_class instead"
41
+
42
+ alias_method :collections_search_builder_class, :list_search_builder_class
43
+ deprecation_deprecate collections_search_builder_class: "use list_search_builder_class instead"
44
+
45
+ alias_method :collection_member_search_builder_class, :member_search_builder_class
46
+ deprecation_deprecate collection_member_search_builder_class: "use member_search_builder_class instead"
47
+
36
48
  self.presenter_class = CurationConcerns::CollectionPresenter
37
49
  self.form_class = CurationConcerns::Forms::CollectionEditForm
50
+
51
+ # To build a query to find a list of collections
52
+ self.list_search_builder_class = CurationConcerns::CollectionSearchBuilder
53
+ # The search builder to find the collection
54
+ self.single_item_search_builder_class = CurationConcerns::WorkSearchBuilder
55
+ # The search builder to find the collections' members
56
+ self.member_search_builder_class = CurationConcerns::CollectionMemberSearchBuilder
38
57
  end
39
58
 
40
59
  def index
41
60
  # run the solr query to find the collections
42
- query = collections_search_builder.with(params).query
61
+ query = list_search_builder.with(params).query
43
62
  @response = repository.search(query)
44
63
  @document_list = @response.documents
45
64
  end
@@ -55,7 +74,7 @@ module CurationConcerns
55
74
 
56
75
  def edit
57
76
  query_collection_members
58
- find_collections
77
+ @user_collections = find_collections_for_form
59
78
  form
60
79
  end
61
80
 
@@ -144,6 +163,17 @@ module CurationConcerns
144
163
 
145
164
  protected
146
165
 
166
+ # TODO: This method could become a collection service.
167
+ # TODO: It seems suspicious that this is returning collections with read
168
+ # access rather than collections with edit access
169
+ # run a solr query to get the collections the user has access to read
170
+ # @return [Array] a list of the user's collections
171
+ def find_collections_for_form
172
+ query = list_search_builder.with(q: '').query
173
+ response = repository.search(query)
174
+ response.documents
175
+ end
176
+
147
177
  def remove_select_something_first_flash
148
178
  flash.delete(:notice) if flash.notice == 'Select something first'
149
179
  end
@@ -152,25 +182,38 @@ module CurationConcerns
152
182
  @presenter ||= begin
153
183
  # Query Solr for the collection.
154
184
  # run the solr query to find the collection members
155
- response = repository.search(collection_search_builder.query)
185
+ response = repository.search(single_item_search_builder.query)
156
186
  curation_concern = response.documents.first
157
187
  raise CanCan::AccessDenied unless curation_concern
158
188
  presenter_class.new(curation_concern, current_ability)
159
189
  end
160
190
  end
161
191
 
162
- def collection_search_builder
163
- collection_search_builder_class.new(self).with(params.except(:q, :page))
192
+ # Instantiates the search builder that builds a query for a single item
193
+ # this is useful in the show view.
194
+ def single_item_search_builder
195
+ single_item_search_builder_class.new(self).with(params.except(:q, :page))
164
196
  end
165
197
 
166
- def collection_search_builder_class
167
- CurationConcerns::WorkSearchBuilder
198
+ alias collection_search_builder single_item_search_builder
199
+ deprecation_deprecate collection_search_builder: "use single_item_search_builder instead"
200
+
201
+ # Instantiates the search builder that builds a query for items that are
202
+ # members of the current collection. This is used in the show view.
203
+ def member_search_builder
204
+ @member_search_builder ||= member_search_builder_class.new(self)
168
205
  end
169
206
 
170
- def collection_member_search_builder_class
171
- CurationConcerns::CollectionMemberSearchBuilder
207
+ alias collection_member_search_builder member_search_builder
208
+ deprecation_deprecate collection_member_search_builder: "use member_search_builder instead"
209
+
210
+ def list_search_builder
211
+ list_search_builder_class.new(self)
172
212
  end
173
213
 
214
+ alias collections_search_builder list_search_builder
215
+ deprecation_deprecate collections_search_builder: "use list_search_builder instead"
216
+
174
217
  def collection_params
175
218
  form_class.model_attributes(params[:collection])
176
219
  end
@@ -189,7 +232,7 @@ module CurationConcerns
189
232
 
190
233
  # @return <Hash> a representation of the solr query that find the collection members
191
234
  def query_for_collection_members
192
- collection_member_search_builder.with(params_for_members_query).query
235
+ member_search_builder.with(params_for_members_query).query
193
236
  end
194
237
 
195
238
  # You can override this method if you need to provide additional inputs to the search
@@ -200,10 +243,6 @@ module CurationConcerns
200
243
  params.merge(q: params[:cq])
201
244
  end
202
245
 
203
- def collection_member_search_builder
204
- @collection_member_search_builder ||= collection_member_search_builder_class.new(self)
205
- end
206
-
207
246
  def process_member_changes
208
247
  case params[:collection][:members]
209
248
  when 'add' then add_members_to_collection
@@ -0,0 +1,23 @@
1
+ module CurationConcerns
2
+ module PermissionsControllerBehavior
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include CurationConcerns::CurationConcernController
7
+
8
+ def confirm
9
+ end
10
+
11
+ def copy
12
+ authorize! :edit, curation_concern
13
+ VisibilityCopyJob.perform_later(curation_concern)
14
+ flash_message = 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
15
+ redirect_to [main_app, curation_concern], notice: flash_message
16
+ end
17
+
18
+ def curation_concern
19
+ @curation_concern ||= ActiveFedora::Base.find(params[:id])
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,7 +1,9 @@
1
1
  module CurationConcerns::SelectsCollections
2
2
  extend ActiveSupport::Concern
3
+ extend Deprecation
3
4
 
4
5
  included do
6
+ Deprecation.warn(CurationConcerns::SelectsCollections, "CurationConcerns::SelectsCollections is deprecated and will be removed in curation_concerns 2.0")
5
7
  configure_blacklight do |config|
6
8
  config.search_builder_class = CurationConcerns::CollectionSearchBuilder
7
9
  end
@@ -1,18 +1,3 @@
1
1
  class CurationConcerns::PermissionsController < ApplicationController
2
- include CurationConcerns::CurationConcernController
3
- with_themed_layout '1_column'
4
-
5
- def confirm
6
- end
7
-
8
- def copy
9
- authorize! :edit, curation_concern
10
- VisibilityCopyJob.perform_later(curation_concern)
11
- flash_message = 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
12
- redirect_to [main_app, curation_concern], notice: flash_message
13
- end
14
-
15
- def curation_concern
16
- @curation_concern ||= ActiveFedora::Base.find(params[:id])
17
- end
2
+ include CurationConcerns::PermissionsControllerBehavior
18
3
  end
@@ -51,13 +51,6 @@ module CurationConcerns
51
51
  super
52
52
  end
53
53
  end
54
-
55
- # Overriden to cast 'rights' to an array
56
- def sanitize_params(form_params)
57
- super.tap do |params|
58
- params['rights'] = Array.wrap(params['rights']) if params.key?('rights')
59
- end
60
- end
61
54
  end
62
55
 
63
56
  private
@@ -1,23 +1,8 @@
1
1
  # View Helpers for Hydra Batch Edit functionality
2
2
  module BatchSelectHelper
3
- # determines if the given document id is in the batch
4
- # def item_in_batch?(doc_id)
5
- # session[:batch_document_ids] && session[:batch_document_ids].include?(doc_id) ? true : false
6
- # end
7
-
8
- # Displays the batch edit tools. Put this in your search result page template. We recommend putting it in catalog/_sort_and_per_page.html.erb
9
- def batch_select_tools
10
- render partial: '/batch_select/tools'
11
- end
12
-
13
3
  # Displays the button to select/deselect items for your batch. Call this in the index partial that's rendered for each search result.
14
4
  # @param [Hash] document the Hash (aka Solr hit) for one Solr document
15
5
  def button_for_add_to_batch(document)
16
6
  render partial: '/batch_select/add_button', locals: { document: document }
17
7
  end
18
-
19
- # Displays the check all button to select/deselect items for your batch. Put this in your search result page template. We put it in catalog/index.html
20
- def batch_check_all(label = 'Use all results')
21
- render partial: '/batch_select/check_all', locals: { label: label }
22
- end
23
8
  end
@@ -1,4 +1,41 @@
1
1
  module CurationConcerns::CollectionsHelper
2
+ def has_collection_search_parameters?
3
+ !params[:cq].blank?
4
+ end
5
+
6
+ def button_for_remove_from_collection(collection, document, label = 'Remove From Collection')
7
+ render '/collections/button_remove_from_collection', collection: collection, label: label, document: document
8
+ end
9
+
10
+ def button_for_remove_selected_from_collection(collection, label = 'Remove From Collection')
11
+ render '/collections/button_for_remove_selected_from_collection', collection: collection, label: label
12
+ end
13
+
14
+ # add hidden fields to a form for removing a single document from a collection
15
+ def single_item_action_remove_form_fields(form, document)
16
+ single_item_action_form_fields(form, document, 'remove')
17
+ end
18
+
19
+ # add hidden fields to a form for adding a single document to a collection
20
+ def single_item_action_add_form_fields(form, document)
21
+ single_item_action_form_fields(form, document, 'add')
22
+ end
23
+
24
+ # add hidden fields to a form for performing an action on a single document on a collection
25
+ def single_item_action_form_fields(form, document, action)
26
+ render '/collections/single_item_action_fields', form: form, document: document, action: action
27
+ end
28
+
29
+ def hidden_collection_members
30
+ erbout = ''
31
+ if params[:batch_document_ids].present?
32
+ params[:batch_document_ids].each do |batch_item|
33
+ erbout.concat hidden_field_tag('batch_document_ids[]', batch_item)
34
+ end
35
+ end
36
+ erbout.html_safe
37
+ end
38
+
2
39
  def collection_modal_id(collectible)
3
40
  "#{collectible.to_param.tr(':', '-')}-modal"
4
41
  end
@@ -49,13 +86,10 @@ module CurationConcerns::CollectionsHelper
49
86
  if current_user.respond_to?(:collections)
50
87
  return current_user.collections.map { |c| [c.title.join(', '), c.id] }
51
88
  end
52
- query = ActiveFedora::SolrQueryBuilder
53
- .construct_query_for_rel(
54
- has_model: Collection.to_class_uri)
55
89
  convert_solr_docs_to_select_options(
56
- ActiveFedora::SolrService.query(query,
57
- fl: 'title_tesim id',
58
- rows: 1000)
90
+ ::Collection.search_with_conditions({},
91
+ fl: 'title_tesim id',
92
+ rows: 1000)
59
93
  )
60
94
  end
61
95
 
@@ -8,6 +8,4 @@ module CurationConcerns::MainAppHelpers
8
8
  include CurationConcerns::EmbargoHelper
9
9
  include CurationConcerns::LeaseHelper
10
10
  include CurationConcerns::CollectionsHelper
11
- include CurationConcerns::PermissionsHelper
12
- include CurationConcerns::RightsHelper
13
11
  end
@@ -3,13 +3,15 @@ class CharacterizeJob < ActiveJob::Base
3
3
 
4
4
  # @param [FileSet] file_set
5
5
  # @param [String] file_id identifier for a Hydra::PCDM::File
6
- def perform(file_set, file_id)
7
- filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id)
6
+ # @param [String, NilClass] filepath the cached file within the CurationConcerns.config.working_path
7
+ def perform(file_set, file_id, filepath = nil)
8
+ filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id, filepath)
8
9
  raise LoadError, "#{file_set.class.characterization_proxy} was not found" unless file_set.characterization_proxy?
9
10
  Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filename)
10
11
  Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
11
12
  file_set.characterization_proxy.save!
12
13
  file_set.update_index
13
- CreateDerivativesJob.perform_later(file_set, file_id)
14
+ file_set.parent.in_collections.each(&:update_index) if file_set.parent
15
+ CreateDerivativesJob.perform_later(file_set, file_id, filename)
14
16
  end
15
17
  end
@@ -3,9 +3,10 @@ class CreateDerivativesJob < ActiveJob::Base
3
3
 
4
4
  # @param [FileSet] file_set
5
5
  # @param [String] file_id identifier for a Hydra::PCDM::File
6
- def perform(file_set, file_id)
6
+ # @param [String, NilClass] filepath the cached file within the CurationConcerns.config.working_path
7
+ def perform(file_set, file_id, filepath = nil)
7
8
  return if file_set.video? && !CurationConcerns.config.enable_ffmpeg
8
- filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id)
9
+ filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id, filepath)
9
10
 
10
11
  file_set.create_derivatives(filename)
11
12
 
@@ -2,36 +2,36 @@ class IngestFileJob < ActiveJob::Base
2
2
  queue_as CurationConcerns.config.ingest_queue_name
3
3
 
4
4
  # @param [FileSet] file_set
5
- # @param [String] filename the cached file within the CurationConcerns.config.working_path
6
- # @param [String,NilClass] mime_type
5
+ # @param [String] filepath the cached file within the CurationConcerns.config.working_path
7
6
  # @param [User] user
8
- # @param [String] relation ('original_file')
9
- def perform(file_set, filename, mime_type, user, relation = 'original_file')
10
- local_file = File.open(filename, "rb")
11
- # If mime-type is known, wrap in an IO decorator
12
- # Otherwise allow Hydra::Works service to determine mime_type
13
- if mime_type
14
- local_file = Hydra::Derivatives::IoDecorator.new(local_file)
15
- local_file.mime_type = mime_type
16
- local_file.original_name = File.basename(filename)
17
- end
7
+ # @option opts [String] mime_type
8
+ # @option opts [String] filename
9
+ # @option opts [String] relation, ex. :original_file
10
+ def perform(file_set, filepath, user, opts = {})
11
+ relation = opts.fetch(:relation, :original_file).to_sym
18
12
 
19
- # Tell AddFileToFileSet service to skip versioning because versions will be minted by VersionCommitter (called by save_characterize_and_record_committer) when necessary
13
+ # Wrap in an IO decorator to attach passed-in options
14
+ local_file = Hydra::Derivatives::IoDecorator.new(File.open(filepath, "rb"))
15
+ local_file.mime_type = opts.fetch(:mime_type, nil)
16
+ local_file.original_name = opts.fetch(:filename, File.basename(filepath))
17
+
18
+ # Tell AddFileToFileSet service to skip versioning because versions will be minted by
19
+ # VersionCommitter when necessary during save_characterize_and_record_committer.
20
20
  Hydra::Works::AddFileToFileSet.call(file_set,
21
21
  local_file,
22
- relation.to_sym,
22
+ relation,
23
23
  versioning: false)
24
24
 
25
25
  # Persist changes to the file_set
26
26
  file_set.save!
27
27
 
28
- repository_file = file_set.send(relation.to_sym)
28
+ repository_file = file_set.send(relation)
29
29
 
30
30
  # Do post file ingest actions
31
31
  CurationConcerns::VersioningService.create(repository_file, user)
32
32
 
33
33
  # TODO: this is a problem, the file may not be available at this path on another machine.
34
34
  # It may be local, or it may be in s3
35
- CharacterizeJob.perform_later(file_set, repository_file.id)
35
+ CharacterizeJob.perform_later(file_set, repository_file.id, filepath)
36
36
  end
37
37
  end
@@ -17,6 +17,11 @@ module CurationConcerns
17
17
  property :description, predicate: ::RDF::Vocab::DC.description do |index|
18
18
  index.as :stored_searchable
19
19
  end
20
+
21
+ property :creator, predicate: ::RDF::Vocab::DC11.creator do |index|
22
+ index.as :symbol
23
+ end
24
+
20
25
  has_many :members,
21
26
  predicate: ::RDF::Vocab::DC.isPartOf,
22
27
  class_name: 'ActiveFedora::Base'
@@ -28,9 +28,17 @@ module CurationConcerns
28
28
  property :keyword, predicate: ::RDF::Vocab::DC11.relation do |index|
29
29
  index.as :stored_searchable, :facetable
30
30
  end
31
+
32
+ # Used for a license
31
33
  property :rights, predicate: ::RDF::Vocab::DC.rights do |index|
32
34
  index.as :stored_searchable
33
35
  end
36
+
37
+ # This is for the rights statement
38
+ property :rights_statement, predicate: ::RDF::Vocab::EDM.rights do |index|
39
+ index.as :stored_searchable
40
+ end
41
+
34
42
  property :publisher, predicate: ::RDF::Vocab::DC11.publisher do |index|
35
43
  index.as :stored_searchable, :facetable
36
44
  end
@@ -14,7 +14,7 @@ module CurationConcerns
14
14
  end
15
15
 
16
16
  def to_s
17
- title.present? ? title : 'No Title'
17
+ title.present? ? title.join(' | ') : 'No Title'
18
18
  end
19
19
 
20
20
  module ClassMethods
@@ -35,11 +35,10 @@ module CurationConcerns
35
35
 
36
36
  # One query per member_id because Solr is not a relational database
37
37
  sizes = member_ids.collect do |work_id|
38
- query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::FileSet.to_class_uri)
39
38
  argz = { fl: "id, #{file_size_field}",
40
39
  fq: "{!join from=#{member_ids_field} to=id}id:#{work_id}"
41
40
  }
42
- files = ActiveFedora::SolrService.query(query, argz)
41
+ files = ::FileSet.search_with_conditions({}, argz)
43
42
  files.reduce(0) { |sum, f| sum + f[file_size_field].to_i }
44
43
  end
45
44
 
@@ -2,9 +2,9 @@ module CurationConcerns
2
2
  module Serializers
3
3
  def to_s
4
4
  if title.present?
5
- Array.wrap(title).join(' | ')
5
+ title.join(' | ')
6
6
  elsif label.present?
7
- Array.wrap(label).join(' | ')
7
+ label
8
8
  else
9
9
  'No Title'
10
10
  end
@@ -66,7 +66,7 @@ module CurationConcerns
66
66
  end
67
67
 
68
68
  def thumbnail_id
69
- first(Solrizer.solr_name('thumbnail_id', :symbol))
69
+ first(Solrizer.solr_name('hasRelatedImage', :symbol))
70
70
  end
71
71
 
72
72
  # Date created is indexed as a string. This allows users to enter values like: 'Circa 1840-1844'
@@ -104,7 +104,8 @@ module CurationConcerns
104
104
  end
105
105
 
106
106
  def creator
107
- fetch(Solrizer.solr_name('creator'), [])
107
+ descriptor = hydra_model.index_config[:creator].behaviors.first
108
+ fetch(Solrizer.solr_name('creator', descriptor), [])
108
109
  end
109
110
 
110
111
  def contributor