hyrax 4.0.0 → 5.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +124 -232
  3. data/.dassie/.env +8 -2
  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/environments/test.rb +1 -0
  9. data/.dassie/config/initializers/hyrax.rb +3 -1
  10. data/.dassie/config/initializers/riiif.rb +11 -7
  11. data/.dassie/config/metadata/collection_resource.yaml +3 -0
  12. data/.dassie/config/metadata/monograph.yaml +8 -0
  13. data/.dassie/config/metadata/sample_metadata.yaml +1 -0
  14. data/.dassie/config/redis.yml +2 -0
  15. data/.dassie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  16. data/.dassie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  17. data/.dassie/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.hyrax.rb +8 -0
  18. data/.dassie/db/migrate/20230821153635_add_fields_to_counter_metric.rb +8 -0
  19. data/.dassie/db/schema.rb +22 -3
  20. data/.dockerignore +7 -0
  21. data/.github/PULL_REQUEST_TEMPLATE.md +10 -7
  22. data/.github/release.yml +5 -2
  23. data/.gitignore +1 -1
  24. data/.koppie/.env +13 -4
  25. data/.koppie/Gemfile +10 -12
  26. data/.koppie/Gemfile.koppie +2 -0
  27. data/.koppie/Rakefile +0 -2
  28. data/.koppie/app/models/ability.rb +1 -5
  29. data/.koppie/app/models/user.rb +0 -2
  30. data/.koppie/config/application.rb +2 -1
  31. data/.koppie/config/arkivo.yml +6 -0
  32. data/.koppie/config/blacklight.yml +2 -2
  33. data/.koppie/config/environments/test.rb +1 -0
  34. data/.koppie/config/features.yml +2 -0
  35. data/.koppie/config/initializers/1_valkyrie.rb +29 -6
  36. data/.koppie/config/initializers/arkivo_constraint.rb +12 -0
  37. data/.koppie/config/initializers/hyrax.rb +10 -4
  38. data/.koppie/config/initializers/riiif.rb +11 -7
  39. data/.koppie/config/metadata/collection_resource.yaml +49 -0
  40. data/.koppie/config/metadata/generic_work.yaml +2 -0
  41. data/.koppie/config/metadata/monograph.yaml +10 -0
  42. data/.koppie/config/role_map.yml +3 -25
  43. data/.koppie/config/routes.rb +1 -2
  44. data/.koppie/config/solr.yml +1 -1
  45. data/.koppie/config/valkyrie_index.yml +4 -10
  46. data/.koppie/config/zotero.yml +6 -0
  47. data/.koppie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  48. data/.koppie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  49. data/.koppie/db/schema.rb +12 -1
  50. data/.koppie/yarn.lock +23 -23
  51. data/.regen +1 -1
  52. data/CONTAINERS.md +1 -3
  53. data/Dockerfile +17 -13
  54. data/Gemfile +4 -21
  55. data/Gemfile.dassie +2 -0
  56. data/Gemfile.koppie +2 -0
  57. data/README.md +0 -1
  58. data/Rakefile +0 -11
  59. data/app/actors/hyrax/actors/base_actor.rb +4 -3
  60. data/app/actors/hyrax/actors/embargo_actor.rb +3 -3
  61. data/app/actors/hyrax/actors/lease_actor.rb +5 -2
  62. data/app/assets/javascripts/hyrax/batch_select_all.js +1 -1
  63. data/app/assets/javascripts/hyrax/file_manager/member.es6 +1 -1
  64. data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
  65. data/app/assets/stylesheets/hyrax/_file-listing.scss +0 -2
  66. data/app/assets/stylesheets/hyrax/_work-show.scss +19 -3
  67. data/app/assets/stylesheets/hyrax/sidebar.scss +23 -0
  68. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +8 -2
  69. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +7 -1
  70. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +79 -0
  71. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +64 -14
  72. data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
  73. data/app/controllers/hyrax/api/items_controller.rb +2 -3
  74. data/app/controllers/hyrax/batch_edits_controller.rb +39 -10
  75. data/app/controllers/hyrax/batch_uploads_controller.rb +5 -1
  76. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  77. data/app/controllers/hyrax/downloads_controller.rb +8 -1
  78. data/app/controllers/hyrax/file_sets_controller.rb +50 -6
  79. data/app/controllers/hyrax/my/collections_controller.rb +2 -0
  80. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +16 -2
  81. data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +38 -0
  82. data/app/forms/hyrax/forms/collection_form.rb +0 -15
  83. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +0 -34
  84. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  85. data/app/forms/hyrax/forms/file_set_form.rb +2 -2
  86. data/app/forms/hyrax/forms/pcdm_object_form.rb +21 -0
  87. data/app/forms/hyrax/forms/permission_template_form.rb +2 -7
  88. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +118 -0
  89. data/app/forms/hyrax/forms/resource_form.rb +21 -34
  90. data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
  91. data/app/forms/hyrax/forms/work_form.rb +1 -1
  92. data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
  93. data/app/helpers/hyrax/dashboard_helper_behavior.rb +30 -9
  94. data/app/helpers/hyrax/membership_helper.rb +13 -1
  95. data/app/helpers/hyrax/work_form_helper.rb +0 -107
  96. data/app/indexers/hyrax/file_set_indexer.rb +6 -0
  97. data/app/indexers/hyrax/location_indexer.rb +29 -0
  98. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +36 -5
  99. data/app/indexers/hyrax/valkyrie_work_indexer.rb +9 -2
  100. data/app/inputs/controlled_vocabulary_input.rb +1 -1
  101. data/app/jobs/characterize_job.rb +1 -1
  102. data/app/jobs/create_work_job.rb +36 -4
  103. data/app/jobs/valkyrie_characterization_job.rb +9 -0
  104. data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
  105. data/app/jobs/valkyrie_ingest_job.rb +1 -4
  106. data/app/models/admin_set.rb +1 -31
  107. data/app/models/collection_branding_info.rb +2 -9
  108. data/app/models/concerns/hyrax/ability.rb +2 -1
  109. data/app/models/concerns/hyrax/collection_behavior.rb +4 -12
  110. data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
  111. data/app/models/concerns/hyrax/riiif_file.rb +30 -0
  112. data/app/models/concerns/hyrax/solr_document_behavior.rb +20 -3
  113. data/app/models/hyrax/collection_type.rb +5 -14
  114. data/app/models/hyrax/counter_metric.rb +7 -0
  115. data/app/models/hyrax/file_metadata.rb +9 -9
  116. data/app/models/hyrax/file_set.rb +76 -15
  117. data/app/models/hyrax/orcid_validator.rb +0 -6
  118. data/app/models/hyrax/resource.rb +30 -2
  119. data/app/models/hyrax/work.rb +2 -5
  120. data/app/presenters/hyrax/collection_presenter.rb +0 -17
  121. data/app/presenters/hyrax/embargo_presenter.rb +4 -0
  122. data/app/presenters/hyrax/file_set_presenter.rb +6 -0
  123. data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
  124. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +6 -4
  125. data/app/presenters/hyrax/presenter_renderer.rb +0 -7
  126. data/app/presenters/hyrax/version_list_presenter.rb +19 -10
  127. data/app/presenters/hyrax/version_presenter.rb +19 -4
  128. data/app/presenters/hyrax/work_show_presenter.rb +6 -11
  129. data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
  130. data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
  131. data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
  132. data/app/services/hyrax/admin_set_create_service.rb +0 -17
  133. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +16 -9
  134. data/app/services/hyrax/collections/collection_member_service.rb +1 -1
  135. data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
  136. data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
  137. data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
  138. data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
  139. data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
  140. data/app/services/hyrax/derivative_path.rb +14 -4
  141. data/app/services/hyrax/embargo_manager.rb +106 -13
  142. data/app/services/hyrax/embargo_service.rb +12 -10
  143. data/app/services/hyrax/file_set_derivatives_service.rb +14 -13
  144. data/app/services/hyrax/fixity_check_failure_service.rb +1 -1
  145. data/app/services/hyrax/identifier/dispatcher.rb +9 -2
  146. data/app/services/hyrax/lease_manager.rb +88 -8
  147. data/app/services/hyrax/listeners/file_metadata_listener.rb +16 -8
  148. data/app/services/hyrax/listeners/member_cleanup_listener.rb +2 -28
  149. data/app/services/hyrax/listeners/metadata_index_listener.rb +11 -0
  150. data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
  151. data/app/services/hyrax/lock_manager.rb +1 -2
  152. data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
  153. data/app/services/hyrax/riiif_file_resolver.rb +50 -0
  154. data/app/services/hyrax/simple_schema_loader.rb +31 -0
  155. data/app/services/hyrax/solr_query_service.rb +7 -6
  156. data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
  157. data/app/services/hyrax/statistics/over_time.rb +1 -1
  158. data/app/services/hyrax/statistics/users/over_time.rb +3 -1
  159. data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
  160. data/app/services/hyrax/statistics/works/count.rb +1 -1
  161. data/app/services/hyrax/thumbnail_path_service.rb +5 -0
  162. data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
  163. data/app/services/hyrax/valkyrie_upload.rb +16 -28
  164. data/app/services/hyrax/versioning_service.rb +30 -15
  165. data/app/services/hyrax/visibility_intention.rb +1 -4
  166. data/app/services/hyrax/visibility_propagator.rb +1 -1
  167. data/app/services/hyrax/work_uploads_handler.rb +1 -1
  168. data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
  169. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
  170. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
  171. data/app/services/hyrax/workflow/permission_query.rb +23 -2
  172. data/app/validators/hyrax/collection_membership_validator.rb +1 -1
  173. data/app/views/catalog/_search_form.html.erb +1 -1
  174. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  175. data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
  176. data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
  177. data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
  178. data/app/views/hyrax/base/_file_manager_resource_form.html.erb +1 -1
  179. data/app/views/hyrax/base/_form.html.erb +0 -10
  180. data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
  181. data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
  182. data/app/views/hyrax/base/_form_visibility_component.html.erb +4 -4
  183. data/app/views/hyrax/base/_items.html.erb +1 -1
  184. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  185. data/app/views/hyrax/base/_workflow_actions.html.erb +25 -23
  186. data/app/views/hyrax/base/file_manager.html.erb +1 -1
  187. data/app/views/hyrax/base/show.json.jbuilder +4 -3
  188. data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
  189. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  190. data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
  191. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +3 -3
  192. data/app/views/hyrax/file_sets/_versioning.html.erb +5 -5
  193. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +4 -4
  194. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  195. data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
  196. data/app/views/hyrax/file_sets/show.html.erb +5 -3
  197. data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
  198. data/app/views/hyrax/my/_search_form.html.erb +1 -1
  199. data/app/views/hyrax/notifications/_notifications.html.erb +1 -1
  200. data/app/views/hyrax/users/_vitals.html.erb +1 -1
  201. data/bin/dev-entrypoint.sh +13 -0
  202. data/chart/hyrax/Chart.yaml +18 -14
  203. data/chart/hyrax/README.md +34 -21
  204. data/chart/hyrax/templates/_helpers.tpl +34 -1
  205. data/chart/hyrax/templates/configmap-env.yaml +12 -2
  206. data/chart/hyrax/templates/secrets.yaml +1 -1
  207. data/chart/hyrax/values.yaml +39 -14
  208. data/config/initializers/file_length_patch.rb +10 -0
  209. data/config/initializers/listeners.rb +4 -10
  210. data/config/initializers/storage_adapter_initializer.rb +1 -1
  211. data/config/locales/hyrax.en.yml +8 -0
  212. data/config/metadata/basic_metadata.yaml +52 -0
  213. data/config/metadata/core_metadata.yaml +4 -0
  214. data/config/metadata/file_set_metadata.yaml +20 -1
  215. data/config/metadata/hyrax_internal_metadata.yaml +57 -0
  216. data/docker-compose-koppie.yml +36 -22
  217. data/docker-compose-sirenia.yml +202 -0
  218. data/docker-compose.yml +42 -26
  219. data/documentation/developing-your-hyrax-based-app.md +6 -14
  220. data/documentation/legacyREADME.md +3 -1
  221. data/hyrax.gemspec +12 -13
  222. data/karma.conf.js +9 -10
  223. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +2 -0
  224. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  225. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +11 -7
  226. data/lib/generators/hyrax/templates/db/migrate/20230725222727_create_hyrax_counter_metrics.rb.erb +14 -0
  227. data/lib/generators/hyrax/templates/db/migrate/20230803165135_change_work_id_to_string.rb.erb +5 -0
  228. data/lib/generators/hyrax/templates/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.rb.erb +8 -0
  229. data/lib/generators/hyrax/templates/db/migrate/20230821153635_add_fields_to_counter_metric.rb.erb +8 -0
  230. data/lib/generators/hyrax/templates/db/seeds.rb +1 -1
  231. data/lib/generators/hyrax/work_resource/templates/form.rb.erb +1 -1
  232. data/lib/generators/hyrax/work_resource/templates/metadata.yaml +2 -0
  233. data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
  234. data/lib/hyrax/configuration.rb +147 -43
  235. data/lib/hyrax/controlled_vocabularies/location.rb +7 -1
  236. data/lib/hyrax/engine.rb +2 -1
  237. data/lib/hyrax/form_fields.rb +6 -0
  238. data/lib/hyrax/publisher.rb +23 -3
  239. data/lib/hyrax/redis_event_store.rb +7 -8
  240. data/lib/hyrax/resource_name.rb +4 -0
  241. data/lib/hyrax/specs/capybara.rb +25 -37
  242. data/lib/hyrax/specs/shared_specs/hydra_works.rb +34 -7
  243. data/lib/hyrax/specs/shared_specs/indexers.rb +24 -6
  244. data/lib/hyrax/transactions/collection_destroy.rb +3 -2
  245. data/lib/hyrax/transactions/container.rb +47 -0
  246. data/lib/hyrax/transactions/file_metadata_destroy.rb +20 -0
  247. data/lib/hyrax/transactions/file_set_destroy.rb +3 -1
  248. data/lib/hyrax/transactions/file_set_update.rb +21 -0
  249. data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
  250. data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -1
  251. data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
  252. data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +46 -0
  253. data/lib/hyrax/transactions/steps/delete_all_file_sets.rb +46 -0
  254. data/lib/hyrax/transactions/steps/file_metadata_delete.rb +40 -0
  255. data/lib/hyrax/transactions/steps/remove_from_membership.rb +45 -0
  256. data/lib/hyrax/transactions/steps/save.rb +21 -0
  257. data/lib/hyrax/transactions/work_create.rb +1 -0
  258. data/lib/hyrax/transactions/work_destroy.rb +3 -2
  259. data/lib/hyrax/version.rb +1 -1
  260. data/lib/hyrax.rb +1 -0
  261. data/lib/tasks/collection_type_global_id.rake +9 -4
  262. data/lib/tasks/embargo_lease.rake +1 -0
  263. data/lib/valkyrie/indexing/solr/indexing_adapter.rb +2 -0
  264. data/lib/wings/active_fedora_converter/default_work.rb +7 -2
  265. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  266. data/lib/wings/active_fedora_converter.rb +53 -11
  267. data/lib/wings/attribute_transformer.rb +24 -17
  268. data/lib/wings/model_transformer.rb +23 -12
  269. data/lib/wings/orm_converter.rb +23 -18
  270. data/lib/wings/setup.rb +23 -3
  271. data/lib/wings/valkyrie/persister.rb +4 -2
  272. data/lib/wings/valkyrie/storage.rb +8 -90
  273. data/lib/wings.rb +5 -0
  274. data/package.json +3 -1
  275. data/tasks/hyrax_dev.rake +2 -33
  276. data/template.rb +1 -1
  277. metadata +104 -81
  278. data/.engine_cart.yml +0 -3
  279. data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
  280. data/app/services/hyrax/collections/migration_service.rb +0 -113
  281. data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
  282. data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
  283. data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
  284. data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
  285. data/app/views/hyrax/users/_user_util_links_extra.html.erb +0 -0
  286. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +0 -9
