hyrax 3.0.0.pre.rc4 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +41 -8
  3. data/.dassie/Gemfile +10 -5
  4. data/.dassie/config/cable.yml +1 -1
  5. data/.dassie/config/environments/development.rb +2 -0
  6. data/.dassie/config/environments/production.rb +1 -1
  7. data/.dassie/config/initializers/hyrax.rb +5 -0
  8. data/.dassie/config/initializers/riiif.rb +22 -20
  9. data/.dassie/config/redis.yml +1 -0
  10. data/.dassie/config/role_map.yml +2 -0
  11. data/.dassie/db/seeds.rb +9 -1
  12. data/.dassie/package.json +3 -5
  13. data/.dockerignore +4 -0
  14. data/.env +1 -2
  15. data/.rubocop.yml +4 -0
  16. data/CONTAINERS.md +21 -1
  17. data/Dockerfile +46 -17
  18. data/Gemfile +21 -27
  19. data/app/actors/hyrax/actors/base_actor.rb +1 -1
  20. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +89 -41
  21. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  22. data/app/actors/hyrax/actors/file_actor.rb +4 -2
  23. data/app/actors/hyrax/actors/file_set_actor.rb +18 -11
  24. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
  25. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  26. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  27. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +38 -8
  28. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +0 -4
  29. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  30. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
  31. data/app/controllers/hyrax/dashboard/collections_controller.rb +14 -14
  32. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  33. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  34. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
  35. data/app/forms/hyrax/forms/collection_form.rb +12 -6
  36. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
  37. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  38. data/app/forms/hyrax/forms/permission.rb +23 -0
  39. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  40. data/app/forms/hyrax/forms/resource_form.rb +31 -13
  41. data/app/forms/hyrax/forms/work_form.rb +5 -2
  42. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  43. data/app/helpers/hyrax/collections_helper.rb +88 -2
  44. data/app/helpers/hyrax/dashboard_helper_behavior.rb +16 -5
  45. data/app/helpers/hyrax/embargo_helper.rb +4 -0
  46. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  47. data/app/helpers/hyrax/hyrax_helper_behavior.rb +8 -0
  48. data/app/helpers/hyrax/lease_helper.rb +4 -0
  49. data/app/helpers/hyrax/url_helper.rb +4 -1
  50. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  51. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  52. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +118 -0
  53. data/app/indexers/hyrax/valkyrie_indexer.rb +10 -4
  54. data/app/indexers/hyrax/valkyrie_work_indexer.rb +3 -1
  55. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  56. data/app/jobs/attach_files_to_work_job.rb +19 -10
  57. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  58. data/app/jobs/embargo_expiry_job.rb +7 -5
  59. data/app/jobs/file_set_attached_event_job.rb +6 -1
  60. data/app/jobs/ingest_local_file_job.rb +18 -2
  61. data/app/jobs/inherit_permissions_job.rb +9 -5
  62. data/app/jobs/lease_expiry_job.rb +6 -4
  63. data/app/models/admin_set.rb +6 -25
  64. data/app/models/collection_branding_info.rb +25 -9
  65. data/app/models/concerns/hyrax/ability.rb +14 -1
  66. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  67. data/app/models/concerns/hyrax/embargoable.rb +24 -0
  68. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  69. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -46
  70. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  71. data/app/models/concerns/hyrax/user.rb +9 -3
  72. data/app/models/concerns/hyrax/work_behavior.rb +1 -1
  73. data/app/models/hyrax/file_set.rb +7 -0
  74. data/app/models/hyrax/pcdm_collection.rb +1 -0
  75. data/app/models/hyrax/permission_template.rb +98 -12
  76. data/app/models/hyrax/virus_scanner.rb +27 -18
  77. data/app/models/hyrax/work.rb +2 -0
  78. data/app/models/job_io_wrapper.rb +1 -1
  79. data/app/models/sipity/agent.rb +1 -0
  80. data/app/models/sipity/entity.rb +30 -8
  81. data/app/models/sipity/workflow.rb +1 -0
  82. data/app/models/sipity.rb +42 -0
  83. data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
  84. data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
  85. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  86. data/app/presenters/hyrax/collection_presenter.rb +41 -20
  87. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  88. data/app/presenters/hyrax/file_usage.rb +3 -2
  89. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
  90. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  91. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  92. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  93. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  94. data/app/presenters/hyrax/version_presenter.rb +3 -2
  95. data/app/presenters/hyrax/work_show_presenter.rb +30 -5
  96. data/app/presenters/hyrax/work_usage.rb +5 -3
  97. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  98. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  99. data/app/search_builders/hyrax/collection_member_search_builder.rb +6 -1
  100. data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
  101. data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
  102. data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
  103. data/app/services/hyrax/access_control_list.rb +1 -1
  104. data/app/services/hyrax/adapters/nesting_index_adapter.rb +1 -1
  105. data/app/services/hyrax/admin_set_create_service.rb +3 -1
  106. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  107. data/app/services/hyrax/collections/collection_member_service.rb +112 -27
  108. data/app/services/hyrax/collections/migration_service.rb +4 -2
  109. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  110. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  111. data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
  112. data/app/services/hyrax/contextual_path.rb +24 -1
  113. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  114. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  115. data/app/services/hyrax/edit_permissions_service.rb +74 -41
  116. data/app/services/hyrax/embargo_manager.rb +1 -1
  117. data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
  118. data/app/services/hyrax/graph_exporter.rb +1 -1
  119. data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
  120. data/app/services/hyrax/listeners/metadata_index_listener.rb +18 -1
  121. data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
  122. data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
  123. data/app/services/hyrax/listeners.rb +2 -0
  124. data/app/services/hyrax/multiple_membership_checker.rb +53 -29
  125. data/app/services/hyrax/persist_derivatives.rb +3 -1
  126. data/app/services/hyrax/resource_status.rb +7 -0
  127. data/app/services/hyrax/search_service.rb +4 -2
  128. data/app/services/hyrax/solr_query_builder_service.rb +45 -8
  129. data/app/services/hyrax/solr_query_service.rb +224 -0
  130. data/app/services/hyrax/solr_service.rb +8 -1
  131. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  132. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  133. data/app/services/hyrax/versioning_service.rb +1 -1
  134. data/app/services/hyrax/visibility_intention.rb +20 -2
  135. data/app/services/hyrax/visibility_propagator.rb +30 -1
  136. data/app/services/hyrax/work_uploads_handler.rb +22 -4
  137. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  138. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  139. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  140. data/app/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb +1 -1
  141. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  142. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  143. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  144. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  145. data/app/views/hyrax/base/_form_share.html.erb +1 -5
  146. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  147. data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
  148. data/app/views/hyrax/base/_guts4form.html.erb +3 -3
  149. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  150. data/app/views/hyrax/base/_show_actions.html.erb +2 -2
  151. data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
  152. data/app/views/hyrax/base/_workflow_actions.html.erb +1 -1
  153. data/app/views/hyrax/batch_edits/edit.html.erb +2 -2
  154. data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
  155. data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
  156. data/app/views/hyrax/collections/_search_form.html.erb +1 -1
  157. data/app/views/hyrax/collections/show.html.erb +1 -1
  158. data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
  159. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
  160. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  161. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  162. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  163. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  164. data/app/views/hyrax/file_sets/_actions.html.erb +10 -0
  165. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  166. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  167. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  168. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  169. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  170. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  171. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  172. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  173. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  174. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  175. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  176. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  177. data/app/views/hyrax/stats/file.html.erb +1 -1
  178. data/app/views/hyrax/stats/work.html.erb +1 -1
  179. data/app/views/hyrax/uploads/_js_templates.html.erb +4 -4
  180. data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +4 -4
  181. data/app/views/hyrax/users/_contributions.html.erb +1 -1
  182. data/app/views/hyrax/users/_profile_tabs.html.erb +2 -2
  183. data/app/views/hyrax/users/_search_form.html.erb +1 -1
  184. data/app/views/hyrax/users/_user.html.erb +1 -1
  185. data/app/views/hyrax/users/_user_info.html.erb +9 -9
  186. data/bin/db-migrate-seed.sh +6 -2
  187. data/bin/hyrax-entrypoint.sh +0 -14
  188. data/bin/solrcloud-assign-configset.sh +35 -0
  189. data/bin/solrcloud-upload-configset.sh +42 -0
  190. data/chart/hyrax/Chart.yaml +12 -8
  191. data/chart/hyrax/README.md +94 -11
  192. data/chart/hyrax/templates/NOTES.txt +1 -1
  193. data/chart/hyrax/templates/_helpers.tpl +98 -0
  194. data/chart/hyrax/templates/branding-pvc.yaml +14 -0
  195. data/chart/hyrax/templates/configmap-env.yaml +21 -11
  196. data/chart/hyrax/templates/cron-embargo.yaml +24 -0
  197. data/chart/hyrax/templates/cron-lease.yaml +24 -0
  198. data/chart/hyrax/templates/deployment-worker.yaml +129 -0
  199. data/chart/hyrax/templates/deployment.yaml +125 -4
  200. data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
  201. data/chart/hyrax/templates/ingress.yaml +13 -4
  202. data/chart/hyrax/templates/secrets.yaml +12 -2
  203. data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
  204. data/chart/hyrax/values.yaml +186 -2
  205. data/config/brakeman.ignore +2 -2
  206. data/config/features.rb +47 -43
  207. data/config/initializers/listeners.rb +4 -0
  208. data/config/initializers/valkryrie_storage.rb +7 -0
  209. data/config/locales/hyrax.de.yml +1 -1
  210. data/config/locales/hyrax.en.yml +1 -1
  211. data/config/locales/hyrax.es.yml +1 -1
  212. data/config/locales/hyrax.fr.yml +1 -1
  213. data/config/locales/hyrax.it.yml +1 -1
  214. data/config/locales/hyrax.pt-BR.yml +1 -1
  215. data/config/locales/hyrax.zh.yml +1 -1
  216. data/docker-compose.yml +39 -8
  217. data/documentation/developing-your-hyrax-based-app.md +4 -4
  218. data/documentation/legacyREADME.md +3 -3
  219. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
  220. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
  221. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  222. data/lib/hyrax/configuration.rb +28 -0
  223. data/lib/hyrax/engine.rb +3 -1
  224. data/lib/hyrax/errors.rb +2 -0
  225. data/lib/hyrax/resource_name.rb +1 -0
  226. data/lib/hyrax/specs/capybara.rb +5 -3
  227. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  228. data/lib/hyrax/transactions/container.rb +32 -1
  229. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  230. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  231. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  232. data/lib/hyrax/transactions/steps/delete_resource.rb +38 -0
  233. data/lib/hyrax/transactions/steps/destroy_work.rb +1 -0
  234. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  235. data/lib/hyrax/transactions/work_create.rb +2 -1
  236. data/lib/hyrax/transactions/work_destroy.rb +20 -0
  237. data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
  238. data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -0
  239. data/lib/hyrax/version.rb +1 -1
  240. data/lib/hyrax.rb +9 -0
  241. data/lib/tasks/collection_type_global_id.rake +1 -1
  242. data/lib/tasks/embargo_lease.rake +27 -0
  243. data/lib/tasks/regenerate_derivatives.rake +12 -0
  244. data/lib/wings/active_fedora_converter/default_work.rb +19 -0
  245. data/lib/wings/attribute_transformer.rb +29 -19
  246. data/lib/wings/converter_value_mapper.rb +2 -2
  247. data/lib/wings/model_transformer.rb +21 -20
  248. data/lib/wings/orm_converter.rb +42 -23
  249. data/lib/wings/setup.rb +2 -0
  250. data/lib/wings/valkyrie/persister.rb +8 -5
  251. data/lib/wings/valkyrie/query_service.rb +96 -41
  252. data/lib/wings/valkyrie/storage.rb +56 -1
  253. data/lib/wings.rb +0 -21
  254. data/template.rb +1 -1
  255. metadata +41 -21
  256. data/chart/fcrepo/.gitignore +0 -2
  257. data/chart/fcrepo/.helmignore +0 -23
  258. data/chart/fcrepo/Chart.yaml +0 -11
  259. data/chart/fcrepo/README.md +0 -50
  260. data/chart/fcrepo/templates/NOTES.txt +0 -21
  261. data/chart/fcrepo/templates/_helpers.tpl +0 -68
  262. data/chart/fcrepo/templates/configmap-env.yaml +0 -19
  263. data/chart/fcrepo/templates/deployment.yaml +0 -109
  264. data/chart/fcrepo/templates/ingress.yaml +0 -41
  265. data/chart/fcrepo/templates/pvc.yaml +0 -20
  266. data/chart/fcrepo/templates/secret.yaml +0 -12
  267. data/chart/fcrepo/templates/service.yaml +0 -15
  268. data/chart/fcrepo/templates/serviceaccount.yaml +0 -12
  269. data/chart/fcrepo/templates/tests/test-connection.yaml +0 -15
  270. data/chart/fcrepo/values.yaml +0 -79
  271. data/chart/hyrax/templates/fcrepo-secret.yaml +0 -13
