hyrax 5.0.0.rc1 → 5.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +11 -4
  3. data/.dassie/.env +5 -1
  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/initializers/riiif.rb +5 -11
  9. data/.dassie/config/metadata/collection_resource.yaml +3 -0
  10. data/.dassie/config/metadata/monograph.yaml +8 -0
  11. data/.dassie/config/metadata/sample_metadata.yaml +1 -0
  12. data/.dassie/config/redis.yml +2 -0
  13. data/.dassie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  14. data/.dassie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  15. data/.dassie/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.hyrax.rb +8 -0
  16. data/.dassie/db/migrate/20230821153635_add_fields_to_counter_metric.rb +8 -0
  17. data/.dassie/db/schema.rb +20 -1
  18. data/.dockerignore +2 -1
  19. data/.gitignore +1 -1
  20. data/.koppie/.env +10 -4
  21. data/.koppie/Gemfile +10 -12
  22. data/.koppie/Gemfile.koppie +2 -0
  23. data/.koppie/Rakefile +0 -2
  24. data/.koppie/app/forms/collection_resource_form.rb +0 -1
  25. data/.koppie/app/indexers/collection_resource_indexer.rb +0 -1
  26. data/.koppie/app/models/ability.rb +1 -5
  27. data/.koppie/app/models/collection_resource.rb +0 -1
  28. data/.koppie/app/models/user.rb +0 -2
  29. data/.koppie/config/application.rb +2 -1
  30. data/.koppie/config/arkivo.yml +6 -0
  31. data/.koppie/config/blacklight.yml +2 -2
  32. data/.koppie/config/features.yml +2 -0
  33. data/.koppie/config/initializers/1_valkyrie.rb +29 -6
  34. data/.koppie/config/initializers/arkivo_constraint.rb +12 -0
  35. data/.koppie/config/initializers/hyrax.rb +2 -2
  36. data/.koppie/config/initializers/riiif.rb +6 -11
  37. data/.koppie/config/metadata/collection_resource.yaml +177 -1
  38. data/.koppie/config/metadata/generic_work.yaml +2 -0
  39. data/.koppie/config/metadata/monograph.yaml +10 -0
  40. data/.koppie/config/role_map.yml +3 -25
  41. data/.koppie/config/routes.rb +1 -2
  42. data/.koppie/config/solr.yml +1 -1
  43. data/.koppie/config/valkyrie_index.yml +4 -10
  44. data/.koppie/config/zotero.yml +6 -0
  45. data/.koppie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
  46. data/.koppie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
  47. data/.koppie/db/schema.rb +12 -1
  48. data/CONTAINERS.md +1 -3
  49. data/Dockerfile +11 -2
  50. data/Gemfile +4 -21
  51. data/Gemfile.dassie +2 -0
  52. data/Gemfile.koppie +2 -0
  53. data/README.md +0 -1
  54. data/Rakefile +0 -11
  55. data/app/actors/hyrax/actors/embargo_actor.rb +3 -6
  56. data/app/assets/javascripts/hyrax/batch_select_all.js +1 -1
  57. data/app/assets/javascripts/hyrax/file_manager/member.es6 +1 -1
  58. data/app/assets/stylesheets/hyrax/_file-listing.scss +0 -2
  59. data/app/assets/stylesheets/hyrax/_work-show.scss +19 -3
  60. data/app/assets/stylesheets/hyrax/sidebar.scss +23 -0
  61. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +7 -1
  62. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +7 -1
  63. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +14 -9
  64. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +50 -9
  65. data/app/controllers/hyrax/api/items_controller.rb +2 -3
  66. data/app/controllers/hyrax/batch_edits_controller.rb +6 -6
  67. data/app/controllers/hyrax/batch_uploads_controller.rb +5 -1
  68. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  69. data/app/controllers/hyrax/file_sets_controller.rb +49 -6
  70. data/app/controllers/hyrax/my/collections_controller.rb +2 -0
  71. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +16 -2
  72. data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +38 -0
  73. data/app/forms/hyrax/forms/collection_form.rb +0 -15
  74. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +0 -34
  75. data/app/forms/hyrax/forms/file_set_form.rb +2 -2
  76. data/app/forms/hyrax/forms/pcdm_object_form.rb +21 -0
  77. data/app/forms/hyrax/forms/permission_template_form.rb +0 -7
  78. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +49 -21
  79. data/app/forms/hyrax/forms/resource_form.rb +21 -34
  80. data/app/helpers/hyrax/dashboard_helper_behavior.rb +13 -0
  81. data/app/indexers/hyrax/location_indexer.rb +29 -0
  82. data/app/indexers/hyrax/pcdm_collection_indexer.rb +0 -8
  83. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +1 -6
  84. data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -0
  85. data/app/inputs/controlled_vocabulary_input.rb +1 -1
  86. data/app/jobs/characterize_job.rb +1 -1
  87. data/app/jobs/create_work_job.rb +36 -4
  88. data/app/jobs/valkyrie_characterization_job.rb +9 -0
  89. data/app/jobs/valkyrie_ingest_job.rb +1 -3
  90. data/app/models/collection_branding_info.rb +2 -9
  91. data/app/models/concerns/hyrax/ability.rb +2 -1
  92. data/app/models/concerns/hyrax/collection_behavior.rb +4 -12
  93. data/app/models/concerns/hyrax/riiif_file.rb +30 -0
  94. data/app/models/concerns/hyrax/solr_document_behavior.rb +19 -2
  95. data/app/models/hyrax/counter_metric.rb +7 -0
  96. data/app/models/hyrax/file_metadata.rb +3 -2
  97. data/app/models/hyrax/file_set.rb +75 -22
  98. data/app/models/hyrax/orcid_validator.rb +0 -6
  99. data/app/models/hyrax/work.rb +2 -5
  100. data/app/presenters/hyrax/collection_presenter.rb +0 -17
  101. data/app/presenters/hyrax/embargo_presenter.rb +4 -0
  102. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +6 -4
  103. data/app/presenters/hyrax/version_list_presenter.rb +19 -10
  104. data/app/presenters/hyrax/version_presenter.rb +19 -4
  105. data/app/services/hyrax/admin_set_create_service.rb +0 -17
  106. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +5 -0
  107. data/app/services/hyrax/collections/collection_member_service.rb +1 -1
  108. data/app/services/hyrax/embargo_manager.rb +45 -18
  109. data/app/services/hyrax/embargo_service.rb +12 -10
  110. data/app/services/hyrax/file_set_derivatives_service.rb +11 -11
  111. data/app/services/hyrax/fixity_check_failure_service.rb +1 -1
  112. data/app/services/hyrax/identifier/dispatcher.rb +9 -2
  113. data/app/services/hyrax/listeners/file_metadata_listener.rb +14 -6
  114. data/app/services/hyrax/listeners/member_cleanup_listener.rb +2 -28
  115. data/app/services/hyrax/listeners/metadata_index_listener.rb +11 -0
  116. data/app/services/hyrax/lock_manager.rb +1 -2
  117. data/app/services/hyrax/riiif_file_resolver.rb +50 -0
  118. data/app/services/hyrax/simple_schema_loader.rb +31 -0
  119. data/app/services/hyrax/valkyrie_persist_derivatives.rb +1 -1
  120. data/app/services/hyrax/valkyrie_upload.rb +12 -26
  121. data/app/services/hyrax/versioning_service.rb +29 -15
  122. data/app/services/hyrax/work_uploads_handler.rb +1 -1
  123. data/app/validators/hyrax/collection_membership_validator.rb +1 -1
  124. data/app/views/catalog/_search_form.html.erb +1 -1
  125. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  126. data/app/views/hyrax/base/_file_manager_resource_form.html.erb +1 -1
  127. data/app/views/hyrax/base/_form_visibility_component.html.erb +4 -4
  128. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  129. data/app/views/hyrax/base/_workflow_actions.html.erb +25 -23
  130. data/app/views/hyrax/base/show.json.jbuilder +2 -1
  131. data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
  132. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  133. data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
  134. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +3 -3
  135. data/app/views/hyrax/file_sets/_versioning.html.erb +5 -5
  136. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +4 -4
  137. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  138. data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
  139. data/app/views/hyrax/my/_search_form.html.erb +1 -1
  140. data/app/views/hyrax/notifications/_notifications.html.erb +1 -1
  141. data/app/views/hyrax/users/_vitals.html.erb +1 -1
  142. data/bin/dev-entrypoint.sh +13 -0
  143. data/chart/hyrax/Chart.yaml +3 -3
  144. data/chart/hyrax/templates/_helpers.tpl +8 -0
  145. data/chart/hyrax/templates/configmap-env.yaml +1 -1
  146. data/chart/hyrax/values.yaml +3 -0
  147. data/config/initializers/file_length_patch.rb +10 -0
  148. data/config/metadata/basic_metadata.yaml +52 -0
  149. data/config/metadata/core_metadata.yaml +4 -0
  150. data/config/metadata/file_set_metadata.yaml +19 -0
  151. data/config/metadata/hyrax_internal_metadata.yaml +57 -0
  152. data/docker-compose-koppie.yml +23 -22
  153. data/docker-compose-sirenia.yml +202 -0
  154. data/docker-compose.yml +27 -24
  155. data/documentation/developing-your-hyrax-based-app.md +2 -2
  156. data/hyrax.gemspec +10 -11
  157. data/karma.conf.js +1 -1
  158. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +2 -0
  159. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +13 -19
  160. data/lib/generators/hyrax/templates/db/migrate/20230725222727_create_hyrax_counter_metrics.rb.erb +14 -0
  161. data/lib/generators/hyrax/templates/db/migrate/20230803165135_change_work_id_to_string.rb.erb +5 -0
  162. data/lib/generators/hyrax/templates/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.rb.erb +8 -0
  163. data/lib/generators/hyrax/templates/db/migrate/20230821153635_add_fields_to_counter_metric.rb.erb +8 -0
  164. data/lib/generators/hyrax/templates/db/seeds.rb +1 -1
  165. data/lib/generators/hyrax/work_resource/templates/form.rb.erb +1 -1
  166. data/lib/generators/hyrax/work_resource/templates/metadata.yaml +2 -0
  167. data/lib/hyrax/configuration.rb +147 -49
  168. data/lib/hyrax/controlled_vocabularies/location.rb +7 -1
  169. data/lib/hyrax/engine.rb +0 -1
  170. data/lib/hyrax/form_fields.rb +6 -0
  171. data/lib/hyrax/publisher.rb +4 -0
  172. data/lib/hyrax/redis_event_store.rb +7 -8
  173. data/lib/hyrax/resource_name.rb +4 -0
  174. data/lib/hyrax/specs/capybara.rb +25 -42
  175. data/lib/hyrax/specs/shared_specs/hydra_works.rb +34 -7
  176. data/lib/hyrax/specs/shared_specs/indexers.rb +24 -6
  177. data/lib/hyrax/transactions/collection_destroy.rb +3 -2
  178. data/lib/hyrax/transactions/container.rb +42 -0
  179. data/lib/hyrax/transactions/file_metadata_destroy.rb +20 -0
  180. data/lib/hyrax/transactions/file_set_destroy.rb +3 -1
  181. data/lib/hyrax/transactions/file_set_update.rb +21 -0
  182. data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -1
  183. data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +46 -0
  184. data/lib/hyrax/transactions/steps/delete_all_file_sets.rb +46 -0
  185. data/lib/hyrax/transactions/steps/file_metadata_delete.rb +40 -0
  186. data/lib/hyrax/transactions/steps/remove_from_membership.rb +45 -0
  187. data/lib/hyrax/transactions/work_destroy.rb +3 -2
  188. data/lib/hyrax/version.rb +1 -1
  189. data/lib/tasks/collection_type_global_id.rake +9 -4
  190. data/lib/tasks/embargo_lease.rake +1 -0
  191. data/lib/valkyrie/indexing/solr/indexing_adapter.rb +2 -0
  192. data/lib/wings/active_fedora_converter.rb +6 -0
  193. data/lib/wings/attribute_transformer.rb +24 -17
  194. data/lib/wings/model_transformer.rb +0 -8
  195. data/lib/wings/orm_converter.rb +23 -18
  196. data/lib/wings/setup.rb +2 -2
  197. data/lib/wings/valkyrie/storage.rb +8 -90
  198. data/lib/wings.rb +5 -0
  199. data/tasks/hyrax_dev.rake +2 -33
  200. data/template.rb +1 -1
  201. metadata +90 -72
  202. data/.engine_cart.yml +0 -3
  203. data/app/views/hyrax/users/_user_util_links_extra.html.erb +0 -0
  204. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +0 -9
