hyrax 5.0.0.rc1 → 5.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +11 -4
  3. data/.dassie/.env +5 -1
  4. data/.dassie/Gemfile +27 -42
  5. data/.dassie/Gemfile.dassie +2 -0
  6. data/.dassie/app/assets/config/manifest.js +2 -0
  7. data/.dassie/app/assets/stylesheets/hyrax.scss +1 -0
  8. data/.dassie/config/initializers/riiif.rb +5 -11
  9. data/.dassie/config/metadata/collection_resource.yaml +3 -0
  10. data/.dassie/config/metadata/monograph.yaml +8 -0
  11. data/.dassie/config/metadata/sample_metadata.yaml +1 -0
  12. data/.dassie/config/redis.yml +2 -0
  13. data/.dassie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  14. data/.dassie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  15. data/.dassie/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.hyrax.rb +8 -0
  16. data/.dassie/db/migrate/20230821153635_add_fields_to_counter_metric.rb +8 -0
  17. data/.dassie/db/schema.rb +20 -1
  18. data/.dockerignore +2 -1
  19. data/.gitignore +1 -1
  20. data/.koppie/.env +10 -4
  21. data/.koppie/Gemfile +10 -12
  22. data/.koppie/Gemfile.koppie +2 -0
  23. data/.koppie/Rakefile +0 -2
  24. data/.koppie/app/forms/collection_resource_form.rb +0 -1
  25. data/.koppie/app/indexers/collection_resource_indexer.rb +0 -1
  26. data/.koppie/app/models/ability.rb +1 -5
  27. data/.koppie/app/models/collection_resource.rb +0 -1
  28. data/.koppie/app/models/user.rb +0 -2
  29. data/.koppie/config/application.rb +2 -1
  30. data/.koppie/config/arkivo.yml +6 -0
  31. data/.koppie/config/blacklight.yml +2 -2
  32. data/.koppie/config/features.yml +2 -0
  33. data/.koppie/config/initializers/1_valkyrie.rb +29 -6
  34. data/.koppie/config/initializers/arkivo_constraint.rb +12 -0
  35. data/.koppie/config/initializers/hyrax.rb +2 -2
  36. data/.koppie/config/initializers/riiif.rb +6 -11
  37. data/.koppie/config/metadata/collection_resource.yaml +177 -1
  38. data/.koppie/config/metadata/generic_work.yaml +2 -0
  39. data/.koppie/config/metadata/monograph.yaml +10 -0
  40. data/.koppie/config/role_map.yml +3 -25
  41. data/.koppie/config/routes.rb +1 -2
  42. data/.koppie/config/solr.yml +1 -1
  43. data/.koppie/config/valkyrie_index.yml +4 -10
  44. data/.koppie/config/zotero.yml +6 -0
  45. data/.koppie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  46. data/.koppie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  47. data/.koppie/db/schema.rb +12 -1
  48. data/CONTAINERS.md +1 -3
  49. data/Dockerfile +11 -2
  50. data/Gemfile +4 -21
  51. data/Gemfile.dassie +2 -0
  52. data/Gemfile.koppie +2 -0
  53. data/README.md +0 -1
  54. data/Rakefile +0 -11
  55. data/app/actors/hyrax/actors/embargo_actor.rb +3 -6
  56. data/app/assets/javascripts/hyrax/batch_select_all.js +1 -1
  57. data/app/assets/javascripts/hyrax/file_manager/member.es6 +1 -1
  58. data/app/assets/stylesheets/hyrax/_file-listing.scss +0 -2
  59. data/app/assets/stylesheets/hyrax/_work-show.scss +19 -3
  60. data/app/assets/stylesheets/hyrax/sidebar.scss +23 -0
  61. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +7 -1
  62. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +7 -1
  63. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +14 -9
  64. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +50 -9
  65. data/app/controllers/hyrax/api/items_controller.rb +2 -3
  66. data/app/controllers/hyrax/batch_edits_controller.rb +6 -6
  67. data/app/controllers/hyrax/batch_uploads_controller.rb +5 -1
  68. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  69. data/app/controllers/hyrax/file_sets_controller.rb +49 -6
  70. data/app/controllers/hyrax/my/collections_controller.rb +2 -0
  71. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +16 -2
  72. data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +38 -0
  73. data/app/forms/hyrax/forms/collection_form.rb +0 -15
  74. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +0 -34
  75. data/app/forms/hyrax/forms/file_set_form.rb +2 -2
  76. data/app/forms/hyrax/forms/pcdm_object_form.rb +21 -0
  77. data/app/forms/hyrax/forms/permission_template_form.rb +0 -7
  78. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +49 -21
  79. data/app/forms/hyrax/forms/resource_form.rb +21 -34
  80. data/app/helpers/hyrax/dashboard_helper_behavior.rb +13 -0
  81. data/app/indexers/hyrax/location_indexer.rb +29 -0
  82. data/app/indexers/hyrax/pcdm_collection_indexer.rb +0 -8
  83. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +1 -6
  84. data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -0
  85. data/app/inputs/controlled_vocabulary_input.rb +1 -1
  86. data/app/jobs/characterize_job.rb +1 -1
  87. data/app/jobs/create_work_job.rb +36 -4
  88. data/app/jobs/valkyrie_characterization_job.rb +9 -0
  89. data/app/jobs/valkyrie_ingest_job.rb +1 -3
  90. data/app/models/collection_branding_info.rb +2 -9
  91. data/app/models/concerns/hyrax/ability.rb +2 -1
  92. data/app/models/concerns/hyrax/collection_behavior.rb +4 -12
  93. data/app/models/concerns/hyrax/riiif_file.rb +30 -0
  94. data/app/models/concerns/hyrax/solr_document_behavior.rb +19 -2
  95. data/app/models/hyrax/counter_metric.rb +7 -0
  96. data/app/models/hyrax/file_metadata.rb +3 -2
  97. data/app/models/hyrax/file_set.rb +75 -22
  98. data/app/models/hyrax/orcid_validator.rb +0 -6
  99. data/app/models/hyrax/work.rb +2 -5
  100. data/app/presenters/hyrax/collection_presenter.rb +0 -17
  101. data/app/presenters/hyrax/embargo_presenter.rb +4 -0
  102. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +6 -4
  103. data/app/presenters/hyrax/version_list_presenter.rb +19 -10
  104. data/app/presenters/hyrax/version_presenter.rb +19 -4
  105. data/app/services/hyrax/admin_set_create_service.rb +0 -17
  106. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +5 -0
  107. data/app/services/hyrax/collections/collection_member_service.rb +1 -1
  108. data/app/services/hyrax/embargo_manager.rb +45 -18
  109. data/app/services/hyrax/embargo_service.rb +12 -10
  110. data/app/services/hyrax/file_set_derivatives_service.rb +11 -11
  111. data/app/services/hyrax/fixity_check_failure_service.rb +1 -1
  112. data/app/services/hyrax/identifier/dispatcher.rb +9 -2
  113. data/app/services/hyrax/listeners/file_metadata_listener.rb +14 -6
  114. data/app/services/hyrax/listeners/member_cleanup_listener.rb +2 -28
  115. data/app/services/hyrax/listeners/metadata_index_listener.rb +11 -0
  116. data/app/services/hyrax/lock_manager.rb +1 -2
  117. data/app/services/hyrax/riiif_file_resolver.rb +50 -0
  118. data/app/services/hyrax/simple_schema_loader.rb +31 -0
  119. data/app/services/hyrax/valkyrie_persist_derivatives.rb +1 -1
  120. data/app/services/hyrax/valkyrie_upload.rb +12 -26
  121. data/app/services/hyrax/versioning_service.rb +29 -15
  122. data/app/services/hyrax/work_uploads_handler.rb +1 -1
  123. data/app/validators/hyrax/collection_membership_validator.rb +1 -1
  124. data/app/views/catalog/_search_form.html.erb +1 -1
  125. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  126. data/app/views/hyrax/base/_file_manager_resource_form.html.erb +1 -1
  127. data/app/views/hyrax/base/_form_visibility_component.html.erb +4 -4
  128. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  129. data/app/views/hyrax/base/_workflow_actions.html.erb +25 -23
  130. data/app/views/hyrax/base/show.json.jbuilder +2 -1
  131. data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
  132. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  133. data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
  134. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +3 -3
  135. data/app/views/hyrax/file_sets/_versioning.html.erb +5 -5
  136. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +4 -4
  137. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  138. data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
  139. data/app/views/hyrax/my/_search_form.html.erb +1 -1
  140. data/app/views/hyrax/notifications/_notifications.html.erb +1 -1
  141. data/app/views/hyrax/users/_vitals.html.erb +1 -1
  142. data/bin/dev-entrypoint.sh +13 -0
  143. data/chart/hyrax/Chart.yaml +3 -3
  144. data/chart/hyrax/templates/_helpers.tpl +8 -0
  145. data/chart/hyrax/templates/configmap-env.yaml +1 -1
  146. data/chart/hyrax/values.yaml +3 -0
  147. data/config/initializers/file_length_patch.rb +10 -0
  148. data/config/metadata/basic_metadata.yaml +52 -0
  149. data/config/metadata/core_metadata.yaml +4 -0
  150. data/config/metadata/file_set_metadata.yaml +19 -0
  151. data/config/metadata/hyrax_internal_metadata.yaml +57 -0
  152. data/docker-compose-koppie.yml +23 -22
  153. data/docker-compose-sirenia.yml +202 -0
  154. data/docker-compose.yml +27 -24
  155. data/documentation/developing-your-hyrax-based-app.md +2 -2
  156. data/hyrax.gemspec +10 -11
  157. data/karma.conf.js +1 -1
  158. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +2 -0
  159. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +13 -19
  160. data/lib/generators/hyrax/templates/db/migrate/20230725222727_create_hyrax_counter_metrics.rb.erb +14 -0
  161. data/lib/generators/hyrax/templates/db/migrate/20230803165135_change_work_id_to_string.rb.erb +5 -0
  162. data/lib/generators/hyrax/templates/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.rb.erb +8 -0
  163. data/lib/generators/hyrax/templates/db/migrate/20230821153635_add_fields_to_counter_metric.rb.erb +8 -0
  164. data/lib/generators/hyrax/templates/db/seeds.rb +1 -1
  165. data/lib/generators/hyrax/work_resource/templates/form.rb.erb +1 -1
  166. data/lib/generators/hyrax/work_resource/templates/metadata.yaml +2 -0
  167. data/lib/hyrax/configuration.rb +147 -49
  168. data/lib/hyrax/controlled_vocabularies/location.rb +7 -1
  169. data/lib/hyrax/engine.rb +0 -1
  170. data/lib/hyrax/form_fields.rb +6 -0
  171. data/lib/hyrax/publisher.rb +4 -0
  172. data/lib/hyrax/redis_event_store.rb +7 -8
  173. data/lib/hyrax/resource_name.rb +4 -0
  174. data/lib/hyrax/specs/capybara.rb +25 -42
  175. data/lib/hyrax/specs/shared_specs/hydra_works.rb +34 -7
  176. data/lib/hyrax/specs/shared_specs/indexers.rb +24 -6
  177. data/lib/hyrax/transactions/collection_destroy.rb +3 -2
  178. data/lib/hyrax/transactions/container.rb +42 -0
  179. data/lib/hyrax/transactions/file_metadata_destroy.rb +20 -0
  180. data/lib/hyrax/transactions/file_set_destroy.rb +3 -1
  181. data/lib/hyrax/transactions/file_set_update.rb +21 -0
  182. data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -1
  183. data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +46 -0
  184. data/lib/hyrax/transactions/steps/delete_all_file_sets.rb +46 -0
  185. data/lib/hyrax/transactions/steps/file_metadata_delete.rb +40 -0
  186. data/lib/hyrax/transactions/steps/remove_from_membership.rb +45 -0
  187. data/lib/hyrax/transactions/work_destroy.rb +3 -2
  188. data/lib/hyrax/version.rb +1 -1
  189. data/lib/tasks/collection_type_global_id.rake +9 -4
  190. data/lib/tasks/embargo_lease.rake +1 -0
  191. data/lib/valkyrie/indexing/solr/indexing_adapter.rb +2 -0
  192. data/lib/wings/active_fedora_converter.rb +6 -0
  193. data/lib/wings/attribute_transformer.rb +24 -17
  194. data/lib/wings/model_transformer.rb +0 -8
  195. data/lib/wings/orm_converter.rb +23 -18
  196. data/lib/wings/setup.rb +2 -2
  197. data/lib/wings/valkyrie/storage.rb +8 -90
  198. data/lib/wings.rb +5 -0
  199. data/tasks/hyrax_dev.rake +2 -33
  200. data/template.rb +1 -1
  201. metadata +90 -72
  202. data/.engine_cart.yml +0 -3
  203. data/app/views/hyrax/users/_user_util_links_extra.html.erb +0 -0
  204. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +0 -9
