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
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ class CounterMetric < ApplicationRecord
5
+ validates :work_id, :date, presence: true
6
+ end
7
+ end
@@ -18,8 +18,7 @@ module Hyrax
18
18
  "with id #{file.id}. Initializing a new one")
19
19
 
20
20
  FileMetadata.new(file_identifier: file.id,
21
- alternative_ids: [file.id],
22
- original_filename: File.basename(file.io))
21
+ original_filename: File.basename(file.disk_path))
23
22
  end
24
23
 
25
24
  class FileMetadata < Valkyrie::Resource
@@ -36,6 +35,7 @@ module Hyrax
36
35
  ORIGINAL_FILE = ::Valkyrie::Vocab::PCDMUse.OriginalFile
37
36
  EXTRACTED_TEXT = ::Valkyrie::Vocab::PCDMUse.ExtractedText
38
37
  THUMBNAIL = ::Valkyrie::Vocab::PCDMUse.ThumbnailImage
38
+ SERVICE_FILE = ::Valkyrie::Vocab::PCDMUse.ServiceFile
39
39
 
40
40
  ##
41
41
  # @param use [RDF::URI, Symbol]
@@ -59,7 +59,7 @@ module Hyrax
59
59
  module_function :uri_for
60
60
  end
61
61
 
62
- attribute :file_identifier, Valkyrie::Types::ID # id of the file stored by the storage adapter
62
+ attribute :file_identifier, ::Valkyrie::Types::ID # id of the file stored by the storage adapter
63
63
  attribute :alternate_ids, Valkyrie::Types::Set.of(Valkyrie::Types::ID) # id of the file, populated for queryability
64
64
  attribute :file_set_id, ::Valkyrie::Types::ID # id of parent file set resource
65
65
 
@@ -67,11 +67,11 @@ module Hyrax
67
67
  attribute :label, ::Valkyrie::Types::Set
68
68
  attribute :original_filename, ::Valkyrie::Types::String
69
69
  attribute :mime_type, ::Valkyrie::Types::String.default(GENERIC_MIME_TYPE)
70
- attribute :type, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze) # Use += to add types, not <<
70
+ attribute :pcdm_use, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze) # Use += to add pcdm_uses, not <<
71
71
 
72
72
  # attributes set by fits
73
73
  attribute :format_label, ::Valkyrie::Types::Set
74
- attribute :size, ::Valkyrie::Types::Set
74
+ attribute :recorded_size, ::Valkyrie::Types::Set
75
75
  attribute :well_formed, ::Valkyrie::Types::Set
76
76
  attribute :valid, ::Valkyrie::Types::Set
77
77
  attribute :date_created, ::Valkyrie::Types::Set
@@ -130,19 +130,19 @@ module Hyrax
130
130
  ##
131
131
  # @return [Boolean]
132
132
  def original_file?
133
- type.include?(Use::ORIGINAL_FILE)
133
+ pcdm_use.include?(Use::ORIGINAL_FILE)
134
134
  end
135
135
 
136
136
  ##
137
137
  # @return [Boolean]
138
138
  def thumbnail_file?
139
- type.include?(Use::THUMBNAIL)
139
+ pcdm_use.include?(Use::THUMBNAIL)
140
140
  end
141
141
 
142
142
  ##
143
143
  # @return [Boolean]
144
144
  def extracted_file?
145
- type.include?(Use::EXTRACTED_TEXT)
145
+ pcdm_use.include?(Use::EXTRACTED_TEXT)
146
146
  end
147
147
 
148
148
  def title
@@ -154,7 +154,7 @@ module Hyrax
154
154
  end
155
155
 
156
156
  def valid?
157
- file.valid?(size: size.first, digests: { sha256: checksum&.first&.sha256 })
157
+ file.valid?(size: recorded_size.first, digests: { sha256: checksum&.first&.sha256 })
158
158
  end
159
159
 
160
160
  ##
@@ -6,28 +6,47 @@ module Hyrax
6
6
  #
7
7
  # ## Relationships
8
8
  #
9
- # ### File Set and Work
9
+ # ### FileSet and Work
10
10
  #
11
11
  # * Defined: The relationship is defined by the inverse relationship stored in the
12
12
  # work's `:member_ids` attribute.
13
- # * Tested: The work tests the relationship.
14
- # * File Set to Work: (1..1) A file set must be in one and only one work.
13
+ # * Tested: The test for the Work class tests the relationship.
14
+ # * FileSet to Work: (n..1) A FileSet must be in one and only one work. A Work can have zero to many FileSets.
15
+ # * See Hyrax::Work for code to get and set file sets for the work.
15
16
  #