@@ -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,21 +60,55 @@ 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
47
63
 
48
- ##
49
- # @return [Valkyrie::ID]
50
- def representative_id
51
- id
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
52
107
  end
53
108
 
54
109
  ##
55
110
  # @return [Valkyrie::ID]
56
- def representative_id=(_input)
57
- # saving a file set using valkyrie would err because this method didn't exist.
58
- Rails.logger.warn('This is not a valid method for file sets')
111
+ def representative_id
59
112
  id
60
113
  end
61
114
 
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -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.
@@ -15,6 +15,11 @@ class Hyrax::Characterization::ValkyrieCharacterizationService
15
15
  new(metadata: metadata, file: file, **options).characterize
16
16
  saved = Hyrax.persister.save(resource: metadata)
17
17
  Hyrax.publisher.publish('file.metadata.updated', metadata: saved, user: user)
18
+
19
+ Hyrax.publisher.publish('file.characterized',
20
+ file_set: Hyrax.query_service.find_by(id: saved.file_set_id),
21
+ file_id: saved.id.to_s,
22
+ path_hint: saved.file_identifier.to_s)
18
23
  end
19
24
 
20
25
  ##
@@ -106,7 +106,7 @@ module Hyrax
106
106
  def add_member(collection_id:, new_member:, user:)
