hyrax 4.0.0 → 5.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +124 -232
  3. data/.dassie/.env +8 -2
  4. data/.dassie/Gemfile +27 -42
  5. data/.dassie/Gemfile.dassie +2 -0
  6. data/.dassie/app/assets/config/manifest.js +2 -0
  7. data/.dassie/app/assets/stylesheets/hyrax.scss +1 -0
  8. data/.dassie/config/environments/test.rb +1 -0
  9. data/.dassie/config/initializers/hyrax.rb +3 -1
  10. data/.dassie/config/initializers/riiif.rb +11 -7
  11. data/.dassie/config/metadata/collection_resource.yaml +3 -0
  12. data/.dassie/config/metadata/monograph.yaml +8 -0
  13. data/.dassie/config/metadata/sample_metadata.yaml +1 -0
  14. data/.dassie/config/redis.yml +2 -0
  15. data/.dassie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  16. data/.dassie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  17. data/.dassie/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.hyrax.rb +8 -0
  18. data/.dassie/db/migrate/20230821153635_add_fields_to_counter_metric.rb +8 -0
  19. data/.dassie/db/schema.rb +22 -3
  20. data/.dockerignore +7 -0
  21. data/.github/PULL_REQUEST_TEMPLATE.md +10 -7
  22. data/.github/release.yml +5 -2
  23. data/.gitignore +1 -1
  24. data/.koppie/.env +13 -4
  25. data/.koppie/Gemfile +10 -12
  26. data/.koppie/Gemfile.koppie +2 -0
  27. data/.koppie/Rakefile +0 -2
  28. data/.koppie/app/models/ability.rb +1 -5
  29. data/.koppie/app/models/user.rb +0 -2
  30. data/.koppie/config/application.rb +2 -1
  31. data/.koppie/config/arkivo.yml +6 -0
  32. data/.koppie/config/blacklight.yml +2 -2
  33. data/.koppie/config/environments/test.rb +1 -0
  34. data/.koppie/config/features.yml +2 -0
  35. data/.koppie/config/initializers/1_valkyrie.rb +29 -6
  36. data/.koppie/config/initializers/arkivo_constraint.rb +12 -0
  37. data/.koppie/config/initializers/hyrax.rb +10 -4
  38. data/.koppie/config/initializers/riiif.rb +11 -7
  39. data/.koppie/config/metadata/collection_resource.yaml +49 -0
  40. data/.koppie/config/metadata/generic_work.yaml +2 -0
  41. data/.koppie/config/metadata/monograph.yaml +10 -0
  42. data/.koppie/config/role_map.yml +3 -25
  43. data/.koppie/config/routes.rb +1 -2
  44. data/.koppie/config/solr.yml +1 -1
  45. data/.koppie/config/valkyrie_index.yml +4 -10
  46. data/.koppie/config/zotero.yml +6 -0
  47. data/.koppie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  48. data/.koppie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  49. data/.koppie/db/schema.rb +12 -1
  50. data/.koppie/yarn.lock +23 -23
  51. data/.regen +1 -1
  52. data/CONTAINERS.md +1 -3
  53. data/Dockerfile +17 -13
  54. data/Gemfile +4 -21
  55. data/Gemfile.dassie +2 -0
  56. data/Gemfile.koppie +2 -0
  57. data/README.md +0 -1
  58. data/Rakefile +0 -11
  59. data/app/actors/hyrax/actors/base_actor.rb +4 -3
  60. data/app/actors/hyrax/actors/embargo_actor.rb +3 -3
  61. data/app/actors/hyrax/actors/lease_actor.rb +5 -2
  62. data/app/assets/javascripts/hyrax/batch_select_all.js +1 -1
  63. data/app/assets/javascripts/hyrax/file_manager/member.es6 +1 -1
  64. data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
  65. data/app/assets/stylesheets/hyrax/_file-listing.scss +0 -2
  66. data/app/assets/stylesheets/hyrax/_work-show.scss +19 -3
  67. data/app/assets/stylesheets/hyrax/sidebar.scss +23 -0
  68. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +8 -2
  69. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +7 -1
  70. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +79 -0
  71. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +64 -14
  72. data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
  73. data/app/controllers/hyrax/api/items_controller.rb +2 -3
  74. data/app/controllers/hyrax/batch_edits_controller.rb +39 -10
  75. data/app/controllers/hyrax/batch_uploads_controller.rb +5 -1
  76. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  77. data/app/controllers/hyrax/downloads_controller.rb +8 -1
  78. data/app/controllers/hyrax/file_sets_controller.rb +50 -6
  79. data/app/controllers/hyrax/my/collections_controller.rb +2 -0
  80. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +16 -2
  81. data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +38 -0
  82. data/app/forms/hyrax/forms/collection_form.rb +0 -15
  83. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +0 -34
  84. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  85. data/app/forms/hyrax/forms/file_set_form.rb +2 -2
  86. data/app/forms/hyrax/forms/pcdm_object_form.rb +21 -0
  87. data/app/forms/hyrax/forms/permission_template_form.rb +2 -7
  88. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +118 -0
  89. data/app/forms/hyrax/forms/resource_form.rb +21 -34
  90. data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
  91. data/app/forms/hyrax/forms/work_form.rb +1 -1
  92. data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
  93. data/app/helpers/hyrax/dashboard_helper_behavior.rb +30 -9
  94. data/app/helpers/hyrax/membership_helper.rb +13 -1
  95. data/app/helpers/hyrax/work_form_helper.rb +0 -107
  96. data/app/indexers/hyrax/file_set_indexer.rb +6 -0
  97. data/app/indexers/hyrax/location_indexer.rb +29 -0
  98. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +36 -5
  99. data/app/indexers/hyrax/valkyrie_work_indexer.rb +9 -2
  100. data/app/inputs/controlled_vocabulary_input.rb +1 -1
  101. data/app/jobs/characterize_job.rb +1 -1
  102. data/app/jobs/create_work_job.rb +36 -4
  103. data/app/jobs/valkyrie_characterization_job.rb +9 -0
  104. data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
  105. data/app/jobs/valkyrie_ingest_job.rb +1 -4
  106. data/app/models/admin_set.rb +1 -31
  107. data/app/models/collection_branding_info.rb +2 -9
  108. data/app/models/concerns/hyrax/ability.rb +2 -1
  109. data/app/models/concerns/hyrax/collection_behavior.rb +4 -12
  110. data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
  111. data/app/models/concerns/hyrax/riiif_file.rb +30 -0
  112. data/app/models/concerns/hyrax/solr_document_behavior.rb +20 -3
  113. data/app/models/hyrax/collection_type.rb +5 -14
  114. data/app/models/hyrax/counter_metric.rb +7 -0
  115. data/app/models/hyrax/file_metadata.rb +9 -9
  116. data/app/models/hyrax/file_set.rb +76 -15
  117. data/app/models/hyrax/orcid_validator.rb +0 -6
  118. data/app/models/hyrax/resource.rb +30 -2
  119. data/app/models/hyrax/work.rb +2 -5
  120. data/app/presenters/hyrax/collection_presenter.rb +0 -17
  121. data/app/presenters/hyrax/embargo_presenter.rb +4 -0
  122. data/app/presenters/hyrax/file_set_presenter.rb +6 -0
  123. data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
  124. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +6 -4
  125. data/app/presenters/hyrax/presenter_renderer.rb +0 -7
  126. data/app/presenters/hyrax/version_list_presenter.rb +19 -10
  127. data/app/presenters/hyrax/version_presenter.rb +19 -4
  128. data/app/presenters/hyrax/work_show_presenter.rb +6 -11
  129. data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
  130. data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
  131. data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
  132. data/app/services/hyrax/admin_set_create_service.rb +0 -17
  133. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +16 -9
  134. data/app/services/hyrax/collections/collection_member_service.rb +1 -1
  135. data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
  136. data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
  137. data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
  138. data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
  139. data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
  140. data/app/services/hyrax/derivative_path.rb +14 -4
  141. data/app/services/hyrax/embargo_manager.rb +106 -13
  142. data/app/services/hyrax/embargo_service.rb +12 -10
  143. data/app/services/hyrax/file_set_derivatives_service.rb +14 -13
  144. data/app/services/hyrax/fixity_check_failure_service.rb +1 -1
  145. data/app/services/hyrax/identifier/dispatcher.rb +9 -2
  146. data/app/services/hyrax/lease_manager.rb +88 -8
  147. data/app/services/hyrax/listeners/file_metadata_listener.rb +16 -8
  148. data/app/services/hyrax/listeners/member_cleanup_listener.rb +2 -28
  149. data/app/services/hyrax/listeners/metadata_index_listener.rb +11 -0
  150. data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
  151. data/app/services/hyrax/lock_manager.rb +1 -2
  152. data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
  153. data/app/services/hyrax/riiif_file_resolver.rb +50 -0
  154. data/app/services/hyrax/simple_schema_loader.rb +31 -0
  155. data/app/services/hyrax/solr_query_service.rb +7 -6
  156. data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
  157. data/app/services/hyrax/statistics/over_time.rb +1 -1
  158. data/app/services/hyrax/statistics/users/over_time.rb +3 -1
  159. data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
  160. data/app/services/hyrax/statistics/works/count.rb +1 -1
  161. data/app/services/hyrax/thumbnail_path_service.rb +5 -0
  162. data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
  163. data/app/services/hyrax/valkyrie_upload.rb +16 -28
  164. data/app/services/hyrax/versioning_service.rb +30 -15
  165. data/app/services/hyrax/visibility_intention.rb +1 -4
  166. data/app/services/hyrax/visibility_propagator.rb +1 -1
  167. data/app/services/hyrax/work_uploads_handler.rb +1 -1
  168. data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
  169. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
  170. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
  171. data/app/services/hyrax/workflow/permission_query.rb +23 -2
  172. data/app/validators/hyrax/collection_membership_validator.rb +1 -1
  173. data/app/views/catalog/_search_form.html.erb +1 -1
  174. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  175. data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
  176. data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
  177. data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
  178. data/app/views/hyrax/base/_file_manager_resource_form.html.erb +1 -1
  179. data/app/views/hyrax/base/_form.html.erb +0 -10
  180. data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
  181. data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
  182. data/app/views/hyrax/base/_form_visibility_component.html.erb +4 -4
  183. data/app/views/hyrax/base/_items.html.erb +1 -1
  184. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  185. data/app/views/hyrax/base/_workflow_actions.html.erb +25 -23
  186. data/app/views/hyrax/base/file_manager.html.erb +1 -1
  187. data/app/views/hyrax/base/show.json.jbuilder +4 -3
  188. data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
  189. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  190. data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
  191. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +3 -3
  192. data/app/views/hyrax/file_sets/_versioning.html.erb +5 -5
  193. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +4 -4
  194. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  195. data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
  196. data/app/views/hyrax/file_sets/show.html.erb +5 -3
  197. data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
  198. data/app/views/hyrax/my/_search_form.html.erb +1 -1
  199. data/app/views/hyrax/notifications/_notifications.html.erb +1 -1
  200. data/app/views/hyrax/users/_vitals.html.erb +1 -1
  201. data/bin/dev-entrypoint.sh +13 -0
  202. data/chart/hyrax/Chart.yaml +18 -14
  203. data/chart/hyrax/README.md +34 -21
  204. data/chart/hyrax/templates/_helpers.tpl +34 -1
  205. data/chart/hyrax/templates/configmap-env.yaml +12 -2
  206. data/chart/hyrax/templates/secrets.yaml +1 -1
  207. data/chart/hyrax/values.yaml +39 -14
  208. data/config/initializers/file_length_patch.rb +10 -0
  209. data/config/initializers/listeners.rb +4 -10
  210. data/config/initializers/storage_adapter_initializer.rb +1 -1
  211. data/config/locales/hyrax.en.yml +8 -0
  212. data/config/metadata/basic_metadata.yaml +52 -0
  213. data/config/metadata/core_metadata.yaml +4 -0
  214. data/config/metadata/file_set_metadata.yaml +20 -1
  215. data/config/metadata/hyrax_internal_metadata.yaml +57 -0
  216. data/docker-compose-koppie.yml +36 -22
  217. data/docker-compose-sirenia.yml +202 -0
  218. data/docker-compose.yml +42 -26
  219. data/documentation/developing-your-hyrax-based-app.md +6 -14
  220. data/documentation/legacyREADME.md +3 -1
  221. data/hyrax.gemspec +12 -13
  222. data/karma.conf.js +9 -10
  223. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +2 -0
  224. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  225. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +11 -7
  226. data/lib/generators/hyrax/templates/db/migrate/20230725222727_create_hyrax_counter_metrics.rb.erb +14 -0
  227. data/lib/generators/hyrax/templates/db/migrate/20230803165135_change_work_id_to_string.rb.erb +5 -0
  228. data/lib/generators/hyrax/templates/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.rb.erb +8 -0
  229. data/lib/generators/hyrax/templates/db/migrate/20230821153635_add_fields_to_counter_metric.rb.erb +8 -0
  230. data/lib/generators/hyrax/templates/db/seeds.rb +1 -1
  231. data/lib/generators/hyrax/work_resource/templates/form.rb.erb +1 -1
  232. data/lib/generators/hyrax/work_resource/templates/metadata.yaml +2 -0
  233. data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
  234. data/lib/hyrax/configuration.rb +147 -43
  235. data/lib/hyrax/controlled_vocabularies/location.rb +7 -1
  236. data/lib/hyrax/engine.rb +2 -1
  237. data/lib/hyrax/form_fields.rb +6 -0
  238. data/lib/hyrax/publisher.rb +23 -3
  239. data/lib/hyrax/redis_event_store.rb +7 -8
  240. data/lib/hyrax/resource_name.rb +4 -0
  241. data/lib/hyrax/specs/capybara.rb +25 -37
  242. data/lib/hyrax/specs/shared_specs/hydra_works.rb +34 -7
  243. data/lib/hyrax/specs/shared_specs/indexers.rb +24 -6
  244. data/lib/hyrax/transactions/collection_destroy.rb +3 -2
  245. data/lib/hyrax/transactions/container.rb +47 -0
  246. data/lib/hyrax/transactions/file_metadata_destroy.rb +20 -0
  247. data/lib/hyrax/transactions/file_set_destroy.rb +3 -1
  248. data/lib/hyrax/transactions/file_set_update.rb +21 -0
  249. data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
  250. data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -1
  251. data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
  252. data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +46 -0
  253. data/lib/hyrax/transactions/steps/delete_all_file_sets.rb +46 -0
  254. data/lib/hyrax/transactions/steps/file_metadata_delete.rb +40 -0
  255. data/lib/hyrax/transactions/steps/remove_from_membership.rb +45 -0
  256. data/lib/hyrax/transactions/steps/save.rb +21 -0
  257. data/lib/hyrax/transactions/work_create.rb +1 -0
  258. data/lib/hyrax/transactions/work_destroy.rb +3 -2
  259. data/lib/hyrax/version.rb +1 -1
  260. data/lib/hyrax.rb +1 -0
  261. data/lib/tasks/collection_type_global_id.rake +9 -4
  262. data/lib/tasks/embargo_lease.rake +1 -0
  263. data/lib/valkyrie/indexing/solr/indexing_adapter.rb +2 -0
  264. data/lib/wings/active_fedora_converter/default_work.rb +7 -2
  265. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  266. data/lib/wings/active_fedora_converter.rb +53 -11
  267. data/lib/wings/attribute_transformer.rb +24 -17
  268. data/lib/wings/model_transformer.rb +23 -12
  269. data/lib/wings/orm_converter.rb +23 -18
  270. data/lib/wings/setup.rb +23 -3
  271. data/lib/wings/valkyrie/persister.rb +4 -2
  272. data/lib/wings/valkyrie/storage.rb +8 -90
  273. data/lib/wings.rb +5 -0
  274. data/package.json +3 -1
  275. data/tasks/hyrax_dev.rake +2 -33
  276. data/template.rb +1 -1
  277. metadata +104 -81
  278. data/.engine_cart.yml +0 -3
  279. data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
  280. data/app/services/hyrax/collections/migration_service.rb +0 -113
  281. data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
  282. data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
  283. data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
  284. data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
  285. data/app/views/hyrax/users/_user_util_links_extra.html.erb +0 -0
  286. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +0 -9
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
7
7
  # @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