@@ -8,38 +8,12 @@ module Hyrax
8
8
  # Called when 'object.deleted' event is published
9
9
  # @param [Dry::Events::Event] event
10
10
  # @return [void]
11
- def on_object_deleted(event)
12
- return unless event.payload.key?(:object) # legacy callback
13
- return if event[:object].is_a?(ActiveFedora::Base) # handled by legacy code
14
-
15
- Hyrax.custom_queries.find_child_file_sets(resource: event[:object]).each do |file_set|
16
- Hyrax.persister.delete(resource: file_set)
17
- Hyrax.publisher
18
- .publish('object.deleted', object: file_set, id: file_set.id, user: event[:user])
19
- rescue StandardError # we don't uncaught errors looping filesets
20
- Hyrax.logger.warn "Failed to delete #{file_set.class}:#{file_set.id} " \
21
- "during cleanup for resource: #{event[:object]}. " \
22
- 'This member may now be orphaned.'
23
- end
24
- end
11
+ def on_object_deleted(event); end
25
12
 
26
13
  # Called when 'collection.deleted' event is published
27
14
  # @param [Dry::Events::Event] event
28
15
  # @return [void]
29
- def on_collection_deleted(event)
30
- return unless event.payload.key?(:collection) # legacy callback
31
- return if event[:collection].is_a?(ActiveFedora::Base) # handled by legacy code
32
-
33
- Hyrax.custom_queries.find_members_of(collection: event[:collection]).each do |resource|
34
- resource.member_of_collection_ids -= [event[:collection].id]
35
- Hyrax.persister.save(resource: resource)
36
- Hyrax.publisher
37
- .publish('collection.membership.updated', collection: event[:collection], user: event[:user])
38
- rescue StandardError
39
- Hyrax.logger.warn "Failed to remove collection reference from #{work.class}:#{work.id} " \
40
- "during cleanup for collection: #{event[:collection]}. "
41
- end
42
- end
16
+ def on_collection_deleted(event); end
43
17
  end