107
107
  message = Hyrax::MultipleMembershipChecker.new(item: new_member).check(collection_ids: [collection_id], include_current_members: true)
108
108
  raise Hyrax::SingleMembershipError, message if message.present?
109
- new_member.member_of_collection_ids << collection_id # only populate this direction
109
+ new_member.member_of_collection_ids += [collection_id] # only populate this direction
110
110
  new_member = Hyrax.persister.save(resource: new_member)
111
111
  publish_metadata_updated(new_member, user)
112
112
  new_member
@@ -12,12 +12,13 @@ module Hyrax
12
12
  # date is today or later.
13
13
  # - "Applied" means the embargo's pre-release visibility has been set on
14
14
  # the resource.
15
- # - "Released" means the embargo's post-release visibility has been set on
16
- # the resource.
17
15
  # - "Enforced" means the object's visibility matches the pre-release
18
16
  # visibility of the embargo; i.e. the embargo has been applied,
19
17
  # but not released.
20
- # - "Deactivate" means that the existing embargo will be removed
18
+ # - "Released" means the embargo's post-release visibility has been set on
19
+ # the resource.
20
+ # - "Deactivate" means that the existing embargo will be removed, even
21
+ # if it active.
21
22
  #
22
23
  # Note that an resource may be `#under_embargo?` even if the embargo is not