@@ -18,7 +18,7 @@ module Hyrax
18
18
 
19
19
  self.model_class = ::Collection
20
20
 
21
- self.membership_service_class = Collections::CollectionMemberService
21
+ self.membership_service_class = Collections::CollectionMemberSearchService
22
22
 
23
23
  delegate :blacklight_config, to: Hyrax::CollectionsController
24
24
 
@@ -80,18 +80,20 @@ module Hyrax
80
80
  def banner_info
81
81
  @banner_info ||= begin
82
82
  # Find Banner filename
83
- banner_info = CollectionBrandingInfo.where(collection_id: id).where(role: "banner")
83
+ banner_info = CollectionBrandingInfo.where(collection_id: id, role: "banner")
84
84
  banner_file = File.split(banner_info.first.local_path).last unless banner_info.empty?
85
+ alttext = banner_info.first.alt_text unless banner_info.empty?
85
86
  file_location = banner_info.first.local_path unless banner_info.empty?
86
87
  relative_path = "/" + banner_info.first.local_path.split("/")[-4..-1].join("/") unless banner_info.empty?
87
- { file: banner_file, full_path: file_location, relative_path: relative_path }
88
+ { file: banner_file, full_path: file_location, relative_path: relative_path, alttext: alttext }
88
89
  end
