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
@@ -56,6 +56,29 @@ $gutter-width: $grid-gutter-width/2;
56
56
  }
57
57
  }
58
58
 
59
+ &:not(.maximized) {
60
+ .sidebar-action-text,
61
+ a span + span,
62
+ h5 {
63
+ display: none;
64
+ }
65
+
66
+ .nav li {
67
+ text-align: center;
68
+ a {
69
+ padding-left: 0;
70
+ padding-right: 0;
71
+ }
72
+ .fa {
73
+ margin-right: 0;
74
+ }
75
+ }
76
+
77
+ .nav-item {
78
+ width: $drawer-small;
79
+ }
80
+ }
81
+
59
82
  .sidebar-toggle {
60
83
  cursor: pointer;
61
84
  background-color: $body-background-color;
@@ -31,7 +31,13 @@ module Hyrax
31
31
  filter_docs_with_edit_access!
32
32
  copy_visibility = []
33
33
  copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] } if params[:embargoes]
34
- resources = Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: Hyrax.config.use_valkyrie?)
34
+
35
+ resources = if Hyrax.config.use_valkyrie?
36
+ Hyrax.query_service.find_many_by_ids(ids: batch)
37
+ else
38
+ Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: false)
39
+ end
40
+
35
41
  resources.each do |resource|
36
42
  if Hyrax.config.use_valkyrie?
37
43
  EmbargoManager.new(resource: resource).release!
@@ -29,7 +29,13 @@ module Hyrax
29
29
  filter_docs_with_edit_access!
30
30
  copy_visibility = []
31
31
  copy_visibility = params[:leases].values.map { |h| h[:copy_visibility] } if params[:leases]
32
- resources = Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: Hyrax.config.use_valkyrie?)
32
+
33
+ resources = if Hyrax.config.use_valkyrie?
34
+ Hyrax.query_service.find_many_by_ids(ids: batch)
35
+ else
36
+ Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: false)
37
+ end
38
+
33
39
  resources.each do |resource|
34
40
  if Hyrax.config.use_valkyrie?
35
41
  LeaseManager.new(resource: resource).release!
@@ -13,10 +13,11 @@ module Hyrax
13
13
  response.headers["Accept-Ranges"] = "bytes"
14
14
  self.status = 200
15
15
  use = params.fetch(:file, :original_file).to_sym
16
- file_metadata = find_file_metadata(file_set: file_set, use: use)
16
+ mime_type = params[:mime_type]
17
+ file_metadata = find_file_metadata(file_set: file_set, use: use, mime_type: mime_type)
17
18
  return unless stale?(last_modified: file_metadata.updated_at, template: false)
18
19
 
19
- file = Hyrax.storage_adapter.find_by(id: file_metadata.file_identifier)
20
+ file = Valkyrie::StorageAdapter.find_by(id: file_metadata.file_identifier)
20
21
  prepare_file_headers_valkyrie(metadata: file_metadata, file: file)
21
22
 
22
23
  # Warning - using the range header will load the range selection in to memory
@@ -25,7 +26,7 @@ module Hyrax
25
26
  file.rewind
26
27
  send_data send_range_valkyrie(file: file), data_options(file_metadata)
27
28
  else
28
- send_file file.disk_path
29
+ send_file file.disk_path, data_options(file_metadata).except(:status)
29
30
  end
30
31
  end
31
32
 
@@ -60,15 +61,19 @@ module Hyrax
60
61
  self.content_type = metadata.mime_type
61
62
  end
62
63
 
63
- def find_file_metadata(file_set:, use: :original_file)
64
- use = :thumbnail_file if use == :thumbnail
65
- begin
64
+ def find_file_metadata(file_set:, use: :original_file, mime_type: nil)
65
+ if mime_type.nil?
66
+ use = :thumbnail_file if use == :thumbnail
66
67
  use = Hyrax::FileMetadata::Use.uri_for(use: use)