23
24
  # be `#enforced?` (in this case, the application should seek to apply the
@@ -109,11 +110,25 @@ module Hyrax
109
110
  .embargo
110
111
  end
111
112
 
113
+ # @return [Boolean]
114
+ def deactivate_embargo_for(resource:, query_service: Hyrax.query_service)
115
+ new(resource: resource, query_service: query_service)
116
+ .deactivate
117
+ end
118
+
119
+ # @return [Boolean]
120
+ def deactivate_embargo_for!(resource:, query_service: Hyrax.query_service)
121
+ new(resource: resource, query_service: query_service)
122
+ .deactivate!
123
+ end
124
+
125
+ # @return [Boolean]
112
126
  def release_embargo_for(resource:, query_service: Hyrax.query_service)
113
127
  new(resource: resource, query_service: query_service)
114
128
  .release
115
129
  end
116
130
 
131
+ # @return [Boolean]
117
132
  def release_embargo_for!(resource:, query_service: Hyrax.query_service)
118
133
  new(resource: resource, query_service: query_service)
119
134
  .release!
@@ -149,20 +164,20 @@ module Hyrax
149
164
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
150
165
  end
151
166
 
152
- # Deactivates the embargo and logs a message to the embargo_history property
153
- def deactivate!
154
- embargo_state = embargo.active? ? 'active' : 'expired'
155
- embargo_record = embargo_history_message(
156
- embargo_state,
157
- Time.zone.today,
158
- embargo.embargo_release_date,
159
- embargo.visibility_during_embargo,
160
- embargo.visibility_after_embargo
161
- )
167
+ ##
168
+ # Deactivates the embargo
169
+ # @return [Boolean]
170
+ def deactivate
171
+ release(force: true) &&
172
+ nullify(force: true)
173
+ end
162
174
 
163
- release(force: true)
175
+ ##
176
+ # Deactivates the embargo
177
+ # @return [Boolean]
178
+ def deactivate!
179
+ release!(force: true)
164
180
  nullify(force: true)
165
- embargo.embargo_history += [embargo_record]
166
181
  end
167
182
 
168
183
  ##
@@ -211,15 +226,16 @@ module Hyrax
211
226
  ##
212
227
  # Drop the embargo by setting its release date and visibility settings to `nil`.