89
90
  end
90
91
 
91
92
  def logo_info
92
93
  @logo_info ||= begin
93
94
  # Find Logo filename, alttext, linktext
94
- logos_info = CollectionBrandingInfo.where(collection_id: id).where(role: "logo")
95
+ logos_info = CollectionBrandingInfo.where(collection_id: id, role: "logo")
96
+
95
97
  logos_info.map do |logo_info|
96
98
  logo_file = File.split(logo_info.local_path).last
97
99
  relative_path = "/" + logo_info.local_path.split("/")[-4..-1].join("/")
@@ -121,6 +123,11 @@ module Hyrax
121
123
  collection_member_service.available_member_subcollections.documents
122
124
  end
123
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}.
124
131
  def available_parent_collections(scope:)
125
132
  return @available_parents if @available_parents.present?
126
133
 
@@ -128,8 +135,7 @@ module Hyrax
128
135
  colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
129
136
  @available_parents = colls.map do |col|
130
137
  { "id" => col.id, "title_first" => col.title.first }
131
- end
132
- @available_parents.to_json
138
+ end.to_json
133
139
  end
134
140
 
135
141
  private
@@ -32,18 +32,40 @@ module Hyrax
32
32
 
33
33
  def save
34
34
  return false unless valid?
35
- persistence_service.persist_nested_collection_for(parent: parent, child: child)
35
+ persistence_service.persist_nested_collection_for(parent: parent, child: child, user: context.current_user)
36
36
  end