16
- # @example Get work for a file set:
17
+ # @example Get Work for a FileSet:
17
18
  # work = Hyrax.custom_queries.find_parent_work(resource: file_set)
18
19
  #
19
- # * Work to File Set: (0..m) A work can have many file sets.
20
- # * See Hyrax::Work for code to get and set file sets for the work.
20
+ # ### FileSet and FileMetadata
21
21
  #
22
- # ### File Set and File (TBD)
22
+ # * Defined: The relationship is defined by the FileSet's `:file_ids` attribute.
23
+ # * FileSet to FileMetadata: (0..n) A FileSet can have many FileMetadatas. A FileMetadata must be in one and only one FileSet.
24
+ #
25
+ # @example Get all FileMetadata for a FileSet:
26
+ # file_metadata = Hyrax.custom_queries.find_files(file_set: file_set)
27
+ #
28
+ # @example Attach a File to a FileSet through a FileMetadata. This will create
29
+ # a FileMetadata for a File object, attach the File to the FileMetadata, and
30
+ # attach that FileMetadata to a given FileSet.
31
+ # ::Hyrax::ValkyrieUpload.file(
32
+ # io: file_io,
33
+ # filename: "myfile.jpg",
34
+ # file_set: file_set,
35
+ # use: pcdm_use,
36
+ # user: user
37
+ # )
38
+ #
39
+ # ### FileMetadata and Files
40
+ #
41
+ # * Defined: The relationship is defined by the FileMetadata's `:file_identifier` attribute.
42
+ # * FileMetadata to File: (1..1) A FileMetadata can have one and only one File
43
+ #
44
+ # @example Get a File for a FileMetadata
45
+ # file = Hyrax.storage_adapter.find_by(id: file_metadata.file_identifier)
23
46
  #
24
47
  # @see Hyrax::Work
48
+ # @see Hyrax::CustomQueries::Navigators::FindFiles#find_files
25
49
  # @see Hyrax::CustomQueries::Navigators::ParentWorkNavigator#find_parent_work
26
- #
27
- # @todo The description in Hydra::Works Shared Modeling is out of date and uses
28
- # terminology to describe the relationships that is no longer used in code.
29
- # Update the model and link to it. This can be a simple relationship diagram
30
- # with a link to the original Works Shared Modeling for historical perspective.
31
50
  # @see https://wiki.duraspace.org/display/samvera/Hydra%3A%3AWorks+Shared+Modeling
32
51
  class FileSet < Hyrax::Resource
33
52
  include Hyrax::Schema(:core_metadata)
@@ -41,9 +60,51 @@ module Hyrax
41
60
  self.characterization_proxy = Hyrax.config.characterization_proxy
42
61
 
43
62
  attribute :file_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID) # id for FileMetadata resources
44
- attribute :thumbnail_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
45
- attribute :original_file_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
46
- attribute :extracted_text_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
63
+
64
+ # @return [Hyrax::FileMetadata, nil]
65
+ def original_file
66
+ Hyrax.custom_queries.find_original_file(file_set: self)
67
+ rescue Valkyrie::Persistence::ObjectNotFoundError
68
+ nil
69
+ end
70
+
71
+ # @return [Valkyrie::ID, nil]
72
+ def original_file_id
73
+ original_file&.id
74
+ end
75
+
76
+ # @return [String, Nil] versioned identifier suitable for use in a IIIF manifest
77
+ def iiif_id
78
+ orig_file = original_file
79
+ return nil if orig_file.nil? || orig_file.file_identifier.blank?
80
+ latest_file = Hyrax::VersioningService.latest_version_of(orig_file)
81
+ version = latest_file&.version_id ? Digest::MD5.hexdigest(latest_file.version_id) : nil
82
+ "#{id}/files/#{orig_file.id}#{'/' + version if version}"
83
+ end
84
+
85
+ # @return [Hyrax::FileMetadata, nil]
86
+ def thumbnail
87
+ Hyrax.custom_queries.find_thumbnail(file_set: self)
88
+ rescue Valkyrie::Persistence::ObjectNotFoundError
89
+ nil
90
+ end
91
+
92
+ # @return [Valkyrie::ID, nil]
93
+ def thumbnail_id
94
+ thumbnail&.id
95
+ end
96
+
97
+ # @return [Hyrax::FileMetadata, nil]
98
+ def extracted_text
99
+ Hyrax.custom_queries.find_extracted_text(file_set: self)
100
+ rescue Valkyrie::Persistence::ObjectNotFoundError
101
+ nil
102
+ end
103
+
104
+ # @return [Valkyrie::ID, nil]
105
+ def extracted_text_id
106
+ extracted_text&.id
107
+ end
47
108
 
