hyrax 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +46 -13
  3. data/.dassie/Gemfile +11 -6
  4. data/.dassie/app/controllers/catalog_controller.rb +6 -0
  5. data/.dassie/config/initializers/hyrax.rb +5 -0
  6. data/.dassie/config/initializers/riiif.rb +22 -20
  7. data/.dassie/config/role_map.yml +2 -0
  8. data/.dassie/db/seeds.rb +1 -1
  9. data/.dassie/package.json +3 -5
  10. data/.dockerignore +3 -0
  11. data/.env +1 -2
  12. data/.rubocop.yml +4 -0
  13. data/CONTAINERS.md +21 -1
  14. data/Dockerfile +42 -17
  15. data/Gemfile +21 -27
  16. data/app/actors/hyrax/actors/base_actor.rb +2 -2
  17. data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -3
  18. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
  19. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  20. data/app/actors/hyrax/actors/file_set_actor.rb +12 -5
  21. data/app/assets/stylesheets/hyrax/_styles.scss +5 -0
  22. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +30 -10
  23. data/app/controllers/concerns/hyrax/controller.rb +13 -2
  24. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  25. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  26. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
  27. data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -19
  28. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +5 -6
  29. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  30. data/app/controllers/hyrax/collections_controller.rb +3 -1
  31. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +24 -17
  32. data/app/controllers/hyrax/dashboard/collections_controller.rb +99 -35
  33. data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +75 -39
  34. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  35. data/app/controllers/hyrax/my_controller.rb +4 -4
  36. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  37. data/app/controllers/hyrax/workflow_actions_controller.rb +11 -6
  38. data/app/forms/hyrax/forms/administrative_set_form.rb +62 -0
  39. data/app/forms/hyrax/forms/collection_form.rb +14 -8
  40. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +38 -6
  41. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  42. data/app/forms/hyrax/forms/pcdm_collection_form.rb +64 -0
  43. data/app/forms/hyrax/forms/permission.rb +23 -0
  44. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  45. data/app/forms/hyrax/forms/resource_form.rb +34 -26
  46. data/app/forms/hyrax/forms/work_form.rb +5 -2
  47. data/app/forms/hyrax/forms/workflow_action_form.rb +4 -0
  48. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  49. data/app/helpers/hyrax/collections_helper.rb +88 -2
  50. data/app/helpers/hyrax/dashboard_helper_behavior.rb +16 -5
  51. data/app/helpers/hyrax/embargo_helper.rb +4 -0
  52. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  53. data/app/helpers/hyrax/hyrax_helper_behavior.rb +9 -0
  54. data/app/helpers/hyrax/lease_helper.rb +4 -0
  55. data/app/helpers/hyrax/url_helper.rb +4 -1
  56. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  57. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  58. data/app/indexers/hyrax/pcdm_collection_indexer.rb +2 -0
  59. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +2 -0
  60. data/app/indexers/hyrax/valkyrie_indexer.rb +4 -3
  61. data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -1
  62. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  63. data/app/jobs/attach_files_to_work_job.rb +19 -10
  64. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  65. data/app/jobs/ingest_local_file_job.rb +18 -2
  66. data/app/jobs/inherit_permissions_job.rb +9 -5
  67. data/app/models/admin_set.rb +22 -30
  68. data/app/models/collection_branding_info.rb +25 -9
  69. data/app/models/concerns/hyrax/ability/admin_set_ability.rb +31 -7
  70. data/app/models/concerns/hyrax/ability/collection_ability.rb +35 -20
  71. data/app/models/concerns/hyrax/ability/collection_type_ability.rb +1 -1
  72. data/app/models/concerns/hyrax/ability.rb +5 -3
  73. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  74. data/app/models/concerns/hyrax/embargoable.rb +24 -0
  75. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  76. data/app/models/concerns/hyrax/solr_document_behavior.rb +11 -54
  77. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  78. data/app/models/concerns/hyrax/user.rb +9 -3
  79. data/app/models/concerns/hyrax/work_behavior.rb +1 -1
  80. data/app/models/hyrax/administrative_set.rb +7 -1
  81. data/app/models/hyrax/file_set.rb +6 -0
  82. data/app/models/hyrax/pcdm_collection.rb +1 -0
  83. data/app/models/hyrax/permission.rb +1 -1
  84. data/app/models/hyrax/permission_template.rb +112 -12
  85. data/app/models/hyrax/virus_scanner.rb +27 -18
  86. data/app/models/hyrax/work.rb +1 -0
  87. data/app/models/hyrax/workflow_action_info.rb +16 -0
  88. data/app/models/sipity/agent.rb +1 -0
  89. data/app/models/sipity/comment.rb +17 -0
  90. data/app/models/sipity/entity.rb +30 -8
  91. data/app/models/sipity/workflow.rb +1 -0
  92. data/app/models/sipity.rb +53 -2
  93. data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
  94. data/app/presenters/hyrax/admin_set_presenter.rb +13 -4
  95. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  96. data/app/presenters/hyrax/collection_presenter.rb +44 -23
  97. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  98. data/app/presenters/hyrax/file_usage.rb +3 -2
  99. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
  100. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  101. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  102. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  103. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  104. data/app/presenters/hyrax/version_presenter.rb +3 -2
  105. data/app/presenters/hyrax/work_show_presenter.rb +32 -6
  106. data/app/presenters/hyrax/work_usage.rb +5 -3
  107. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  108. data/app/search_builders/hyrax/abstract_type_relation.rb +4 -2
  109. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  110. data/app/search_builders/hyrax/collection_member_search_builder.rb +6 -1
  111. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +1 -1
  112. data/app/search_builders/hyrax/exposed_models_relation.rb +1 -1
  113. data/app/search_builders/hyrax/filter_by_type.rb +1 -2
  114. data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
  115. data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
  116. data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
  117. data/app/services/hyrax/admin_set_create_service.rb +136 -52
  118. data/app/services/hyrax/collection_types/permissions_service.rb +1 -1
  119. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  120. data/app/services/hyrax/collections/collection_member_service.rb +122 -27
  121. data/app/services/hyrax/collections/migration_service.rb +4 -2
  122. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  123. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  124. data/app/services/hyrax/collections/permissions_create_service.rb +82 -78
  125. data/app/services/hyrax/collections/permissions_service.rb +1 -1
  126. data/app/services/hyrax/contextual_path.rb +24 -1
  127. data/app/services/hyrax/curation_concern.rb +24 -2
  128. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  129. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  130. data/app/services/hyrax/default_middleware_stack.rb +11 -0
  131. data/app/services/hyrax/edit_permissions_service.rb +74 -41
  132. data/app/services/hyrax/ensure_well_formed_admin_set_service.rb +3 -3
  133. data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
  134. data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +1 -0
  135. data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
  136. data/app/services/hyrax/listeners/metadata_index_listener.rb +25 -9
  137. data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
  138. data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
  139. data/app/services/hyrax/listeners.rb +2 -0
  140. data/app/services/hyrax/multiple_membership_checker.rb +53 -29
  141. data/app/services/hyrax/permission_manager.rb +4 -4
  142. data/app/services/hyrax/persist_derivatives.rb +3 -1
  143. data/app/services/hyrax/resource_status.rb +7 -0
  144. data/app/services/hyrax/search_service.rb +4 -2
  145. data/app/services/hyrax/solr_query_builder_service.rb +45 -8
  146. data/app/services/hyrax/solr_query_service.rb +224 -0
  147. data/app/services/hyrax/solr_service.rb +9 -2
  148. data/app/services/hyrax/statistics/collections/over_time.rb +2 -1
  149. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  150. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  151. data/app/services/hyrax/visibility_intention.rb +20 -2
  152. data/app/services/hyrax/visibility_propagator.rb +30 -1
  153. data/app/services/hyrax/work_uploads_handler.rb +17 -2
  154. data/app/services/hyrax/workflow/abstract_notification.rb +2 -2
  155. data/app/services/hyrax/workflow/action_taken_service.rb +16 -4
  156. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  157. data/app/services/hyrax/workflow/activate_object.rb +5 -4
  158. data/app/services/hyrax/workflow/changes_required_notification.rb +5 -4
  159. data/app/services/hyrax/workflow/deactivate_object.rb +7 -5
  160. data/app/services/hyrax/workflow/deposited_notification.rb +8 -4
  161. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +7 -3
  162. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +10 -3
  163. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  164. data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +8 -2
  165. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  166. data/app/services/hyrax/workflow/workflow_action_service.rb +4 -1
  167. data/app/views/hyrax/admin/admin_sets/_form.html.erb +1 -1
  168. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  169. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  170. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  171. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  172. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  173. data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
  174. data/app/views/hyrax/base/_guts4form.html.erb +3 -3
  175. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  176. data/app/views/hyrax/base/_show_actions.html.erb +2 -2
  177. data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
  178. data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
  179. data/app/views/hyrax/collections/show.html.erb +1 -1
  180. data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -1
  181. data/app/views/hyrax/dashboard/collections/_form.html.erb +4 -4
  182. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
  183. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  184. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +1 -1
  185. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  186. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  187. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  188. data/app/views/hyrax/file_sets/_actions.html.erb +10 -0
  189. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  190. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  191. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  192. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  193. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  194. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  195. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  196. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  197. data/app/views/hyrax/homepage/index.html.erb +1 -1
  198. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  199. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  200. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  201. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  202. data/app/views/hyrax/my/collections/_modal_collection_types_to_create.html.erb +1 -1
  203. data/app/views/layouts/hyrax/dashboard.html.erb +1 -0
  204. data/app/views/layouts/hyrax.html.erb +1 -0
  205. data/app/views/shared/_read_only.html.erb +5 -0
  206. data/bin/db-migrate-seed.sh +3 -1
  207. data/bin/hyrax-entrypoint.sh +0 -14
  208. data/bin/solrcloud-assign-configset.sh +11 -3
  209. data/bin/solrcloud-upload-configset.sh +17 -6
  210. data/chart/hyrax/Chart.yaml +9 -5
  211. data/chart/hyrax/README.md +52 -5
  212. data/chart/hyrax/templates/_helpers.tpl +23 -1
  213. data/chart/hyrax/templates/branding-pvc.yaml +14 -0
  214. data/chart/hyrax/templates/configmap-env.yaml +14 -3
  215. data/chart/hyrax/templates/deployment-worker.yaml +129 -0
  216. data/chart/hyrax/templates/deployment.yaml +95 -0
  217. data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
  218. data/chart/hyrax/templates/ingress.yaml +13 -4
  219. data/chart/hyrax/templates/secrets.yaml +9 -0
  220. data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
  221. data/chart/hyrax/values.yaml +114 -1
  222. data/config/brakeman.ignore +2 -2
  223. data/config/features.rb +50 -43
  224. data/config/initializers/1_healthz.rb +1 -0
  225. data/config/initializers/listeners.rb +4 -1
  226. data/config/initializers/valkryrie_storage.rb +7 -0
  227. data/config/locales/hyrax.de.yml +1 -1
  228. data/config/locales/hyrax.en.yml +2 -1
  229. data/config/locales/hyrax.es.yml +1 -1
  230. data/config/locales/hyrax.fr.yml +1 -1
  231. data/config/locales/hyrax.it.yml +1 -1
  232. data/config/locales/hyrax.pt-BR.yml +1 -1
  233. data/config/locales/hyrax.zh.yml +1 -1
  234. data/db/seeds.rb +1 -1
  235. data/docker-compose.yml +39 -8
  236. data/documentation/developing-your-hyrax-based-app.md +3 -3
  237. data/documentation/legacyREADME.md +3 -3
  238. data/hyrax.gemspec +1 -1
  239. data/lib/generators/hyrax/templates/catalog_controller.rb +3 -1
  240. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +15 -0
  241. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
  242. data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +1 -1
  243. data/lib/generators/hyrax/work_resource/templates/indexer_spec.rb.erb +1 -0
  244. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  245. data/lib/hyrax/collection_name.rb +6 -2
  246. data/lib/hyrax/configuration.rb +56 -0
  247. data/lib/hyrax/engine.rb +3 -1
  248. data/lib/hyrax/errors.rb +2 -0
  249. data/lib/hyrax/form_fields.rb +1 -0
  250. data/lib/hyrax/publisher.rb +12 -0
  251. data/lib/hyrax/resource_name.rb +1 -0
  252. data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
  253. data/lib/hyrax/resource_sync/resource_list_writer.rb +2 -2
  254. data/lib/hyrax/specs/capybara.rb +5 -3
  255. data/lib/hyrax/specs/shared_specs/hydra_works.rb +2 -0
  256. data/lib/hyrax/specs/shared_specs/indexers.rb +6 -0
  257. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  258. data/lib/hyrax/transactions/collection_create.rb +25 -0
  259. data/lib/hyrax/transactions/collection_update.rb +20 -0
  260. data/lib/hyrax/transactions/container.rb +47 -0
  261. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  262. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  263. data/lib/hyrax/transactions/steps/add_to_collections.rb +13 -1
  264. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  265. data/lib/hyrax/transactions/steps/apply_collection_type_permissions.rb +29 -0
  266. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  267. data/lib/hyrax/transactions/steps/save.rb +18 -6
  268. data/lib/hyrax/transactions/steps/set_collection_type_gid.rb +35 -0
  269. data/lib/hyrax/transactions/work_create.rb +2 -1
  270. data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
  271. data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -0
  272. data/lib/hyrax/version.rb +1 -1
  273. data/lib/hyrax.rb +9 -0
  274. data/lib/tasks/collection_type_global_id.rake +1 -1
  275. data/lib/tasks/default_admin_set.rake +12 -11
  276. data/lib/tasks/regenerate_derivatives.rake +12 -0
  277. data/lib/wings/active_fedora_converter/default_work.rb +15 -0
  278. data/lib/wings/converter_value_mapper.rb +2 -2
  279. data/lib/wings/model_transformer.rb +17 -1
  280. data/lib/wings/orm_converter.rb +18 -2
  281. data/lib/wings/setup.rb +2 -0
  282. data/lib/wings/valkyrie/persister.rb +7 -5
  283. data/lib/wings/valkyrie/query_service.rb +60 -17
  284. data/lib/wings/valkyrie/storage.rb +56 -1
  285. data/lib/wings.rb +0 -21
  286. data/template.rb +1 -1
  287. metadata +42 -9