@@ -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
@@ -171,6 +206,7 @@ module Hyrax
171
206
  respond_to do |wants|
172
207
  wants.html do
173
208
  initialize_edit_form
209
+ # TODO: return a valuable error message
174
210
  flash[:error] = "There was a problem processing your request."
175
211
  render 'edit', status: :unprocessable_entity
176
212
  end
@@ -250,6 +286,14 @@ module Hyrax
250
286
  params.key?(:revision) && params[:revision] != curation_concern.latest_content_version.label
251
287
  end
252
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
+
253
297
  # Override this method to add additional response formats to your local app
254
298
  def additional_response_formats(_); end
255
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.
@@ -6,7 +6,7 @@ module Hyrax::Forms
6
6
 
7
7
  delegate :depositor, :permissions, :human_readable_type, to: :model
8
8
 
9
- self.required_fields = [:title, :creator, :license]
9
+ self.required_fields = [:title, :creator]
10
10
 
11
11
  self.model_class = ::FileSet
12
12
 
@@ -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
@@ -266,6 +259,8 @@ module Hyrax
266
259
  # rubocop:disable Metrics/CyclomaticComplexity
267
260
  # rubocop:disable Metrics/PerceivedComplexity
268
261
  def permission_template_update_params
262
+ return attributes unless attributes.key?(:release_varies) || attributes.key?(:release_embargo)
263
+
269
264
  filtered_attributes = attributes.except(:release_varies, :release_embargo)