48
109
  ##
49
110
  # @return [Valkyrie::ID]
@@ -7,12 +7,6 @@ module Hyrax
7
7
  record.errors.add(:orcid, 'must be a string of 19 characters, e.g., "0000-0000-0000-0000"') unless ORCID_REGEXP.match?(record.orcid)
8
8
  end
9
9
 
10
- # @deprecated
11
- def self.match(string)
12
- Deprecation.warn "Use 'Hyrax::OrcidValidator.extract_bare_orcid(from:)'"
13
- extract_bare_orcid_from(from: string)
14
- end
15
-
16
10
  # @api public
17
11
  # @param [String] from
18
12
  # @return nil if the given string is not in the Orcid form
@@ -35,8 +35,8 @@ module Hyrax
35
35
  include Hyrax::WithEvents
36
36
 
37
37
  attribute :alternate_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID)
38
- attribute :embargo, Hyrax::Embargo.optional
39
- attribute :lease, Hyrax::Lease.optional
38
+ attribute :embargo_id, Valkyrie::Types::ID
39
+ attribute :lease_id, Valkyrie::Types::ID
40
40
 
41
41
  delegate :edit_groups, :edit_groups=,
42
42
  :edit_users, :edit_users=,
@@ -91,6 +91,10 @@ module Hyrax
91
91
  false
92
92
  end
93
93
 
94
+ def ==(other)
95
+ attributes.except(:created_at, :updated_at) == other.attributes.except(:created_at, :updated_at)
96
+ end
97
+
94
98
  def permission_manager
95
99
  @permission_manager ||= Hyrax::PermissionManager.new(resource: self)
96
100
  end
@@ -103,6 +107,30 @@ module Hyrax
103
107
  visibility_reader.read
104
108
  end
105
109
 
110
+ def embargo=(value)
111
+ raise TypeError "can't convert #{value.class} into Hyrax::Embargo" unless value.is_a? Hyrax::Embargo
112
+
113
+ @embargo = value
114
+ self.embargo_id = @embargo.id
115
+ end
116
+
117
+ def embargo
118
+ return @embargo if @embargo
119
+ @embargo = Hyrax.query_service.find_by(id: embargo_id) if embargo_id.present?
120
+ end
121
+
122
+ def lease=(value)
123
+ raise TypeError "can't convert #{value.class} into Hyrax::Lease" unless value.is_a? Hyrax::Lease
124
+
125
+ @lease = value
126
+ self.lease_id = @lease.id
127
+ end
128
+
129
+ def lease
130
+ return @lease if @lease
131
+ @lease = Hyrax.query_service.find_by(id: lease_id) if lease_id.present?
132
+ end
133
+
106
134
  protected
107
135
 
108
136
  def visibility_writer
@@ -63,7 +63,7 @@ module Hyrax
63
63
  # `it_behaves_like 'has_members'`. Shared specs are defined in /lib/hyrax/specs/shared_specs/hydra_works.rb.
64
64
  # * Work to File Set: (0..m) A work can have many file sets.
65
65
  # @example Add a file set to a work (code from Hyrax::WorkUploadsHandler#append_to_work)
66
- # work.member_ids << file_set.id
66
+ # work.member_ids += [file_set.id]
67
67
  # work.representative_id = file_set.id if work.respond_to?(:representative_id) && work.representative_id.blank?
68
68
  # work.thumbnail_id = file_set.id if work.respond_to?(:thumbnail_id) && work.thumbnail_id.blank?
69
69
  # Hyrax.persister.save(resource: work)
@@ -91,11 +91,8 @@ module Hyrax
91
91
  #
92
92
  # @see /lib/hyrax/specs/shared_specs/hydra_works.rb
93
93
  #
94
- # @todo The description in Hydra::Works Shared Modeling is out of date and uses
95
- # terminology to describe the relationships that is no longer used in code.
96
- # Update the model and link to it. This can be a simple relationship diagram
97
- # with a link to the original Works Shared Modeling for historical perspective.
98
94
  # @see https://wiki.lyrasis.org/display/samvera/Hydra::Works+Shared+Modeling