@@ -30,7 +30,7 @@ module Hyrax
30
30
  def fetch_thumbnail(object)
31
31
  return object if object.thumbnail_id == object.id
32
32
  Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: object.thumbnail_id)
33
- rescue Hyrax::ObjectNotFoundError
33
+ rescue Valkyrie::Persistence::ObjectNotFoundError, Hyrax::ObjectNotFoundError
34
34
  Rails.logger.error("Couldn't find thumbnail #{object.thumbnail_id} for #{object.id}")
35
35
  nil
36
36
  end
@@ -54,7 +54,7 @@ module Hyrax
54
54
  ##
55
55
  # @return [Boolean]
56
56
  def valid_embargo?
57
- wants_embargo? && release_date.present?
57
+ wants_embargo? && release_date.present? && a_valid_date?(release_date)
58
58
  end
59
59
 
60
60
  ##
@@ -66,7 +66,7 @@ module Hyrax
66
66
  ##
67
67
  # @return [Boolean]
68
68
  def valid_lease?
69
- wants_lease? && release_date.present?
69
+ wants_lease? && release_date.present? && a_valid_date?(release_date)
70
70
  end
71
71
 
72
72
  ##
@@ -74,5 +74,23 @@ module Hyrax
74
74
  def wants_lease?
75
75
  visibility == LEASE_REQUEST