270
265
  # If 'varies' before date option selected, then set release_period='before' and save release_date as-is
271
266
  if attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Forms
4
+ class ResourceBatchEditForm < Hyrax::Forms::ResourceForm
5
+ include Hyrax::FormFields(:basic_metadata)
6
+
7
+ self.required_fields = []
8
+ self.model_class = Hyrax.primary_work_type
9
+
10
+ # Terms that need to exclude from batch edit
11
+ class_attribute :terms_excluded
12
+ self.terms_excluded = [:abstract, :label, :source]
13
+
14
+ # Contains a list of titles of all the works in the batch
15
+ attr_accessor :names
16
+
17
+ # @param [Hyrax::Work] model the model backing the form
18
+ # @param [Ability] current_ability the user authorization model
19
+ # @param [Array<String>] batch_document_ids a list of document ids in the batch
20
+ def initialize(model, _current_ability, batch_document_ids)
21
+ @names = []
22
+ @batch_document_ids = batch_document_ids
23
+ if @batch_document_ids.present?
24
+ combined_fields = model_attributes(model, initialize_combined_fields)
25
+ super(model.class.new(combined_fields))
26
+ else
27
+ super(model)
28
+ end
29
+ end
30
+
31
+ def terms
32
+ self.class.terms
33
+ end
34
+
35
+ def self.terms
36
+ return Hyrax::Forms::BatchEditForm.terms if model_class < ActiveFedora::Base
37
+
38
+ terms_primary = definitions.select { |_, definition| definition[:primary] }
39
+ .keys.map(&:to_sym)
40
+ terms_secondary = definitions.select { |_, definition| definition[:display] && !definition[:primary] }
41
+ .keys.map(&:to_sym)
42
+
43
+ (terms_primary + terms_secondary) - terms_excluded
44
+ end
45
+
46
+ attr_reader :batch_document_ids
47
+
48
+ # Returns a list of parameters we accept from the form
49
+ def self.build_permitted_params
50
+ terms_permitted_params + additional_permitted_params
51
+ end
52
+
53
+ # Returns a list of parameters other than those terms for the form
54
+ # rubocop:disable Metrics/MethodLength
55
+ def self.additional_permitted_params
56
+ [{ permissions_attributes: [:type, :name, :access, :id, :_destroy] },
57
+ :on_behalf_of,
58
+ :version,
59
+ :add_works_to_collection,
60
+ :visibility_during_embargo,
61
+ :embargo_release_date,
62
+ :visibility_after_embargo,
63
+ :visibility_during_lease,
64
+ :lease_expiration_date,
65
+ :visibility_after_lease,
66
+ :visibility,
67
+ { based_near_attributes: [:id, :_destroy] }]
68
+ end
69
+ # rubocop:enable Metrics/MethodLength
70
+
71
+ # Returns a list of permitted parameters for the terms
72
+ # @param terms Array[Symbol]
73
+ # @return Array[Hash]
74
+ def self.terms_permitted_params
75
+ [].tap do |params|
76
+ terms.each do |term|
77
+ h = {}
78
+ h[term] = []
79
+ params << h
80
+ end
81
+ end
82
+ end
83
+
84
+ # @param name [Symbol]
85
+ # @return [Symbol]
86
+ # @note Added for ActiveModel compatibility.
87
+ def column_for_attribute(name)
88
+ name
89
+ end
90
+
91
+ private
92
+
93
+ # override this method if you need to initialize more complex RDF assertions (b-nodes)
94
+ # @return [Hash<String, Array>] the list of unique values per field
95
+ def initialize_combined_fields
96
+ # For each of the files in the batch, set the attributes to be the concatenation of all the attributes
97
+ batch_document_ids.each_with_object({}) do |doc_id, combined_attributes|
98
+ work = Hyrax.query_service.find_by(id: doc_id)
99
+ terms.each do |field|
100
+ combined_attributes[field] ||= []
101
+ combined_attributes[field] = (combined_attributes[field] + Array.wrap(work[field])).uniq
102
+ end
103
+ names << work.to_s
104
+ end
105
+ end
106
+
107
+ # Model attributes for ActiveFedora compatibility
108
+ def model_attributes(model, attrs)
109
+ return attrs unless model.is_a? ActiveFedora::Base
110
+
111
+ attrs.keys.each do |k|
112
+ attrs[k] = Array.wrap(attrs[k]).first unless model.class.properties[k.to_s]&.multiple?
113
+ end
114
+ attrs
115
+ end
116
+ end
117
+ end
118
+ end
@@ -5,29 +5,26 @@ module Hyrax
5
5
  ##
