hyrax 5.0.0.rc2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +14 -0
  3. data/.dassie/app/listeners/hyrax_listener.rb +81 -0
  4. data/.dassie/config/environments/test.rb +0 -5
  5. data/.dassie/config/initializers/hyrax.rb +5 -0
  6. data/.dassie/config/initializers/publisher.rb +3 -0
  7. data/.dassie/config/initializers/riiif.rb +77 -0
  8. data/.gitignore +4 -0
  9. data/.koppie/.env +2 -2
  10. data/.koppie/app/forms/collection_resource_form.rb +1 -0
  11. data/.koppie/app/indexers/collection_resource_indexer.rb +1 -0
  12. data/.koppie/app/listeners/hyrax_listener.rb +81 -0
  13. data/.koppie/app/models/collection.rb +1 -1
  14. data/.koppie/app/models/collection_resource.rb +1 -0
  15. data/.koppie/config/analytics.yml +5 -5
  16. data/.koppie/config/initializers/publisher.rb +3 -0
  17. data/.koppie/config/initializers/riiif.rb +78 -0
  18. data/.koppie/config/metadata/collection_resource.yaml +8 -166
  19. data/.koppie/config/metadata/sample_metadata.yaml +4 -0
  20. data/CONTAINERS.md +39 -2
  21. data/Dockerfile +14 -11
  22. data/Gemfile +8 -7
  23. data/README.md +2 -0
  24. data/app/actors/hyrax/actors/base_actor.rb +6 -3
  25. data/app/actors/hyrax/actors/file_actor.rb +1 -1
  26. data/app/actors/hyrax/actors/lease_actor.rb +3 -6
  27. data/app/assets/javascripts/hyrax/save_work/uploaded_files.es6 +10 -2
  28. data/app/assets/stylesheets/hyrax/sidebar.scss +6 -1
  29. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +1 -1
  30. data/app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb +12 -19
  31. data/app/controllers/concerns/hyrax/stream_file_downloads_controller_behavior.rb +54 -0
  32. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +38 -9
  33. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +19 -14
  34. data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -2
  35. data/app/controllers/hyrax/admin/analytics/work_reports_controller.rb +5 -5
  36. data/app/controllers/hyrax/dashboard/collections_controller.rb +2 -5
  37. data/app/controllers/hyrax/downloads_controller.rb +1 -0
  38. data/app/controllers/hyrax/file_sets_controller.rb +3 -2
  39. data/app/controllers/hyrax/my/collections_controller.rb +1 -1
  40. data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +1 -0
  41. data/app/forms/concerns/hyrax/contained_in_works_behavior.rb +24 -0
  42. data/app/forms/concerns/hyrax/deposit_agreement_behavior.rb +12 -0
  43. data/app/forms/concerns/hyrax/leaseability_behavior.rb +49 -0
  44. data/app/forms/concerns/hyrax/permission_behavior.rb +20 -0
  45. data/app/forms/hyrax/forms/administrative_set_form.rb +1 -5
  46. data/app/forms/hyrax/forms/collection_form.rb +19 -0
  47. data/app/forms/hyrax/forms/file_set_form.rb +5 -0
  48. data/app/forms/hyrax/forms/pcdm_collection_form.rb +1 -5
  49. data/app/forms/hyrax/forms/pcdm_object_form.rb +13 -22
  50. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +7 -2
  51. data/app/forms/hyrax/forms/resource_form.rb +30 -100
  52. data/app/forms/hyrax/forms.rb +52 -0
  53. data/app/helpers/hyrax/hyrax_helper_behavior.rb +2 -0
  54. data/app/indexers/{hyrax → concerns/hyrax}/location_indexer.rb +1 -5
  55. data/app/indexers/{hyrax → concerns/hyrax}/permission_indexer.rb +2 -2
  56. data/app/indexers/{hyrax → concerns/hyrax}/visibility_indexer.rb +1 -1
  57. data/app/indexers/hyrax/administrative_set_indexer.rb +5 -17
  58. data/app/indexers/hyrax/indexers/administrative_set_indexer.rb +25 -0
  59. data/app/indexers/hyrax/indexers/file_set_indexer.rb +144 -0
  60. data/app/indexers/hyrax/indexers/pcdm_collection_indexer.rb +27 -0
  61. data/app/indexers/hyrax/indexers/pcdm_object_indexer.rb +72 -0
  62. data/app/indexers/hyrax/indexers/resource_indexer.rb +86 -0
  63. data/app/indexers/hyrax/indexers.rb +54 -0
  64. data/app/indexers/hyrax/pcdm_collection_indexer.rb +5 -18
  65. data/app/indexers/hyrax/valkyrie_collection_indexer.rb +6 -4
  66. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +5 -136
  67. data/app/indexers/hyrax/valkyrie_indexer.rb +8 -112
  68. data/app/indexers/hyrax/valkyrie_work_indexer.rb +5 -64
  69. data/app/indexers/hyrax/work_indexer.rb +1 -0
  70. data/app/jobs/create_work_job.rb +1 -0
  71. data/app/models/admin_set.rb +20 -1
  72. data/app/models/collection.rb +5 -0
  73. data/app/models/concerns/hyrax/ability/admin_set_ability.rb +13 -28
  74. data/app/models/concerns/hyrax/ability/collection_ability.rb +26 -28
  75. data/app/models/concerns/hyrax/ability/resource_ability.rb +19 -0
  76. data/app/models/concerns/hyrax/ability.rb +11 -9
  77. data/app/models/concerns/hyrax/collection_behavior.rb +8 -0
  78. data/app/models/concerns/hyrax/solr_document_behavior.rb +15 -5
  79. data/app/models/concerns/hyrax/work_behavior.rb +4 -0
  80. data/app/models/featured_work.rb +12 -4
  81. data/app/models/file_set.rb +5 -0
  82. data/app/models/hyrax/administrative_set.rb +1 -1
  83. data/app/models/hyrax/change_set.rb +2 -2
  84. data/app/models/hyrax/file_metadata.rb +34 -7
  85. data/app/models/hyrax/file_set.rb +2 -2
  86. data/app/models/hyrax/group.rb +9 -38
  87. data/app/models/hyrax/group_behavior.rb +58 -0
  88. data/app/models/hyrax/model_registry.rb +111 -0
  89. data/app/models/hyrax/pcdm_collection.rb +1 -7
  90. data/app/models/hyrax/resource.rb +66 -8
  91. data/app/models/hyrax/statistic.rb +1 -1
  92. data/app/models/hyrax/work.rb +1 -7
  93. data/app/presenters/hyrax/collapsable_section_presenter.rb +7 -3
  94. data/app/presenters/hyrax/file_set_presenter.rb +8 -6
  95. data/app/presenters/hyrax/lease_presenter.rb +4 -0
  96. data/app/presenters/hyrax/menu_presenter.rb +14 -2
  97. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +1 -1
  98. data/app/presenters/hyrax/version_list_presenter.rb +6 -4
  99. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  100. data/app/search_builders/hyrax/catalog_search_builder.rb +8 -2
  101. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +5 -3
  102. data/app/search_builders/hyrax/exposed_models_relation.rb +1 -1
  103. data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
  104. data/app/search_builders/hyrax/filter_by_type.rb +3 -2
  105. data/app/search_builders/hyrax/member_with_files_search_builder.rb +1 -1
  106. data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
  107. data/app/search_builders/hyrax/my/find_works_search_builder.rb +8 -3
  108. data/app/services/hyrax/access_control_list.rb +21 -4
  109. data/app/services/hyrax/action/create_valkyrie_work.rb +80 -0
  110. data/app/services/hyrax/admin_set_create_service.rb +7 -3
  111. data/app/services/hyrax/admin_set_service.rb +2 -2
  112. data/app/services/hyrax/collections/collection_member_search_service.rb +2 -0
  113. data/app/services/hyrax/collections/permissions_service.rb +27 -9
  114. data/app/services/hyrax/custom_queries/find_collections_by_type.rb +1 -1
  115. data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
  116. data/app/services/hyrax/custom_queries/navigators/find_files.rb +1 -1
  117. data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +1 -1
  118. data/app/services/hyrax/edit_permissions_service.rb +1 -1
  119. data/app/services/hyrax/embargo_manager.rb +1 -1
  120. data/app/services/hyrax/file_set_file_service.rb +21 -10
  121. data/app/services/hyrax/form_factory.rb +1 -1
  122. data/app/services/hyrax/lease_manager.rb +39 -16
  123. data/app/services/hyrax/lease_service.rb +12 -6
  124. data/app/services/hyrax/listeners/acl_index_listener.rb +1 -1
  125. data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +1 -1
  126. data/app/services/hyrax/listeners/member_cleanup_listener.rb +15 -1
  127. data/app/services/hyrax/listeners/object_lifecycle_listener.rb +5 -1
  128. data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +2 -1
  129. data/app/services/hyrax/listeners/workflow_listener.rb +13 -0
  130. data/app/services/hyrax/listeners.rb +2 -1
  131. data/app/services/hyrax/location_service.rb +3 -0
  132. data/app/services/hyrax/multiple_membership_checker.rb +1 -1
  133. data/app/services/hyrax/simple_schema_loader.rb +1 -1
  134. data/app/services/hyrax/solr_service.rb +19 -5
  135. data/app/services/hyrax/statistics/collections/over_time.rb +1 -1
  136. data/app/services/hyrax/statistics/query_service.rb +6 -0
  137. data/app/services/hyrax/valkyrie_persist_derivatives.rb +11 -4
  138. data/app/services/hyrax/valkyrie_upload.rb +1 -1
  139. data/app/services/hyrax/work_uploads_handler.rb +5 -4
  140. data/app/views/_user_util_links.html.erb +1 -1
  141. data/app/views/collections/edit_fields/_based_near.html.erb +11 -7
  142. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +67 -67
  143. data/app/views/hyrax/admin/admin_sets/edit.html.erb +1 -1
  144. data/app/views/hyrax/admin/collection_types/_form_participants.html.erb +3 -1
  145. data/app/views/hyrax/base/_attribute_rows.html.erb +1 -0
  146. data/app/views/hyrax/base/_base_form_files_prepend.html.erb +4 -0
  147. data/app/views/hyrax/base/_form_files.html.erb +65 -64
  148. data/app/views/hyrax/base/show.html.erb +2 -3
  149. data/app/views/hyrax/collections/show.html.erb +7 -9
  150. data/app/views/hyrax/dashboard/_sidebar.html.erb +4 -3
  151. data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +2 -2
  152. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  153. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  154. data/app/views/hyrax/my/facet.html.erb +1 -1
  155. data/app/views/layouts/_head_tag_content.html.erb +1 -0
  156. data/app/views/shared/_footer.html.erb +1 -1
  157. data/chart/hyrax/Chart.yaml +3 -3
  158. data/chart/hyrax/templates/_tmplvalues.tpl +38 -0
  159. data/chart/hyrax/templates/deployment-worker.yaml +6 -2
  160. data/chart/hyrax/templates/deployment.yaml +9 -3
  161. data/chart/hyrax/values.yaml +9 -1
  162. data/config/initializers/listeners.rb +1 -1
  163. data/config/locales/hyrax.de.yml +5 -0
  164. data/config/locales/hyrax.en.yml +10 -0
  165. data/config/locales/hyrax.es.yml +5 -0
  166. data/config/locales/hyrax.fr.yml +5 -0
  167. data/config/locales/hyrax.it.yml +5 -0
  168. data/config/locales/hyrax.pt-BR.yml +5 -0
  169. data/config/locales/hyrax.zh.yml +5 -0
  170. data/config/metadata/basic_metadata.yaml +1 -0
  171. data/config/metadata/core_metadata.yaml +2 -0
  172. data/config/metadata/file_set_metadata.yaml +2 -0
  173. data/docker-compose-koppie.yml +3 -3
  174. data/docker-compose-sirenia.yml +3 -3
  175. data/documentation/developing-your-hyrax-based-app.md +89 -67
  176. data/hyrax.gemspec +9 -2
  177. data/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +1 -1
  178. data/lib/generators/hyrax/config_generator.rb +12 -0
  179. data/lib/generators/hyrax/install_generator.rb +37 -7
  180. data/lib/generators/hyrax/listeners_generator.rb +18 -0
  181. data/lib/generators/hyrax/models_generator.rb +1 -10
  182. data/lib/generators/hyrax/riiif_generator.rb +6 -4
  183. data/lib/generators/hyrax/templates/.env +9 -0
  184. data/lib/generators/hyrax/templates/.lando.yml +50 -0
  185. data/lib/generators/hyrax/templates/app/listeners/hyrax_listener.rb +81 -0
  186. data/lib/generators/hyrax/templates/app/models/file_set.rb +1 -2
  187. data/lib/generators/hyrax/templates/config/initializers/1_valkyrie.rb +102 -0
  188. data/lib/generators/hyrax/templates/config/initializers/file_services.rb +6 -0
  189. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +41 -5
  190. data/lib/generators/hyrax/templates/config/initializers/publisher.rb +3 -0
  191. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +77 -0
  192. data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
  193. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
  194. data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
  195. data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
  196. data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
  197. data/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +1 -1
  198. data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
  199. data/lib/generators/hyrax/templates/config/redis.yml +3 -6
  200. data/lib/generators/hyrax/templates/config/valkyrie_index.yml +4 -9
  201. data/lib/generators/hyrax/work_resource/templates/indexer.rb.erb +1 -1
  202. data/lib/hyrax/configuration.rb +95 -7
  203. data/lib/hyrax/indexer.rb +1 -1
  204. data/lib/hyrax/publisher.rb +5 -2
  205. data/lib/hyrax/resource_sync/change_list_writer.rb +1 -1
  206. data/lib/hyrax/resource_sync/resource_list_writer.rb +1 -1
  207. data/lib/hyrax/specs/capybara.rb +1 -0
  208. data/lib/hyrax/specs/shared_specs/hydra_works.rb +78 -20
  209. data/lib/hyrax/specs/shared_specs/indexers.rb +1 -1
  210. data/lib/hyrax/transactions/admin_set_destroy.rb +2 -1
  211. data/lib/hyrax/transactions/container.rb +5 -0
  212. data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -0
  213. data/lib/hyrax/transactions/steps/check_for_default_admin_set.rb +32 -0
  214. data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +1 -1
  215. data/lib/hyrax/transactions/steps/save.rb +2 -1
  216. data/lib/hyrax/transactions/steps/set_user_as_creator.rb +1 -1
  217. data/lib/hyrax/transactions/steps/update_work_members.rb +2 -0
  218. data/lib/hyrax/version.rb +1 -1
  219. data/lib/hyrax.rb +1 -0
  220. data/lib/tasks/embargo_lease.rake +1 -0
  221. data/lib/valkyrie/indexing/solr/indexing_adapter.rb +21 -7
  222. data/lib/wings/active_fedora_converter/default_work.rb +4 -5
  223. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  224. data/lib/wings/model_registry.rb +8 -0
  225. data/lib/wings/model_transformer.rb +19 -2
  226. data/lib/wings/orm_converter.rb +4 -0
  227. data/lib/wings/services/custom_queries/find_ids_by_model.rb +2 -2
  228. data/lib/wings/valkyrie/query_service.rb +5 -2
  229. data/lib/wings.rb +3 -0
  230. data/spec/factories/access_control.rb +12 -0
  231. data/spec/factories/admin_sets.rb +32 -0
  232. data/spec/factories/admin_sets_lw.rb +222 -0
  233. data/spec/factories/administrative_sets.rb +79 -0
  234. data/spec/factories/api_items.rb +92 -0
  235. data/spec/factories/collection_branding_infos.rb +12 -0
  236. data/spec/factories/collection_type_participants.rb +9 -0
  237. data/spec/factories/collection_types.rb +139 -0
  238. data/spec/factories/collections.rb +282 -0
  239. data/spec/factories/collections_factory.rb +107 -0
  240. data/spec/factories/content_blocks.rb +5 -0
  241. data/spec/factories/counter_metrics.rb +12 -0
  242. data/spec/factories/featured_works.rb +5 -0
  243. data/spec/factories/file_sets.rb +45 -0
  244. data/spec/factories/generic_works.rb +200 -0
  245. data/spec/factories/hyrax_collection.rb +92 -0
  246. data/spec/factories/hyrax_default_admin_set.rb +7 -0
  247. data/spec/factories/hyrax_embargo.rb +18 -0
  248. data/spec/factories/hyrax_file_metadata.rb +92 -0
  249. data/spec/factories/hyrax_file_set.rb +129 -0
  250. data/spec/factories/hyrax_lease.rb +18 -0
  251. data/spec/factories/hyrax_resource.rb +15 -0
  252. data/spec/factories/hyrax_work.rb +221 -0
  253. data/spec/factories/object_id.rb +7 -0
  254. data/spec/factories/operations.rb +22 -0
  255. data/spec/factories/permission.rb +7 -0
  256. data/spec/factories/permission_template_accesses.rb +17 -0
  257. data/spec/factories/permission_templates.rb +111 -0
  258. data/spec/factories/proxy_deposit_requests.rb +7 -0
  259. data/spec/factories/single_use_links.rb +14 -0
  260. data/spec/factories/sipity_entities.rb +17 -0
  261. data/spec/factories/uploaded_files.rb +11 -0
  262. data/spec/factories/users.rb +52 -0
  263. data/spec/factories/workflow_actions.rb +7 -0
  264. data/spec/factories/workflow_states.rb +7 -0
  265. data/spec/factories/workflows.rb +7 -0
  266. data/spec/support/book_resource.rb +36 -0
  267. data/spec/support/can_can_overrides.rb +43 -0
  268. data/spec/support/clean_solr.rb +7 -0
  269. data/spec/support/controller_level_helpers.rb +27 -0
  270. data/spec/support/factory_helpers.rb +94 -0
  271. data/spec/support/fakes/fake_actor.rb +22 -0
  272. data/spec/support/fakes/fake_authority.rb +14 -0
  273. data/spec/support/fakes/fake_search_builder_scope.rb +44 -0
  274. data/spec/support/fakes/indexing_adapter.rb +17 -0
  275. data/spec/support/fakes/test_hydra_group_service.rb +55 -0
  276. data/spec/support/features/batch_edit_actions.rb +37 -0
  277. data/spec/support/features/session_helpers.rb +15 -0
  278. data/spec/support/features/workflow.rb +10 -0
  279. data/spec/support/features.rb +11 -0
  280. data/spec/support/form_with_validations.rb +15 -0
  281. data/spec/support/input_support.rb +12 -0
  282. data/spec/support/logging_formatter.rb +67 -0
  283. data/spec/support/matchers/api_responses.rb +27 -0
  284. data/spec/support/matchers/collection_type_property_matchers.rb +30 -0
  285. data/spec/support/matchers/embargo.rb +9 -0
  286. data/spec/support/matchers/lease.rb +9 -0
  287. data/spec/support/matchers/match_valkyrie_ids_with_af_ids.rb +12 -0
  288. data/spec/support/matchers/pcdm_matchers.rb +34 -0
  289. data/spec/support/matchers/permission.rb +31 -0
  290. data/spec/support/matchers/response_matchers.rb +8 -0
  291. data/spec/support/optional_example.rb +17 -0
  292. data/spec/support/rake.rb +42 -0
  293. data/spec/support/selectors.rb +112 -0
  294. data/spec/support/shared_examples_for_collection_presenter.rb +44 -0
  295. data/spec/support/simple_work.rb +28 -0
  296. data/spec/support/spec_statistic.rb +24 -0
  297. data/spec/support/speedup.rb +7 -0
  298. data/spec/support/statistic_helper.rb +10 -0
  299. data/spec/support/valkyrie_indexing.rb +2 -0
  300. data/spec/support/wings_models.rb +9 -0
  301. data/template.rb +1 -3
  302. metadata +113 -30
  303. data/app/indexers/hyrax/resource_indexer.rb +0 -15
  304. data/app/models/concerns/hyrax/riiif_file.rb +0 -30
  305. data/app/services/hyrax/characterization/model_wrapper.rb +0 -0
  306. data/app/services/hyrax/custom_queries/find_by_collection_type.rb +0 -0
  307. data/app/services/hyrax/query_service.rb +0 -0
  308. data/app/services/hyrax/riiif_file_resolver.rb +0 -50
  309. data/lib/hyrax/specs/disable_animations_in_test_environment.rb +0 -53
  310. /data/app/indexers/{hyrax → concerns/hyrax}/thumbnail_indexer.rb +0 -0