76
76
  end
77
+
78
+ private
79
+
80
+ ##
81
+ # @param date [Object]
82
+ # @return [Boolean]
83
+ # @note If we don't have a valid date, we really can't have a
84
+ # valid release_date
85
+ def a_valid_date?(date)
86
+ return true if date.is_a?(Date)
87
+ return true if date.is_a?(Time)
88
+ Date.parse(date)
89
+ # In Ruby 2.7.x, Date::Error descends from ArgumentError; Once
90
+ # we stop supporting pre-2.7, we can switch this to the more
91
+ # narrow Date::Error
92
+ rescue ArgumentError
93
+ false
94
+ end
77
95
  end
78
96
  end
@@ -2,7 +2,7 @@
2
2
  module Hyrax
3
3
  ##
4
4
  # @abstract Propagates visibility from a provided object (e.g. a Work) to some
5
- # group of its members (e.g. file_sets).
5
+ # group of its members (e.g. file_sets).
6
6
  class VisibilityPropagator
7
7
  ##
8
8
  # @param source [#visibility] the object to propagate visibility from
@@ -14,6 +14,35 @@ module Hyrax
14
14
  FileSetVisibilityPropagator.new(source: source)
15
15
  when Hyrax::Resource # Valkyrie
16
16
  ResourceVisibilityPropagator.new(source: source)