44
18
  end
45
19
  end
@@ -83,6 +83,17 @@ module Hyrax
83
83
  Hyrax.index_adapter.delete(resource: event[:collection])
84
84
  end
85
85
 
86
+ ##
87
+ # Remove the resource from the index.
88
+ #
89
+ # Called when 'file.metadata.deleted' event is published
90
+ # @param [Dry::Events::Event] event
91
+ # @return [void]
92
+ def on_file_metadata_deleted(event)
93
+ return unless resource? event.payload[:metadata]
94
+ Hyrax.index_adapter.delete(resource: event[:metadata])
95
+ end
96
+
86
97
  private
87
98
 
88
99
  def resource?(resource)
@@ -47,11 +47,10 @@ module Hyrax
47
47
  # @api private
48
48
  #
49
49
  # @note support both a ConnectionPool and a raw Redis client for now.
50
- # we should drop support for `Redis.current` in 5.0.0.
51
50
  # `#then` supports both options. for a ConnectionPool it will block
52
51
  # until a connection is available.
53
52
  def pool
54
- Hyrax.config.redis_connection || Redis.current
53
+ Hyrax.config.redis_connection || Redis.new
55
54
  end
56
55
  end
57
56
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ # Riiif file resolver for valkyrie resources
4
+ class RiiifFileResolver
5
+ include ActiveSupport::Benchmarkable
6
+
7
+ # @param [String] id from iiif manifest
8
+ # @return [Riiif::File]
9
+ def find(id)
10
+ path = nil
11
+ file_locks[id].with_write_lock do
12
+ path = build_path(id)
13
+ path = build_path(id, force: true) unless File.exist?(path) # Ensures the file is locally available
14
+ end
15
+ RiiifFile.new(path, id: id)
16
+ end
17
+
18
+ # tracks individual file locks
19
+ # @see RiiifFile
20
+ # @return [Concurrent::Map<Concurrent::ReadWriteLock>]
21
+ def file_locks
22
+ @file_locks ||= Concurrent::Map.new do |k, v|
23
+ k.compute_if_absent(v) { Concurrent::ReadWriteLock.new }
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def build_path(id, force: false)
30
+ Riiif::Image.cache.fetch("riiif:" + Digest::MD5.hexdigest("path:#{id}"),
31
+ expires_in: Riiif::Image.expires_in,
32
+ force: force) do
33
+ load_file(id)
34
+ end
35
+ end
36
+
37
+ def load_file(id)
38
+ benchmark "RiiifFileResolver loaded #{id}", level: :debug do
39
+ fs_id = id.sub(/\A([^\/]*)\/.*/, '\1')
40
+ file_set = Hyrax.query_service.find_by(id: fs_id)
41
+ file_metadata = Hyrax.custom_queries.find_original_file(file_set: file_set)
42
+ file_metadata.file.disk_path.to_s # Stores a local copy in tmpdir
43
+ end
44
+ end
45
+
46
+ def logger
47
+ Hyrax.logger
48
+ end
49
+ end
50
+ end
@@ -43,6 +43,12 @@ module Hyrax
43
43
  end