8
- class <%= class_name %>Form < Hyrax::Forms::ResourceForm(<%= class_name %>)
8
+ class <%= class_name %>Form < Hyrax::Forms::PcdmObjectForm(<%= class_name %>)
9
9
  include Hyrax::FormFields(:basic_metadata)
10
10
  include Hyrax::FormFields(:<%= file_name %>)
11
11
 
@@ -2,6 +2,8 @@
2
2
  # index key names, and form properties.
3
3
  #
4
4
  # Attributes must have a type but all other configuration options are optional.
5
+ # Please note: If using Valkyrie's Fedora Metadata Adapter, predicates for attributes
6
+ # must be placed here.
5
7
  #
6
8
  # attributes:
7
9
  # attribute_name:
@@ -69,7 +69,12 @@ module Hyrax
69
69
  ##
70
70
  # @api public
71
71
  def to_global_id
72
- URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id
72
+ # this covers the use case of creating a non Valkyrie::Resource, while using Valkyrie
73
+ if model_name.name.constantize <= Valkyrie::Resource
74
+ URI::GID.build app: GlobalID.app, model_name: Hyrax::ValkyrieGlobalIdProxy.to_s, model_id: @id
75
+ else
76
+ URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id
77
+ end
73
78
  end
74
79
  end
