hyrax 3.3.0 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +26 -17
  3. data/.dassie/.env +2 -1
  4. data/.dassie/Gemfile +1 -1
  5. data/.dassie/app/forms/collection_resource_form.rb +8 -0
  6. data/.dassie/app/indexers/collection_resource_indexer.rb +8 -0
  7. data/.dassie/app/models/collection_resource.rb +35 -0
  8. data/.dassie/config/initializers/file_services.rb +4 -0
  9. data/.dassie/config/initializers/hyrax.rb +12 -1
  10. data/.dassie/config/metadata/collection_resource.yaml +23 -0
  11. data/.dassie/db/seeds.rb +74 -17
  12. data/.dassie/spec/forms/collection_resource_form_spec.rb +13 -0
  13. data/.dassie/spec/indexers/collection_resource_indexer_spec.rb +14 -0
  14. data/.dassie/spec/models/collection_resource_spec.rb +13 -0
  15. data/.github/release.yml +26 -0
  16. data/.gitignore +3 -0
  17. data/.regen +1 -1
  18. data/.rubocop.yml +1 -1
  19. data/.rubocop_fixme.yml +22 -3
  20. data/CONTAINERS.md +18 -13
  21. data/Dockerfile +4 -3
  22. data/app/actors/hyrax/actors/file_actor.rb +6 -4
  23. data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
  24. data/app/assets/javascripts/hyrax/analytics_events.js +8 -2
  25. data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
  26. data/app/assets/javascripts/hyrax/collections_v2.es6 +13 -0
  27. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +1 -3
  28. data/app/controllers/concerns/hyrax/controller.rb +21 -0
  29. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
  30. data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
  31. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +12 -19
  32. data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
  33. data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
  34. data/app/controllers/hyrax/citations_controller.rb +1 -1
  35. data/app/controllers/hyrax/dashboard/collections_controller.rb +176 -83
  36. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +1 -1
  37. data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
  38. data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
  39. data/app/forms/hyrax/forms/collection_form.rb +1 -1
  40. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
  41. data/app/forms/hyrax/forms/pcdm_collection_form.rb +30 -2
  42. data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
  43. data/app/forms/hyrax/forms/resource_form.rb +23 -5
  44. data/app/forms/hyrax/forms/widgets/admin_set_visibility.rb +1 -1
  45. data/app/helpers/hyrax/collections_helper.rb +14 -0
  46. data/app/helpers/hyrax/membership_helper.rb +1 -1
  47. data/app/helpers/hyrax/trophy_helper.rb +1 -1
  48. data/app/helpers/hyrax/url_helper.rb +1 -1
  49. data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
  50. data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
  51. data/app/indexers/hyrax/file_set_indexer.rb +1 -0
  52. data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -2
  53. data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
  54. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +6 -6
  55. data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
  56. data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
  57. data/app/inputs/controlled_vocabulary_input.rb +2 -0
  58. data/app/jobs/change_depositor_event_job.rb +47 -0
  59. data/app/jobs/characterize_job.rb +43 -3
  60. data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
  61. data/app/jobs/content_depositor_change_event_job.rb +2 -1
  62. data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
  63. data/app/jobs/import_url_job.rb +4 -6
  64. data/app/jobs/inherit_permissions_job.rb +1 -1
  65. data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
  66. data/app/jobs/valkyrie_ingest_job.rb +41 -35
  67. data/app/models/admin_set.rb +10 -2
  68. data/app/models/collection_branding_info.rb +8 -6
  69. data/app/models/concerns/hyrax/collection_behavior.rb +3 -3
  70. data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
  71. data/app/models/concerns/hyrax/solr_document/metadata.rb +1 -0
  72. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
  73. data/app/models/concerns/hyrax/user.rb +11 -0
  74. data/app/models/concerns/hyrax/work_behavior.rb +1 -1
  75. data/app/models/featured_work_list.rb +0 -1
  76. data/app/models/hyrax/administrative_set.rb +36 -1
  77. data/app/models/hyrax/collection_type.rb +2 -2
  78. data/app/models/hyrax/file_metadata.rb +37 -3
  79. data/app/models/hyrax/file_set.rb +43 -4
  80. data/app/models/hyrax/group.rb +19 -0
  81. data/app/models/hyrax/pcdm_collection.rb +56 -1
  82. data/app/models/hyrax/permission_template.rb +11 -5
  83. data/app/models/hyrax/work.rb +91 -0
  84. data/app/models/job_io_wrapper.rb +1 -1
  85. data/app/models/proxy_deposit_request.rb +1 -1
  86. data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
  87. data/app/presenters/hyrax/member_presenter_factory.rb +2 -4
  88. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
  89. data/app/presenters/hyrax/work_show_presenter.rb +10 -6
  90. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
  91. data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
  92. data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
  93. data/app/search_builders/hyrax/my/collections_search_builder.rb +11 -4
  94. data/app/services/hyrax/access_control_list.rb +20 -6
  95. data/app/services/hyrax/adapters/nesting_index_adapter.rb +3 -3
  96. data/app/services/hyrax/admin_set_create_service.rb +21 -37
  97. data/app/services/hyrax/change_content_depositor_service.rb +2 -2
  98. data/app/services/hyrax/change_depositor_service.rb +70 -0
  99. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +4 -6
  100. data/app/services/hyrax/collections/collection_member_service.rb +3 -5
  101. data/app/services/hyrax/collections/nested_collection_query_service.rb +24 -12
  102. data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
  103. data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
  104. data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
  105. data/app/services/hyrax/default_middleware_stack.rb +3 -0
  106. data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
  107. data/app/services/hyrax/file_set_type_service.rb +2 -5
  108. data/app/services/hyrax/listeners/file_metadata_listener.rb +31 -1
  109. data/app/services/hyrax/listeners/member_cleanup_listener.rb +27 -11
  110. data/app/services/hyrax/listeners/metadata_index_listener.rb +39 -0
  111. data/app/services/hyrax/listeners/proxy_deposit_listener.rb +14 -8
  112. data/app/services/hyrax/location_service.rb +33 -0
  113. data/app/services/hyrax/multiple_membership_checker.rb +46 -1
  114. data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
  115. data/app/services/hyrax/simple_schema_loader.rb +5 -1
  116. data/app/services/hyrax/solr_query_service.rb +12 -7
  117. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  118. data/app/services/hyrax/valkyrie_persist_derivatives.rb +50 -0
  119. data/app/services/hyrax/valkyrie_upload.rb +94 -0
  120. data/app/services/hyrax/work_uploads_handler.rb +0 -10
  121. data/app/services/hyrax/workflow/workflow_importer.rb +7 -9
  122. data/app/services/hyrax/workflow/workflow_schema.rb +3 -5
  123. data/app/strategies/hyrax/strategies/yaml_strategy.rb +4 -6
  124. data/app/uploaders/hyrax/uploaded_file_uploader.rb +4 -4
  125. data/app/utils/hyrax/data_destroyers/collection_branding_destroyer.rb +29 -0
  126. data/app/utils/hyrax/data_destroyers/collection_types_destroyer.rb +26 -0
  127. data/app/utils/hyrax/data_destroyers/default_admin_set_id_cache_destroyer.rb +26 -0
  128. data/app/utils/hyrax/data_destroyers/featured_works_destroyer.rb +27 -0
  129. data/app/utils/hyrax/data_destroyers/permission_templates_destroyer.rb +30 -0
  130. data/app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb +42 -0
  131. data/app/utils/hyrax/data_destroyers/stats_destroyer.rb +33 -0
  132. data/app/utils/hyrax/data_maintenance.rb +51 -0
  133. data/app/utils/hyrax/required_data_seeder.rb +21 -0
  134. data/app/utils/hyrax/required_data_seeders/collection_seeder.rb +26 -0
  135. data/app/utils/hyrax/required_data_seeders/collection_type_seeder.rb +36 -0
  136. data/app/utils/hyrax/test_data_seeder.rb +24 -0
  137. data/app/utils/hyrax/test_data_seeders/collection_seeder.rb +91 -0
  138. data/app/utils/hyrax/test_data_seeders/collection_type_seeder.rb +72 -0
  139. data/app/utils/hyrax/test_data_seeders/user_seeder.rb +52 -0
  140. data/app/validators/hyrax/collection_membership_validator.rb +39 -0
  141. data/app/views/catalog/_index_header_list_default.html.erb +8 -1
  142. data/app/views/catalog/_thumbnail_list_default.html.erb +8 -3
  143. data/app/views/collections/edit_fields/_based_near.html.erb +7 -7
  144. data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
  145. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
  146. data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
  147. data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
  148. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  149. data/app/views/hyrax/base/_form.html.erb +1 -1
  150. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  151. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +2 -2
  152. data/app/views/hyrax/dashboard/collections/_form.html.erb +24 -17
  153. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -0
  154. data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
  155. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
  156. data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
  157. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
  158. data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +1 -1
  159. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
  160. data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
  161. data/app/views/hyrax/file_sets/_actions.html.erb +2 -2
  162. data/app/views/hyrax/my/_facet_pagination.html.erb +12 -9
  163. data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
  164. data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
  165. data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
  166. data/app/views/hyrax/my/collections/index.html.erb +3 -2
  167. data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
  168. data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
  169. data/app/views/hyrax/my/works/_tabs.html.erb +6 -1
  170. data/app/views/hyrax/my/works/index.html.erb +4 -2
  171. data/chart/hyrax/Chart.yaml +11 -7
  172. data/chart/hyrax/README.md +22 -1
  173. data/chart/hyrax/templates/_helpers.tpl +4 -0
  174. data/chart/hyrax/templates/cron-embargo.yaml +5 -0
  175. data/chart/hyrax/templates/cron-lease.yaml +5 -0
  176. data/chart/hyrax/templates/deployment-worker.yaml +11 -0
  177. data/chart/hyrax/templates/ingress.yaml +7 -6
  178. data/chart/hyrax/values.yaml +152 -0
  179. data/config/features.rb +48 -50
  180. data/config/initializers/listeners.rb +0 -1
  181. data/config/initializers/{valkryrie_storage.rb → storage_adapter_initializer.rb} +5 -0
  182. data/config/locales/hyrax.de.yml +18 -17
  183. data/config/locales/hyrax.en.yml +30 -28
  184. data/config/locales/hyrax.es.yml +10 -9
  185. data/config/locales/hyrax.fr.yml +2 -1
  186. data/config/locales/hyrax.it.yml +3 -2
  187. data/config/locales/hyrax.pt-BR.yml +2 -1
  188. data/config/locales/hyrax.zh.yml +2 -1
  189. data/config/metadata/basic_metadata.yaml +2 -0
  190. data/config/metadata/core_metadata.yaml +1 -1
  191. data/docker-compose.yml +47 -42
  192. data/documentation/developing-your-hyrax-based-app.md +1 -1
  193. data/documentation/legacyREADME.md +1 -1
  194. data/hyrax.gemspec +5 -3
  195. data/lib/generators/hyrax/collection_resource/USAGE +20 -0
  196. data/lib/generators/hyrax/collection_resource/collection_resource_generator.rb +133 -0
  197. data/lib/generators/hyrax/collection_resource/templates/collection.rb.erb +34 -0
  198. data/lib/generators/hyrax/collection_resource/templates/collection_form.rb.erb +7 -0
  199. data/lib/generators/hyrax/collection_resource/templates/collection_form_spec.rb.erb +13 -0
  200. data/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +7 -0
  201. data/lib/generators/hyrax/collection_resource/templates/collection_indexer_spec.rb.erb +13 -0
  202. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +22 -0
  203. data/lib/generators/hyrax/collection_resource/templates/collection_spec.rb.erb +12 -0
  204. data/lib/generators/hyrax/install_generator.rb +9 -0
  205. data/lib/hyrax/administrative_set_name.rb +18 -0
  206. data/lib/hyrax/collection_name.rb +2 -0
  207. data/lib/hyrax/configuration.rb +22 -0
  208. data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
  209. data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
  210. data/lib/hyrax/controlled_vocabularies.rb +1 -0
  211. data/lib/hyrax/publisher.rb +49 -0
  212. data/lib/hyrax/schema.rb +16 -13
  213. data/lib/hyrax/specs/capybara.rb +1 -1
  214. data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -5
  215. data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
  216. data/lib/hyrax/transactions/admin_set_create.rb +2 -1
  217. data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
  218. data/lib/hyrax/transactions/admin_set_update.rb +21 -0
  219. data/lib/hyrax/transactions/collection_destroy.rb +22 -0
  220. data/lib/hyrax/transactions/collection_update.rb +5 -2
  221. data/lib/hyrax/transactions/container.rb +97 -23
  222. data/lib/hyrax/transactions/create_work.rb +3 -0
  223. data/lib/hyrax/transactions/destroy_work.rb +3 -0
  224. data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
  225. data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
  226. data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
  227. data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
  228. data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
  229. data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
  230. data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
  231. data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
  232. data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
  233. data/lib/hyrax/transactions/steps/save.rb +24 -6
  234. data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
  235. data/lib/hyrax/transactions/steps/save_collection_banner.rb +59 -0
  236. data/lib/hyrax/transactions/steps/save_collection_logo.rb +109 -0
  237. data/lib/hyrax/transactions/steps/save_work.rb +3 -0
  238. data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
  239. data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
  240. data/lib/hyrax/transactions/update_work.rb +4 -3
  241. data/lib/hyrax/transactions/work_create.rb +1 -1
  242. data/lib/hyrax/transactions/work_destroy.rb +2 -1
  243. data/lib/hyrax/transactions/work_update.rb +19 -0
  244. data/lib/hyrax/version.rb +1 -1
  245. data/lib/wings/active_fedora_converter/file_metadata_node.rb +48 -0
  246. data/lib/wings/active_fedora_converter/instance_builder.rb +68 -0
  247. data/lib/wings/active_fedora_converter.rb +3 -3
  248. data/lib/wings/attribute_transformer.rb +5 -1
  249. data/lib/wings/services/custom_queries/find_file_metadata.rb +19 -8
  250. data/lib/wings/setup.rb +3 -1
  251. data/lib/wings/valkyrie/persister.rb +2 -0
  252. data/lib/wings/valkyrie/query_service.rb +6 -7
  253. data/lib/wings/valkyrie/storage.rb +7 -1
  254. data/template.rb +1 -1
  255. metadata +99 -12
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax::ValkyrieUpload
4
+ # @param [IO] io
5
+ # @param [String] filename
6
+ # @param [Hyrax::FileSet] file_set
7
+ # @param [RDF::URI] use
8
+ # @param [User] user
9
+ #
10
+ # @see Hyrax::FileMetadata::Use
11
+ # @return [Hyrax::FileMetadata] the metadata representing the uploaded file
12
+ # rubocop:disable Metrics/MethodLength
13
+ # rubocop:disable Metrics/ParameterLists
14
+ def self.file(
15
+ filename:,
16
+ file_set:,
17
+ io:,
18
+ storage_adapter: Hyrax.storage_adapter,
19
+ use: Hyrax::FileMetadata::Use::ORIGINAL_FILE,
20
+ user: nil
21
+ )
22
+
23
+ streamfile = storage_adapter.upload(
24
+ file: io,
25
+ original_filename: filename,
26
+ resource: file_set,
27
+ use: use
28
+ )
29
+ io.close
30
+
31
+ file_metadata = Hyrax::FileMetadata(streamfile)
32
+ file_metadata.file_set_id = file_set.id
33
+
34
+ case use
35
+ when Hyrax::FileMetadata::Use::ORIGINAL_FILE
36
+ # Set file set label.
37
+ reset_title = file_set.title.first == file_set.label
38
+ # set title to label if that's how it was before this characterization
39
+ file_set.title = file_metadata.original_filename if reset_title
40
+ # always set the label to the original_name
41
+ file_set.label = file_metadata.original_filename
42
+ when Hyrax::FileMetadata::Use::THUMBNAIL
43
+ # TODO: the parent work's thumbnail_id remains incorrect (it's set to the
44
+ # FileSet ID, rather than the ID of this thumbnail FileMetadata; but
45
+ # trying to update the parent attributes here doesn't seem to stick
46
+ file_set.thumbnail_id = file_metadata.id
47
+ end
48
+
49
+ saved_metadata = Hyrax.persister.save(resource: file_metadata)
50
+ Hyrax.publisher.publish("object.file.uploaded", metadata: saved_metadata)
51
+
52
+ add_file_to_file_set(file_set: file_set,
53
+ file_metadata: saved_metadata,
54
+ user: user)
55
+
56
+ Hyrax.publisher.publish('file.metadata.updated', metadata: saved_metadata, user: user)
57
+
58
+ saved_metadata
59
+ end
60
+
61
+ # @param [Hyrax::FileSet] file_set the file set to add to
62
+ # @param [Hyrax::FileMetadata] file_metadata the metadata object representing
63
+ # the file to add
64
+ # @param [::User] user the user performing the add
65
+ #
66
+ # @return [Hyrax::FileSet] updated file set
67
+ def self.add_file_to_file_set(file_set:, file_metadata:, user:)
68
+ file_set.file_ids << file_metadata.id
69
+ set_file_use_ids(file_set, file_metadata)
70
+
71
+ Hyrax.persister.save(resource: file_set)
72
+ Hyrax.publisher.publish('object.membership.updated', object: file_set, user: user)
73
+ end
74
+
75
+ # @api private
76
+ # @param [Hyrax::FileSet] file_set the file set to add to
77
+ # @param [Hyrax::FileMetadata] file_metadata the metadata object representing
78
+ # the file to add
79
+ # @return [void]
80
+ def self.set_file_use_ids(file_set, file_metadata)
81
+ file_metadata.type.each do |type|
82
+ case type
83
+ when Hyrax::FileMetadata::Use::ORIGINAL_FILE
84
+ file_set.original_file_id = file_metadata.id
85
+ when Hyrax::FileMetadata::Use::THUMBNAIL
86
+ file_set.thumbnail_id = file_metadata.id
87
+ when Hyrax::FileMetadata::Use::EXTRACTED_TEXT
88
+ file_set.extracted_text_id = file_metadata.id
89
+ else
90
+ Rails.logger.warn "Unknown file use #{file_metadata.type} specified for #{file_metadata.file_identifier}"
91
+ end
92
+ end
93
+ end
94
+ end
@@ -116,9 +116,6 @@ module Hyrax
116
116
 