44
44
  end
45
45
 
46
+ def permissive_schema_for_valkrie_adapter
47
+ metadata_files.each_with_object({}) do |schema_name, ret_hsh|
48
+ predicate_pairs(ret_hsh, schema_name)
49
+ end
50
+ end
51
+
46
52
  ##
47
53
  # @api private
48
54
  class AttributeDefinition
@@ -154,5 +160,30 @@ module Hyrax
154
160
  def config_search_paths
155
161
  [Rails.root, Hyrax::Engine.root]
156
162
  end
163
+
164
+ def metadata_files
165
+ file_name_arr = []
166
+ config_search_paths.each { |root_path| file_name_arr += Dir.entries(root_path.to_s + "/config/metadata/") }
167
+ file_name_arr.reject { |fn| !fn.include?('.yaml') }.uniq.map { |y| y.gsub('.yaml', '') }
168
+ end
169
+
170
+ def predicate_pairs(ret_hsh, schema_name)
171
+ schema_config(schema_name)['attributes'].each do |name, config|
172
+ predicate = RDF::URI(config['predicate'])
173
+ if ret_hsh[name].blank?
174
+ ret_hsh[name.to_sym] = predicate
175
+ elsif ret_hsh[name] != predicate
176
+ multiple_predicate_message(name, ret_hsh[name], predicate)
177
+ end
178
+ end
179
+ end
180
+
181
+ def multiple_predicate_message(name, existing, incoming)
182
+ message = "The attribute of #{name} has been assigned a predicate multiple times " \
183
+ "within the metadata YAMLs. Please be aware that once the attribute's " \
184
+ "predicate value is first assigned, any other value will be ignored. " \
185
+ "The existing value is #{existing} preventing the use of #{incoming}"
186
+ Hyrax.logger.warn(message)
187
+ end
157
188
  end
158
189
  end
@@ -32,7 +32,7 @@ module Hyrax
32
32
 
33
33
  filename = filename(directives)
34
34
  Hyrax.logger.debug "Uploading derivative for FileSet #{file_set.id} as #{filename}"
35
- uploader.upload(io: tmpfile, filename: filename, file_set: file_set, use: file_metadata(directives))
35
+ uploader.upload(io: tmpfile, filename: filename, file_set: file_set, use: file_metadata(directives), mime_type: directives[:mime_type])
36
36
  end
37
37
 
38
38
  # The filepath will look something like
@@ -34,12 +34,15 @@ class Hyrax::ValkyrieUpload
34
34
  @storage_adapter = storage_adapter
35
35
  end
36
36
 
37
- def upload(filename:, file_set:, io:, use: Hyrax::FileMetadata::Use::ORIGINAL_FILE, user: nil)
37
+ def upload(filename:, file_set:, io:, use: Hyrax::FileMetadata::Use::ORIGINAL_FILE, user: nil, mime_type: nil) # rubocop:disable Metrics/AbcSize
38
+ return version_upload(file_set: file_set, io: io, user: user) if use == Hyrax::FileMetadata::Use::ORIGINAL_FILE && file_set.original_file_id && storage_adapter.supports?(:versions)
38
39
  streamfile = storage_adapter.upload(file: io, original_filename: filename, resource: file_set)
39
40
  file_metadata = Hyrax::FileMetadata(streamfile)
40
41
  file_metadata.file_set_id = file_set.id
41
42
  file_metadata.pcdm_use = [use]
42
43
  file_metadata.recorded_size = [io.size]
44
+ file_metadata.mime_type = mime_type if mime_type
45
+ file_metadata.original_filename = File.basename(filename).to_s || File.basename(io)
43
46
 
44
47
  if use == Hyrax::FileMetadata::Use::ORIGINAL_FILE
45
48
  # Set file set label.
@@ -63,6 +66,13 @@ class Hyrax::ValkyrieUpload
63
66
  saved_metadata
64
67
  end
65
68
 
69
+ def version_upload(file_set:, io:, user:)
70
+ file_metadata = Hyrax.query_service.custom_queries.find_file_metadata_by(id: file_set.original_file_id)
71
+ Hyrax::VersioningService.create(file_metadata, user, io)
72
+ Hyrax.publisher.publish("file.uploaded", metadata: file_metadata)
73
+ ContentNewVersionEventJob.perform_later(file_set, user)
74
+ end
75
+
66
76
  # @param [Hyrax::FileSet] file_set the file set to add to
67
77
  # @param [Hyrax::FileMetadata] file_metadata the metadata object representing
68
78
  # the file to add
@@ -70,32 +80,8 @@ class Hyrax::ValkyrieUpload
70
80
  #
71
81
  # @return [Hyrax::FileSet] updated file set
72
82
  def add_file_to_file_set(file_set:, file_metadata:, user:)
73
- file_set.file_ids << file_metadata.id
74
- set_file_use_ids(file_set, file_metadata)
75
-
83
+ file_set.file_ids += [file_metadata.id]
76
84
  Hyrax.persister.save(resource: file_set)
77
85
  Hyrax.publisher.publish('object.membership.updated', object: file_set, user: user)
78
86
  end
79
-
80
- private
81
-
82
- # @api private
83
- # @param [Hyrax::FileSet] file_set the file set to add to
84
- # @param [Hyrax::FileMetadata] file_metadata the metadata object representing
85
- # the file to add
86
- # @return [void]
87
- def set_file_use_ids(file_set, file_metadata)
88
- file_metadata.pcdm_use.each do |type|
89
- case type
90
- when Hyrax::FileMetadata::Use::ORIGINAL_FILE
91
- file_set.original_file_id = file_metadata.id
92
- when Hyrax::FileMetadata::Use::THUMBNAIL
93
- file_set.thumbnail_id = file_metadata.id
94
- when Hyrax::FileMetadata::Use::EXTRACTED_TEXT
95
- file_set.extracted_text_id = file_metadata.id
96
- else
97
- Hyrax.logger.warn "Unknown file use #{file_metadata.type} specified for #{file_metadata.file_identifier}"
98
- end
99
- end
100
- end
101
87
  end