75
80
  end
@@ -9,6 +9,8 @@ module Hyrax
9
9
  # engine options. For convenient reference, options are grouped into the
10
10
  # following functional areas:
11
11
  #
12
+ # - Analytics
13
+ # - Files
12
14
  # - Groups
13
15
  # - Identifiers
14
16
  # - IIIF
@@ -148,6 +150,132 @@ module Hyrax
148
150
  attr_writer :analytic_start_date
149
151
  attr_reader :analytic_start_date
150
152
 
153
+ # @!endgroup
154
+ # @!group Files
155
+
156
+ ##
157
+ # @!attribute [rw] characterization_service
158
+ # @return [#run] the service to use for charactaerization for Valkyrie
159
+ # objects
160
+ # @ see Hyrax::Characterization::ValkyrieCharacterizationService
161
+ attr_writer :characterization_service
162
+ def characterization_service
163
+ @characterization_service ||=
164
+ Hyrax::Characterization::ValkyrieCharacterizationService
165
+ end
166
+
167
+ ##
168
+ # Options to pass to the characterization service
169
+ # @!attribute [rw] characterization_options
170
+ # @return [Hash] of options like {ch12n_tool: :fits_servlet}
171
+ attr_writer :characterization_options
172
+ def characterization_options
173
+ @characterization_options ||= {}
174
+ end
175
+
176
+ ##
177
+ # @!attribute [w] characterization_proxy
178
+ # Which FileSet file to use for mime type resolution
179
+ # @ see Hyrax::FileSetTypeService
180
+ attr_writer :characterization_proxy
181
+ def characterization_proxy
182
+ @characterization_proxy ||= :original_file
183
+ end
184
+
185
+ # Override characterization runner
186
+ attr_accessor :characterization_runner
187
+
188
+ def mime_types_map # rubocop:disable Metrics/MethodLength
189
+ {
190
+ audio_mime_types: [
191
+ 'audio/mp3',
192
+ 'audio/mpeg',
193
+ 'audio/wav',
194
+ 'audio/x-wave',
195
+ 'audio/x-wav',
196
+ 'audio/ogg'
197
+ ],
198
+ image_mime_types: [
199
+ 'image/png',
200
+ 'image/jpeg',
201
+ 'image/jpg',
202
+ 'image/jp2',
203
+ 'image/bmp',
204
+ 'image/gif',
205
+ 'image/tiff'
206
+ ],
207
+ office_mime_types: [
208
+ 'text/rtf',
209
+ 'application/msword',
210
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
211
+ 'application/vnd.oasis.opendocument.text',
212
+ 'application/vnd.ms-excel',
213
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
214
+ 'application/vnd.ms-powerpoint',
215
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
216
+ ],
217
+ pdf_mime_types: ['application/pdf'],
218
+ video_mime_types: [
219
+ 'video/mpeg',
220
+ 'video/mp4',
221
+ 'video/webm',
222
+ 'video/x-msvideo',
223
+ 'video/avi',
224
+ 'video/quicktime',
225
+ 'application/mxf'
226
+ ]
227
+ }
228
+ end
229
+
230
+ # First see if we can get them from the FileSet model. If not, use
231
+ # configuration.
232
+ # @param [Symbol] type as listed in mime_types_map keys, aligned with
233
+ # FileSet method names for backwards compatibility.
234
+ def lookup_mimes(type)
235
+ vals = "FileSet".safe_constantize.try(type)
236
+ return vals if vals.is_a?(Array)
237
+ mime_types_map[type]
238
+ end
239
+
240
+ attr_writer :derivative_mime_type_mappings
241
+
242
+ ##
243
+ # Maps mimetypes to create_*_derivatives methods
244
+ #
245
+ # @note these used to be set by +Hydra::Works::MimeTypes+ methods injected
246
+ # into `FileSet`. for backwards compatibility, those are used as defaults
247
+ # if present, but since `FileSet` is an application side model (and slated
248
+ # to be removed) we shouldn't count on it providing these methods.
249
+ #
250
+ # @see Hyrax::VaDerivativeService
251
+ def derivative_mime_type_mappings
252
+ @derivative_mime_type_mappings ||=
253
+ { audio: lookup_mimes(:audio_mime_types),
254
+ image: lookup_mimes(:image_mime_types),
255
+ office: lookup_mimes(:office_mime_types),
256
+ pdf: lookup_mimes(:pdf_mime_types),
257
+ video: lookup_mimes(:video_mime_types) }
258
+ end
259
+
260
+ attr_writer :derivative_services
261
+ # The registered candidate derivative services. In the array, the first `valid?` candidate will
262
+ # handle the derivative generation.
263
+ #
264
+ # @return [Array] of objects that conform to Hyrax::DerivativeService interface.
265
+ # @see Hyrax::DerivativeService
266
+ def derivative_services
267
+ @derivative_services ||= [Hyrax::FileSetDerivativesService]
268
+ end
269
+
270
+ attr_writer :fixity_service
271
+ def fixity_service
272
+ @fixity_service ||= Hyrax::Fixity::ActiveFedoraFixityService
273
+ end
274
+
275
+ attr_writer :max_days_between_fixity_checks
276
+ def max_days_between_fixity_checks
277
+ @max_days_between_fixity_checks ||= 7
278
+ end
151
279
  # @!endgroup