117
117
  ValkyrieIngestJob.perform_later(file)
118
118
 
119
- # this triggers the re-index
120
- Hyrax.publisher.publish('object.metadata.updated', object: file_set, user: file.user)
121
-
122
119
  { file_set: file_set, user: file.user }
123
120
  end
124
121
 
@@ -163,13 +160,6 @@ module Hyrax
163
160
  @target_permissions ||= Hyrax::AccessControlList.new(resource: work)
164
161
  end
165
162
 
166
- ##
167
- # @api private
168
- # @return [JobIoWrapper]
169
- def wrap_file(file, file_set)
170
- JobIoWrapper.create_with_varied_file_handling!(user: file.user, file: file, relation: :original_file, file_set: file_set)
171
- end
172
-
173
163
  ##
174
164
  # @api private
175
165
  #
@@ -128,16 +128,14 @@ module Hyrax
128
128
  def call
129
129
  self.errors = []
130
130
  Array.wrap(data.fetch(:workflows)).map do |configuration|
131
- begin
132
- find_or_create_from(configuration: configuration)
133
- rescue InvalidStateRemovalException => e
134
- e.states.each do |state|
135
- error = I18n.t('hyrax.workflow.load.state_error', workflow_name: state.workflow.name, state_name: state.name, entity_count: state.entities.count)
136
- Rails.logger.error(error)
137
- errors << error
138
- end
139
- Sipity::Workflow.find_by(name: configuration[:name])
131
+ find_or_create_from(configuration: configuration)
132
+ rescue InvalidStateRemovalException => e
133
+ e.states.each do |state|
134
+ error = I18n.t('hyrax.workflow.load.state_error', workflow_name: state.workflow.name, state_name: state.name, entity_count: state.entities.count)
135
+ Rails.logger.error(error)
136
+ errors << error
140
137
  end