95
+ # for a historical perspective.
99
96
  class Work < Hyrax::Resource
100
97
  include Hyrax::Schema(:core_metadata)
101
98
 
@@ -172,23 +172,6 @@ module Hyrax
172
172
  create_work_presenter.first_model
173
173
  end
174
174
 
175
- ##
176
- # @deprecated this implementation requires an extra db round trip, had a
177
- # buggy cacheing mechanism, and was largely duplicative of other code.
178
- # all versions of this code are replaced by
179
- # {CollectionsHelper#available_parent_collections_data}.
180
- def available_parent_collections(scope:)
181
- Deprecation.warn("#{self.class}#available_parent_collections is " \
182
- "deprecated. Use available_parent_collections_data " \
183
- "helper instead.")
184
- return @available_parents if @available_parents.present?
185
- collection = Hyrax.config.collection_class.find(id)
186
- colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
187
- @available_parents = colls.map do |col|
188
- { "id" => col.id, "title_first" => col.title.first }
189
- end.to_json
190
- end
191
-
192
175
  def subcollection_count=(total)
193
176
  @subcollection_count = total unless total.nil?
194
177
  end
@@ -23,5 +23,9 @@ module Hyrax
23
23
  def embargo_history
24
24
  solr_document['embargo_history_ssim']
25
25
  end
26
+
27
+ def enforced?
28
+ solr_document.embargo_enforced?
29
+ end
26
30
  end
27
31
  end
@@ -105,6 +105,12 @@ module Hyrax
105
105
  current_ability.can?(:edit, id) || current_ability.can?(:destroy, id) || current_ability.can?(:download, id)
106
106
  end
107
107
 
108
+ ##
109
+ # @return [Array<String>]
110
+ def show_partials
111
+ ['show_details']
112
+ end
113
+
108
114
  private
109
115
 
110
116
  def link_presenter_class
@@ -56,7 +56,7 @@ module Hyrax
56
56
  ##
57
57
  # @return [Boolean]
58
58
  def file_set?
59
- model.try(:file_set?) || Array(model[:has_model_ssim]).include?('FileSet')
59
+ model.try(:file_set?) || Array(model[:has_model_ssim]).include?('FileSet') || Array(model[:has_model_ssim]).include?('Hyrax::FileSet')
60
60
  end
61
61
 
62
62
  ##
@@ -93,12 +93,8 @@ module Hyrax
93
93
  ##
94
94
  # @return [Array<#to_s>]
95
95
  def member_ids
96
- case model
97
- when Valkyrie::Resource
98
- Array(model.try(:member_ids))
99
- else
100
- Hyrax::SolrDocument::OrderedMembers.decorate(model).ordered_member_ids
101
- end
96
+ m = model.is_a?(::SolrDocument) ? model.hydra_model : model.class
97
+ m < Hyrax::Resource ? Array(model.member_ids) : Hyrax::SolrDocument::OrderedMembers.decorate(model).ordered_member_ids
102
98
  end
103
99
 
104
100
  ##
@@ -28,7 +28,7 @@ module Hyrax
28
28
  # @return [Array<FileSetPresenter, WorkShowPresenter>]
29
29
  # @return [Enumerator<FileSetPresenter>]
30
30
  def file_set_presenters
31
- return enum_for(:file_set_presenters) unless block_given?
31
+ return enum_for(:file_set_presenters).to_a unless block_given?
32
32
 
33
33
  results = query_docs(generic_type: "FileSet")
34
34
 
@@ -47,14 +47,14 @@ module Hyrax
47
47
  # we recommend making sparing use of this feature.
48
48
  #
49
49
  # @overload member_presenters
50
- # @return [Enumerator<FileSetPresenter, WorkShowPresenter>]
50
+ # @return [Array<FileSetPresenter, WorkShowPresenter>]
51
51
  # @raise [ArgumentError] if an unindexed id is passed
52
52
  # @overload member_presenters
53
53
  # @param [Array<#to_s>] ids
54
- # @return [Enumerator<FileSetPresenter, WorkShowPresenter>]
54
+ # @return [Array<FileSetPresenter, WorkShowPresenter>]
55
55
  # @raise [ArgumentError] if an unindexed id is passed
56
56
  def member_presenters(ids = object.member_ids)
57
- return enum_for(:member_presenters, ids) unless block_given?
57
+ return enum_for(:member_presenters, ids).to_a unless block_given?
58
58
 