37
37
 
38
+ ##
39
+ # @deprecated this method is unused by hyrax, and is effectively a
40
+ # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
41
+ # if you want to be sure to use nested indexing to generate this list,
42
+ # use the query service directly.
43
+ #
38
44
  # For the given parent, what are all of the available collections that
39
45
  # can be added as sub-collection of the parent.
40
46
  def available_child_collections
47
+ Deprecation.warn "#{self.class}#available_child_collections " \
48
+ "is deprecated. the helper of the same name or " \
49
+ "Hyrax::Collections::NestedCollectionQueryService " \
50
+ "instead."
51
+
41
52
  query_service.available_child_collections(parent: parent, scope: context)
42
53
  end
43
54
 
55
+ ##
56
+ # @deprecated this method is unused by hyrax, and is effectively a
57
+ # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
58
+ # if you want to be sure to use nested indexing to generate this list,
59
+ # use the query service directly.
60
+ #
44
61
  # For the given child, what are all of the available collections to
45
62
  # which the child can be added as a sub-collection.
46
63
  def available_parent_collections
64
+ Deprecation.warn "#{self.class}#available_parent_collections " \
65
+ "is deprecated. the helper of the same name or " \
66
+ "Hyrax::Collections::NestedCollectionQueryService " \
67
+ "instead."
68
+
47
69
  query_service.available_parent_collections(child: child, scope: context)