@@ -5,7 +5,7 @@ module Hyrax
5
5
 
6
6
  # This overrides the models in FilterByType
7
7
  def models
8
- [::FileSet, ::Hyrax::FileSet]
8
+ Hyrax::ModelRegistry.file_set_classes
9
9
  end
10
10
  end
11
11
  end
@@ -43,7 +43,7 @@ module Hyrax
43
43
  # types from appearing in search results
44
44
  # @return [Array<Class>] the list of work types to include in searches
45
45
  def work_types
46
- Hyrax.config.curation_concerns
46
+ Hyrax::ModelRegistry.work_classes
47
47
  end
48
48
 
49
49
  def work_classes
@@ -53,7 +53,8 @@ module Hyrax
53
53
 
54
54
  def collection_classes
55
55
  return [] if only_works?
56
- [::Collection, Hyrax.config.collection_class].uniq
56
+
57
+ Hyrax::ModelRegistry.collection_classes
57
58
  end
58
59
  end
59
60
  end
@@ -9,7 +9,7 @@ module Hyrax
9
9
  # This is like include_collection_ids, but it also joins the files.
10
10
  def include_contained_files(solr_parameters)
11
11
  solr_parameters[:fq] ||= []
12
- solr_parameters[:fq] << "{!join from=file_set_ids_ssim to=id}{!join from=child_object_ids_ssim to=id}id:#{collection_id}"
12
+ solr_parameters[:fq] << "{!join from=member_ids_ssim to=id}{!join from=child_object_ids_ssim to=id}id:#{collection_id}"
13
13
  end