17
+ else
18
+ NullVisibilityPropogator.new(source: source)
19
+ end
20
+ end
21
+
22
+ ##
23
+ # Provides a null/logging implementation of the visibility propogator.
24
+ class NullVisibilityPropogator
25
+ ##
26
+ # @!attribute [rw] source
27
+ # @return [#visibility]
28
+ attr_accessor :source
29
+
30
+ ##
31
+ # @param source [#visibility] the object to propagate visibility from
32
+ def initialize(source:)
33
+ self.source = source
34
+ end
35
+
36
+ ##
37
+ # @return [void]
38
+ # @raise [RuntimeError] if we're in development mode
39
+ def propogate
40
+ message = "Tried to propogate visibility to members of #{source} " \
41
+ "but didn't know what kind of object it is. Model " \
42
+ "name #{source.try(:model_name)}. Called from #{caller[0]}."
43
+
44
+ Hyrax.logger.warn(message)
45
+ Rails.env.development? ? raise(message) : :noop
17
46
  end
18
47
  end
19
48
  end
@@ -48,7 +48,9 @@ module Hyrax
48
48
  # @return [Enumberable<Hyrax::UploadedFile>]
49
49
  # @!attribute [r] work
50
50
  # @return [Hyrax::Work]
51
- attr_reader :files, :work
51
+ # @!attribute [r] file_set_params
52
+ # @return [Enumerable<Hash>]
53
+ attr_reader :files, :work, :file_set_params
52
54
 
53
55
  ##
54
56
  # @param [Hyrax::Work] work
@@ -71,9 +73,10 @@ module Hyrax
71
73
  # @return [WorkFileSetManager] self
72
74
  # @raise [ArgumentError] if any of the uploaded files are not an
73
75
  # `UploadedFile`
74
- def add(files:)
76
+ def add(files:, file_set_params: [])
75
77
  validate_files(files) &&
76
78
  @files = Array.wrap(files).reject { |f| f.file_set_uri.present? }
79
+ @file_set_params = file_set_params
77
80
  self
78
81
  end
79
82
 
@@ -105,6 +108,10 @@ module Hyrax
105
108
 
106
109
  # copy ACLs; should we also be propogating embargo/lease?
107
110
  Hyrax::AccessControlList.copy_permissions(source: target_permissions, target: file_set)
111
+
112
+ # set visibility from params and save
113
+ file_set.visibility = file_set_extra_params(file)[:visibility] if file_set_extra_params(file)[:visibility].present?
114
+ file_set.permission_manager.acl.save if file_set.permission_manager.acl.pending_changes?
108
115
  append_to_work(file_set)
109
116
 
110
117
  IngestJob.perform_later(wrap_file(file, file_set))
@@ -135,6 +142,14 @@ module Hyrax
135
142
  title: file.uploader.filename }
136
143
  end
137
144
 
145
+ ##
146
+ # @api private
147
+ #
148
+ # return [Hash(Symbol => Object)]
149
+ def file_set_extra_params(file)
150
+ file_set_params&.find { |fs| fs[:uploaded_file_id] == file.id.to_s } || {}
151
+ end
152
+
138
153
  ##