6
6
  # @api public
7
7
  #
8
- # @example defining a form class using HydraEditor-like configuration
9
- # class MonographForm < Hyrax::Forms::ResourceForm(Monograph)
10
- # self.required_fields = [:title, :creator, :rights_statement]
11
- # # other WorkForm-like configuration here
12
- # end
8
+ # Returns the form class associated with a given model.
13
9
  #
14
- # @note The returned class will extend +Hyrax::Forms::PcdmObjectForm+, not
15
- # only +Hyrax::Forms::ResourceForm+. This is for backwards‐compatibility
16
- # with existing Hyrax instances and satisfies the expected general use
17
- # case (building forms for various PCDM object classes), but is *not*
18
- # necessarily suitable for other kinds of Hyrax resource, like
19
- # +Hyrax::FileSet+s.
20
- def self.ResourceForm(work_class)
21
- Class.new(Hyrax::Forms::PcdmObjectForm) do
22
- self.model_class = work_class
23
-
24
- ##
25
- # @return [String]
26
- def self.inspect
27
- return "Hyrax::Forms::ResourceForm(#{model_class})" if name.blank?
28
- super
10
+ # @note The default case assumes that the provided model class is for a
11
+ # PCDM object and returns a +Hyrax::Forms::PcdmObjectForm+. This is for
12
+ # backwards‐compatibility with existing Hyrax instances. However, a
13
+ # different +Hyrax::Forms::ResourceForm+ subclass will be returned in
14
+ # some known cases where that is preferable.
15
+ def self.ResourceForm(model_class)
16
+ @resource_forms ||= {}.compare_by_identity
17
+ @resource_forms[model_class] ||=
18
+ if model_class <= Hyrax::AdministrativeSet
19
+ Hyrax::Forms::AdministrativeSetForm
20
+ elsif model_class <= Hyrax::FileSet
21
+ Hyrax::Forms::FileSetForm
22
+ elsif model_class <= Hyrax::PcdmCollection
23
+ Hyrax::Forms::PcdmCollectionForm
24
+ else
25
+ "Hyrax::Forms::PcdmObjectForm".constantize # autoload
26
+ Hyrax::Forms::PcdmObjectForm(model_class)
29
27
  end