213
228
  #
214
- # @param force [boolean] force the nullify even when the embargo period is current
229
+ # @param force [Boolean] force the nullify even when the embargo period is current
215
230
  #
216
- # @return [void]
231
+ # @return [Boolean]
217
232
  def nullify(force: false)
218
233
  return false if !force && under_embargo?
219
234
 
220
235
  embargo.embargo_release_date = nil
221
236
  embargo.visibility_during_embargo = nil
222
237
  embargo.visibility_after_embargo = nil
238
+ true
223
239
  end
224
240
 
225
241
  ##
@@ -231,6 +247,17 @@ module Hyrax
231
247
  # @return [Boolean] truthy if the embargo has been applied
232
248
  def release(force: false)
233
249
  return false if !force && under_embargo?
250
+
251
+ embargo_state = embargo.active? ? 'active' : 'expired'
252
+ history_record = embargo_history_message(
253
+ embargo_state,
254
+ Hyrax::TimeService.time_in_utc,
255
+ embargo.embargo_release_date,
256
+ embargo.visibility_during_embargo,
257
+ embargo.visibility_after_embargo
258
+ )
259
+ embargo.embargo_history += [history_record]
260
+
234
261
  return true if embargo.visibility_after_embargo.nil?
235
262
 
236
263
  resource.visibility = embargo.visibility_after_embargo
@@ -266,7 +293,7 @@ module Hyrax
266
293
 
267
294
  protected
268
295
 
269
- # Create the log message used when deactivating an embargo
296
+ # Create the log message used when releasing an embargo
270
297
  def embargo_history_message(state, deactivate_date, release_date, visibility_during, visibility_after)
271
298
  I18n.t 'hydra.embargo.history_message',
272
299
  state: state,
@@ -1,24 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
+ ##
4
+ # Methods for Querying Repository to find Embargoed Objects
3
5
  class EmbargoService < RestrictionService
4
6
  class << self
5
- #
6
- # Methods for Querying Repository to find Embargoed Objects
7
- #
8
-
9
7
  # Returns all assets with embargo release date set to a date in the past
10
- def assets_with_expired_embargoes
8
+ def assets_with_expired_enforced_embargoes
11
9
  builder = Hyrax::ExpiredEmbargoSearchBuilder.new(self)
12
10
  presenters(builder)
13
11
  end
12
+ alias assets_with_expired_embargoes assets_with_expired_enforced_embargoes
14
13
 
15
- # Returns all assets with embargo release date set
16
- # (assumes that when lease visibility is applied to assets
17
- # whose leases have expired, the lease expiration date will be removed from its metadata)
18
- def assets_under_embargo
14
+ ##
15
+ # Returns all assets with embargoes that are currently enforced,
16
+ # regardless of whether the embargoes are active or expired.
17
+ #
18
+ # @see Hyrax::EmbargoManager
19
+ def assets_with_enforced_embargoes
19
20
  builder = Hyrax::EmbargoSearchBuilder.new(self)
20
- presenters(builder)
21
+ presenters(builder).select(&:enforced?)
21
22
  end
23
+ alias assets_under_embargo assets_with_enforced_embargoes
22
24
 
23
25
  # Returns all assets that have had embargoes deactivated in the past.
24
26
  def assets_with_deactivated_embargoes
@@ -5,7 +5,7 @@ module Hyrax
5
5
  attr_reader :file_set
6
6
  delegate :mime_type, to: :file_set
7
7
 
8
- # @param file_set [Hyrax::FileSet] At least for this class, it must have #uri and #mime_type
8
+ # @param file_set [Hyrax::FileSet, Hyrax::FileMetadata] At least for this class, it must have #uri and #mime_type
9
9
  def initialize(file_set)
10
10
  @file_set = file_set
11
11
  end
@@ -31,11 +31,11 @@ module Hyrax
31
31
 
32
32
  def create_derivatives(filename)
33
33
  case mime_type
34
- when *file_set.class.pdf_mime_types then create_pdf_derivatives(filename)
35
- when *file_set.class.office_document_mime_types then create_office_document_derivatives(filename)
36
- when *file_set.class.audio_mime_types then create_audio_derivatives(filename)
37
- when *file_set.class.video_mime_types then create_video_derivatives(filename)
38
- when *file_set.class.image_mime_types then create_image_derivatives(filename)
34
+ when *Hyrax.config.derivative_mime_type_mappings[:pdf] then create_pdf_derivatives(filename)
35
+ when *Hyrax.config.derivative_mime_type_mappings[:office] then create_office_document_derivatives(filename)
36
+ when *Hyrax.config.derivative_mime_type_mappings[:audio] then create_audio_derivatives(filename)
37
+ when *Hyrax.config.derivative_mime_type_mappings[:video] then create_video_derivatives(filename)
38
+ when *Hyrax.config.derivative_mime_type_mappings[:image] then create_image_derivatives(filename)
39
39
  end