139
154
  # @api private
140
155
  #
@@ -39,9 +39,9 @@ module Hyrax
39
39
  # @option recipients [Array<Hyrax::User>] :to a list of users to which to send the notification
40
40
  # @option recipients [Array<Hyrax::User>] :cc a list of users to which to copy on the notification
41
41
  def initialize(entity, comment, user, recipients)
42
- @work_id = entity.proxy_for_global_id.sub(/.*\//, '')
42
+ @work_id = entity.proxy_for.id
43
43
  @title = entity.proxy_for.title.first
44
- @comment = comment.respond_to?(:comment) ? comment.comment.to_s : ''
44
+ @comment = comment&.comment.to_s
45
45
  # Convert to hash with indifferent access to allow both string and symbol keys
46
46
  @recipients = recipients.with_indifferent_access
47
47
  @user = user
@@ -14,7 +14,14 @@ module Hyrax
14
14
  end
15
15
 
16
16
  def initialize(target:, action:, comment:, user:)
17
- @target = target
17
+ @target =
18
+ case target
19
+ when Valkyrie::Resource
20
+ Hyrax::ChangeSet.for(target)
21
+ else
22
+ target
23
+ end
24
+
18
25
  @action = action
19
26
  @comment = comment
20
27
  @user = user
@@ -70,10 +77,15 @@ module Hyrax
70
77
  # @api private
71
78
  def save_target
72
79
  case target
73
- when ActiveFedora::Base
74
- target.save
80
+ when Valkyrie::ChangeSet
81
+ return target.model unless target.changed?
82
+
83
+ Hyrax::Transactions::Container['change_set.apply']
84
+ .with_step_args('change_set.save' => { user: user })
85
+ .call(target)
86
+ .value!
75
87
  else
76
- Hyrax.persister.save(resource: target)
88
+ target.save
77
89
  end
78
90
  end
79
91
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Workflow
4
+ ##
5
+ # Produces a list of workflow-ready objects for a given user. Results are
6
+ # given as a presenter objects with SolrDocument-like behavior, with added
7
+ # support for workflow states.
8
+ #
9
+ # @example
10
+ # Hyrax::Workflow::ActionableObjects.new(user: current_user).each do |object|
11
+ # puts object.title
12
+ # puts object.workflow_state
13
+ # end
14
+ #
15
+ # @see Hyrax::Workflow::ObjectInWorkflowDecorator
16
+ class ActionableObjects
17
+ include Enumerable
18
+
19
+ ##
20
+ # @!attribute [rw] user
21
+ # @return [::User]
22
+ attr_accessor :user
23
+
24
+ ##
25
+ # @param [::User] user the user whose
26
+ def initialize(user:)
27
+ @user = user
28
+ end
29
+
30
+ ##
31
+ # @return [Hyrax::Workflow::ObjectInWorkflowDecorator]
32
+ def each
33
+ return enum_for(:each) unless block_given?
34
+ ids_and_states = id_state_pairs
35
+ return if ids_and_states.none?
36
+
37
+ docs = Hyrax::SolrQueryService.new.with_ids(ids: ids_and_states.map(&:first)).solr_documents
38
+
39
+ docs.each do |solr_doc|
40
+ object = ObjectInWorkflowDecorator.new(solr_doc)
41
+ _, state = ids_and_states.find { |id, _| id == object.id }
42
+
43
+ object.workflow_state = state
44
+
45
+ yield object
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ ##
52
+ # @api private
53
+ # @return [Array[String, Sipity::WorkflowState]]
54
+ def id_state_pairs
55
+ gids_and_states = PermissionQuery
56
+ .scope_entities_for_the_user(user: user)
57
+ .pluck(:proxy_for_global_id, :workflow_state_id)
58
+
59
+ return [] if gids_and_states.none?
60
+
61
+ all_states = Sipity::WorkflowState.find(gids_and_states.map(&:last).uniq)
62
+
63
+ gids_and_states.map do |str, state_id|
64
+ [GlobalID.new(str).model_id,
65
+ all_states.find { |state| state.id == state_id }]
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -3,14 +3,15 @@ module Hyrax
3
3
  module Workflow
4
4
  module ActivateObject
5
5
  ##
6
- # This is a built in function for workflow, setting the `#state`
7
- # of the target to the Fedora 'active' status URI
6
+ # This is a built in function for workflow, setting the +#state+
7
+ # of the target to the Fedora +active+ status URI
8
8
  #
9
- # @param target [#state] an instance of a model that includes `Hyrax::Suppressible`
9
+ # @param target [#state] an instance of a model with a +#state+ property;
10
+ # e.g. a {Hyrax::Work}
10
11
  #
11
12
  # @return [RDF::Vocabulary::Term] the Fedora Resource Status 'active' term
12
13
  def self.call(target:, **)
13
- target.state = Vocab::FedoraResourceStatus.active
14
+ target.state = Hyrax::ResourceStatus::ACTIVE
14
15
  end
15
16
  end
16
17
  end
@@ -9,14 +9,15 @@ module Hyrax
9
9
  end
10
10
 
11
11
  def message
12
- I18n.t('hyrax.notifications.workflow.changes_required.message', title: title,
13
- link: (link_to work_id, document_path),
14
- comment: comment)
12
+ I18n.t('hyrax.notifications.workflow.changes_required.message',
13
+ title: title,
14
+ link: (link_to work_id, document_path),
15
+ comment: comment)
15
16
  end
16
17
 
17
18
  def users_to_notify
18
19
  user_key = document.depositor
19
- super << ::User.find_by(email: user_key)
20
+ super << ::User.find_by_user_key(user_key)
20
21
  end
21
22
  end
22
23
  end
@@ -2,15 +2,17 @@
2
2
  module Hyrax
3
3
  module Workflow
4
4
  ##
5
- # This is a built in function for workflow, setting the `#state`
6
- # of the target to the Fedora 'inactive' status URI
5
+ # This is a built in function for workflow, setting the +#state+
6
+ # of the target to the Fedora +inactive+ status URI
7
7
  #
8
- # @param target [#state] an instance of a model that includes `Hyrax::Suppressible`
8
+ # @param target [#state] an instance of a model with a +#state+ property;
9
+ # e.g. a {Hyrax::Work}
9
10
  #
10
- # @return [RDF::Vocabulary::Term] the Fedora Resource Status 'inactive' term
11
+ # @return [RDF::URI] the Fedora Resource Status 'inactive' term
12
+ # @see Hyrax::ResourceStatus
11
13
  module DeactivateObject
12
14
  def self.call(target:, **)
13
- target.state = Vocab::FedoraResourceStatus.inactive
15
+ target.state = Hyrax::ResourceStatus::INACTIVE
14
16
  end
15
17
  end
16
18
  end
@@ -9,13 +9,17 @@ module Hyrax
9
9
  end
10
10
 
11
11
  def message
12
- I18n.t('hyrax.notifications.workflow.deposited.message', title: title, link: (link_to work_id, document_path),
13
- user: user.user_key, comment: comment)
12
+ I18n.t('hyrax.notifications.workflow.deposited.message',
13
+ title: title,
14
+ link: (link_to work_id, document_path),
15
+ user: user.user_key,
16
+ comment: comment)
14
17
  end
15
18
 
16
19
  def users_to_notify
17
- user_key = Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: work_id).depositor
18
- super << ::User.find_by(email: user_key)
20
+ user_key = @entity.proxy_for.depositor
21
+
22
+ super << ::User.find_by_user_key(user_key)
19
23
  end