30
- end
31
28
  end
32
29
 
33
30
  ##
@@ -121,19 +118,9 @@ module Hyrax
121
118
  # monograph = Monograph.new
122
119
  # change_set = Hyrax::Forms::ResourceForm.for(monograph)
123
120
  def for(resource)
124
- "#{resource.class.name}Form".constantize.new(resource)
125
- rescue NameError => _err
126
- case resource
127
- when Hyrax::AdministrativeSet
128
- Hyrax::Forms::AdministrativeSetForm.new(resource)
129
- when Hyrax::FileSet
130
- Hyrax::Forms::FileSetForm.new(resource)
131
- when Hyrax::PcdmCollection
132
- Hyrax::Forms::PcdmCollectionForm.new(resource)
133
- else
134
- # NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
135
- Hyrax::Forms::ResourceForm(resource.class).new(resource)
136
- end
121
+ klass = "#{resource.class.name}Form".safe_constantize
122
+ klass ||= Hyrax::Forms::ResourceForm(resource.class)
123
+ klass.new(resource)
137
124
  end
138
125
 
139
126
  ##
@@ -11,6 +11,7 @@ module Hyrax
11
11
  # +EmbargoesControllerBehavior+.
12
12
  class WorkEmbargoForm < Hyrax::ChangeSet