138
+ Sipity::Workflow.find_by(name: configuration[:name])
141
139
  end
142
140
  end
143
141
 
@@ -20,11 +20,9 @@ module Hyrax
20
20
  include Dry::Types()
21
21
 
22
22
  Constant = Types::Class.constructor do |v|
23
- begin
24
- v.constantize
25
- rescue NameError => _err
26
- v
27
- end
23
+ v.constantize
24
+ rescue NameError => _err
25
+ v
28
26
  end
29
27
  end
30
28
 
@@ -34,12 +34,10 @@ module Hyrax::Strategies
34
34
 
35
35
  def yaml_file
36
36
  @yaml_file ||=
37
- begin
38
- if File.exist?(@config_file)
39
- YAML.load_file(@config_file)
40
- else
41
- {}
42
- end
37
+ if File.exist?(@config_file)
38
+ YAML.load_file(@config_file)
39
+ else
40
+ {}
43
41
  end
44
42
  end
45
43
  end
@@ -4,21 +4,21 @@ module Hyrax
4
4
  # Override the directory where uploaded files will be stored.
5
5
  # This is a sensible default for uploaders that are meant to be mounted:
6
6
  def store_dir
7
- configured_upload_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
7
+ (configured_upload_path / model.class.to_s.underscore / mounted_as.to_s / model.id.to_s).to_s
8
8
  end