152
280
  # @!group Groups
153
281
 
@@ -440,6 +568,20 @@ module Hyrax
440
568
  @derivatives_storage_adapter = Valkyrie::StorageAdapter.find(adapter.to_sym)
441
569
  end
442
570
 
571
+ # A HTTP connection to use for Valkyrie Fedora requests
572
+ #
573
+ # @return [#call] lambda/proc that generates a Faraday connection
574
+ def fedora_connection_builder
575
+ @fedora_connection_builder ||= lambda { |url|
576
+ Faraday.new(url) do |f|
577
+ f.request :multipart
578
+ f.request :url_encoded
579
+ f.adapter Faraday.default_adapter
580
+ end
581
+ }
582
+ end
583
+ attr_writer :fedora_connection_builder
584
+
443
585
  ##
444
586
  # @return [#save, #save_all, #delete, #wipe!] an indexing adapter
445
587
  def index_adapter
@@ -485,39 +627,6 @@ module Hyrax
485
627
  @microdata_default_type ||= 'http://schema.org/CreativeWork'
486
628
  end
487
629
 
488
- attr_writer :fixity_service
489
- def fixity_service
490
- @fixity_service ||= Hyrax::Fixity::ActiveFedoraFixityService
491
- end
492
-
493
- attr_writer :max_days_between_fixity_checks
494
- def max_days_between_fixity_checks
495
- @max_days_between_fixity_checks ||= 7
496
- end
497
-
498
- # Override characterization runner
499
- attr_accessor :characterization_runner
500
-
501
- ##
502
- # @!attribute [rw] characterization_service
503
- # @return [#run] the service to use for charactaerization for Valkyrie
504
- # objects
505
- # @ see Hyrax::Characterization::ValkyrieCharacterizationService
506
- attr_writer :characterization_service
507
- def characterization_service
508
- @characterization_service ||=
509
- Hyrax::Characterization::ValkyrieCharacterizationService
510
- end
511
-
512
- ##
513
- # @!attribute [w] characterization_proxy
514
- # Which FileSet file to use for mime type resolution
515
- # @ see Hyrax::FileSetTypeService
516
- attr_writer :characterization_proxy
517
- def characterization_proxy
518
- @characterization_proxy ||= :original_file
519
- end
520
-
521
630
  # Attributes for the lock manager which ensures a single process/thread is mutating a ore:Aggregation at once.