@@ -32,14 +32,12 @@ module Hyrax
32
32
  # If the resource is nil, or if it is a Hyrax::FileMetadata and versioning
33
33
  # is not supported in the storage adapter, an empty array will be returned.
34
34
  def versions
35
- if resource.nil?
35
+ if !supports_multiple_versions?
36
36
  []
37
37
  elsif resource.is_a?(Hyrax::FileMetadata)
38
- if storage_adapter.try(:"supports?", :versions)
39
- storage_adapter.find_versions(id: resource.file_identifier).to_a
40
- else
41
- []
42
- end
38
+ # Reverse - Valkyrie puts these most recent first, we assume most recent
39
+ # last.
40
+ storage_adapter.find_versions(id: resource.file_identifier).to_a.reverse
43
41
  else
44
42
  return resource.versions if resource.versions.is_a?(Array)
45
43
  resource.versions.all.to_a
@@ -53,6 +51,16 @@ module Hyrax
53
51
  versions.last
54
52
  end
55
53
 
54
+ ##
55
+ # Returns whether support for multiple versions exists on this
56
+ # +Hyrax::VersioningService+.
57
+ #
58
+ # Versioning is unsupported on nil resources or on Valkyrie resources when
59
+ # the configured storage adapter does not advertise versioning support.
60
+ def supports_multiple_versions?
61
+ !(resource.nil? || resource.is_a?(Hyrax::FileMetadata) && !storage_adapter.try(:"supports?", :versions))
62
+ end
63
+
56
64
  ##
57
65
  # Returns the file ID of the latest version of the file associated with this
58
66
  # Hyrax::VersioningService, or the ID of the file resource itself if no
@@ -61,7 +69,7 @@ module Hyrax
61
69
  # If the resource is nil, this method returns an empty string.
62
70
  def versioned_file_id
63
71
  latest = latest_version
64
- if latest
72
+ if latest && !resource.is_a?(Hyrax::FileMetadata)
65
73
  if latest.respond_to?(:id)
66
74
  latest.id
67
75
  else
@@ -70,7 +78,7 @@ module Hyrax
70
78
  elsif resource.nil?
71
79
  ""
72
80
  elsif resource.is_a?(Hyrax::FileMetadata)
73
- resource.file_identifier
81
+ latest_version&.version_id || resource.file_identifier
74
82
  else
75
83
  resource.id
76
84
  end
@@ -80,9 +88,9 @@ module Hyrax
80
88
  # Make a version and record the version committer
81
89
  # @param [ActiveFedora::File | Hyrax::FileMetadata] content
82
90
  # @param [User, String] user
83
- def create(content, user = nil)
91
+ def create(content, user = nil, file = nil)
84
92
  use_valkyrie = content.is_a? Hyrax::FileMetadata
85
- perform_create(content, user, use_valkyrie)
93
+ perform_create(content, user, file, use_valkyrie)
86
94
  end
87
95
 
88
96
  # @param [ActiveFedora::File | Hyrax::FileMetadata] file
@@ -102,14 +110,14 @@ module Hyrax
102
110
  user_key = user_key.user_key if user_key.respond_to?(:user_key)
103
111
  version = latest_version_of(content)
104
112
  return if version.nil?
105
- version_id = content.is_a?(Hyrax::FileMetadata) ? version.id.to_s : version.uri
113
+ version_id = content.is_a?(Hyrax::FileMetadata) ? version.version_id.to_s : version.uri
106
114
  Hyrax::VersionCommitter.create(version_id: version_id, committer_login: user_key)
107
115
  end
108
116
 
109
117
  private
110
118
 
111
- def perform_create(content, user, use_valkyrie)
112
- use_valkyrie ? perform_create_through_valkyrie(content, user) : perform_create_through_active_fedora(content, user)
119
+ def perform_create(content, user, file, use_valkyrie)
120
+ use_valkyrie ? perform_create_through_valkyrie(content, file, user) : perform_create_through_active_fedora(content, user)
113
121
  rescue NotImplementedError
114
122
  Hyrax.logger.warn "Declining to create a Version for #{content}; #{self} doesn't support versioning with use_valkyrie: #{use_valkyrie}"
115
123
  end
@@ -119,8 +127,14 @@ module Hyrax
119
127
  record_committer(content, user) if user
120
128
  end
121
129
 
122
- def perform_create_through_valkyrie(content, user) # no-op
123
- raise NotImplementedError
130
+ def perform_create_through_valkyrie(content, file, user)
131
+ raise NotImplementedError unless Hyrax.storage_adapter.supports?(:versions)
132
+ Hyrax.storage_adapter.upload_version(id: content.file_identifier, file: file)
133
+ record_committer(content, user) if user
134
+ end
135
+
136
+ def storage_adapter
137
+ Hyrax.storage_adapter
124
138
  end
125
139
  end
126
140
  end
@@ -124,7 +124,7 @@ module Hyrax
124
124
  #
125
125
  # @todo figure out how to know less about Work's ideas about FileSet use here. Maybe post-Wings, work.
126
126
  def append_to_work(file_set)
127
- work.member_ids << file_set.id
127
+ work.member_ids += [file_set.id]
128
128
  work.representative_id = file_set.id if work.respond_to?(:representative_id) && work.representative_id.blank?
129
129
  work.thumbnail_id = file_set.id if work.respond_to?(:thumbnail_id) && work.thumbnail_id.blank?
130
130
  end
@@ -29,7 +29,7 @@ module Hyrax
29
29
  record.member_of_collections_attributes