48
70
  end
49
71
 
@@ -61,7 +83,7 @@ module Hyrax
61
83
 
62
84
  def remove
63
85
  if context.can? :edit, parent
64
- persistence_service.remove_nested_relationship_for(parent: parent, child: child)
86
+ persistence_service.remove_nested_relationship_for(parent: parent, child: child, user: context.current_user)
65
87
  else
66
88
  errors.add(:parent, :cannot_remove_relationship)
67
89
  false
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Forms
5
+ ##
6
+ # @api public
7
+ class FileSetForm < Hyrax::ChangeSet
8
+ include Hyrax::FormFields(:core_metadata)
9
+
10
+ class << self
11
+ ##
12
+ # @return [Array<Symbol>] list of required field names as symbols
13
+ def required_fields
14
+ definitions
15
+ .select { |_, definition| definition[:required] }
16
+ .keys.map(&:to_sym)
17
+ end
18
+ end
19
+
20
+ property :creator, required: true
21
+ property :license, required: true
22
+
23
+ property :based_near
24
+ property :contributor
25
+ property :date_created
26
+ property :description
27
+ property :identifier
28
+ property :keyword
29
+ property :language
30
+ property :publisher
31
+ property :related_url
32
+ property :subject
33
+
34
+ property :permissions, virtual: true
35
+ property :visibility, default: VisibilityIntention::PRIVATE
36
+
37
+ # virtual properties for embargo/lease;
38
+ property :embargo_release_date, virtual: true
39
+ property :visibility_after_embargo, virtual: true
40
+ property :visibility_during_embargo, virtual: true
41
+ property :lease_expiration_date, virtual: true
42
+ property :visibility_after_lease, virtual: true
43
+ property :visibility_during_lease, virtual: true
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Forms
4
+ ##
5
+ # Nested form for permissions.
6
+ #
7
+ # @note due to historical oddities with Hydra::AccessControls and Hydra
8
+ # Editor, Hyrax's views rely on `agent_name` and `access` as field
9
+ # names. we provide these as virtual fields and prepopulate these from
10
+ # `Hyrax::Permission`.
11
+ class Permission < Hyrax::ChangeSet
12
+ property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
13
+ property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
14
+
15
+ ##
16
+ # @note support a {#to_hash} method for compatibility with
17
+ # {Hydra::AccessControl::Permissions}
18
+ def to_hash
19
+ { name: agent_name, access: access }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -12,7 +12,13 @@ module Hyrax
12
12
  # @return [#to_s] the primary key of the associated admin_set or collection
13
13
  # def source_id (because you might come looking for this method)
14
14
  delegate :id, to: :source_model, prefix: :source
15
- delegate :reset_access_controls!, to: :source_model
15
+
16
+ ##
17
+ # @deprecated use PermissionTemplate#reset_access_controls instead.
18
+ def reset_access_controls!
19
+ Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
20
+ source_model.reset_access_controls!
21
+ end
16
22
 
17
23
  # Stores which radio button under release "Varies" option is selected
18
24
  attr_accessor :release_varies
@@ -67,7 +73,7 @@ module Hyrax
67
73
  # Copy this access to the permissions of the Admin Set or Collection and to
68
74
  # the WorkflowResponsibilities of the active workflow if this is an Admin Set
69
75
  def update_access(remove_agent: false)
70
- reset_access_controls!
76
+ source_model.reset_access_controls!
71
77
  update_workflow_responsibilities(remove_agent: remove_agent) if source_model.is_a?(AdminSet)
72
78
  end
73
79
 
@@ -32,15 +32,17 @@ module Hyrax
32
32
  # This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
33
33
  class ResourceForm < Hyrax::ChangeSet
34
34
  ##
35
- # Nested form for permissions.
36
- #
37
- # @note due to historical oddities with Hydra::AccessControls and Hydra
38
- # Editor, Hyrax's views rely on `agent_name` and `access` as field
39
- # names. we provide these as virtual fields and prepopulate these from
40
- # `Hyrax::Permission`.
41
- class Permission < Hyrax::ChangeSet
42
- property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
43
- property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
35
+ # @api private
36
+ InWorksPopulator = lambda do |_options|
37
+ self.in_works_ids =
38
+ if persisted?
39
+ Hyrax.query_service
40
+ .find_inverse_references_by(resource: model, property: :member_ids)
41
+ .select(&:work?)
42
+ .map(&:id)
43
+ else
44
+ []
45
+ end
44
46
  end