20
24
  end
21
25
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
3
  module Workflow
4
+ ##
4
5
  # This is a built in function for workflow, so that a workflow action can be created that
5
6
  # grants the creator the ability to alter it.
6
7
  module GrantEditToDepositor
@@ -8,11 +9,14 @@ module Hyrax
8
9
  # @return void
9
10
  def self.call(target:, **)
10
11
  return true unless target.try(:depositor)
11
- target.edit_users = target.edit_users.to_a + Array.wrap(target.depositor) # += works in Ruby 2.6+
12
- target.try(:permission_manager)&.acl&.save
12
+
13
+ model = target.try(:model) || target # get the model if target is a ChangeSet
14
+ model.edit_users = model.edit_users.to_a + Array.wrap(target.depositor) # += works in Ruby 2.6+
15
+ model.try(:permission_manager)&.acl&.save
16
+
13
17
  # If there are a lot of members, granting access to each could take a
14
18
  # long time. Do this work in the background.
15
- GrantEditToMembersJob.perform_later(target, target.depositor)
19
+ GrantEditToMembersJob.perform_later(model, target.depositor)
16
20
  end
17
21
  end
18
22
  end
@@ -1,16 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
3
  module Workflow
4
+ ##
4
5
  # This is a built in function for workflow, so that a workflow action can be created that
5
6
  # grants the creator the ability to view their work.
6
7
  module GrantReadToDepositor
7
- # @param [#read_users=, #read_users] target (likely an ActiveRecord::Base) to which we are adding read_users for the depositor
8
+ # @param [#read_users=, #read_users] target to which we are adding read_users
9
+ # for the depositor
8
10
  # @return void
9
11
  def self.call(target:, **)
10
- target.read_users += [target.depositor]
12
+ return true unless target.try(:depositor)
13
+
14
+ model = target.try(:model) || target # get the model if target is a ChangeSet
15
+ model.read_users = model.read_users.to_a + Array.wrap(target.depositor) # += works in Ruby 2.6+
16
+ model.try(:permission_manager)&.acl&.save
17
+
11
18
  # If there are a lot of members, granting access to each could take a
12
19
  # long time. Do this work in the background.
13
- GrantReadToMembersJob.perform_later(target, target.depositor)
20
+ GrantReadToMembersJob.perform_later(model, target.depositor)
14
21
  end
15
22
  end