67
- rescue ArgumentError
68
- raise Hyrax::ObjectNotFoundError
68
+ results = Hyrax.custom_queries.find_many_file_metadata_by_use(resource: file_set, use: use)
69
+ else
70
+ files = Hyrax.custom_queries.find_files(file_set: file_set)
71
+ results = [files.find { |f| f.mime_type == mime_type }]
69
72
  end
70
- results = Hyrax.custom_queries.find_many_file_metadata_by_use(resource: file_set, use: use)
73
+
71
74
  results.first || raise(Hyrax::ObjectNotFoundError)
75
+ rescue ArgumentError
76
+ raise(Hyrax::ObjectNotFoundError)
72
77
  end
73
78
  end
74
79
  end
@@ -79,14 +79,11 @@ module Hyrax
79
79
  wants.html { presenter && parent_presenter }
80
80
  wants.json do
81
81
  # load @curation_concern manually because it's skipped for html
82
- @curation_concern = Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: params[:id])
82
+ @curation_concern = load_curation_concern
83
83
  curation_concern # This is here for authorization checks (we could add authorize! but let's use the same method for CanCanCan)
84
84
  render :show, status: :ok
85
85
  end
86
86
  additional_response_formats(wants)
87
- wants.ttl { render body: presenter.export_as_ttl, mime_type: Mime[:ttl] }
88
- wants.jsonld { render body: presenter.export_as_jsonld, mime_type: Mime[:jsonld] }
89
- wants.nt { render body: presenter.export_as_nt, mime_type: Mime[:nt] }
90
87
  end
91
88
  end
92
89
  # rubocop:enable Metrics/AbcSize
@@ -114,9 +111,9 @@ module Hyrax
114
111
  Hyrax.config.callback.run(:after_destroy, curation_concern.id, current_user, warn: false)
115
112
  else
116
113
  transactions['work_resource.destroy']
117
- .with_step_args('work_resource.delete' => { user: current_user })
118
- .call(curation_concern)
119
- .value!
114
+ .with_step_args('work_resource.delete' => { user: current_user },
115
+ 'work_resource.delete_all_file_sets' => { user: current_user })
116
+ .call(curation_concern).value!
120
117
 
121
118
  title = Array(curation_concern.title).first
122
119
  end
@@ -139,13 +136,20 @@ module Hyrax
139
136
  json = iiif_manifest_builder.manifest_for(presenter: iiif_manifest_presenter)
140
137
 
141
138
  respond_to do |wants|
142
- wants.json { render json: json }
143
- wants.html { render json: json }
139
+ wants.any { render json: json }
144
140
  end
145
141
  end
146
142
 
147
143
  private
148
144
 
145
+ def load_curation_concern
146
+ if Hyrax.config.disable_wings
147
+ Hyrax.query_service.find_by(id: params[:id])
148
+ else
149
+ Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: params[:id])
150
+ end
151
+ end
152
+
149
153
  def iiif_manifest_builder
150
154
  self.class.iiif_manifest_builder ||
151
155
  (Flipflop.cache_work_iiif_manifest? ? Hyrax::CachingIiifManifestBuilder.new : Hyrax::ManifestBuilderService.new)
@@ -427,6 +431,13 @@ module Hyrax
427
431
  end
428
432
 
429
433
  def additional_response_formats(format)
434
+ respond_to_endnote(format)
435
+ respond_to_ttl(format)
436
+ respond_to_jsonld(format)
437
+ respond_to_nt(format)
438
+ end
439
+
440
+ def respond_to_endnote(format)
430
441
  format.endnote do