45
47
 
46
48
  ##
@@ -77,7 +79,12 @@ module Hyrax
77
79
  property :date_uploaded, readable: false
78
80
  property :agreement_accepted, virtual: true, default: false, prepopulator: ->(_opts) { self.agreement_accepted = !model.new_record }
79
81
 
80
- collection :permissions, virtual: true, default: [], form: Permission, prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions }
82
+ collection(:permissions,
83
+ virtual: true,
84
+ default: [],
85
+ form: Hyrax::Forms::Permission,
86
+ populator: :permission_populator,
87
+ prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
81
88
 
82
89
  # virtual properties for embargo/lease;
83
90
  property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date }
@@ -90,6 +97,7 @@ module Hyrax
90
97
 
91
98
  # pcdm relationships
92
99
  property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = AdminSet::DEFAULT_ID }
100
+ property :in_works_ids, virtual: true, prepopulator: InWorksPopulator
93
101
  property :member_ids, default: [], type: Valkyrie::Types::Array
94
102
  property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
95
103
 
@@ -116,10 +124,15 @@ module Hyrax
116
124
  # @example
117
125
  # monograph = Monograph.new
118
126
  # change_set = Hyrax::Forms::ResourceForm.for(monograph)
119
- def for(work)
120
- "#{work.class}Form".constantize.new(work)
127
+ def for(resource)
128
+ "#{resource.class.name}Form".constantize.new(resource)
121
129
  rescue NameError => _err
122
- Hyrax::Forms::ResourceForm(work.class).new(work)
130
+ case resource
131
+ when Hyrax::FileSet
132
+ Hyrax::Forms::FileSetForm.new(resource)
133
+ else
134
+ Hyrax::Forms::ResourceForm(resource.class).new(resource)
135
+ end
123
136
  end
124
137
 
125
138
  ##
@@ -186,6 +199,11 @@ module Hyrax
186
199
 
187
200
  private
188
201
 
202
+ # https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
203
+ def permission_populator(collection:, index:, **)
204
+ Hyrax::Forms::Permission.new(collection[index])
205
+ end
206
+
189
207
  def _form_field_definitions
190
208
  self.class.definitions
191
209
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
- # rubocop:disable Metrics/ClassLength
3
2
  module Hyrax
4
3
  module Forms
5
4
  # @abstract
6
- class WorkForm
5
+ class WorkForm # rubocop:disable Metrics/ClassLength
7
6
  include HydraEditor::Form
8
7
  include HydraEditor::Form::Permissions
9
8
  attr_accessor :current_ability
@@ -176,6 +175,10 @@ module Hyrax
176
175
  based_near_attributes: [:id, :_destroy],
177
176
  member_of_collections_attributes: [:id, :_destroy],
178
177
  work_members_attributes: [:id, :_destroy]
178
+ },
179
+ {
180
+ file_set: [:visibility, :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
181
+ :visibility_during_lease, :lease_expiration_date, :visibility_after_lease, :uploaded_file_id]
179
182
  }
180
183
  ]
181
184
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
- # View Helpers for Hydra Batch Edit functionality
2
+
3
3
  module Hyrax
4
+ ##
5
+ # View Helpers for Hydra Batch Edit functionality
4
6
  module BatchEditsHelper
5
7
  # Displays the delete button for batch editing
6
8
  def batch_delete
@@ -1,6 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- module CollectionsHelper
3
+ module CollectionsHelper # rubocop:disable Metrics/ModuleLength
4
+ ##
5
+ # @since 3.1.0
6
+ # @return [Array<SolrDocument>]
7
+ def available_child_collections(collection:)
8
+ Hyrax::Collections::NestedCollectionQueryService
9
+ .available_child_collections(parent: collection, scope: controller, limit_to_id: nil)
10
+ end
11
+
12
+ ##
13
+ # @since 3.1.0
14
+ #
15
+ # @note provides data for handleAddToCollection javascript
16
+ #
17
+ # @return [String] JSON document containing id/title pairs for eligible
18
+ # parent collections to be displayed in an "Add to Collection" dropdown
19
+ def available_parent_collections_data(collection:)
20
+ Hyrax::Collections::NestedCollectionQueryService
21
+ .available_parent_collections(child: collection, scope: controller, limit_to_id: nil)
22
+ .map do |result|
23
+ { "id" => result.id, "title_first" => result.title.first }
24
+ end.to_json
25
+ end
26
+
4
27
  ##