13
13
  property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator, prepopulator: :embargo_populator
14
+ property :embargo_history, virtual: true, prepopulator: proc { |_opts| self.embargo_history = model.embargo&.embargo_history }
14
15
  property :embargo_release_date, virtual: true, prepopulator: proc { |_opts| self.embargo_release_date = model.embargo&.embargo_release_date }
15
16
  property :visibility_after_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
16
17
  property :visibility_during_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_during_embargo = model.embargo&.visibility_during_embargo }
@@ -158,7 +158,7 @@ module Hyrax
158
158
  # In particular we are discarding any access grant parameters for works that
159
159
  # are going into a mediated deposit workflow.
160
160
  def self.sanitize_params(form_params)
161
- admin_set_id = form_params[:admin_set_id]
161
+ admin_set_id = Array(form_params[:admin_set_id]).first
162
162
  return super if admin_set_id && workflow_for(admin_set_id: admin_set_id).allows_access_grant?
163
163
  params_without_permissions = permitted_params.reject { |arg| arg.respond_to?(:key?) && arg.key?(:permissions_attributes) }
164
164
  form_params.permit(*params_without_permissions)
@@ -11,6 +11,7 @@ module Hyrax
11
11
  # +LeasesControllerBehavior+.
12
12
  class WorkLeaseForm < Hyrax::ChangeSet