431
442
  send_data(presenter.solr_document.export_as_endnote,
432
443
  type: "application/x-endnote-refer",
@@ -434,6 +445,36 @@ module Hyrax
434
445
  end
435
446
  end
436
447
 
448
+ def respond_to_ttl(format)
449
+ format.ttl do
450
+ if presenter.valkyrie_presenter?
451
+ render plain: "Error: Not Implemented", status: :not_implemented
452
+ else
453
+ render body: presenter.export_as_ttl, mime_type: Mime[:ttl]
454
+ end
455
+ end
456
+ end
457
+
458
+ def respond_to_jsonld(format)
459
+ format.jsonld do
460
+ if presenter.valkyrie_presenter?
461
+ render plain: "Error: Not Implemented", status: :not_implemented
462
+ else
463
+ render body: presenter.export_as_jsonld, mime_type: Mime[:jsonld]
464
+ end
465
+ end
466
+ end
467
+
468
+ def respond_to_nt(format)
469
+ format.nt do
470
+ if presenter.valkyrie_presenter?
471
+ render plain: "Error: Not Implemented", status: :not_implemented
472
+ else
473
+ render body: presenter.export_as_nt, mime_type: Mime[:nt]
474
+ end
475
+ end
476
+ end
477
+
437
478
  def save_permissions
438
479
  @saved_permissions =
439
480
  case curation_concern
@@ -33,12 +33,11 @@ module Hyrax
33
33
  private
34
34
 
35
35
  def my_load_and_authorize_resource
36
- @work = Hyrax::WorkRelation.new.find(params[:id])
37
-
36
+ @work = Hyrax.query_service.find_by(id: params[:id])
38
37
  return render plain: "#{user} lacks access to #{@work}", status: :unauthorized unless user.can? :edit, @work
39
38
 
40
39
  return render plain: "Forbidden: #{@work} not deposited via Arkivo", status: :forbidden if @work.arkivo_checksum.nil?
41
- rescue ActiveFedora::ObjectNotFoundError
40
+ rescue ActiveFedora::ObjectNotFoundError, Valkyrie::Persistence::ObjectNotFoundError
42
41
  render plain: "id '#{params[:id]}' not found", status: :not_found
43
42
  end
44
43
 
@@ -41,9 +41,9 @@ module Hyrax
41
41
  batch.each do |doc_id|
42
42
  resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id))
43
43
  transactions['collection_resource.destroy']
44
- .with_step_args('collection_resource.delete' => { user: current_user })
45
- .call(resource)
46
- .value!
44
+ .with_step_args('collection_resource.delete' => { user: current_user },
45
+ 'collection_resource.remove_from_membership' => { user: current_user })
46
+ .call(resource).value!
47
47
  end
48
48
  flash[:notice] = "Batch delete complete"
49
49
  after_destroy_collection
@@ -108,9 +108,9 @@ module Hyrax
108
108
  batch.each do |id|
109
109
  resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(id))
110
110
  transactions['work_resource.destroy']
111
- .with_step_args('work_resource.delete' => { user: current_user })
112
- .call(resource)
113
- .value!
111
+ .with_step_args('work_resource.delete' => { user: current_user },
112
+ 'work_resource.delete_all_file_sets' => { user: current_user })
113
+ .call(resource).value!
114
114
  end
115
115
  after_update
116
116
  end
@@ -5,7 +5,11 @@ module Hyrax
5
5
  include Hyrax::WorksControllerBehavior
6
6
 
7
7
  # Gives the class of the form.
8
- class BatchUploadFormService < Hyrax::WorkFormService
8
+ class BatchUploadFormService
9
+ def self.build(resource, current_ability, *extra)
10
+ form_class.new(resource, current_ability, *extra)
11
+ end
12
+
9
13
  def self.form_class(_ = nil)
10
14
  ::Hyrax::Forms::BatchUploadForm
11
15
  end
@@ -245,7 +245,10 @@ module Hyrax
245
245
  end
246
246
 
247
247
  def valkyrie_destroy
248
- if transactions['collection_resource.destroy'].call(@collection).success?
248
+ if transactions['collection_resource.destroy']
249
+ .with_step_args('collection_resource.delete' => { user: current_user },
250
+ 'collection_resource.remove_from_membership' => { user: current_user })
251
+ .call(@collection).success?
249
252
  after_destroy(params[:id])
250
253
  else
251
254
  after_destroy_error(params[:id])
@@ -113,20 +113,30 @@ module Hyrax
113
113
  def update_metadata
114
114
  case file_set