5
28
  # @since 3.0.0
6
29
  # @return [#to_s]
@@ -97,6 +120,69 @@ module Hyrax
97
120
  single_item_action_form_fields(form, document, 'remove')
98
121
  end
99
122
 
123
+ ##
124
+ # @param collection [Object]
125
+ def collection_type_label_for(collection:)
126
+ case collection
127
+ when Valkyrie::Resource
128
+ CollectionType
129
+ .find_by_gid!(collection.collection_type_gid)
130
+ .title
131
+ else
132
+ collection.collection_type.title
133
+ end
134
+ end
135
+
136
+ ##
137
+ # @param collection [Object]
138
+ #
139
+ # @return [Boolean]
140
+ def collection_brandable?(collection:)
141
+ case collection
142
+ when Valkyrie::Resource
143
+ CollectionType
144
+ .find_by_gid!(collection.collection_type_gid)
145
+ .brandable?
146
+ else
147
+ collection.try(:brandable?)
148
+ end
149
+ end
150
+
151
+ ##
152
+ # @param collection [Object]
153
+ #
154
+ # @return [Boolean]
155
+ def collection_discoverable?(collection:)
156
+ case collection
157
+ when Valkyrie::Resource
158
+ CollectionType
159
+ .find_by_gid!(collection.collection_type_gid)
160
+ .discoverable?
161
+ else
162
+ collection.try(:discoverable?)
163
+ end
164
+ end
165
+
166
+ ##
167
+ # @param collection [Object]
168
+ #
169
+ # @return [Boolean]
170
+ def collection_sharable?(collection:)
171
+ case collection
172
+ when Valkyrie::Resource
173
+ CollectionType
174
+ .find_by_gid!(collection.collection_type_gid)
175
+ .sharable?
176
+ else
177
+ collection.try(:sharable?)
178
+ end
179
+ end
180
+
181
+ ##
182
+ # @note this helper is primarily intended for use with blacklight facet
183
+ # fields. it assumes we index a `collection_type_gid` and the helper
184
+ # can be passed as as a `helper_method:` to `add_facet_field`.
185
+ #
100
186
  # @param collection_type_gid [String] The gid of the CollectionType to be looked up
101
187
  # @return [String] The CollectionType's title if found, else the gid
102
188
  def collection_type_label(collection_type_gid)
@@ -112,4 +198,4 @@ module Hyrax
112
198
  render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action
113
199
  end
114
200
  end
115
- end
201
+ end # rubocop:enable Metrics/ModuleLength
@@ -7,25 +7,36 @@ module Hyrax
7
7
 
8
8
  # @param user [User]
9
9
  # @param where [Hash] applied as the where clause when querying the Hyrax::WorkRelation
10
- #
10
+ # @return [Integer] number of works matching the where that the user deposited
11
11
  # @see Hyrax::WorkRelation
12
12
  def number_of_works(user = current_user, where: { generic_type_sim: "Work" })
13
- where_clause = where.merge(DepositSearchBuilder.depositor_field => user.user_key)
14
- Hyrax::WorkRelation.new.where(where_clause).count
13
+ field_pairs = field_pairs(user)
14
+ field_pairs.merge!(where)
15
+ Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs).count
15
16
  rescue RSolr::Error::ConnectionRefused
16
17
  'n/a'
17
18
  end
18
19
 
20
+ # @param user [User]
21
+ # @return [Integer] number of FileSets the user deposited
19
22
  def number_of_files(user = current_user)
20
- ::FileSet.where(DepositSearchBuilder.depositor_field => user.user_key).count
23
+ Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
21
24
  rescue RSolr::Error::ConnectionRefused
22
25
  'n/a'
23
26
  end
24
27
 
28
+ # @param user [User]
29
+ # @return [Integer] number of Collections the user created
25
30
  def number_of_collections(user = current_user)
26
- ::Collection.where(DepositSearchBuilder.depositor_field => user.user_key).count
31
+ Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
27
32
  rescue RSolr::Error::ConnectionRefused
28
33
  'n/a'
29
34
  end
35
+
36
+ private
37
+
38
+ def field_pairs(user)
39
+ { DepositSearchBuilder.depositor_field => user.user_key }
40
+ end
30
41
  end
31
42
  end