522
631
  # @!attribute [w] lock_retry_count
523
632
  # How many times to retry to acquire the lock before raising UnableToAcquireLockError
@@ -672,6 +781,11 @@ module Hyrax
672
781
  Qa::Authorities::Geonames.username = username
673
782
  end
674
783
 
784
+ def location_service
785
+ @location_service ||= Hyrax::LocationService.new
786
+ end
787
+ attr_writer :location_service
788
+
675
789
  attr_writer :active_deposit_agreement_acceptance
676
790
  def active_deposit_agreement_acceptance?
677
791
  return true if @active_deposit_agreement_acceptance.nil?
@@ -876,16 +990,6 @@ module Hyrax
876
990
  @range_for_number_of_results_to_display_per_page ||= [10, 20, 50, 100]
877
991
  end
878
992
 
879
- attr_writer :derivative_services
880
- # The registered candidate derivative services. In the array, the first `valid?` candidate will
881
- # handle the derivative generation.
882
- #
883
- # @return [Array] of objects that conform to Hyrax::DerivativeService interface.
884
- # @see Hyrax::DerivativeService
885
- def derivative_services
886
- @derivative_services ||= [Hyrax::FileSetDerivativesService]
887
- end
888
-
889
993
  attr_writer :visibility_map
890
994
  # A mapping from visibility string values to permissions; the default and