9
9
 
10
10
  def cache_dir
11
- configured_cache_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
11
+ (configured_cache_path / model.class.to_s.underscore / mounted_as.to_s / model.id.to_s).to_s
12
12
  end
13
13
 
14
14
  private
15
15
 
16
16
  def configured_upload_path
17
- Hyrax.config.upload_path.call
17
+ Pathname.new(Hyrax.config.upload_path.call)
18
18
  end
19
19
 
20
20
  def configured_cache_path
21
- Hyrax.config.cache_path.call
21
+ Pathname.new(Hyrax.config.cache_path.call)
22
22
  end
23
23
  end
24
24
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # Collection branding info is tightly coupled to collections. When they are
5
+ # removed using wipe!, the associated database entries for collection branding
6
+ # also have to be deleted.
7
+ #
8
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
9
+ # Data can not be recovered.
10
+ #
11
+ # @todo This destroys branding info in the database. Should it also delete
12
+ # related banner and logo files?
13
+ class CollectionBrandingDestroyer
14
+ class << self
15
+ attr_accessor :logger
16
+
17
+ def destroy_data(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
18
+ raise("CollectionBrandingDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
19
+ @logger = logger
20
+
21
+ logger.info("Destroying collection branding...")
22
+
23
+ Hyrax::CollectionBrandingInfo.destroy_all
24
+ logger.info(" collection branding -- DESTROYED")
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # Collection types are recreated by the release seed data. Clear out here to
5
+ # start with a fresh set.
6
+ #
7
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
8
+ # Data can not be recovered.
9
+ #
10
+ class CollectionTypesDestroyer
11
+ class << self
12
+ attr_accessor :logger
13
+
14
+ def destroy_data(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
15
+ raise("CollectionTypesDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
16
+ @logger = logger
17
+
18
+ logger.info("Destroying collection types...")
19
+
20
+ Hyrax::CollectionType.destroy_all
21
+ logger.info(" collection types -- DESTROYED")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # When the default admin set is removed using wipe!, the cache of the default
5
+ # admin set id also needs to be deleted.
6
+ #
7
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
8
+ # Data can not be recovered.
9
+ #
10
+ class DefaultAdminSetIdCacheDestroyer
11
+ class << self
12
+ attr_accessor :logger
13
+
14
+ def destroy_data(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
15
+ raise("DefaultAdminSetIdCacheDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
16
+ @logger = logger
17
+
18
+ logger.info("Destroying default admin set id cache...")
19
+
20
+ Hyrax::DefaultAdministrativeSet.destroy_all
21
+ logger.info(" default admin set id cache -- DESTROYED")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # Featured works are tightly coupled to works in the repository. When they
5
+ # are removed using wipe!, the associated database entries for featured
6
+ # works also need to be deleted.
7
+ #
8
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
9
+ # Data can not be recovered.
10
+ #
11
+ class FeaturedWorksDestroyer
12
+ class << self
13
+ attr_accessor :logger
14
+
15
+ def destroy_data(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
16
+ raise("FeaturedWorksDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
17
+ @logger = logger
18
+
19
+ logger.info("Destroying featured works...")
20
+
21
+ FeaturedWork.destroy_all
22
+ logger.info(" featured works -- DESTROYED")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # PermissionTemplates are tightly coupled to admin sets and collections.
5
+ # When they are removed using wipe!, the associated database entries for
6
+ # permission templates also have to be deleted.
7
+ #
8
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
9
+ # Data can not be recovered.
10
+ #
11
+ class PermissionTemplatesDestroyer
12
+ class << self
13
+ attr_accessor :logger
14
+
15
+ def destroy_data(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
16
+ raise("PermissionTemplatesDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
17
+ @logger = logger
18
+
19
+ logger.info("Destroying permission templates...")
20
+
21
+ Hyrax::PermissionTemplateAccess.destroy_all
22
+ logger.info(" permission templates access -- DESTROYED")
23
+
24
+ Hyrax::PermissionTemplate.destroy_all
25
+ logger.info(" permission templates -- DESTROYED")
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # Clear all repository metadata from the datastore (e.g. Fedora, Postgres)
5
+ # and from Solr.
6
+ #
7
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
8
+ # Data can not be recovered.
9
+ #
10
+ # @note When using Wings adapter, which wraps ActiveFedora, the persister wipe!
11
+ # method clears both Fedora and Solr. Optionally, an index_adapter may also
12
+ # be set to use Valkyrie to write to a second Solr core. If the Hyrax index
13
+ # adapter is the NullIndexingAdapter, that means that Valkyrie is not being
14
+ # used to index the repository metadata and does not need to be cleared using
15
+ # the Hyrax index adapter.
16
+ #
17
+ # When using other Valkyrie persistence adapters, wipe! only clears the repository
18
+ # metadata from the datastore (e.g. ORM table in Postgres). The index adapter
19
+ # is used to clear metadata from Solr.
20
+ #
21
+ class RepositoryMetadataDestroyer
22
+ class << self
23
+ attr_accessor :logger
24
+
25
+ def destroy_metadata(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
26
+ raise("RepositoryMetadataDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
27
+ @logger = logger
28
+
29
+ logger.info("Destroying all repository metadata...")
30
+
31
+ unless Hyrax.index_adapter.is_a? Valkyrie::Indexing::NullIndexingAdapter
32
+ conn = Hyrax.index_adapter.connection
33
+ conn.delete_by_query('*:*', params: { 'softCommit' => true })
34
+ end
35
+ Hyrax.persister.wipe!
36
+
37
+ logger.info(" repository metadata -- DESTROYED")
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module DataDestroyers
4
+ # Stats are tightly coupled to works and files in the repository. When they
5
+ # are removed using wipe!, the associated database entries for stats also
6
+ # need to be deleted.
7
+ #
8
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
9
+ # Data can not be recovered.
10
+ #
11
+ class StatsDestroyer
12
+ class << self
13
+ attr_accessor :logger
14
+
15
+ def destroy_data(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
16
+ raise("StatsDataDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
17
+ @logger = logger
18
+
19
+ logger.info("Destroying stats...")
20
+
21
+ FileDownloadStat.destroy_all
22
+ logger.info(" file download stats -- DESTROYED")
23
+
24
+ FileViewStat.destroy_all
25
+ logger.info(" file view stats -- DESTROYED")
26
+
27
+ WorkViewStat.destroy_all
28
+ logger.info(" work view stats -- DESTROYED")
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ ##
5
+ # These methods created for use in rake tasks and db/seeds.rb They can be used to:
6
+ # * clear repository metadata and related data and files
7
+ # * clear temporary files
8
+ # * clear logs
9
+ #
10
+ # @note WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive.
11
+ # Data can not be recovered.
12
+ #
13
+ class DataMaintenance
14
+ attr_accessor :logger, :allow_destruction_in_production
15
+
16
+ def initialize(logger: Logger.new(STDOUT), allow_destruction_in_production: false)
17
+ raise("Destruction of data is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
18
+ @logger = logger
19
+ @allow_destruction_in_production = allow_destruction_in_production
20
+ end
21
+
22
+ # Clear repository metadata and related data
23
+ # * clear repository metadata from the datastore (e.g. Fedora, Postgres) and from Solr
24
+ # * clear targeted application data that is tightly coupled to repository metadata
25
+ # * delete files that are tightly coupled to repository metadata
26
+ def destroy_repository_metadata_and_related_data
27
+ Hyrax::DataDestroyers::RepositoryMetadataDestroyer.destroy_metadata(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
28
+ Hyrax::DataDestroyers::StatsDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
29
+ Hyrax::DataDestroyers::FeaturedWorksDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
30
+ Hyrax::DataDestroyers::PermissionTemplatesDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
31
+ Hyrax::DataDestroyers::CollectionBrandingDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
32
+ Hyrax::DataDestroyers::DefaultAdminSetIdCacheDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
33
+ Hyrax::DataDestroyers::CollectionTypesDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
34
+
35
+ # TODO: Stubbed until RepositoryFilesDestroyer is written
36
+ # Hyrax::DataDestroyers::RepositoryFilesDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
37
+ end
38
+
39
+ # @todo write code to clear out log files
40
+ def destroy_log_files
41
+ # Stubbed until LogFilesDestroyer is written
42
+ # Hyrax::DataDestroyers::LogFilesDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
43
+ end
44
+
45
+ # @todo write code to delete tmp files
46
+ def destroy_tmp_files
47
+ # Stubbed until TmpFilesDestroyer is written
48
+ # Hyrax::DataDestroyers::TmpFilesDestroyer.destroy_data(logger: logger, allow_destruction_in_production: allow_destruction_in_production)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ # This class was created for use in rake tasks and db/seeds.rb. It generates
4
+ # required repository metadata including Admin Set and User collection types and
5
+ # the default admin set.
6
+ #
7
+ # Seeders of required data are non-destructive. If the data already exists,
8
+ # it will not be replaced.
9
+ class RequiredDataSeeder
10
+ attr_accessor :logger
11
+
12
+ def initialize(logger: Logger.new(STDOUT))
13
+ @logger = logger
14
+ end
15
+
16
+ def generate_seed_data
17
+ Hyrax::RequiredDataSeeders::CollectionTypeSeeder.generate_seeds(logger: logger)
18
+ Hyrax::RequiredDataSeeders::CollectionSeeder.generate_seeds(logger: logger)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+
2
+
3
+ # frozen_string_literal: true
4
+ module Hyrax
5
+ module RequiredDataSeeders
6
+ # This class was created for use in rake tasks and db/seeds.rb. It generates
7
+ # collections that are required for all Hyrax applications.
8
+ #
9
+ # Seeders of required data are non-destructive. If the data already exists,
10
+ # it will not be replaced.
11
+ class CollectionSeeder
12
+ class << self
13
+ attr_accessor :logger
14
+
15
+ def generate_seeds(logger: Logger.new(STDOUT))
16
+ @logger = logger
17
+
18
+ logger.info("Adding required collections...")
19
+
20
+ default_admin_set = Hyrax::AdminSetCreateService.find_or_create_default_admin_set
21
+ logger.info " #{default_admin_set.title.first} -- FOUND OR CREATED"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module RequiredDataSeeders
4
+ # This class was created for use in rake tasks and db/seeds.rb. It generates
5
+ # collection types that are required for all Hyrax applications.
6
+ #
7
+ # Seeders of required data are non-destructive. If the data already exists,
8
+ # it will not be replaced.
9
+ class CollectionTypeSeeder
10
+ class << self
11
+ attr_accessor :logger
12
+
13
+ def generate_seeds(logger: Logger.new(STDOUT))
14
+ @logger = logger
15
+
16
+ logger.info("Adding required collection types...")
17
+
18
+ as_ct = Hyrax::CollectionType.find_or_create_admin_set_type
19
+ set_badge_color(as_ct, '#990000')
20
+ logger.info(" #{as_ct.title} -- FOUND OR CREATED")
21
+
22
+ user_ct = Hyrax::CollectionType.find_or_create_default_collection_type
23
+ set_badge_color(user_ct, '#0099cc')
24
+ logger.info(" #{user_ct.title} -- FOUND OR CREATED")
25
+ end
26
+
27
+ private
28
+
29
+ def set_badge_color(collection_type, badge_color = nil)
30
+ collection_type.badge_color = badge_color
31
+ collection_type.save
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ # This class was created for use in rake tasks and db/seeds.rb. It generates
5
+ # repository metadata needed for release testing. This data can also be helpful
6
+ # for local development testing.
7
+ class TestDataSeeder
8
+ attr_accessor :logger, :allow_seeding_in_production
9
+
10
+ def initialize(logger: Logger.new(STDOUT), allow_seeding_in_production: false)
11
+ raise("TestDataSeeder is not for use in production!") if Rails.env.production? && !allow_seeding_in_production
12
+ @logger = logger
13
+ @allow_seeding_in_production = allow_seeding_in_production
14
+ end
15
+
16
+ def generate_seed_data
17
+ Hyrax::TestDataSeeders::UserSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
18
+ Hyrax::TestDataSeeders::CollectionTypeSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
19
+ Hyrax::TestDataSeeders::CollectionSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
20
+ # TODO: add work seeder
21
+ # Hyrax::TestDataSeeders::WorkSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
22
+ end
23
+ end
24
+ end