30
30
  .each do |_k, h|
31
31
  next if h["_destroy"] == "true"
32
- collection_ids << Valkyrie::ID.new(h["id"])
32
+ collection_ids += [Valkyrie::ID.new(h["id"])]
33
33
  end
34
34
  end
35
35
 
@@ -8,7 +8,7 @@
8
8
  </label>
9
9
 
10
10
  <div class="input-group col-sm-9">
11
- <%= text_field_tag :q, current_search_parameters , class: "q form-control", id: "search-field-header", placeholder: t("hyrax.search.form.q.placeholder") %>
11
+ <%= text_field_tag :q, current_search_parameters , 'aria-label': 'Search', class: "q form-control", id: "search-field-header", placeholder: t("hyrax.search.form.q.placeholder") %>
12
12
 
13
13
  <div class="input-group-append">
14
14
  <button type="submit" class="btn btn-primary" id="search-submit-header">
@@ -40,7 +40,7 @@
40
40
  <% unless collection_type.admin_set? || collection_type.user_collection? %>
41
41
  <button class="btn btn-danger btn-sm delete-collection-type"
42
42
  data-collection-type="<%= collection_type.to_json %>"
43
- data-collection-type-index="<%= hyrax.dashboard_collections_path({ 'f[collection_type_gid_ssim][]' => collection_type.to_global_id.to_s, 'f[has_model_ssim][]' => 'Collection' }) %>"
43
+ data-collection-type-index="<%= hyrax.dashboard_collections_path({ 'f[collection_type_gid_ssim][]' => collection_type.to_global_id.to_s }) %>"
44
44
  data-has-collections="<%= collection_type.collections.any? %>">
45
45
  <%= t('helpers.action.delete') %>
46
46
  </button>
@@ -1,5 +1,5 @@
1
1
  <div class="resource-form-container">
2
- <%= simple_form_for [main_app, @form], remote: true, html: { id: 'resource-form', 'data-type': 'json' } do |f| %>
2
+ <%= simple_form_for [main_app, @form], remote: true, authenticity_token: true, html: { id: 'resource-form', 'data-type': 'json' } do |f| %>
3
3
  <%= f.input :thumbnail_id, as: :hidden, input_html: { data: {member_link: 'thumbnail_id'}} %>
4
4
  <%= f.input :representative_id, as: :hidden, input_html: { data: {member_link: 'representative_id'}} %>
5
5
  <% end %>
@@ -31,7 +31,7 @@
31
31
  </li>
32
32
  <li class="form-check">
33
33
  <label class="form-check-label">
34
- <%= f.radio_button :visibility, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO, class: 'form-check-input', data: { 'target': '#collapseEmbargo' } %>
34
+ <%= f.radio_button :visibility, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO, 'aria-label': 'Embargo', class: 'form-check-input', data: { 'target': '#collapseEmbargo' } %>
35
35
  <%= visibility_badge(Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO) %>
36
36
  <br />
37
37
  <%= t('hyrax.visibility.embargo.note_html') %>
@@ -39,7 +39,7 @@
39
39
  <div class="form-inline">
40
40
  <%= f.input :visibility_during_embargo, wrapper: :inline, collection: visibility_options(:restrict), include_blank: false %>
41
41
  <%= t('hyrax.works.form.visibility_until') %>
42
- <%= f.date_field :embargo_release_date, wrapper: :inline, value: f.object.embargo_release_date&.to_date || Date.tomorrow, class: 'datepicker form-control' %>
42
+ <%= f.date_field :embargo_release_date, wrapper: :inline, 'aria-label': 'Embargo Release Date', value: f.object.embargo_release_date&.to_date || Date.tomorrow, class: 'datepicker form-control' %>
43
43
  <%= f.input :visibility_after_embargo, wrapper: :inline, collection: visibility_options(:loosen), include_blank: false %>
44
44
  </div>
45
45
  </div>
@@ -47,7 +47,7 @@
47
47
  </li>
48
48
  <li class="form-check">
49
49
  <label class="form-check-label">
50
- <%= f.radio_button :visibility, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE, class: 'form-check-input', data: { 'target': '#collapseLease' } %>
50
+ <%= f.radio_button :visibility, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE, 'aria-label': 'Lease', class: 'form-check-input', data: { 'target': '#collapseLease' } %>
51
51
  <%= visibility_badge(Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE) %>
52
52
  <br />
53
53
  <%= t('hyrax.visibility.lease.note_html') %>
@@ -55,7 +55,7 @@
55
55
  <div class="form-inline">
56
56
  <%= f.input :visibility_during_lease, wrapper: :inline, collection: visibility_options(:loosen), include_blank: false %>
57
57
  <%= t('hyrax.works.form.visibility_until') %>
58
- <%= f.date_field :lease_expiration_date, wrapper: :inline, value: f.object.lease_expiration_date&.to_date || Date.tomorrow, class: 'datepicker form-control' %>
58
+ <%= f.date_field :lease_expiration_date, wrapper: :inline, 'aria-label': 'Lease Expiration Date', value: f.object.lease_expiration_date&.to_date || Date.tomorrow, class: 'datepicker form-control' %>
59
59
  <%= f.input :visibility_after_lease, wrapper: :inline, collection: visibility_options(:restrict), include_blank: false %>
60
60
  </div>
61
61
  </div>
@@ -2,7 +2,7 @@
2
2
  <div class="col-sm-6">
3
3
  <% if !workflow_restriction?(presenter) %>
4
4
  <% if presenter.show_deposit_for?(collections: @user_collections) %>
5
- <input type="checkbox" style="display:none" name="batch_document_ids[]" id="batch_document_<%= presenter.id %>" value="<%= presenter.id %>" class="batch_document_selector" checked="checked" />
5
+ <input type="checkbox" aria-label="Batch Documents" style="display:none" name="batch_document_ids[]" id="batch_document_<%= presenter.id %>" value="<%= presenter.id %>" class="batch_document_selector" checked="checked" />
6
6
  <%= button_tag t('hyrax.dashboard.my.action.add_to_collection'),