891
995
  # reference implementation is provided by {Hyrax::VisibilityMap}.
@@ -14,7 +14,13 @@ module Hyrax
14
14
  end
15
15
 
16
16
  def full_label
17
- Hyrax::LocationService.new.full_label(rdf_subject.to_s)
17
+ location_service.full_label(rdf_subject.to_s)
18
+ end
19
+
20
+ private
21
+
22
+ def location_service
23
+ Hyrax.config.location_service
18
24
  end
19
25
  end
20
26
  end
data/lib/hyrax/engine.rb CHANGED
@@ -8,7 +8,6 @@ module Hyrax
8
8
  require 'breadcrumbs_on_rails'
9
9
  require 'clipboard/rails'
10
10
  require 'draper'
11
- require 'dry/equalizer'
12
11
  require 'dry/events'
13
12
  require 'dry/struct'
14
13
  require 'dry/validation'
@@ -20,6 +19,8 @@ module Hyrax
20
19
  require 'qa'
21
20
  require 'tinymce-rails'
22
21
  require 'valkyrie'
22
+ require 'cancancan'
23
+ require 'blacklight'
23
24
 
24
25
  require 'hydra/derivatives'
25
26
  require 'hyrax/active_fedora_dummy_model'
@@ -51,6 +51,12 @@ module Hyrax
51
51
  descendant.property field_name.to_sym, options.merge(display: true, default: [])
52
52
  descendant.validates field_name.to_sym, presence: true if options.fetch(:required, false)
53
53
  end
54
+
55
+ # Auto include any matching FormFieldBehaviors
56
+ schema_name = name.to_s.camelcase
57
+ behavior = "#{schema_name}FormFieldsBehavior".safe_constantize ||
58
+ "Hyrax::#{schema_name}FormFieldsBehavior".safe_constantize
59
+ descendant.include(behavior) if behavior
54
60
  end
55
61
  end
56
62
  end
@@ -137,6 +137,14 @@ module Hyrax
137
137
  # a system user.
138
138
  register_event('file.metadata.updated')
139
139
 
140
+ # @since 5.0.0
141
+ # @macro a_registered_event
142
+ register_event('file.metadata.deleted')
143
+
144
+ # @since 5.0.0
145
+ # @macro a_registered_event
146
+ register_event('file.uploaded')
147
+
140
148
  # @since 3.0.0
141
149
  # @macro a_registered_event
142
150
  register_event('file.set.audited')
@@ -191,8 +199,20 @@ module Hyrax
191
199
  # `#member_ids`)
192
200
  register_event('object.metadata.updated')
193
201
 
194
- # @since 3.2.0
195
- # @macro a_registered_event
196
- register_event('object.file.uploaded')
202
+ ##
203
+ # @return Array[Object] the listeners Hyrax subscribes by default.
204
+ def default_listeners
205
+ @default_listeners ||=
206
+ [Hyrax::Listeners::AclIndexListener.new,
207
+ Hyrax::Listeners::BatchNotificationListener.new,
208
+ Hyrax::Listeners::FileMetadataListener.new,
209
+ Hyrax::Listeners::FileSetLifecycleListener.new,
210
+ Hyrax::Listeners::FileSetLifecycleNotificationListener.new,
211
+ Hyrax::Listeners::MemberCleanupListener.new,
212
+ Hyrax::Listeners::MetadataIndexListener.new,
213
+ Hyrax::Listeners::ObjectLifecycleListener.new,
214
+ Hyrax::Listeners::TrophyCleanupListener.new,
215
+ Hyrax::Listeners::WorkflowListener.new].freeze
216
+ end
197
217
  end
198
218
  end
@@ -25,15 +25,14 @@ module Hyrax
25
25
  #
26
26
  # @return [Redis]
27
27
  def instance
28
- connection = Hyrax.config.redis_connection || Redis.current
29
-
30
- if connection.is_a? Redis::Namespace
31
- connection.namespace = namespace
32
- connection
33
- elsif connection == Redis.current
34
- Redis.current = Redis::Namespace.new(namespace, redis: connection)
28
+ if Hyrax.config.redis_connection&.is_a?(Redis::Namespace)
29
+ c = Hyrax.config.redis_connection
30
+ c.namespace = namespace
31
+ c
32
+ elsif Hyrax.config.redis_connection
33
+ Hyrax.config.redis_connection
35
34
  else
36
- connection
35
+ Redis::Namespace.new(namespace, redis: Redis.new)
37
36
  end
38
37
  end
39
38
 
@@ -15,5 +15,9 @@ module Hyrax
15
15
  @route_key = legacy_model.model_name.route_key
16
16
  @singular_route_key = legacy_model.model_name.singular_route_key
17
17
  end
18
+
19
+ def human
20
+ super.titleize
21
+ end
18
22
  end
19
23
  end
@@ -15,52 +15,40 @@ require 'capybara/rspec'
15
15
  require 'capybara/rails'
16
16
  require 'capybara-screenshot/rspec'
17
17
  require 'selenium-webdriver'
18
- require 'webdrivers' unless ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present?
19
18
 
20
19
  Capybara.save_path = ENV['CI'] ? "/tmp/test-results" : Rails.root.join('tmp', 'capybara')
21
20
 