115
115
  when Hyrax::Resource
116
- change_set = Hyrax::Forms::ResourceForm.for(file_set)
117
-
118
- change_set.validate(attributes) &&
119
- transactions['change_set.apply'].call(change_set).value_or { false }
116
+ valkyrie_update_metadata
120
117
  else
121
118
  file_attributes = form_class.model_attributes(attributes)
122
119
  actor.update_metadata(file_attributes)
123
120
  end
124
121
  end
125
122
 
123
+ def valkyrie_update_metadata
124
+ change_set = Hyrax::Forms::ResourceForm.for(file_set)
125
+
126
+ result =
127
+ change_set.validate(attributes) &&
128
+ transactions['change_set.update_file_set']
129
+ .with_step_args(
130
+ 'file_set.save_acl' => { permissions_params: change_set.input_params["permissions"] }
131
+ )
132
+ .call(change_set).value_or { false }
133
+ @file_set = result if result
134
+ end
135
+
126
136
  def parent(file_set: curation_concern)
127
137
  @parent ||=
128
138
  case file_set
129
- when Hyrax::Resource
139
+ when Hyrax::FileSet
130
140
  Hyrax.query_service.find_parents(resource: file_set).first
131
141
  else
132
142
  file_set.parent
@@ -134,6 +144,7 @@ module Hyrax
134
144
  end
135
145
 
136
146
  def attempt_update
147
+ return attempt_update_valkyrie if ::FileSet < Hyrax::Resource
137
148
  if wants_to_revert?
138
149
  actor.revert_content(params[:revision])
139
150
  elsif params.key?(:file_set)
@@ -149,9 +160,33 @@ module Hyrax
149
160
  end
150
161
  end
151
162
 
163
+ def attempt_update_valkyrie
164
+ return revert_valkyrie if wants_to_revert_valkyrie?
165
+ if params.key?(:file_set)
166
+ if params[:file_set].key?(:files)
167
+ ValkyrieIngestJob.perform_later(uploaded_file_from_path)
168
+ else
169
+ update_metadata
170
+ end
171
+ elsif params.key?(:files_files) # version file already uploaded with ref id in :files_files array
172
+ uploaded_files = Array(Hyrax::UploadedFile.find(params[:files_files]))
173
+ uploaded_files.first.file_set_uri = file_set.id.to_s
174
+ uploaded_files.first.save
175
+ ValkyrieIngestJob.perform_later(uploaded_files.first)
176
+ update_metadata
177
+ end
178
+ end
179
+
180
+ def revert_valkyrie
181
+ Hyrax::VersioningService.create(file_metadata, current_user, Hyrax.storage_adapter.find_by(id: params[:revision]))
182
+ # update_metadata
183
+ Hyrax.publisher.publish("file.uploaded", metadata: file_set.original_file)
184
+ true
185
+ end
186
+
152
187
  def uploaded_file_from_path
153
188
  uploaded_file = CarrierWave::SanitizedFile.new(params[:file_set][:files].first)
154
- Hyrax::UploadedFile.create(user_id: current_user.id, file: uploaded_file)
189
+ Hyrax::UploadedFile.create(user_id: current_user.id, file: uploaded_file, file_set_uri: @file_set.id.to_s)
155
190
  end
156
191
 
157
192
  def after_update_response
@@ -251,6 +286,14 @@ module Hyrax
251
286
  params.key?(:revision) && params[:revision] != curation_concern.latest_content_version.label
252
287
  end
253
288
 
289
+ def wants_to_revert_valkyrie?
290
+ params.key?(:revision) && params[:revision] != Hyrax::VersioningService.new(resource: file_metadata).latest_version.version_id.to_s
291
+ end
292
+
293
+ def file_metadata
294
+ @file_metadata ||= Hyrax.query_service.custom_queries.find_file_metadata_by(id: curation_concern.original_file_id)
295
+ end
296
+
254
297
  # Override this method to add additional response formats to your local app
255
298
  def additional_response_formats(_); end