7
7
  class: 'btn btn-secondary submits-batches submits-batches-add',
8
8
  data: { toggle: "modal", target: "#collection-list-container" } %>
@@ -6,33 +6,35 @@
6
6
  </button>
7
7
  <%= form_tag main_app.hyrax_workflow_action_path(presenter), method: :put do %>
8
8
  <div id="workflow_controls_collapse" class="card-body collapse">
9
- <div class="col-sm-3 workflow-actions">
10
- <h3><%= t('.actions') %></h3>
9
+ <div class="row">
10
+ <div class="col-sm-3 workflow-actions">
11
+ <h3><%= t('.actions') %></h3>
11
12
 
12
- <% presenter.workflow.actions.each do |key, label| %>
13
- <div class="form-check">
14
- <label class="form-check-label">
15
- <%= radio_button_tag 'workflow_action[name]', key, key == 'comment_only', class: 'form-check-input' %>
16
- <%= label %>
17
- </label>
18
- </div>
19
- <% end %>
20
- </div>
21
- <div class="col-sm-9 workflow-comments">
22
- <div class="form-group">
23
- <label for="workflow_action_comment"><%= t('.review_comment') %>:</label>
24
- <textarea class="form-control" name="workflow_action[comment]" id="workflow_action_comment"></textarea>
13
+ <% presenter.workflow.actions.each do |key, label| %>
14
+ <div class="form-check">
15
+ <label class="form-check-label">
16
+ <%= radio_button_tag 'workflow_action[name]', key, key == 'comment_only', class: 'form-check-input' %>
17
+ <%= label %>
18
+ </label>
19
+ </div>
20
+ <% end %>
25
21
  </div>
22
+ <div class="col-sm-9 workflow-comments">
23
+ <div class="form-group">
24
+ <label for="workflow_action_comment"><%= t('.review_comment') %>:</label>
25
+ <textarea class="form-control" name="workflow_action[comment]" id="workflow_action_comment"></textarea>
26
+ </div>
26
27
 
27
- <input class="btn btn-primary" type="submit" value="Submit" />
28
+ <input class="btn btn-primary" type="submit" value="Submit" />
28
29
 
29
- <h4><%= t('.previous_comments') %></h4>
30
- <dl>
31
- <% presenter.workflow.comments.each do |comment| %>
32
- <dt><%= comment.name_of_commentor %></dt>
33
- <dd><%= comment.comment %></dd>
34
- <% end %>
35
- </dl>
30
+ <h4><%= t('.previous_comments') %></h4>
31
+ <dl>
32
+ <% presenter.workflow.comments.each do |comment| %>
33
+ <dt><%= comment.name_of_commentor %></dt>
34
+ <dd><%= comment.comment %></dd>
35
+ <% end %>
36
+ </dl>
37
+ </div>
36
38
  </div>
37
39
  </div>
38
40
  <% end %>
@@ -2,5 +2,6 @@
2
2
  @curation_concern = ::Wings::ActiveFedoraConverter.convert(resource: @curation_concern) if
3
3
  @curation_concern.is_a?(Hyrax::Resource) && Object.const_defined?("Wings")
4
4
 
5
- json.extract! @curation_concern, *[:id] + @curation_concern.class.fields.reject { |f| [:has_model].include? f }
5
+ json.extract! @curation_concern, *@curation_concern.class.fields.reject { |f| [:has_model].include? f }
6
+ json.id @curation_concern.id.to_s
6
7
  json.version @curation_concern.try(:etag)
@@ -7,7 +7,7 @@
7
7
  </td>
8
8
  <td>
9
9
  <div class="media">