22
- if ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present?
23
- args = %w[disable-gpu no-sandbox whitelisted-ips window-size=1400,1400]
24
- args.push('headless') if ActiveModel::Type::Boolean.new.cast(ENV['CHROME_HEADLESS_MODE'])
25
-
26
- options = Selenium::WebDriver::Options.chrome("goog:chromeOptions" => { args: args })
27
-
28
- Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
29
- driver = Capybara::Selenium::Driver.new(app,
30
- browser: :remote,
31
- capabilities: options,
32
- url: ENV['HUB_URL'])
21
+ options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
22
+ opts.add_argument("--headless") if ENV["CHROME_HEADLESS_MODE"]
23
+ opts.add_argument("--disable-gpu") if Gem.win_platform?
24
+ # Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
25
+ opts.add_argument("--disable-site-isolation-trials")
26
+ opts.add_argument("--window-size=1440,1440")
27
+ opts.add_argument("--enable-features=NetworkService,NetworkServiceInProcess")
28
+ opts.add_argument("--disable-features=VizDisplayCompositor")
29
+ end
33
30
 
34
- # Fix for capybara vs remote files. Selenium handles this for us
35
- driver.browser.file_detector = lambda do |args|
36
- str = args.first.to_s
37
- str if File.exist?(str)
38
- end
31
+ Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
32
+ driver = Capybara::Selenium::Driver.new(app,
33
+ browser: :remote,
34
+ capabilities: options,
35
+ url: ENV['HUB_URL'])
39
36
 
40
- driver
37
+ # Fix for capybara vs remote files. Selenium handles this for us
38
+ driver.browser.file_detector = lambda do |args|
39
+ str = args.first.to_s
40
+ str if File.exist?(str)
41
41
  end
42
42
 
43
- Capybara.server_host = '0.0.0.0'
44
- Capybara.server_port = 3010
45
-
46
- ip = IPSocket.getaddress(Socket.gethostname)
47
- Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"
48
- else
49
- TEST_HOST = 'localhost:3000'.freeze
50
- # @note In January 2018, TravisCI disabled Chrome sandboxing in its Linux
51
- # container build environments to mitigate Meltdown/Spectre
52
- # vulnerabilities, at which point Hyrax could no longer use the
53
- # Capybara-provided :selenium_chrome_headless driver (which does not
54
- # include the `--no-sandbox` argument).
55
- Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
56
- browser_options = ::Selenium::WebDriver::Chrome::Options.new
57
- browser_options.args << '--headless'
58
- browser_options.args << '--disable-gpu'
59
- browser_options.args << '--no-sandbox'
60
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
61
- end
43
+ driver
62
44
  end
63
45
 
46
+ Capybara.server_host = '0.0.0.0'
47
+ Capybara.server_port = 3010
48
+
49
+ ip = IPSocket.getaddress(Socket.gethostname)
50
+ Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"
51
+
64
52
  Capybara.default_driver = :rack_test # This is a faster driver
65
53
  Capybara.javascript_driver = :selenium_chrome_headless_sandboxless # This is slower
66
54
  Capybara.default_max_wait_time = ENV.fetch('CAPYBARA_WAIT_TIME', 10) # We may have a slow application, let's give it some time.
@@ -249,7 +249,7 @@ RSpec.shared_examples 'a Hyrax::Work' do
249
249
  end
250
250
  end
251
251
 
252
- RSpec.shared_examples 'a Hyrax::FileSet' do
252
+ RSpec.shared_examples 'a Hyrax::FileSet', valkyrie_adapter: :test_adapter do
253
253
  subject(:fileset) { described_class.new }
254
254
  let(:adapter) { Valkyrie::MetadataAdapter.find(:test_adapter) }
255
255
  let(:persister) { adapter.persister }
@@ -275,12 +275,10 @@ RSpec.shared_examples 'a Hyrax::FileSet' do
275
275
  end
276
276
 
277
277
  context 'with files' do
278
- let(:file_class) { Hyrax::FileMetadata }
279
- let(:files) do
280
- [file_class.new, file_class.new, file_class.new]
281
- .map! { |f| persister.save(resource: f) }
282
- end
283
-
278
+ let(:original_file) { FactoryBot.valkyrie_create :hyrax_file_metadata, :original_file }
279
+ let(:thumbnail) { FactoryBot.valkyrie_create :hyrax_file_metadata, :thumbnail }
280
+ let(:extracted_text) { FactoryBot.valkyrie_create :hyrax_file_metadata, :extracted_text }
281
+ let(:files) { [original_file, thumbnail, extracted_text] }
284
282
  let(:file_ids) { files.map(&:id) }
285
283
 
286
284
  before { fileset.file_ids = file_ids }
@@ -301,6 +299,35 @@ RSpec.shared_examples 'a Hyrax::FileSet' do
301
299
  expect { fileset.file_ids << file_ids.first }
302
300
  .not_to change { query_service.custom_queries.find_files(file_set: fileset) }
303
301
  end