13
13
  property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator, prepopulator: :lease_populator
14
+ property :lease_history, virtual: true, prepopulator: proc { |_opts| self.lease_history = model.lease&.lease_history }
14
15
  property :lease_expiration_date, virtual: true, prepopulator: proc { |_opts| self.lease_expiration_date = model.lease&.lease_expiration_date }
15
16
  property :visibility_after_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_after_lease = model.lease&.visibility_after_lease }
16
17
  property :visibility_during_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_during_lease = model.lease&.visibility_during_lease }
@@ -6,21 +6,38 @@ module Hyrax
6
6
  end
7
7
 
8
8
  # @param user [User]
9
- # @param where [Hash] applied as the where clause when querying the Hyrax::WorkRelation
10
- # @return [Integer] number of works matching the where that the user deposited
11
- # @see Hyrax::WorkRelation
12
- def number_of_works(user = current_user, where: { generic_type_sim: "Work" })
13
- field_pairs = field_pairs(user)
14
- field_pairs.merge!(where)
15
- Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs).count
9
+ # @return [Integer] number of works that the user deposited
10
+ def number_of_works(user = current_user)
11
+ Hyrax::SolrQueryService
12
+ .new
13
+ .with_field_pairs(field_pairs: field_pairs(user))
14
+ .with_generic_type(generic_type: 'Work')
15
+ .count
16
16
  rescue RSolr::Error::ConnectionRefused