59
59
  results = query_docs(ids: ids)
60
60
 
@@ -109,6 +109,8 @@ module Hyrax
109
109
  def query_docs(generic_type: nil, ids: object.member_ids)
110
110
  query = "{!terms f=id}#{ids.join(',')}"
111
111
  query += "{!term f=generic_type_si}#{generic_type}" if generic_type
112
+ # works created via ActiveFedora use the _sim field
113
+ query += "{!term f=generic_type_sim}#{generic_type}" if generic_type
112
114
 
113
115
  Hyrax::SolrService
114
116
  .post(q: query, rows: 10_000)
@@ -22,13 +22,6 @@ module Hyrax
22
22
  default: [:"defaults.#{field}", field.to_s.humanize]).presence
23
23
  end
24
24
 
25
- ##
26
- # @deprecated
27
- def fields(terms, &_block)
28
- Deprecation.warn("Fields is deprecated for removal in Hyrax 4.0.0. use #value and #label directly instead.")
29
- @view_context.safe_join(terms.map { |term| yield self, term })
30
- end
31
-
32
25
  private
33
26
 
34
27
  def render_show_field_partial(field_name, locals)
@@ -5,17 +5,19 @@ module Hyrax
5
5
  class VersionListPresenter
6
6
  include Enumerable
7
7
 
8
+ attr_reader :versioning_service
9
+
8
10
  ##
9
- # @param version_list [Array<#created>]
10
- def initialize(version_list)
11
- @raw_list = version_list
11
+ # @param service [Hyrax::VersioningService]
12
+ def initialize(service)
13
+ @versioning_service = service
12
14
  end
13
15
 
14
16
  ##
15
17
  # @param [Object] an object representing the File Set
16
18
  #
17
- # @return [Enumerable<Hyrax::VersionPresenter>] an enumerable of presenters
18
- # for the relevant file versions.
19
+ # @return [Hyrax::VersionListPresenter] an enumerable of presenters for the
20
+ # relevant file versions.
19
21
  #
20
22
  # @raise [ArgumentError] if we can't build an enu
21
23
  def self.for(file_set:)
@@ -24,20 +26,27 @@ module Hyrax
24
26
  else
25
27
  Hyrax::FileSetFileService.new(file_set: file_set).original_file
26
28
  end
27
- new(Hyrax::VersioningService.new(resource: original_file).versions)
29
+ new(Hyrax::VersioningService.new(resource: original_file))
28
30
  rescue NoMethodError
29
31
  raise ArgumentError
30
32
  end
31
33
 
32
- delegate :each, to: :wrapped_list
34
+ delegate :each, :empty?, to: :wrapped_list
35
+ delegate :supports_multiple_versions?, to: :versioning_service
33
36
 
34
37
  private
35
38
 
36
39
  def wrapped_list
37
40
  @wrapped_list ||=
38
- @raw_list.map { |v| Hyrax::VersionPresenter.new(v) } # wrap each item in a presenter
39
- .sort { |a, b| b.version.created <=> a.version.created } # sort list of versions based on creation date
40
- .tap { |l| l.first.try(:current!) } # set the first version to the current version
41
+ begin
42
+ presenters = @versioning_service.versions.map { |v| Hyrax::VersionPresenter.new(v) } # wrap each item in a presenter
43
+ if presenters.first&.version&.respond_to?(:created)
44
+ presenters.sort! { |a, b| b.version.created <=> a.version.created } if presenters.first&.version.respond_to?(:created) # sort list of versions based on creation date
45
+ else
46
+ presenters.reverse!
47
+ end
48
+ presenters.tap { |l| l.first.try(:current!) } # set the first version to the current version
49
+ end
41
50
  end
42
51
  end
43
52
  end
@@ -15,14 +15,29 @@ module Hyrax
15
15
  @current = true
16
16
  end
17
17
 
18
+ def label
19
+ version.try(:label) || version.version_id.to_s
20
+ end
21
+
22
+ def uri
23
+ version.try(:uri) || version.version_id.to_s
24
+ end
25
+
18
26
  def created
19
- @created ||= version.created.in_time_zone.to_formatted_s(:long_ordinal)
27
+ @created ||= created_time&.in_time_zone&.to_formatted_s(:long_ordinal) || "Unknown"
20
28
  end
21
29
 
22
- def committer
30
+ def created_time
31
+ version.try(:created) || version_committer.try(:created_at)
32
+ end
33
+
34
+ def version_committer
23
35
  Hyrax::VersionCommitter