16
23
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Workflow
5
+ ##
6
+ # Decorates objects with attributes with their workflow state.
7
+ class ObjectInWorkflowDecorator < Hyrax::ModelDecorator
8
+ delegate_all
9
+
10
+ ##
11
+ # @!attribute [w] workflow
12
+ # @return [Sipity::Workflow]
13
+ # @!attribute [w] workflow_state
14
+ # @return [Sipity::WorkflowState]
15
+ attr_writer :workflow, :workflow_state
16
+
17
+ ##
18
+ # @return [Boolean]
19
+ def published?
20
+ Hyrax::Admin::WorkflowsController.deposited_workflow_state_name ==
21
+ workflow_state
22
+ end
23
+
24
+ ##
25
+ # @return [String]
26
+ def workflow_state
27
+ @workflow_state&.name || 'unknown'
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
3
  module Workflow
4
+ ##
4
5
  # This is a built in function for workflow, so that a workflow action can be created that
5
6
  # removes the creators the ability to alter it.
6
7
  module RevokeEditFromDepositor
7
8
  def self.call(target:, **)
8
- target.edit_users -= [target.depositor]
9
+ return true unless target.try(:depositor)
10
+
11
+ model = target.try(:model) || target # get the model if target is a ChangeSet
12
+ model.edit_users = model.edit_users.to_a - Array.wrap(target.depositor)
13
+ model.try(:permission_manager)&.acl&.save
14
+
9
15
  # If there are a lot of members, revoking access from each could take a
10
16
  # long time. Do this work in the background.
11
- RevokeEditFromMembersJob.perform_later(target, target.depositor)
17
+ RevokeEditFromMembersJob.perform_later(model, target.depositor)
12
18
  end
13
19
  end
14
20
  end
@@ -1,35 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
3
  module Workflow
4
- # Finds a list of works that we can perform a workflow action on
4
+ ##
5
+ # @deprecated use the Hyrax::Workflow::ActionableObjects enumerator instead.
6
+ # that service is designed as a more efficient and ergonomic replacement
7
+ # for this one, and has fewer dependencies on specific indexing behavior.
8
+ #
9
+ # Finds a list of works that a given user can perform a workflow action on.
5
10
  class StatusListService
6
- # @param context [#current_user, #logger]
11
+ ##
12
+ # @param context_or_user [::User, #current_user]
7
13
  # @param filter_condition [String] a solr filter
8
- def initialize(context, filter_condition)
9
- @context = context
14
+ #
15
+ # @raise [ArgumentError] if th caller fails to provide a user
16
+ def initialize(context_or_user, filter_condition)
17
+ Deprecation
18
+ .warn("Use the Hyrax::Workflow::ActionableObjects enumerator instead.")
19
+
20
+ case context_or_user
21
+ when ::User
22
+ @user = context_or_user
23
+ when nil
24
+ raise ArgumentError, "A current user MUST be provided."
25
+ else
26
+ Deprecation.warn('Initializing StatusListService with a controller ' \
27
+ '"context" is deprecated. Pass in a user instead.')
28
+ @context = context_or_user
29
+ @user = @context.current_user
30
+ end
10
31
  @filter_condition = filter_condition
11
32
  end
12
33
 
34
+ ##
35
+ # @!attribute [r] context
36
+ # @deprecated
37
+ # @return [#current_user]
13
38
  attr_reader :context
39
+ deprecation_deprecate :context
14
40
 
15
- # TODO: We will want to paginate this
16
- # @return [Array<StatusRow>] a list of results that the given user can take action on.
41
+ ##
42
+ # @todo We will want to paginate this
43
+ # @return [Enumerable<StatusRow>] a list of results that the given user can take action on.
17
44
  def each
18
45
  return enum_for(:each) unless block_given?
46
+
19
47
  solr_documents.each do |doc|
20
48
  yield doc
21
49
  end
22
50
  end
23
51
 
24
- # TODO: Make this private for version 1.0
52
+ ##
53
+ # @deprecated
25
54
  def user
26
- context.current_user
55
+ Deprecation.warn('This method was always intended to be private. ' \
56
+ 'It will be removed in Hyrax 4.0')
57
+ @user
27
58
  end
28
59
 
29
60
  private
30
61
 
31
- delegate :logger, to: :context
32
-
62
+ ##
33
63
  # @return [Hash<String,SolrDocument>] a hash of id to solr document
34
64
  def solr_documents
35
65
  search_solr.map { |result| ::SolrDocument.new(result) }
@@ -37,9 +67,9 @@ module Hyrax
37
67
 
38
68
  def search_solr
39
69
  actionable_roles = roles_for_user
40
- logger.debug("Actionable roles for #{user.user_key} are #{actionable_roles}")
70
+ Hyrax.logger.debug("Actionable roles for #{@user.user_key} are #{actionable_roles}")
41
71
  return [] if actionable_roles.empty?
42
- WorkRelation.new.search_with_conditions(query(actionable_roles), rows: 1000, method: :post)
72
+ WorkRelation.new.search_with_conditions(query(actionable_roles), method: :post)
43
73
  end
44
74
 
45
75
  def query(actionable_roles)