256
299
 
@@ -37,6 +37,8 @@ module Hyrax
37
37
  hyrax.my_collections_url(*args)
38
38
  end
39
39
 
40
+ # @api public
41
+ #
40
42
  # The url of the "more" link for additional facet values
41
43
  def search_facet_path(args = {})
42
44
  hyrax.my_dashboard_collections_facet_path(args[:id])
@@ -37,6 +37,14 @@ module Hyrax
37
37
 
38
38
  private
39
39
 
40
+ def send_content
41
+ if @asset.is_a?(Hyrax::FileSet)
42
+ send_file_contents_valkyrie(@asset)
43
+ else
44
+ super
45
+ end
46
+ end
47
+
40
48
  def curation_concern
41
49
  response, _document_list = search_service.search_results
42
50
  response.documents.first
@@ -52,6 +60,12 @@ module Hyrax
52
60
  end
53
61
  end
54
62
 
63
+ def data_options(file_metadata)
64
+ super.tap do |options|
65
+ options[:disposition] = 'attachment' if action_name == 'download'
66
+ end
67
+ end
68
+
55
69
  # This is called in a before filter. It causes @asset to be set.
56
70
  def authorize_download!
57
71
  authorize! :read, asset
@@ -66,7 +80,7 @@ module Hyrax
66
80
  end
67
81
 
68
82
  def asset
69
- @asset ||= Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: single_use_link.item_id, use_valkyrie: false)
83
+ @asset ||= Hyrax.query_service.find_by(id: single_use_link.item_id)
70
84
  end
71
85
 
72
86
  def current_ability
@@ -94,7 +108,7 @@ module Hyrax
94
108
  return unless single_use_link
95
109
 
96
110
  @single_use_link = single_use_link
97
- can :read, [ActiveFedora::Base, ::SolrDocument] do |obj|
111
+ can :read, [ActiveFedora::Base, ::SolrDocument, Hyrax::Resource] do |obj|
98
112
  single_use_link.valid? && single_use_link.item_id == obj.id && single_use_link.destroy!
99
113
  end
100
114
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module BasicMetadataFormFieldsBehavior
4
+ # Provides compatibility with the behavior of the based_near (location) controlled vocabulary form field.
5
+ # The form expects a ControlledVocabularies::Location object as input and produces a hash like those
6
+ # used with accepts_nested_attributes_for.
7
+ def self.included(descendant)
8
+ descendant.property :based_near_attributes, virtual: true, populator: :based_near_populator, prepopulator: :based_near_prepopulator
9
+ end
10
+
11
+ private
12
+
13
+ def based_near_populator(fragment:, **_options)
14
+ adds = []
15
+ deletes = []
16
+ fragment.each do |_, h|
17
+ uri = RDF::URI.parse(h["id"]).to_s
18
+ if h["_destroy"] == "true"
19
+ deletes << uri
20
+ else
21
+ adds << uri
22
+ end
23
+ end
24
+ self.based_near = ((model.based_near + adds) - deletes).uniq
25
+ end
26
+
27
+ def based_near_prepopulator
28
+ self.based_near = based_near.map do |loc|
29
+ uri = RDF::URI.parse(loc)
30
+ if uri
31
+ Hyrax::ControlledVocabularies::Location.new(uri)
32
+ else
33
+ loc
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -123,21 +123,6 @@ module Hyrax
123
123
  collection_member_service.available_member_subcollections.documents
124
124
  end
125
125
 
126
- ##
127
- # @deprecated this implementation requires an extra db round trip, had a
128
- # buggy cacheing mechanism, and was largely duplicative of other code.
129
- # all versions of this code are replaced by
130
- # {CollectionsHelper#available_parent_collections_data}.
131
- def available_parent_collections(scope:)
132
- return @available_parents if @available_parents.present?
133
-
134
- collection = model_class.find(id)
135
- colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
136
- @available_parents = colls.map do |col|
137
- { "id" => col.id, "title_first" => col.title.first }
138
- end.to_json
139
- end
140
-
141
126
  private