24
- .find_by(version_id: @version.uri)
25
- &.committer_login
36
+ .find_by(version_id: @version.try(:uri) || @version.try(:version_id))
37
+ end
38
+
39
+ def committer
40
+ version_committer&.committer_login
26
41
  end
27
42
  end
28
43
  end
@@ -190,16 +190,6 @@ module Hyrax
190
190
  paginated_item_list(page_array: authorized_item_ids)
191
191
  end
192
192
 
193
- ##
194
- # @deprecated use `#member_presenters(ids)` instead
195
- #
196
- # @param [Array<String>] ids a list of ids to build presenters for
197
- # @return [Array<presenter_class>] presenters for the array of ids (not filtered by class)
198
- def member_presenters_for(an_array_of_ids)
199
- Deprecation.warn("Use `#member_presenters` instead.")
200
- member_presenters(an_array_of_ids)
201
- end
202
-
203
193
  # @return [Integer] total number of pages of viewable items
204
194
  def total_pages
205
195
  (total_items.to_f / rows_from_params.to_f).ceil
@@ -262,6 +252,11 @@ module Hyrax
262
252
  Hyrax::ChildTypes.for(parent: solr_document.hydra_model).to_a
263
253
  end
264
254
 
255
+ # @return [Boolean]
256
+ def valkyrie_presenter?
257
+ solr_document.hydra_model < Valkyrie::Resource
258
+ end
259
+
265
260
  private
266
261
 
267
262
  # list of item ids to display is based on ordered_ids
@@ -308,7 +303,7 @@ module Hyrax
308
303
 
309
304
  def member_presenter_factory
310
305
  @member_presenter_factory ||=
311
- if solr_document.hydra_model < Valkyrie::Resource
306
+ if valkyrie_presenter?
312
307
  PcdmMemberPresenterFactory.new(solr_document, current_ability)
313
308
  else
314
309
  self.class
@@ -5,7 +5,7 @@ module Hyrax
5
5
 
6
6
  # This overrides the models in FilterByType
7
7
  def models
8
- [::FileSet]
8
+ [::FileSet, ::Hyrax::FileSet]
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ class ValkyrieAbstractTypeRelation
5
+ def initialize(allowable_types: nil, _opts: {})
6
+ @allowable_types = allowable_types
7
+ end
8
+
9
+ def allowable_types
10
+ @allowable_types.present? ||
11
+ raise(NotImplementedException, "Implement allowable_types in a subclass")
12
+ end
13
+
14
+ def equivalent_class?(klass)
15
+ allowable_types.include?(klass)
16
+ end
17
+
18
+ def count
19
+ Hyrax.query_service.custom_queries.find_count_by(models: allowable_types)
20
+ end
21
+
22
+ def where(hash)
23
+ Hyrax.query_service.find_references_by(resource: hash.values.first, property: hash.keys.first)
24
+ end
25
+
26
+ def ==(other)
27
+ case other
28
+ when Relation
29
+ other.where_values == where_values
30
+ when Array
31
+ to_a == other
32
+ end
33
+ end
34
+
35
+ delegate :inspect, to: :to_a
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ class ValkyrieWorkRelation < ValkyrieAbstractTypeRelation
5
+ def allowable_types
6
+ Hyrax.config.curation_concerns
7
+ end
8
+ end
9
+ end
@@ -18,23 +18,6 @@ module Hyrax
18
18
  self.default_admin_set_persister = Hyrax::DefaultAdministrativeSet
19
19
 
20
20
  class << self
21
- # @api public
22
- # Creates the default Hyrax::AdministrativeSet and corresponding data
23
- # @param admin_set_id [String] The default admin set ID
24
- # @param title [Array<String>] The title of the default admin set
25
- # @return [TrueClass]
26
- # @see Hyrax::AdministrativeSet
27
- # @deprecated
28
- # TODO: When this deprecated method is removed, update private method
29
- # .create_default_admin_set! to remove the parameters.
30
- def create_default_admin_set(admin_set_id: DEFAULT_ID, title: DEFAULT_TITLE)
31
- Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
32
- "Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set'.")
33
- create_default_admin_set!(admin_set_id: admin_set_id, title: title).present?
34
- rescue RuntimeError => _err
35
- false
36
- end
37
-
38
21
  # @api public
39
22
  # Finds the default AdministrativeSet if it exists; otherwise, creates it and corresponding data
40
23
  # @return [Hyrax::AdministrativeSet] The default admin set.