10
- <%= link_to [main_app, document], "class" => "media-left", "aria-hidden" => "true" do %>
10
+ <%= link_to [main_app, document], "class" => "media-left mr-3", "aria-hidden" => "true" do %>
11
11
  <%= document_presenter(document)&.thumbnail&.thumbnail_tag(
12
12
  { class: "d-none d-md-block file_listing_thumbnail", alt: "#{document.title_or_label} #{t('hyrax.homepage.admin_sets.thumbnail')}" },
13
13
  { suppress_link: true }
@@ -12,7 +12,7 @@
12
12
  <input type="checkbox" name="batch_document_ids[]" id="batch_document_<%= id %>" value="<%= id %>" class="batch_document_selector"
13
13
  data-hasaccess="<%= (can?(:edit, collection_presenter.solr_document)) %>" />
14
14
  <% else %>
15
- <input type="checkbox" class="disabled" disabled=true />
15
+ <input type="checkbox" class="disabled batch_document_selector" disabled=true />
16
16
  <% end %>
17
17
  </td>
18
18
  <td>
@@ -7,7 +7,7 @@
7
7
  </td>
8
8
  <td>
9
9
  <div class="media">
10
- <%= link_to [main_app, document], "class" => "media-left", "aria-hidden" => "true" do %>
10
+ <%= link_to [main_app, document], "class" => "media-left mr-3", "aria-hidden" => "true" do %>
11
11
  <%= document_presenter(document)&.thumbnail&.thumbnail_tag(
12
12
  { class: "d-none d-md-block file_listing_thumbnail", alt: document.title_or_label }, { suppress_link: true }
13
13
  ) %>
@@ -11,8 +11,8 @@
11
11
  <% if show_sort_and_per_page? && collection_member_sort_fields.many? %>
12
12
  <div class="sort-toggle">
13
13
  <%= form_tag dashboard_collection_path(collection), method: :get, class: 'per_page' do %>
14
- <div class="form-group row form-control-lg">
15
- <fieldset class="col-sm-9">
14
+ <div class="form-group row">
15
+ <fieldset class="col-sm-7 col-lg-8">
16
16
  <legend class="sr-only"><%= t('hyrax.sort_label') %></legend>
17
17
  <%= label_tag(:sort, t(".sort_by")) %>
18
18
  <%= select_tag(:sort, options_from_collection_for_select(collection_member_sort_fields, 'first', lambda {|field| field.last.label}, h(params[:sort]))) %>
@@ -22,7 +22,7 @@
22
22
  <%= render Blacklight::HiddenSearchStateComponent.new(params: search_state.params_for_search.except(:per_page, :sort)) %>
23
23
  <button class="btn btn-info"><span class="fa fa-refresh"></span> <%= t('helpers.action.refresh') %></button>
24
24
  </fieldset>
25
- <div class="col-sm-3">
25
+ <div class="col-sm-5 col-lg-4">
26
26
  <%= render 'hyrax/collections/view_type_group' %>
27
27
  </div>
28
28
  </div>
@@ -1,6 +1,6 @@
1
1
  <div id="versioning_display" class="tab-pane">
2
2
  <h2><%= t('.header') %></h2>
3
- <%= simple_form_for [main_app, curation_concern], html: { multipart: true, class: 'nav-safety' } do |f| %>
3
+ <% if @version_list.supports_multiple_versions? %><%= simple_form_for [main_app, curation_concern], html: { multipart: true, class: 'nav-safety' } do |f| %>
4
4
  <div id="fileuploadVersioning">
5
5
  <!-- Redirect browsers with JavaScript disabled to the origin page -->
6
6
  <noscript><input type="hidden" name="redirect" value="<%= main_app.root_path %>"/></noscript>
@@ -45,10 +45,10 @@
45
45
  <%= t('.upload') %>
46
46
  <% end %>
47
47
 
48
- </div> <!-- fileuploadVersioning -->
49
- <% end %>
48
+ </div> <!-- /fileuploadVersioning -->
49
+ <% end %><% end %>
50
50
 
51
- <%= form_for [main_app, curation_concern],
51
+ <% if !@version_list.empty? %><%= form_for [main_app, curation_concern],
52
52
  html: { class: 'edit_file_set_previous_version nav-safety' } do |f| %>
53
53
  <h3><%= t('.restore') %></h3>
54
54
  <% @version_list.each do |version| %>
@@ -68,7 +68,7 @@
68
68
  type: 'submit' do %>
69
69
  <%= t('.save') %>
70
70
  <% end %>
71
- <% end %>
71
+ <% end %><% end %>
72
72
 
73
73
  <%= render 'hyrax/uploads/js_templates_versioning' %>
74
74
 
@@ -2,8 +2,8 @@
2
2
  <div>
3
3
  <h2 class="sr-only"><%= t('hyrax.file_set.show.downloadable_content.heading') %></h2>
4
4
  <audio controls="controls" class="audiojs" style="width:100%" controlsList="nodownload" preload="auto">
5
- <source src="<%= hyrax.download_path(file_set, file: 'ogg') %>" type="audio/ogg" />
6
- <source src="<%= hyrax.download_path(file_set, file: 'mp3') %>" type="audio/mpeg" />
5
+ <source src="<%= hyrax.download_path(file_set, file: 'ogg', mime_type: 'audio/ogg') %>" type="audio/ogg" />
6
+ <source src="<%= hyrax.download_path(file_set, file: 'mp3', mime_type: 'audio/mpeg') %>" type="audio/mpeg" />
7
7
  <%= t('hyrax.file_set.show.downloadable_content.audio_tag_not_supported') %>
8
8
  </audio>
9
9
  <%= link_to t('hyrax.file_set.show.downloadable_content.audio_link'),
@@ -15,8 +15,8 @@
15
15
  <% else %>
16
16
  <div>
17
17
  <audio controls="controls" class="audiojs" style="width:100%" controlsList="nodownload" preload="auto">
18
- <source src="<%= hyrax.download_path(file_set, file: 'ogg') %>" type="audio/ogg" />
19
- <source src="<%= hyrax.download_path(file_set, file: 'mp3') %>" type="audio/mpeg" />
18
+ <source src="<%= hyrax.download_path(file_set, file: 'ogg', mime_type: 'audio/ogg') %>" type="audio/ogg" />
19
+ <source src="<%= hyrax.download_path(file_set, file: 'mp3', mime_type: 'audio/mpeg') %>" type="audio/mpeg" />
20
20
  <%= t('hyrax.file_set.show.downloadable_content.audio_tag_not_supported') %>
21
21
  </audio>
22
22
  </div>
@@ -4,7 +4,7 @@
4
4
  <p /><%= link_to t('hyrax.file_set.show.download'),
5
5
  hyrax.download_path(file_set),
6
6
  id: "file_download",
7
- data: { label: file_set.id, work_id: @presenter.id, collection_ids: @presenter.member_of_collection_ids },
7
+ data: { label: file_set.id.to_s, work_id: @presenter.id, collection_ids: @presenter.member_of_collection_ids },
8
8
  target: "_new" %>
9
9
  <% end %>
10
10
  </div>
@@ -2,8 +2,8 @@
2
2
  <div>
3
3
  <h2 class="sr-only"><%= t('hyrax.file_set.show.downloadable_content.heading') %></h2>
4
4
  <video controls="controls" class="video-js vjs-default-skin" style="width:100%" data-setup="{}" controlsList="nodownload" preload="auto">
5
- <source src="<%= hyrax.download_path(file_set, file: 'webm') %>" type="video/webm" />
6
- <source src="<%= hyrax.download_path(file_set, file: 'mp4') %>" type="video/mp4" />
5
+ <source src="<%= hyrax.download_path(file_set, file: 'webm', mime_type: 'video/webm') %>" type="video/webm" />
6
+ <source src="<%= hyrax.download_path(file_set, file: 'mp4', mime_type: 'video/mp4') %>" type="video/mp4" />
7
7
  <%= t('hyrax.file_set.show.downloadable_content.video_tag_not_supported') %>
8
8
  </video>
9
9
  <%= link_to t('hyrax.file_set.show.downloadable_content.video_link'),