@@ -59,7 +89,7 @@ module Hyrax
59
89
  # @param workflow [Sipity::Workflow]
60
90
  # @return [ActiveRecord::Relation<Sipity::WorkflowRole>]
61
91
  def workflow_roles_for_user_and_workflow(workflow)
62
- Hyrax::Workflow::PermissionQuery.scope_processing_workflow_roles_for_user_and_workflow(user: user, workflow: workflow)
92
+ Hyrax::Workflow::PermissionQuery.scope_processing_workflow_roles_for_user_and_workflow(user: @user, workflow: workflow)
63
93
  end
64
94
  end
65
95
  end
@@ -31,7 +31,8 @@ module Hyrax
31
31
  end
32
32
 
33
33
  def create_sipity_comment
34
- return true if comment_text.blank?
34
+ return Sipity::NullComment.new(entity: subject.entity, agent: subject.agent) if
35
+ comment_text.blank?
35
36
  Sipity::Comment.create!(entity: subject.entity, agent: subject.agent, comment: comment_text)
36
37
  end
37
38
 
@@ -44,7 +45,9 @@ module Hyrax
44
45
  )
45
46
  end
46
47
 
48
+ ##
47
49
  # Run any configured custom methods
50
+ #
48
51
  def handle_additional_sipity_workflow_action_processing(comment:)
49
52
  Hyrax::Workflow::ActionTakenService.handle_action_taken(
50
53
  target: subject.work,
@@ -26,7 +26,7 @@
26
26
  <% if f.object.persisted? && f.object.member_ids.present? %>
27
27
  <%# we're loading these values dynamically to speed page load %>
28
28
  <%= f.input :thumbnail_id,
29
- input_html: { data: { text: f.object.thumbnail_title } } %>
29
+ input_html: { data: { text: thumbnail_label_for(object: f.object) } } %>
30
30
  <% end %>
31
31
 
32
32
  </div>
@@ -24,7 +24,7 @@ HTML Properties:
24
24
  </div>
25
25
  <div class="message has-warning hidden"></div>
26
26
  <div style="margin-top: 10px">
27
- <%= link_to t('.attach_new_work'), polymorphic_path([main_app, :new, :hyrax, :parent, curation_concern.model_name.singular], parent_id: curation_concern.id), target: "_blank", class: 'btn btn-primary' %>
27
+ <%= link_to t('.attach_new_work'), polymorphic_path([main_app, :new, :hyrax, :parent, curation_concern.model_name.singular.to_sym], parent_id: curation_concern.id), target: "_blank", class: 'btn btn-primary' %>
28
28
  </div>
29
29
  <table class="table table-striped">
30
30
  <caption><%= t('.caption') %></caption>
@@ -1,8 +1,7 @@
1
1
  <% if Flipflop.assign_admin_set? %>
2
- <%# TODO: avoid direct dependency on AdminSetService and AdminSetOptionsPresenter in the view!! make the controller provide the options! %>
3
2
  <%= f.input :admin_set_id, as: :select,
4
3
  include_blank: false,
5
- collection: Hyrax::AdminSetOptionsPresenter.new(Hyrax::AdminSetService.new(controller)).select_options,
4
+ collection: admin_set_options,
6
5
  input_html: { class: 'form-control' } %>
7
6
  <% end %>
8
7
 
@@ -7,7 +7,7 @@
7
7
  <div class="form-group">
8
8
  <span class="help-block"><%= t("hyrax.base.form_rendering.help_html") %></span>
9
9
  <%= f.select :rendering_ids,
10
- f.object.select_files,
10
+ form_file_set_select_for(parent: f.object),
11
11
  { include_blank: true },
12
12
  { class: 'form-control', multiple: true } %>
13
13
  </div>
@@ -6,7 +6,7 @@
6
6
  </legend>
7
7
  <div class="form-group">
8
8
  <span class="help-block"><%= t("hyrax.base.form_representative.help_html") %></span>
9
- <%= f.select :representative_id, @form.select_files, {}, { class: 'form-control' } %>
9
+ <%= f.select :representative_id, form_file_set_select_for(parent: @form), {}, { class: 'form-control' } %>
10
10
  </div>
11
11
  </fieldset>
12
12
  </div>
@@ -6,7 +6,7 @@
6
6
  </legend>
7
7
  <div class="form-group">
8
8
  <span class="help-block"><%= t("hyrax.base.form_thumbnail.help_html") %></span>
9
- <%= f.select :thumbnail_id, @form.select_files, {}, { class: 'form-control' } %>
9
+ <%= f.select :thumbnail_id, form_file_set_select_for(parent: @form), {}, { class: 'form-control' } %>
10
10
  </div>
11
11
  </fieldset>
12
12
  </div>
@@ -1,3 +1,5 @@
1
1
  <%= f.full_error(:visibility) %>
2
2
  <%= f.full_error(:embargo_release_date) %>
3
3
  <%= f.full_error(:visibility_after_embargo) %>
4
+ <%= f.full_error(:lease_expiration_date) %>
5
+ <%= f.full_error(:visibility_after_lease) %>