14
14
 
15
15
  # include filters into the query to only include the collection memebers
@@ -18,7 +18,7 @@ class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
18
18
  # This overrides the models in FilterByType
19
19
  # @return [Array<Class>] a list of classes to include
20
20
  def models
21
- [::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact
21
+ Hyrax::ModelRegistry.admin_set_classes + Hyrax::ModelRegistry.collection_classes
22
22
  end
23
23
 
24
24
  private
@@ -26,7 +26,7 @@ class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
26
26
  def query_for_my_collections
27
27
  query_service = Hyrax::SolrQueryService.new
28
28
  query_service.with_field_pairs(field_pairs: { depositor_ssim: current_user_key }, type: 'terms')
29
- query_service.with_field_pairs(field_pairs: { has_model_ssim: Hyrax.config.admin_set_model,
29
+ query_service.with_field_pairs(field_pairs: { has_model_ssim: Hyrax::ModelRegistry.admin_set_rdf_representations.join(','),
30
30
  creator_ssim: current_user_key }, type: 'terms')
31
31
  query_service.build(join_with: 'OR')
32
32
  end
@@ -20,11 +20,11 @@ class Hyrax::My::FindWorksSearchBuilder < Hyrax::My::SearchBuilder
20
20
 
21
21
  def show_only_other_works(solr_parameters)
22
22
  solr_parameters[:fq] ||= []
23
- solr_parameters[:fq] += ["-#{Hyrax::SolrQueryBuilderService.construct_query_for_ids([@id])}"]
23
+ solr_parameters[:fq] += ["-#{Hyrax::SolrQueryBuilderService.construct_query_for_ids([parsed_id])}"]
24
24
  end
25
25
 
26
26
  def show_only_works_not_child(solr_parameters)
27
- ids = Hyrax::SolrService.query("{!field f=id}#{@id}", fl: "member_ids_ssim", rows: 10_000).flat_map { |x| x.fetch("member_ids_ssim", []) }
27
+ ids = Hyrax::SolrService.query("{!field f=id}#{parsed_id}", fl: "member_ids_ssim", rows: 10_000).flat_map { |x| x.fetch("member_ids_ssim", []) }
28
28
  solr_parameters[:fq] ||= []
29
29
  solr_parameters[:fq] += ["-#{Hyrax::SolrQueryBuilderService.construct_query_for_ids([ids])}"]
30
30
  end
@@ -32,11 +32,16 @@ class Hyrax::My::FindWorksSearchBuilder < Hyrax::My::SearchBuilder
32
32
  def show_only_works_not_parent(solr_parameters)
33
33
  solr_parameters[:fq] ||= []
34
34
  solr_parameters[:fq] += [
35
- "-" + Hyrax::SolrQueryBuilderService.construct_query(member_ids_ssim: @id)
35
+ "-" + Hyrax::SolrQueryBuilderService.construct_query(member_ids_ssim: parsed_id)
36
36
  ]
37
37
  end
38
38
 
39
39
  def only_works?
40
40
  true
41
41
  end
42
+
43
+ # Since Valkyrie objects pass is an Id object, additional parsing is needed.
44
+ def parsed_id
45
+ @id.is_a?(String) ? @id : @id.id
46
+ end
42
47
  end
@@ -48,14 +48,24 @@ module Hyrax
48
48
  # # => #<Set: {#<Hyrax::Permission access_to=#<Valkyrie::ID:0x000055628b0ae0b8 @id="my_id"> agent="group/public" mode=:read>}>
49
49
  class AccessControlList
50
50
  ##
51
- # @!attribute [rw] resource
51
+ # @!attribute [r] resource
52
52
  # @return [Valkyrie::Resource]
53
53
  # @!attribute [r] persister
54
54
  # @return [#save]
55
55
  # @!attribute [r] query_service
56
56
  # @return [#find_inverse_references_by]
57
57
  attr_reader :persister, :query_service
58
- attr_accessor :resource
58
+ attr_reader :resource
59
+
60
+ ##
61
+ # @param value [Valkyrie::Resource]
62
+ # @return [Valkyrie::Resource]
63
+ def resource=(value)
64
+ # We need to remove the memoization as the @resource has changed.
65
+ @change_set = nil
66
+ @access_control_model = nil
67
+ @resource = value
68
+ end
59
69
 
60
70
  ##
61
71
  # @api public
@@ -167,7 +177,14 @@ module Hyrax
167
177
  return true unless pending_changes?
168
178
 
169
179
  change_set.sync
170
- persister.save(resource: change_set.resource)
180
+
181
+ # change_set.resource is a Hyrax::AccessControl
182
+ #
183
+ # We're setting the once fetched access_control_model to what was returned, so as to avoid
184
+ # a refetch
185
+ @access_control_model = persister.save(resource: change_set.resource)
186
+
187
+ # self.resource is a Hyrax::Resource
171
188
  Hyrax.publisher.publish('object.acl.updated', acl: self, result: :success)
172
189
  @change_set = nil
173
190
 
@@ -251,7 +268,7 @@ module Hyrax
251
268
  ##
252
269
  # @api private
253
270
  def access_control_model
254
- AccessControl.for(resource: resource, query_service: query_service)
271
+ @access_control_model ||= AccessControl.for(resource: resource, query_service: query_service)
255
272
  end
256
273
 
257
274
  ##
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Action
5
+ ##
6
+ # @since 5.0.0
7
+ # @api public
8
+ #
9
+ # Encapsulating the logic of several interacting objects. Namely the idea of using a form to
10
+ # {#validate} given parameters then to {#perform} the action by leveraging the {#transactions}'s
11
+ # {#transaction_name} configured with appropriate {#step_args} and ultimately providing the
12
+ # {#form} to then perform that work.
13
+ class CreateValkyrieWork
14
+ ##
15
+ # @!group Class Attributes
16
+ #
17
+ # @!attribute transaction_name
18
+ # @return [String] the name of the transaction that we call for the CreateValkyrieWorkAction.
19
+ class_attribute :transaction_name, default: 'change_set.create_work'
20
+ # @!endgroup Class Attributes
21
+ ##
22
+
23
+ ##
24
+ # @param form [Object] the form that we'll use for validation and performing the action.
25
+ # @param transactions [Hyrax::Transactions::Container] the transactions
26
+ # @param user [User] the person performing the action
27
+ # @param params [Hash] the contextual parameters for the action; ApplicationController#params
28
+ # if you will.
29
+ # @param work_attribute_key [String] the name of the key within the params that contains
30
+ # the work's attributes
31
+ def initialize(form:, transactions:, user:, params:, work_attributes_key:)
32
+ @form = form
33
+ @transactions = transactions
34
+ @user = user
35
+ @params = params
36
+ @work_attributes_key = work_attributes_key
37
+ @work_attributes = @params.fetch(work_attributes_key, {})
38
+ end
39
+
40
+ attr_reader :form, :transactions, :user, :parent_id, :work_attributes, :uploaded_files, :params, :work_attributes_key
41
+
42
+ ##
43
+ # @api public
44
+ # @return [TrueClass] when the object is valid.
45
+ # @return [FalseClass] when the object is valid.
46
+ def validate
47
+ form.validate(work_attributes)
48
+ end
49
+
50
+ ##
51
+ # @api public
52
+ # @return [#value_or] the resulting created work, when successful. When not successful, the
53
+ # returned value call the given block.
54
+ def perform
55
+ transactions[transaction_name].with_step_args(**step_args).call(form)
56
+ end
57
+
58
+ ##
59
+ # @api public
60
+ #
61
+ # @return [Hash<String,Hash>] the step args to use for the given {#transactions}'s
62
+ # {.transaction_name}
63
+ def step_args
64
+ {
65
+ 'work_resource.add_to_parent' => { parent_id: params[:parent_id], user: user },
66
+ 'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: work_attributes[:file_set] },
67
+ 'change_set.set_user_as_depositor' => { user: user },
68
+ 'work_resource.change_depositor' => { user: ::User.find_by_user_key(form.on_behalf_of) },
69
+ 'work_resource.save_acl' => { permissions_params: form.input_params["permissions"] }
70
+ }
71
+ end
72
+
73
+ # rubocop:disable Lint/DuplicateMethods
74
+ def uploaded_files
75
+ UploadedFile.find(params.fetch(:uploaded_files, []))
76
+ end
77
+ # rubocop:enable Lint/DuplicateMethods
78
+ end
79
+ end
80
+ end
@@ -84,12 +84,16 @@ module Hyrax
84
84
  # Create an instance of `Hyrax::AdministrativeSet` with the suggested_id if supported.
85
85
  # @return [Hyrax::AdministrativeSet] the new admin set
86
86
  def create_admin_set(suggested_id:, title:)
87
- if suggested_id.blank? || Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
87
+ # Leverage the configured admin class, if it is a Valkyrie resource, otherwise fallback.
88
+ # Until we have fully moved to Valkyrie, we will need this logic. Once past, we can
89
+ # use `Hyrax.config.admin_set_class`
90
+ klass = Hyrax.config.admin_set_class < Valkyrie::Resource ? Hyrax.config.admin_set_class : Hyrax::AdministrativeSet
91
+ if suggested_id.blank? || Hyrax.config.disable_wings
88
92
  # allow persister to assign id
89
- Hyrax::AdministrativeSet.new(title: Array.wrap(title))
93
+ klass.new(title: Array.wrap(title))
90
94
  else
91
95
  # use suggested_id
92
- Hyrax::AdministrativeSet.new(id: suggested_id, title: Array.wrap(title))
96
+ klass.new(id: suggested_id, title: Array.wrap(title))
93
97
  end
94
98
  end
95
99
 
@@ -52,8 +52,8 @@ module Hyrax
52
52
  def count_files(admin_sets)
53
53
  file_counts = Hash.new(0)
54
54
  admin_sets.each do |admin_set|
55
- query = "{!join from=file_set_ids_ssim to=id}isPartOf_ssim:#{admin_set.id}"
56
- file_results = Hyrax::SolrService.get(fq: [query, "has_model_ssim:FileSet"], rows: 0)
55
+ query = "{!join from=member_ids_ssim to=id}isPartOf_ssim:#{admin_set.id}"
56
+ file_results = Hyrax::SolrService.get(fq: [query, "{!terms f=has_model_ssim}FileSet,Hyrax::FileSet"], rows: 0)
57
57
  file_counts[admin_set.id] = file_results['response']['numFound']
58
58
  end
59
59
  file_counts
@@ -46,8 +46,10 @@ module Hyrax
46
46
  #
47
47
  # @return [Blacklight::Solr::Response]
48
48
  def available_member_works
49
+ sort_field = user_params[:sort]
49
50
  response, _docs = search_results do |builder|
50
51
  builder.search_includes_models = :works
52
+ builder.merge(sort: sort_field)
51
53
  builder
52
54
  end
53
55
  response
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
3
  module Collections
4
+ # rubocop:disable Metrics/ClassLength
4
5
  class PermissionsService
5
6
  # @api private
6
7
  #
@@ -20,17 +21,34 @@ module Hyrax
20
21
  end
21
22
  private_class_method :source_ids_for_user
22
23
 
24
+ # rubocop:disable Metrics/MethodLength
23
25
  def self.filter_source(source_type:, ids:)
24
26
  return [] if ids.empty?
25
- model = case source_type
26
- when 'admin_set'
27
- Hyrax::AdministrativeSet
28
- when 'collection'
29
- Hyrax::PcdmCollection
30
- end
27
+ models = case source_type
28
+ when 'admin_set'
29
+ Hyrax::ModelRegistry.admin_set_classes
30
+ when 'collection'
31
+ Hyrax::ModelRegistry.collection_classes
32
+ end
31
33
 
32
- Hyrax.custom_queries.find_ids_by_model(model: model, ids: ids).to_a
34
+ # Antics to cope with all of the how the custom queries work.
35
+ if defined?(Wings::ModelRegistry)
36
+ models = models.map do |model|
37
+ Wings::ModelRegistry.reverse_lookup(model)
38
+ rescue NoMethodError
39
+ nil
40
+ end.compact
41
+ end
42
+
43
+ models.flat_map do |model|
44
+ if model
45
+ Hyrax.custom_queries.find_ids_by_model(model: model, ids: ids).to_a
46
+ else
47
+ []
48
+ end
49
+ end.uniq
33
50
  end
51
+ # rubocop:enable Metrics/MethodLength
34
52
  private_class_method :filter_source
35
53
 
36
54
  # @api private
@@ -203,7 +221,7 @@ module Hyrax
203
221
  end
204
222
  private_class_method :deposit_access_to_collection?
205
223
 
206
- # @api private
224
+ # @api public
207
225
  #
208
226
  # Determine if the given user has :manage access for the given collection
209
227
  #
@@ -215,7 +233,6 @@ module Hyrax
215
233
  def self.manage_access_to_collection?(collection_id:, ability:, exclude_groups: [])
216
234
  access_to_collection?(collection_id: collection_id, access: 'manage', ability: ability, exclude_groups: exclude_groups)
217
235
  end
218
- private_class_method :manage_access_to_collection?
219
236
 
220
237
  # @api private
221
238
  #
@@ -250,5 +267,6 @@ module Hyrax
250
267
  end
251
268
  private_class_method :access_to_collection?
252
269
  end
270
+ # rubocop:enable Metrics/ClassLength
253
271
  end
254
272
  end
@@ -30,7 +30,7 @@ module Hyrax
30
30
  # @return [Enumerable<PcdmCollection>]
31
31
  def find_collections_by_type(global_id:)
32
32
  query_service
33
- .find_all_of_model(model: PcdmCollection)
33
+ .find_all_of_model(model: Hyrax.config.collection_model.safe_constantize)
34
34
  .select { |collection| collection.collection_type_gid == global_id }
35
35
  end
36
36
  end
@@ -64,7 +64,7 @@ module Hyrax
64
64
  # @example
65
65
  # Hyrax.query_service.find_file_metadata_by_use(use: ::RDF::URI("http://pcdm.org/ExtractedText"))
66
66
  def find_many_file_metadata_by_use(resource:, use:)
67
- return [] unless resource.try(:file_ids)
67
+ return [] if resource.try(:file_ids).blank?
68
68
 
69
69
  results = find_many_file_metadata_by_ids(ids: resource.file_ids)
70
70
  results.select { |fm| fm.pcdm_use.include?(use) }
@@ -65,7 +65,7 @@ module Hyrax
65
65
  def find_thumbnail(file_set:)
66
66
  find_exactly_one_file_by_use(
67
67
  file_set: file_set,
68
- use: Hyrax::FileMetadata::Use::THUMBNAIL
68
+ use: Hyrax::FileMetadata::Use::THUMBNAIL_IMAGE
69
69
  )
70
70
  end
71
71
 
@@ -33,7 +33,7 @@ module Hyrax
33
33
  if results.count > 1
34
34
  Hyrax.logger.warn("#{resource.work? ? 'Work' : 'File set'} " \
35
35
  "#{resource.id} is in #{results.count} works when it " \
36
- "should be in no more than one.")
36
+ "should be in no more than one. Found in #{results.map(&:id).join(', ')}.")
37
37
  end
38
38
  results.first
39
39
  end
@@ -215,7 +215,7 @@ module Hyrax
215
215
  # @todo Refactor inner working of code as there's lots of branching logic with potential hidden assumptions.
216
216
  def qualifies_as_unauthorized_collection?(resource:)
217
217
  case resource
218
- when AdminSet, Hyrax::AdministrativeSet
218
+ when *Hyrax::ModelRegistry.admin_set_classes
219
219
  # Prior to this refactor, we looked at AdminSet only; However with the advent of the
220
220
  # Hyrax::AdministrativeSet, we need to test both cases.
221
221
  true
@@ -176,7 +176,7 @@ module Hyrax
176
176
  # Deactivates the embargo
177
177
  # @return [Boolean]
178
178
  def deactivate!
179
- release!(force: true)
179
+ release(force: true)
180
180
  nullify(force: true)
181
181
  end
182
182
 
@@ -2,8 +2,17 @@
2
2
 
3
3
  module Hyrax
4
4
  ##
5
- # A service for accessing specific Hyrax::FileMetadata objects referenced by a
6
- # Hyrax::FileSet.
5
+ # A service for accessing {Hyrax::FileMetadata} resources by their status
6
+ # within a {Hyrax::FileSet}. For example, this is the home for the abstraction
7
+ # of a "Primary" file for the FileSet, used for versioning and as the default
8
+ # source for the FileSet label, etc...
9
+ #
10
+ # If you're looking for {Hyrax::FileMetadata} by PCDM Use, use the custom
11
+ # queries (e.g. +Hyrax.custom_queries.find_original_file+).
12
+ #
13
+ # @note housing the "primary" file abstraction here allows us to begin
14
+ # separating from the idea that the `pcdmuse:OriginalFile` is special
15
+ # in Hyrax in a hard coded way.
7
16
  class FileSetFileService
8
17
  ##
9
18
  # @!attribute [r] file_set
@@ -23,7 +32,7 @@ module Hyrax
23
32
  end
24
33
 
25
34
  ##
26
- # Return the Hyrax::FileMetadata which should be considered “original” for
35
+ # Return the Hyrax::FileMetadata which should be considered “primary” for
27
36
  # indexing and version‐tracking.
28
37
  #
29
38
  # If +file_set.original_file_id+ is defined, it will be used; otherwise,
@@ -32,7 +41,7 @@ module Hyrax
32
41
  # first file in its :file_ids.
33
42
  #
34
43
  # @return [Hyrax::FileMetadata]
35
- def original_file
44
+ def primary_file
36
45
  if file_set.original_file_id
37
46
  # Always just use original_file_id if it is defined.
38
47
  #
@@ -43,13 +52,15 @@ module Hyrax
43
52
  # Cache the fallback to avoid needing to do this query twice.
44
53
  #
45
54
  # See NOTE above regarding use of :find_file_metadata_by.
46
- @original_file ||= begin
47
- query_service.custom_queries.find_original_file(file_set: file_set)
48
- rescue Valkyrie::Persistence::ObjectNotFoundError
49
- fallback_id = file_set.file_ids.first
50
- query_service.custom_queries.find_file_metadata_by(id: fallback_id) if fallback_id
51
- end
55
+ @primary_file ||= begin
56
+ query_service.custom_queries.find_original_file(file_set: file_set)
57
+ rescue Valkyrie::Persistence::ObjectNotFoundError
58
+ fallback_id = file_set.file_ids.first
59
+ query_service.custom_queries.find_file_metadata_by(id: fallback_id) if fallback_id
60
+ end
52
61
  end
53
62
  end
63
+ alias original_file primary_file
64
+ deprecation_deprecate :original_file
54
65
  end
55
66
  end
@@ -23,7 +23,7 @@ module Hyrax
23
23
  #
24
24
  # @see https://trailblazer.to/2.0/gems/reform/prepopulator.html
25
25
  def build(model, _ability, _controller)
26
- Hyrax::Forms::ResourceForm.for(model).prepopulate!
26
+ Hyrax::Forms::ResourceForm.for(resource: model).prepopulate!
27
27
  end
28
28
  end
29
29
  end
@@ -12,12 +12,13 @@ module Hyrax
12
12
  # date is today or later.
13
13
  # - "Applied" means the lease's pre-expiration visibility has been set on
14
14
  # the resource.
15
- # - "Released" means the lease's post-expiration visibility has been set on
16
- # the resource.
17
15
  # - "Enforced" means the object's visibility matches the pre-expiration
18
16
  # visibility of the lease; i.e. the lease has been applied,
19
17
  # but not released.
20
- # - "Deactivate" means that the existing lease will be removed
18
+ # - "Released" means the leases's post-release visibility has been set on
19
+ # the resource.
20
+ # - "Deactivate" means that the existing lease will be removed, even if it
21
+ # is active
21
22
  #
22
23
  class LeaseManager # rubocop:disable Metrics/ClassLength
23
24
  ##
@@ -53,11 +54,25 @@ module Hyrax
53
54
  .lease
54
55
  end
55
56
 
57
+ # @return [Boolean]
58
+ def deactivate_lease_for(resource:, query_service: Hyrax.query_service)
59
+ new(resource: resource, query_service: query_service)
60
+ .deactivate
61
+ end
62
+
63
+ # @return [Boolean]
64
+ def deactivate_lease_for!(resource:, query_service: Hyrax.query_service)
65
+ new(resource: resource, query_service: query_service)
66
+ .deactivate!
67
+ end
68
+
69
+ # @return [Boolean]
56
70
  def release_lease_for(resource:, query_service: Hyrax.query_service)
57
71
  new(resource: resource, query_service: query_service)
58
72
  .release
59
73
  end
60
74
 
75
+ # @return [Boolean]
61
76
  def release_lease_for!(resource:, query_service: Hyrax.query_service)
62
77
  new(resource: resource, query_service: query_service)
63
78
  .release!
@@ -93,20 +108,15 @@ module Hyrax
93
108
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
94
109
  end
95
110
 
111
+ def deactivate
112
+ release(force: true) &&
113
+ nullify(force: true)
114
+ end
115
+
96
116
  # Deactivates the lease and logs a message to the lease_history property
97
117
  def deactivate!
98
- lease_state = lease.active? ? 'active' : 'expired'
99
- lease_record = lease_history_message(
100
- lease_state,
101
- Time.zone.today,
102
- lease.lease_expiration_date,
103
- lease.visibility_during_lease,
104
- lease.visibility_after_lease
105
- )
106
-
107
118
  release(force: true)
108
119
  nullify(force: true)
109
- lease.lease_history += [lease_record]
110
120
  end
111
121
 
112
122
  ##
@@ -153,14 +163,15 @@ module Hyrax
153
163
  ##
154
164
  # Drop the lease by setting its release date and visibility settings to `nil`.
155
165
  #
156
- # @param force [boolean] force the nullify even when the lease period is current
157
- # @return [void]
166
+ # @param force [Boolean] force the nullify even when the lease period is current
167
+ # @return [Boolean]
158
168
  def nullify(force: false)
159
169
  return false if !force && under_lease?
160
170
 
161
171
  lease.lease_expiration_date = nil
162
172
  lease.visibility_during_lease = nil
163
173
  lease.visibility_after_lease = nil
174
+ true
164
175
  end
165
176
 
166
177
  ##
@@ -172,6 +183,18 @@ module Hyrax
172
183
  # @return [Boolean]
173
184
  def release(force: false)
174
185
  return false if !force && under_lease?
186
+
187
+ lease_state = lease.active? ? 'active' : 'expired'
188
+ history_record = lease_history_message(
189
+ lease_state,
190
+ Hyrax::TimeService.time_in_utc,
191
+ lease.lease_expiration_date,
192
+ lease.visibility_during_lease,
193
+ lease.visibility_after_lease
194
+ )
195
+
196
+ lease.lease_history += [history_record]
197
+
175
198
  return true if lease.visibility_after_lease.nil?
176
199
 
177
200
  resource.visibility = lease.visibility_after_lease
@@ -202,7 +225,7 @@ module Hyrax
202
225
  [:visibility_after_lease, :visibility_during_lease, :lease_expiration_date]
203
226
  end
204
227
 
205
- # Create the log message used when deactivating a lease
228
+ # Create the log message used when releasing a lease
206
229
  def lease_history_message(state, deactivate_date, expiration_date, visibility_during, visibility_after)
207
230
  I18n.t 'hydra.lease.history_message',
208
231
  state: state,
@@ -1,20 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
+ ##
4
+ # Methods for Querying Repository to find Objects with leases
3
5
  class LeaseService < RestrictionService
4
6
  class << self
5
7
  # Returns all assets with lease expiration date set to a date in the past
6
- def assets_with_expired_leases
8
+ def assets_with_expired_enforced_leases
7
9
  builder = Hyrax::ExpiredLeaseSearchBuilder.new(self)
8
10
  presenters(builder)
9
11
  end
12
+ alias assets_with_expired_leases assets_with_expired_enforced_leases
10
13
 
11
- # Returns all assets with lease expiration date set
12
- # (assumes that when lease visibility is applied to assets
13
- # whose leases have expired, the lease expiration date will be removed from its metadata)
14
- def assets_under_lease
14
+ ##
15
+ # Returns all assets with leases that are currently enforced,
16
+ # regardless of whether the leases are active or expired.
17
+ #
18
+ # @see Hyrax::LeaseManager
19
+ def assets_with_enforced_leases
15
20
  builder = Hyrax::LeaseSearchBuilder.new(self)
16
- presenters(builder)
21
+ presenters(builder).select(&:enforced?)
17
22
  end
23
+ alias assets_under_lease assets_with_enforced_leases
18
24
 
19
25
  # Returns all assets that have had embargoes deactivated in the past.
20
26
  def assets_with_deactivated_leases
@@ -7,7 +7,7 @@ module Hyrax
7
7
  #
8
8
  # Hyrax's `Ability` behavior depends on the index being up-to-date as
9
9
  # concerns-their read/write users/groups, and visibility.
10
- class AclIndexListener
10
+ class ACLIndexListener
11
11
  ##
12
12
  # Re-index the resource for the updated ACL.
13
13
  #
@@ -7,7 +7,7 @@ module Hyrax
7
7
  #
8
8
  # Hyrax's `Ability` behavior depends on the index being up-to-date as
9
9
  # concerns-their read/write users/groups, and visibility.
10
- class ActiveFedoraAclIndexListener
10
+ class ActiveFedoraACLIndexListener
11
11
  ##
12
12
  # Re-index the resource for the updated ACL.
13
13
  #
@@ -8,7 +8,21 @@ 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); end
11
+ def on_object_deleted(event)
12
+ event = event.to_h
13
+ return unless event[:object]
14
+
15
+ object = event[:object]
16
+ user = event[:user]
17
+ return unless object.is_a?(Hyrax::Work)
18
+
19
+ Hyrax.query_service.find_parents(resource: object).each do |parent|
20
+ parent.member_ids -= [object.id]
21
+ Hyrax.persister.save(resource: parent)
22
+ Hyrax.index_adapter.save(resource: parent)
23
+ Hyrax.publisher.publish('object.membership.updated', object: parent, user: user)
24
+ end
25
+ end
12
26
 
13
27
  # Called when 'collection.deleted' event is published
14
28
  # @param [Dry::Events::Event] event