302
+
303
+ it 'returns an original_file' do
304
+ expect(fileset.original_file).to eq original_file
305
+ expect(fileset.original_file_id).to eq original_file.id
306
+ end
307
+
308
+ it 'returns a thumbnail' do
309
+ expect(fileset.thumbnail).to eq thumbnail
310
+ expect(fileset.thumbnail_id).to eq thumbnail.id
311
+ end
312
+
313
+ it 'returns an extracted_text' do
314
+ expect(fileset.extracted_text).to eq extracted_text
315
+ expect(fileset.extracted_text_id).to eq extracted_text.id
316
+ end
317
+
318
+ context 'with simulated original file' do
319
+ let(:file_metadata_double) { double("Fake Hyrax::FileMetadata", id: SecureRandom.uuid, file_identifier: SecureRandom.uuid, versions: [file_double]) }
320
+ let(:file_double) { double("Fake Valkyrie::StorageAdapter::File", id: SecureRandom.uuid, version_id: SecureRandom.uuid)}
321
+
322
+ before do
323
+ allow(fileset).to receive(:original_file).and_return(file_metadata_double)
324
+ fileset.id = Valkyrie::ID.new(SecureRandom.uuid)
325
+ end
326
+
327
+ it 'returns a iiif_id with matching ids' do
328
+ expect(fileset.iiif_id).to eq "#{fileset.id}/files/#{fileset.original_file_id}/#{Digest::MD5.hexdigest(file_double.version_id)}"
329
+ end
330
+ end
304
331
  end
305
332
  end
306
333
  end
@@ -89,8 +89,6 @@ RSpec.shared_examples 'a thumbnail indexer' do
89
89
  before do
90
90
  raise 'indexer_class must be set with `let(:indexer_class)`' unless defined? indexer_class
91
91
  raise 'resource must be set with `let(:resource)` and is expected to be a kind of Hyrax::Resource' unless defined?(resource) && resource.kind_of?(Hyrax::Resource)
92
- # optionally can pass in default_visibility by setting it with a let statement if your application changes the default; Hyrax defines this as 'restricted'
93
- # See samvera/hyrda-head hydra-access-controls/app/models/concerns/hydra/access_controls/access_rights.rb for possible VISIBILITY_TEXT_VALUE_...'
94
92
  end
95
93
  subject(:indexer) { indexer_class.new(resource: resource) }
96
94
  let(:thumbnail_path) { '/downloads/foo12345?file=thumbnail' }
@@ -106,6 +104,27 @@ RSpec.shared_examples 'a thumbnail indexer' do
106
104
  end
107
105
  end
108
106
 
107
+ RSpec.shared_examples 'a location indexer' do
108
+ before do
109
+ raise 'indexer_class must be set with `let(:indexer_class)`' unless defined? indexer_class
110
+ raise 'resource must be set with `let(:resource)` and is expected to be a kind of Hyrax::Resource' unless defined?(resource) && resource.kind_of?(Hyrax::Resource)
111
+ resource.based_near = based_near
112
+ end
113
+ subject(:indexer) { indexer_class.new(resource: resource) }
114
+ let(:based_near) { ["https://sws.geonames.org/4254679/"] }
115
+ let(:based_near_label) { ["Bloomington, Indiana, United States"] }
116
+
117
+ before do
118
+ allow(Hyrax.config.location_service).to receive(:full_label).with(based_near[0]).and_return(based_near_label[0])
119
+ end
120
+
121
+ describe '#to_solr' do
122
+ it 'indexes locations' do
123
+ expect(indexer.to_solr).to include(based_near_tesim: based_near, based_near_label_tesim: based_near_label)
124
+ end
125
+ end
126
+ end
127
+
109
128
  RSpec.shared_examples 'a Core metadata indexer' do
110
129
  before do
111
130
  raise 'indexer_class must be set with `let(:indexer_class)`' unless defined? indexer_class
@@ -138,9 +157,10 @@ RSpec.shared_examples 'a Basic metadata indexer' do
138
157
  end
139
158
  subject(:indexer) { indexer_class.new(resource: resource) }
140
159
 
160
+ it_behaves_like 'a location indexer'
161
+
141
162
  let(:attributes) do
142
163
  {
143
- based_near: ['helsinki', 'finland'],
144
164
  date_created: ['tuesday'],
145
165
  keyword: ['comic strip'],
146
166
  related_url: ['http://example.com/moomin'],
@@ -152,9 +172,7 @@ RSpec.shared_examples 'a Basic metadata indexer' do
152
172
  describe '#to_solr' do
153
173
  it 'indexes basic metadata' do
154
174
  expect(indexer.to_solr)
155
- .to include(based_near_tesim: a_collection_containing_exactly(*attributes[:based_near]),
156
- based_near_sim: a_collection_containing_exactly(*attributes[:based_near]),
157
- date_created_tesim: a_collection_containing_exactly(*attributes[:date_created]),
175
+ .to include(date_created_tesim: a_collection_containing_exactly(*attributes[:date_created]),
158
176
  keyword_sim: a_collection_containing_exactly(*attributes[:keyword]),
159
177
  related_url_tesim: a_collection_containing_exactly(*attributes[:related_url]),
160
178
  resource_type_tesim: a_collection_containing_exactly(*attributes[:resource_type]),
@@ -9,8 +9,9 @@ module Hyrax
9
9
  # @since 3.4.0
10
10
  class CollectionDestroy < Transaction
11
11
  # TODO: Add step that checks if collection is empty for collections of types that require it
12
- DEFAULT_STEPS = ['collection_resource.delete',
13
- 'collection_resource.delete_acl'].freeze
12
+ DEFAULT_STEPS = ['collection_resource.delete_acl',
13
+ 'collection_resource.remove_from_membership',
14
+ 'collection_resource.delete'].freeze
14
15
 
15
16
  ##
16
17
  # @see Hyrax::Transactions::Transaction