142
127
 
143
128
  def all_files_with_access
@@ -44,40 +44,6 @@ module Hyrax
44
44
  persistence_service.persist_nested_collection_for(parent: parent, child: child, user: context.current_user)
45
45
  end
46
46
 
47
- ##
48
- # @deprecated this method is unused by hyrax, and is effectively a
49
- # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
50
- # if you want to be sure to use nested indexing to generate this list,
51
- # use the query service directly.
52
- #
53
- # For the given parent, what are all of the available collections that
54
- # can be added as sub-collection of the parent.
55
- def available_child_collections
56
- Deprecation.warn "#{self.class}#available_child_collections " \
57
- "is deprecated. the helper of the same name or " \
58
- "Hyrax::Collections::NestedCollectionQueryService " \
59
- "instead."
60
-
61
- query_service.available_child_collections(parent: parent, scope: context)
62
- end
63
-
64
- ##
65
- # @deprecated this method is unused by hyrax, and is effectively a
66
- # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
67
- # if you want to be sure to use nested indexing to generate this list,
68
- # use the query service directly.
69
- #
70
- # For the given child, what are all of the available collections to
71
- # which the child can be added as a sub-collection.
72
- def available_parent_collections
73
- Deprecation.warn "#{self.class}#available_parent_collections " \
74
- "is deprecated. the helper of the same name or " \
75
- "Hyrax::Collections::NestedCollectionQueryService " \
76
- "instead."
77
-
78
- query_service.available_parent_collections(child: child, scope: context)
79
- end
80
-
81
47
  # when creating a NEW collection, we need to do some basic validation before
82
48
  # rerouting to new_dashboard_collection_path to add the new collection as
83
49
  # a child. Since we don't yet have a child collection, the valid? option can't be used here.
@@ -12,8 +12,8 @@ module Hyrax
12
12
  # be configurable.
13
13
  include Hyrax::FormFields(:file_set_metadata)
14
14
 
15
- property :representative_id, type: Valkyrie::Types::String
16
- property :thumbnail_id, type: Valkyrie::Types::String
15
+ property :representative_id, type: Valkyrie::Types::String, writeable: false
16
+ property :thumbnail_id, type: Valkyrie::Types::String, writeable: false
17
17
  end
18
18
  end
19
19
  end
@@ -2,6 +2,27 @@
2
2
 
3
3
  module Hyrax
4
4
  module Forms
5
+ ##
6
+ # @api public
7
+ #
8
+ # @example defining a form class using HydraEditor-like configuration
9
+ # class MonographForm < Hyrax::Forms::PcdmObjectForm(Monograph)
10
+ # self.required_fields = [:title, :creator, :rights_statement]
11
+ # # other WorkForm-like configuration here
12
+ # end
13
+ def self.PcdmObjectForm(work_class)
14
+ Class.new(Hyrax::Forms::PcdmObjectForm) do
15
+ self.model_class = work_class
16
+
17
+ ##
18
+ # @return [String]
19
+ def self.inspect
20
+ return "Hyrax::Forms::PcdmObjectForm(#{model_class})" if name.blank?
21
+ super
22
+ end
23
+ end
24
+ end
25
+
5
26
  ##
6
27
  # A form for PCDM objects: resources which have collection relationships and
7
28
  # generally resemble +Hyrax::Work+.
@@ -9,13 +9,6 @@ module Hyrax
9
9
  delegate :access_grants, :access_grants_attributes=, :release_date, :release_period, :visibility, to: :model
10
10
  delegate :available_workflows, :active_workflow, :source, :source_id, to: :model
11
11
 
12
- ##
13
- # @deprecated use PermissionTemplate#reset_access_controls_for instead.
14
- def reset_access_controls!
15
- Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
16
- source_model.reset_access_controls!
17
- end
18
-
19
12
  # Stores which radio button under release "Varies" option is selected
20
13
  attr_accessor :release_varies
21
14
  # Selected release embargo timeframe (if any) under release "Varies" option