17
17
  'n/a'
18
18
  end
19
19
 
20
+ def link_to_works(user = current_user)
21
+ state = Blacklight::SearchState.new(params, CatalogController.blacklight_config)
22
+ facet_type = if Hyrax.config.use_valkyrie?
23
+ state.add_facet_params('generic_type_si', 'Work')
24
+ else
25
+ state.add_facet_params('generic_type_sim', 'Work')
26
+ end
27
+ facet_depositor = state.add_facet_params('depositor_ssim', user.to_s)
28
+ state = Hash.new {}
29
+ state["f"] = facet_type["f"].merge(facet_depositor["f"])
30
+ link_to(t("hyrax.dashboard.stats.works"), main_app.search_catalog_path(state))
31
+ end
32
+
20
33
  # @param user [User]
21
34
  # @return [Integer] number of FileSets the user deposited
22
35
  def number_of_files(user = current_user)
23
- Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
36
+ Hyrax::SolrQueryService
37
+ .new
38
+ .with_field_pairs(field_pairs: field_pairs(user))
39
+ .with_generic_type(generic_type: 'FileSet')
40
+ .count
24
41
  rescue RSolr::Error::ConnectionRefused
25
42
  'n/a'
26
43
  end
@@ -28,7 +45,11 @@ module Hyrax
28
45
  # @param user [User]
29
46
  # @return [Integer] number of Collections the user created
30
47
  def number_of_collections(user = current_user)
31
- Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
48
+ Hyrax::SolrQueryService
49
+ .new
50
+ .with_field_pairs(field_pairs: field_pairs(user))
51
+ .with_generic_type(generic_type: 'Collection')
52
+ .count
32
53
  rescue RSolr::Error::ConnectionRefused
33
54
  'n/a'
34
55
  end
@@ -14,18 +14,30 @@ module Hyrax
14
14
  #
15
15
  # @see app/assets/javascripts/hyrax/relationships.js
16
16
  def member_of_collections_json(resource)
17
+ # this is where we return for dassie
17
18
  return resource.member_of_collections_json if
18
19
  resource.respond_to?(:member_of_collections_json)
19
20
 
20
21
  resource = resource.model if resource.respond_to?(:model)
21
22
 
22
- Hyrax.custom_queries.find_collections_for(resource: resource).map do |collection|
23
+ existing_collections_array = Hyrax.custom_queries.find_collections_for(resource: resource) + add_collection_from_params
24
+ existing_collections_array.map do |collection|
23
25
  { id: collection.id.to_s,
24
26
  label: collection.title.first,
25
27
  path: url_for(collection) }
26
28
  end.to_json
27
29
  end
28
30
 
31
+ def add_collection_from_params
32
+ # avoid errors when creating Valkyrie resources from Dashboard >> Works
33
+ return [] if controller.params[:add_works_to_collection].blank?
34
+
35
+ # new valkyrie works need the collection from params when depositing directly into an existing collection
36
+ return [Hyrax.metadata_adapter.query_service.find_by(id: Valkyrie::ID.new(controller.params[:add_works_to_collection]))] if Hyrax.config.use_valkyrie?
37
+
38
+ [::Collection.find(@controller.params[:add_works_to_collection])]
39
+ end
40
+
29
41
  ##
30
42
  # @param resource [#work_members_json]
31
43
  #