40
40
  end
41
41
 
@@ -91,15 +91,15 @@ module Hyrax
91
91
 
92
92
  def create_audio_derivatives(filename)
93
93
  Hydra::Derivatives::AudioDerivatives.create(filename,
94
- outputs: [{ label: 'mp3', format: 'mp3', url: derivative_url('mp3') },
95
- { label: 'ogg', format: 'ogg', url: derivative_url('ogg') }])
94
+ outputs: [{ label: 'mp3', format: 'mp3', url: derivative_url('mp3'), mime_type: 'audio/mpeg', container: 'service_file' },
95
+ { label: 'ogg', format: 'ogg', url: derivative_url('ogg'), mime_type: 'audio/ogg', container: 'service_file' }])
96
96
  end
97
97
 
98
98
  def create_video_derivatives(filename)
99
99
  Hydra::Derivatives::VideoDerivatives.create(filename,
100
- outputs: [{ label: :thumbnail, format: 'jpg', url: derivative_url('thumbnail') },
101
- { label: 'webm', format: 'webm', url: derivative_url('webm') },
102
- { label: 'mp4', format: 'mp4', url: derivative_url('mp4') }])
100
+ outputs: [{ label: :thumbnail, format: 'jpg', url: derivative_url('thumbnail'), mime_type: 'image/jpeg' },
101
+ { label: 'webm', format: 'webm', url: derivative_url('webm'), mime_type: 'video/webm', container: 'service_file' },
102
+ { label: 'mp4', format: 'mp4', url: derivative_url('mp4'), mime_type: 'video/mp4', container: 'service_file' }])
103
103
  end
104
104
 
105
105
  def create_image_derivatives(filename)
@@ -14,7 +14,7 @@ module Hyrax
14
14
  end
15
15
 
16
16
  def message
17
- uri = file_set.original_file.uri.to_s
17
+ uri = checksum_audit_log.checked_uri
18
18
  file_title = file_set.title.first
19
19
  I18n.t('hyrax.notifications.fixity_check_failure.message', log_date: log_date, file_title: file_title, uri: uri)
20
20
  end
@@ -53,8 +53,15 @@ module Hyrax
53
53
  #
54
54
  # @see #assign_for
55
55
  def assign_for!(object:, attribute: :identifier)
56
- assign_for(object: object, attribute: attribute).save!
57
- object
56
+ result = assign_for(object: object, attribute: attribute)
57
+
58
+ case result
59
+ when Valkyrie::Resource
60
+ Hyrax.persister.save(resource: result)
61
+ else
62
+ result.save
63
+ result
64
+ end
58
65
  end
59
66
  end
60
67
  end
@@ -12,8 +12,16 @@ module Hyrax
12
12
  # @param [Dry::Events::Event] event
13
13
  # @return [void]
14
14
  def on_file_characterized(event)
15
- CreateDerivativesJob
16
- .perform_later(event[:file_set], event[:file_id], event[:path_hint])
15
+ file_set = event[:file_set]
16
+
17
+ case file_set
18
+ when ActiveFedora::Base # ActiveFedora
19
+ CreateDerivativesJob
20
+ .perform_later(file_set, event[:file_id], event[:path_hint])
21
+ else
22
+ ValkyrieCreateDerivativesJob
23
+ .perform_later(file_set.id.to_s, event[:file_id])
24
+ end
17
25
  end
18
26
 
19
27
  ##
@@ -39,10 +47,10 @@ module Hyrax
39
47
  # @param [Dry::Events::Event] event
40
48
  # @return [void]
41
49
  def on_file_uploaded(event)
42
- # Run characterization
43
- Hyrax.config
44
- .characterization_service
45
- .run(metadata: event[:metadata], file: event[:metadata].file)
50
+ # Run characterization for original file only
51
+ return unless event[:metadata]&.original_file?
52
+
53
+ ValkyrieCharacterizationJob.perform_later(event[:metadata].id.to_s)
46
54
  end
47
55
  end
48
56
  end