hyrax 4.0.0.rc3 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +116 -231
  3. data/.dassie/.env +3 -1
  4. data/.dassie/Gemfile +0 -2
  5. data/.dassie/config/analytics.yml +2 -2
  6. data/.dassie/config/environments/test.rb +1 -0
  7. data/.dassie/config/initializers/hyrax.rb +3 -1
  8. data/.dassie/config/initializers/redis_config.rb +0 -1
  9. data/.dassie/config/initializers/riiif.rb +13 -3
  10. data/.dassie/db/schema.rb +2 -2
  11. data/.dockerignore +6 -0
  12. data/.github/ISSUE_TEMPLATE.md +14 -9
  13. data/.github/PULL_REQUEST_TEMPLATE.md +25 -6
  14. data/.github/release.yml +5 -2
  15. data/.koppie/.env +3 -0
  16. data/.koppie/Gemfile +0 -2
  17. data/.koppie/README.md +11 -11
  18. data/.koppie/app/forms/collection_resource_form.rb +1 -0
  19. data/.koppie/app/indexers/collection_resource_indexer.rb +1 -0
  20. data/.koppie/app/models/collection_resource.rb +1 -0
  21. data/.koppie/config/analytics.yml +1 -0
  22. data/.koppie/config/environments/test.rb +1 -0
  23. data/.koppie/config/initializers/hyrax.rb +8 -2
  24. data/.koppie/config/initializers/redis_config.rb +0 -1
  25. data/.koppie/config/initializers/riiif.rb +13 -4
  26. data/.koppie/config/metadata/collection_resource.yaml +1 -128
  27. data/.koppie/yarn.lock +23 -23
  28. data/.regen +1 -1
  29. data/CONTAINERS.md +15 -15
  30. data/Dockerfile +6 -11
  31. data/app/actors/hyrax/actors/base_actor.rb +4 -3
  32. data/app/actors/hyrax/actors/embargo_actor.rb +5 -2
  33. data/app/actors/hyrax/actors/lease_actor.rb +5 -2
  34. data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
  35. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +1 -1
  36. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +74 -0
  37. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +14 -5
  38. data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
  39. data/app/controllers/hyrax/batch_edits_controller.rb +33 -4
  40. data/app/controllers/hyrax/downloads_controller.rb +8 -1
  41. data/app/controllers/hyrax/file_sets_controller.rb +1 -0
  42. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  43. data/app/forms/hyrax/forms/permission_template_form.rb +2 -0
  44. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +90 -0
  45. data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
  46. data/app/forms/hyrax/forms/work_form.rb +1 -1
  47. data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
  48. data/app/helpers/hyrax/dashboard_helper_behavior.rb +17 -9
  49. data/app/helpers/hyrax/membership_helper.rb +13 -1
  50. data/app/helpers/hyrax/work_form_helper.rb +0 -107
  51. data/app/indexers/hyrax/file_set_indexer.rb +6 -0
  52. data/app/indexers/hyrax/pcdm_collection_indexer.rb +8 -0
  53. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +41 -5
  54. data/app/indexers/hyrax/valkyrie_work_indexer.rb +8 -2
  55. data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
  56. data/app/jobs/valkyrie_ingest_job.rb +0 -1
  57. data/app/models/admin_set.rb +1 -31
  58. data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
  59. data/app/models/concerns/hyrax/solr_document_behavior.rb +1 -1
  60. data/app/models/hyrax/collection_type.rb +5 -14
  61. data/app/models/hyrax/file_metadata.rb +6 -7
  62. data/app/models/hyrax/file_set.rb +8 -0
  63. data/app/models/hyrax/resource.rb +30 -2
  64. data/app/presenters/hyrax/file_set_presenter.rb +6 -0
  65. data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
  66. data/app/presenters/hyrax/presenter_renderer.rb +0 -7
  67. data/app/presenters/hyrax/work_show_presenter.rb +6 -11
  68. data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
  69. data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
  70. data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
  71. data/app/services/hyrax/analytics/google.rb +23 -15
  72. data/app/services/hyrax/analytics/matomo.rb +4 -3
  73. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +11 -9
  74. data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
  75. data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
  76. data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
  77. data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
  78. data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
  79. data/app/services/hyrax/derivative_path.rb +14 -4
  80. data/app/services/hyrax/embargo_manager.rb +76 -10
  81. data/app/services/hyrax/file_set_derivatives_service.rb +3 -2
  82. data/app/services/hyrax/lease_manager.rb +88 -8
  83. data/app/services/hyrax/listeners/file_metadata_listener.rb +2 -2
  84. data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
  85. data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
  86. data/app/services/hyrax/solr_query_service.rb +7 -6
  87. data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
  88. data/app/services/hyrax/statistics/over_time.rb +1 -1
  89. data/app/services/hyrax/statistics/users/over_time.rb +3 -1
  90. data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
  91. data/app/services/hyrax/statistics/works/count.rb +1 -1
  92. data/app/services/hyrax/thumbnail_path_service.rb +5 -0
  93. data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
  94. data/app/services/hyrax/valkyrie_upload.rb +5 -3
  95. data/app/services/hyrax/versioning_service.rb +1 -0
  96. data/app/services/hyrax/visibility_intention.rb +1 -4
  97. data/app/services/hyrax/visibility_propagator.rb +1 -1
  98. data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
  99. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
  100. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
  101. data/app/services/hyrax/workflow/permission_query.rb +23 -2
  102. data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
  103. data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
  104. data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
  105. data/app/views/hyrax/base/_form.html.erb +0 -10
  106. data/app/views/hyrax/base/_form_files.html.erb +7 -2
  107. data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
  108. data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
  109. data/app/views/hyrax/base/_form_visibility_component.html.erb +2 -2
  110. data/app/views/hyrax/base/_items.html.erb +1 -1
  111. data/app/views/hyrax/base/file_manager.html.erb +1 -1
  112. data/app/views/hyrax/base/show.json.jbuilder +2 -2
  113. data/app/views/hyrax/file_sets/_versioning.html.erb +1 -1
  114. data/app/views/hyrax/file_sets/show.html.erb +5 -3
  115. data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
  116. data/chart/hyrax/Chart.yaml +18 -14
  117. data/chart/hyrax/README.md +34 -21
  118. data/chart/hyrax/templates/_helpers.tpl +26 -1
  119. data/chart/hyrax/templates/configmap-env.yaml +12 -2
  120. data/chart/hyrax/templates/secrets.yaml +1 -1
  121. data/chart/hyrax/values.yaml +36 -14
  122. data/config/initializers/listeners.rb +4 -10
  123. data/config/initializers/storage_adapter_initializer.rb +1 -1
  124. data/config/locales/hyrax.de.yml +11 -3
  125. data/config/locales/hyrax.en.yml +13 -2
  126. data/config/locales/hyrax.es.yml +4 -1
  127. data/config/locales/hyrax.fr.yml +4 -1
  128. data/config/locales/hyrax.it.yml +5 -2
  129. data/config/locales/hyrax.pt-BR.yml +9 -2
  130. data/config/locales/hyrax.zh.yml +4 -1
  131. data/config/metadata/file_set_metadata.yaml +1 -1
  132. data/docker-compose-koppie.yml +17 -4
  133. data/docker-compose.yml +19 -6
  134. data/documentation/developing-your-hyrax-based-app.md +6 -14
  135. data/documentation/legacyREADME.md +7 -5
  136. data/hyrax.gemspec +2 -2
  137. data/karma.conf.js +8 -9
  138. data/lib/generators/hyrax/templates/config/analytics.yml +1 -0
  139. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  140. data/lib/generators/hyrax/templates/config/initializers/redis_config.rb +0 -1
  141. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +15 -5
  142. data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
  143. data/lib/hyrax/configuration.rb +6 -0
  144. data/lib/hyrax/engine.rb +2 -0
  145. data/lib/hyrax/publisher.rb +19 -3
  146. data/lib/hyrax/specs/capybara.rb +9 -4
  147. data/lib/hyrax/transactions/container.rb +5 -0
  148. data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
  149. data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
  150. data/lib/hyrax/transactions/steps/save.rb +21 -0
  151. data/lib/hyrax/transactions/work_create.rb +1 -0
  152. data/lib/hyrax/version.rb +1 -1
  153. data/lib/hyrax.rb +1 -0
  154. data/lib/wings/active_fedora_converter/default_work.rb +7 -2
  155. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  156. data/lib/wings/active_fedora_converter.rb +47 -11
  157. data/lib/wings/model_transformer.rb +23 -4
  158. data/lib/wings/setup.rb +21 -1
  159. data/lib/wings/valkyrie/persister.rb +4 -2
  160. data/package.json +3 -1
  161. data/template.rb +1 -1
  162. metadata +15 -10
  163. data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
  164. data/app/services/hyrax/collections/migration_service.rb +0 -113
  165. data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
  166. data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
  167. data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
  168. data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
@@ -31,6 +31,7 @@ module Hyrax
31
31
  require 'hyrax/transactions/steps/add_to_collections'
32
32
  require 'hyrax/transactions/steps/add_to_parent'
33
33
  require 'hyrax/transactions/steps/apply_collection_type_permissions'
34
+ require 'hyrax/transactions/steps/apply_permission_template'
34
35
  require 'hyrax/transactions/steps/change_depositor'
35
36
  require 'hyrax/transactions/steps/check_for_empty_admin_set'
36
37
  require 'hyrax/transactions/steps/delete_access_control'
@@ -203,6 +204,10 @@ module Hyrax
203
204
  Steps::AddToParent.new
204
205
  end
205
206
 
207
+ ops.register 'apply_permission_template' do
208
+ Steps::ApplyPermissionTemplate.new
209
+ end
210
+
206
211
  ops.register 'change_depositor' do
207
212
  Steps::ChangeDepositor.new
208
213
  end
@@ -25,6 +25,12 @@ module Hyrax
25
25
  # @return [Dry::Monads::Result]
26
26
  def call(obj, uploaded_files: [], file_set_params: [])
27
27
  if @handler.new(work: obj).add(files: uploaded_files, file_set_params: file_set_params).attach
28
+ file_sets = obj.member_ids.map do |member|
29
+ Hyrax.query_service.find_by(id: member) if Hyrax.query_service.find_by(id: member).is_a? Hyrax::FileSet
30
+ end
31
+
32
+ Hyrax::LeaseManager.create_or_update_lease_on_members(file_sets, obj) if obj.lease
33
+ Hyrax::EmbargoManager.create_or_update_embargo_on_members(file_sets, obj) if obj.embargo
28
34
  Success(obj)
29
35
  else
30
36
  Failure[:failed_to_attach_file_sets, uploaded_files]
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Transactions
4
+ module Steps
5
+ ##
6
+ # A `dry-transcation` step that applies a permission template
7
+ # to a saved object.
8
+ #
9
+ # @note by design, this step should succeed even if for some reason a
10
+ # permission template could not be applied. it's better to complete the
11
+ # rest of the creation process with missing ACL grants than to crash and
12
+ # miss other crucial steps.
13
+ #
14
+ # @since 4.1.0
15
+ class ApplyPermissionTemplate
16
+ include Dry::Monads[:result]
17
+
18
+ ##
19
+ # @param [Hyrax::Work] object
20
+ #
21
+ # @return [Dry::Monads::Result]
22
+ def call(object)
23
+ template = Hyrax::PermissionTemplate.find_by(source_id: object&.admin_set_id)
24
+
25
+ if template.blank?
26
+ Hyrax.logger.info("At create time, #{object} doesn't have a " \
27
+ "PermissionTemplate, which it should have via " \
28
+ "AdministrativeSet #{object&.admin_set_id}). " \
29
+ "Continuing to create this object anyway.")
30
+
31
+ return Success(object)
32
+ end
33
+
34
+ Hyrax::PermissionTemplateApplicator.apply(template).to(model: object) &&
35
+ Success(object)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -29,10 +29,15 @@ module Hyrax
29
29
  # @return [Dry::Monads::Result] `Success(work)` if the change_set is
30
30
  # applied and the resource is saved;
31
31
  # `Failure([#to_s, change_set.resource])`, otherwise.
32
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
32
33
  def call(change_set, user: nil)
33
34
  begin
35
+ valid_future_date?(change_set.lease, 'lease_expiration_date') if change_set.respond_to?(:lease) && change_set.lease
36
+ valid_future_date?(change_set.embargo, 'embargo_release_date') if change_set.respond_to?(:embargo) && change_set.embargo
34
37
  new_collections = changed_collection_membership(change_set)
38
+
35
39
  unsaved = change_set.sync
40
+ save_lease_or_embargo(unsaved)
36
41
  saved = @persister.save(resource: unsaved)
37
42
  rescue StandardError => err
38
43
  return Failure(["Failed save on #{change_set}\n\t#{err.message}", change_set.resource])
@@ -48,9 +53,25 @@ module Hyrax
48
53
  publish_changes(resource: saved, user: user, new: unsaved.new_record, new_collections: new_collections)
49
54
  Success(saved)
50
55
  end
56
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
51
57
 
52
58
  private
53
59
 
60
+ def valid_future_date?(item, attribute)
61
+ raise StandardError, "#{item.model} must use a future date" if item.fields[attribute] < Time.zone.now
62
+ end
63
+
64
+ def save_lease_or_embargo(unsaved)
65
+ if unsaved.embargo.present?
66
+ unsaved.embargo.embargo_release_date = unsaved.embargo.embargo_release_date&.to_datetime
67
+ unsaved.embargo = @persister.save(resource: unsaved.embargo)
68
+ end
69
+ return if unsaved.lease.blank?
70
+
71
+ unsaved.lease.lease_expiration_date = unsaved.lease.lease_expiration_date&.to_datetime
72
+ unsaved.lease = @persister.save(resource: unsaved.lease)
73
+ end
74
+
54
75
  ##
55
76
  # @param [Hyrax::ChangeSet] change_set
56
77
  #
@@ -12,6 +12,7 @@ module Hyrax
12
12
  'change_set.ensure_admin_set',
13
13
  'change_set.set_user_as_depositor',
14
14
  'change_set.apply',
15
+ 'work_resource.apply_permission_template',
15
16
  'work_resource.save_acl',
16
17
  'work_resource.add_file_sets',
17
18
  'work_resource.change_depositor',
data/lib/hyrax/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- VERSION = '4.0.0.rc3'
3
+ VERSION = '5.0.0.rc1'
4
4
  end
data/lib/hyrax.rb CHANGED
@@ -20,6 +20,7 @@ require 'hyrax/version'
20
20
  require 'hyrax/inflections'
21
21
  require 'hyrax/name'
22
22
  require 'hyrax/valkyrie_can_can_adapter'
23
+ require 'retriable'
23
24
  require 'valkyrie/indexing_adapter'
24
25
  require 'valkyrie/indexing/solr/indexing_adapter'
25
26
  require 'valkyrie/indexing/null_indexing_adapter'
@@ -27,7 +27,7 @@ module Wings
27
27
  #
28
28
  # @return [void] apply the property
29
29
  def apply(klass)
30
- return if klass.properties.keys.include?(name) ||
30
+ return if klass.properties.keys.include?(name.to_s) ||
31
31
  klass.protected_property_name?(name)
32
32
  klass.send(definition_method, name, options)
33
33
  end
@@ -98,6 +98,7 @@ module Wings
98
98
  include Hyrax::Noid
99
99
  include Hyrax::Permissions
100
100
  include Hydra::AccessControls::Embargoable
101
+ include Hyrax::CoreMetadata
101
102
  property :nested_resource, predicate: ::RDF::URI("http://example.com/nested_resource"), class_name: "Wings::ActiveFedoraConverter::NestedResource"
102
103
 
103
104
  validates :lease_expiration_date, 'hydra/future_date': true, on: :create
@@ -118,7 +119,7 @@ module Wings
118
119
  end
119
120
 
120
121
  def to_rdf_representation
121
- "Wings(#{valkyrie_class})"
122
+ "Wings(#{valkyrie_class})" unless valkyrie_class&.to_s&.include?('Wings(')
122
123
  end
123
124
  alias inspect to_rdf_representation
124
125
  alias to_s inspect
@@ -136,6 +137,10 @@ module Wings
136
137
  false
137
138
  end
138
139
 
140
+ def file_sets
141
+ members.select(&:file_set?)
142
+ end
143
+
139
144
  def indexing_service
140
145
  Hyrax::ValkyrieIndexer.for(resource: valkyrie_resource)
141
146
  end
@@ -29,7 +29,7 @@ module Wings
29
29
  end
30
30
 
31
31
  def to_rdf_representation
32
- "Wings(#{valkyrie_class})"
32
+ "Wings(#{valkyrie_class})" unless valkyrie_class&.to_s&.include?('Wings(')
33
33
  end
34
34
  alias inspect to_rdf_representation
35
35
  alias to_s inspect
@@ -18,7 +18,7 @@ module Wings
18
18
  #
19
19
  # @note the `Valkyrie::Resource` object passed to this class **must** have an
20
20
  # `#internal_resource` mapping it to an `ActiveFedora::Base` class.
21
- class ActiveFedoraConverter
21
+ class ActiveFedoraConverter # rubocop:disable Metrics/ClassLength
22
22
  ##
23
23
  # Accesses the Class implemented for handling resource attributes
24
24
  # @return [Class]
@@ -93,7 +93,7 @@ module Wings
93
93
  # then the id hasn't been minted and shouldn't yet be set.
94
94
  # @return [String]
95
95
  def id
96
- return resource[:id].to_s if resource[:id]&.is_a?(::Valkyrie::ID) && resource[:id].present?
96
+ return resource[:id].to_s if resource[:id].present? && resource[:id]&.is_a?(::Valkyrie::ID)
97
97
  return "" unless resource.respond_to?(:alternate_ids)
98
98
 
99
99
  resource.alternate_ids.first.to_s
@@ -130,6 +130,7 @@ module Wings
130
130
 
131
131
  ##
132
132
  # apply attributes to the ActiveFedora model
133
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
133
134
  def apply_attributes_to_model(af_object)
134
135
  case af_object
135
136
  when Hydra::AccessControl
@@ -137,15 +138,29 @@ module Wings
137
138
  when ActiveFedora::File
138
139
  add_file_attributes(af_object)
139
140
  else
140
- converted_attrs = normal_attributes
141
- members = Array.wrap(converted_attrs.delete(:members))
142
- files = converted_attrs.delete(:files)
143
- af_object.attributes = converted_attrs
144
- members.empty? ? af_object.try(:ordered_members)&.clear : af_object.try(:ordered_members=, members)
145
- af_object.try(:members)&.replace(members)
146
- af_object.files.build_or_set(files) if files
141
+ parse_attributes(af_object)
147
142
  end
148
143
  end
144
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
145
+
146
+ def parse_attributes(af_object)
147
+ converted_attrs = normal_attributes
148
+ members = Array.wrap(converted_attrs.delete(:members))
149
+ files = converted_attrs.delete(:files)
150
+ af_object.attributes = converted_attrs
151
+ af_object.extracted_text = create_extrated_text(af_object) if resource.attributes[:extracted_text_id].present?
152
+ perform_lease_conversion(af_object: af_object, resource: resource)
153
+ perform_embargo_conversion(af_object: af_object, resource: resource)
154
+ members.empty? ? af_object.try(:ordered_members)&.clear : af_object.try(:ordered_members=, members)
155
+ af_object.try(:members)&.replace(members)
156
+ af_object.files.build_or_set(files) if files
157
+ end
158
+
159
+ def create_extrated_text(af_object)
160
+ pcdm_et_file = af_object.extracted_text.presence || af_object.create_extracted_text
161
+ pcdm_et_file.content = Hyrax.custom_queries.find_many_file_metadata_by_use(resource: resource, use: Hyrax::FileMetadata::Use::EXTRACTED_TEXT).first&.content
162
+ pcdm_et_file
163
+ end
149
164
 
150
165
  # Add attributes from resource which aren't AF properties into af_object
151
166
  def add_access_control_attributes(af_object)
@@ -155,11 +170,32 @@ module Wings
155
170
 
156
171
  # for files, add attributes to metadata_node, plus some other work
157
172
  def add_file_attributes(af_object)
158
- af_object.metadata_node.attributes = normal_attributes
173
+ converted_attrs = normal_attributes
174
+ pcdm_use = converted_attrs.delete(:pcdm_use)
175
+ af_object.metadata_node.attributes = converted_attrs
176
+ af_object.pcdm_use = pcdm_use.first if pcdm_use.present? && pcdm_use.first.present?
159
177
  af_object.original_name = resource.original_filename
160
- new_type = (resource.type - af_object.metadata_node.type.to_a).first
178
+ new_type = (resource.pcdm_use - af_object.metadata_node.type.to_a).first
161
179
  af_object.metadata_node.type = new_type if new_type
162
180
  af_object.mime_type = resource.mime_type
163
181
  end
182
+
183
+ def perform_lease_conversion(af_object:, resource:)
184
+ # TODO(#6134): af_object.lease.class has the same name as resource.lease.class; however, each class has a different object_id
185
+ # so a type mismatch happens. the code below coerces the one object into the other
186
+ return if !resource.try(:lease) || !af_object.reflections.include?(:lease) || af_object.lease&.id
187
+
188
+ resource_lease_dup = af_object.reflections.fetch(:lease).klass.new(resource.lease.attributes.except(:id, :internal_resource, :created_at, :updated_at, :new_record))
189
+ af_object.lease = resource_lease_dup
190
+ end
191
+
192
+ def perform_embargo_conversion(af_object:, resource:)
193
+ # TODO(#6134): af_object.embargo.class has the same name as resource.embargo.class; however, each class has a different object_id
194
+ # so a type mismatch happens. the code below coerces the one object into the other
195
+ return if !resource.try(:embargo) || !af_object.reflections.include?(:embargo) || af_object.embargo&.id
196
+
197
+ resource_embargo_dup = af_object.reflections.fetch(:embargo).klass.new(resource.embargo.attributes.except(:id, :internal_resource, :created_at, :updated_at, :new_record))
198
+ af_object.embargo = resource_embargo_dup
199
+ end
164
200
  end
165
201
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/ClassLength
3
4
  module Wings
4
5
  ##
5
6
  # Transforms ActiveFedora models or objects into Valkyrie::Resource models or
@@ -34,7 +35,7 @@ module Wings
34
35
  #
35
36
  # @param pcdm_object [ActiveFedora::Base]
36
37
  #
37
- # @return [::Valkyrie::Resource] a resource mirroiring `pcdm_object`
38
+ # @return [::Valkyrie::Resource] a resource mirroring `pcdm_object`
38
39
  def self.for(pcdm_object)
39
40
  new(pcdm_object: pcdm_object).build
40
41
  end
@@ -43,6 +44,7 @@ module Wings
43
44
  # Builds a `Valkyrie::Resource` equivalent to the `pcdm_object`
44
45
  #
45
46
  # @return [::Valkyrie::Resource] a resource mirroring `pcdm_object`
47
+ # rubocop:disable Metrics/AbcSize
46
48
  def build
47
49
  klass = cache.fetch(pcdm_object.class) do
48
50
  OrmConverter.to_valkyrie_resource_class(klass: pcdm_object.class)
@@ -53,7 +55,25 @@ module Wings
53
55
  attrs = attributes.tap { |hash| hash[:new_record] = pcdm_object.new_record? }
54
56
  attrs[:alternate_ids] = [::Valkyrie::ID.new(pcdm_object.id)] if pcdm_object.id
55
57
 
56
- klass.new(**attrs).tap { |resource| ensure_current_permissions(resource) }
58
+ klass.new(**attrs).tap do |resource|
59
+ resource.lease = pcdm_object.lease&.valkyrie_resource if pcdm_object.respond_to?(:lease) && pcdm_object.lease
60
+ resource.embargo = pcdm_object.embargo&.valkyrie_resource if pcdm_object.respond_to?(:embargo) && pcdm_object.embargo
61
+ check_size(resource)
62
+ check_pcdm_use(resource)
63
+ ensure_current_permissions(resource)
64
+ end
65
+ end
66
+
67
+ def check_size(resource)
68
+ return unless resource.respond_to?(:recorded_size) && pcdm_object.respond_to?(:size)
69
+ resource.recorded_size = [pcdm_object.size.to_i]
70
+ end
71
+
72
+ def check_pcdm_use(resource)
73
+ return unless resource.respond_to?(:pcdm_use) &&
74
+ pcdm_object.respond_to?(:metadata_node) &&
75
+ pcdm_object&.metadata_node&.respond_to?(:type)
76
+ resource.pcdm_use = pcdm_object.metadata_node.type.to_a
57
77
  end
58
78
 
59
79
  def ensure_current_permissions(resource)
@@ -155,7 +175,6 @@ module Wings
155
175
  def append_embargo(attrs)
156
176
  return unless pcdm_object.try(:embargo)
157
177
  embargo_attrs = pcdm_object.embargo.attributes.symbolize_keys
158
- embargo_attrs[:embargo_history] = embargo_attrs[:embargo_history].to_a
159
178
  embargo_attrs[:id] = ::Valkyrie::ID.new(embargo_attrs[:id]) if embargo_attrs[:id]
160
179
 
161
180
  attrs[:embargo] = Hyrax::Embargo.new(**embargo_attrs)
@@ -164,7 +183,6 @@ module Wings
164
183
  def append_lease(attrs)
165
184
  return unless pcdm_object.try(:lease)
166
185
  lease_attrs = pcdm_object.lease.attributes.symbolize_keys
167
- lease_attrs[:lease_history] = lease_attrs[:embargo_history].to_a
168
186
  lease_attrs[:id] = ::Valkyrie::ID.new(lease_attrs[:id]) if lease_attrs[:id]
169
187
 
170
188
  attrs[:lease] = Hyrax::Lease.new(**lease_attrs)
@@ -186,3 +204,4 @@ module Wings
186
204
  end
187
205
  end
188
206
  end
207
+ # rubocop:enable Metrics/ClassLength
data/lib/wings/setup.rb CHANGED
@@ -36,6 +36,7 @@ module ActiveFedora
36
36
  alias eql? ==
37
37
 
38
38
  def self.supports_property?(property)
39
+ return true if ['pcdm_use'].include?(property.to_s)
39
40
  properties.key?(property.to_s)
40
41
  end
41
42
 
@@ -46,6 +47,14 @@ module ActiveFedora
46
47
  def self.default_sort_params
47
48
  ["system_create_dtsi asc"]
48
49
  end
50
+
51
+ def pcdm_use
52
+ metadata.type
53
+ end
54
+
55
+ def pcdm_use=(value)
56
+ metadata.type = value
57
+ end
49
58
  end
50
59
 
51
60
  module WithMetadata
@@ -56,6 +65,14 @@ module ActiveFedora
56
65
  def changed_attributes
57
66
  super.except(:file_hash)
58
67
  end
68
+
69
+ def pcdm_use
70
+ type
71
+ end
72
+
73
+ def pcdm_use=(value)
74
+ self.type = value
75
+ end
59
76
  end
60
77
  end
61
78
 
@@ -102,7 +119,10 @@ custom_queries = [Hyrax::CustomQueries::Navigators::CollectionMembers,
102
119
  Wings::CustomQueries::FindCollectionsByType,
103
120
  Wings::CustomQueries::FindFileMetadata, # override Hyrax::CustomQueries::FindFileMetadata
104
121
  Wings::CustomQueries::FindIdsByModel,
105
- Wings::CustomQueries::FindManyByAlternateIds] # override Hyrax::CustomQueries::FindManyByAlternateIds
122
+ Wings::CustomQueries::FindManyByAlternateIds,
123
+ Hyrax::CustomQueries::FindModelsByAccess,
124
+ Hyrax::CustomQueries::FindCountBy,
125
+ Hyrax::CustomQueries::FindByDateRange] # override Hyrax::CustomQueries::FindManyByAlternateIds
106
126
  custom_queries.each do |query_handler|
107
127
  Valkyrie.config.metadata_adapter.query_service.custom_queries.register_query_handler(query_handler)
108
128
  end
@@ -22,8 +22,9 @@ module Wings
22
22
 
23
23
  # Persists a resource using ActiveFedora
24
24
  # @param [Valkyrie::Resource] resource
25
+ # @param [Boolean] perform_af_validation
25
26
  # @return [Valkyrie::Resource] the persisted/updated resource
26
- def save(resource:)
27
+ def save(resource:, perform_af_validation: false)
27
28
  af_object = resource_factory.from_resource(resource: resource)
28
29
 
29
30
  check_lock_tokens(af_object: af_object, resource: resource)
@@ -31,7 +32,8 @@ module Wings
31
32
  # the #save! api differs between ActiveFedora::Base and ActiveFedora::File objects,
32
33
  # if we get a falsey response, we expect we have a File that has failed to save due
33
34
  # to empty content
34
- af_object.save! ||
35
+ # we disable validation on the Active Fedora object, only if validations have already been run and passed
36
+ af_object.save!(validate: perform_af_validation) ||
35
37
  raise(FailedSaveError.new("#{af_object.class}#save! returned non-true. It might be missing required content.", obj: af_object))
36
38
 
37
39
  resource_factory.to_resource(object: af_object)
data/package.json CHANGED
@@ -6,6 +6,8 @@
6
6
  "karma-chrome-launcher": "^3.1.1",
7
7
  "karma-coffee-preprocessor": "^1.0.1",
8
8
  "karma-jasmine": "^4.0.2",
9
- "karma-spec-reporter": "^0.0.34"
9
+ "karma-selenium-grid-launcher": "^0.3.0",
10
+ "karma-spec-reporter": "^0.0.34",
11
+ "selenium-webdriver": "^4.10.0"
10
12
  }
11
13
  }
data/template.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  # Hack for https://github.com/rails/rails/issues/35153
3
3
  gsub_file 'Gemfile', /^gem ["']sqlite3["']$/, 'gem "sqlite3", "~> 1.3.0"'
4
- gem 'hyrax', '4.0.0.rc3'
4
+ gem 'hyrax', '5.0.0.rc1'
5
5
  run 'bundle install'
6
6
  generate 'hyrax:install', '-f'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc3
4
+ version: 5.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2023-05-15 00:00:00.000000000 Z
17
+ date: 2023-08-25 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: rails
@@ -1888,6 +1888,7 @@ files:
1888
1888
  - app/controllers/concerns/hyrax/manages_embargoes.rb
1889
1889
  - app/controllers/concerns/hyrax/singular_subresource_controller.rb
1890
1890
  - app/controllers/concerns/hyrax/themed_layout_controller.rb
1891
+ - app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb
1891
1892
  - app/controllers/concerns/hyrax/works_controller_behavior.rb
1892
1893
  - app/controllers/hyrax/admin/admin_sets_controller.rb
1893
1894
  - app/controllers/hyrax/admin/analytics/analytics_controller.rb
@@ -1957,7 +1958,6 @@ files:
1957
1958
  - app/forms/hyrax/forms/dashboard/nest_collection_form.rb
1958
1959
  - app/forms/hyrax/forms/embargo.rb
1959
1960
  - app/forms/hyrax/forms/failed_submission_form_wrapper.rb
1960
- - app/forms/hyrax/forms/file_manager_form.rb
1961
1961
  - app/forms/hyrax/forms/file_set_edit_form.rb
1962
1962
  - app/forms/hyrax/forms/file_set_form.rb
1963
1963
  - app/forms/hyrax/forms/lease.rb
@@ -1965,6 +1965,7 @@ files:
1965
1965
  - app/forms/hyrax/forms/pcdm_object_form.rb
1966
1966
  - app/forms/hyrax/forms/permission.rb
1967
1967
  - app/forms/hyrax/forms/permission_template_form.rb
1968
+ - app/forms/hyrax/forms/resource_batch_edit_form.rb
1968
1969
  - app/forms/hyrax/forms/resource_form.rb
1969
1970
  - app/forms/hyrax/forms/widgets/admin_set_embargo_period.rb
1970
1971
  - app/forms/hyrax/forms/widgets/admin_set_visibility.rb
@@ -2278,6 +2279,8 @@ files:
2278
2279
  - app/search_builders/hyrax/single_result.rb
2279
2280
  - app/search_builders/hyrax/single_use_link_search_builder.rb
2280
2281
  - app/search_builders/hyrax/stats/work_status_search_builder.rb
2282
+ - app/search_builders/hyrax/valkyrie_abstract_type_relation.rb
2283
+ - app/search_builders/hyrax/valkyrie_work_relation.rb
2281
2284
  - app/search_builders/hyrax/work_relation.rb
2282
2285
  - app/search_builders/hyrax/work_search_builder.rb
2283
2286
  - app/search_builders/hyrax/works_search_builder.rb
@@ -2311,7 +2314,6 @@ files:
2311
2314
  - app/services/hyrax/collections/collection_member_search_service.rb
2312
2315
  - app/services/hyrax/collections/collection_member_service.rb
2313
2316
  - app/services/hyrax/collections/managed_collections_service.rb
2314
- - app/services/hyrax/collections/migration_service.rb
2315
2317
  - app/services/hyrax/collections/nested_collection_persistence_service.rb
2316
2318
  - app/services/hyrax/collections/nested_collection_query_service.rb
2317
2319
  - app/services/hyrax/collections/permissions_create_service.rb
@@ -2323,10 +2325,13 @@ files:
2323
2325
  - app/services/hyrax/custom_queries.rb
2324
2326
  - app/services/hyrax/custom_queries/find_access_control.rb
2325
2327
  - app/services/hyrax/custom_queries/find_by_collection_type.rb
2328
+ - app/services/hyrax/custom_queries/find_by_date_range.rb
2326
2329
  - app/services/hyrax/custom_queries/find_collections_by_type.rb
2330
+ - app/services/hyrax/custom_queries/find_count_by.rb
2327
2331
  - app/services/hyrax/custom_queries/find_file_metadata.rb
2328
2332
  - app/services/hyrax/custom_queries/find_ids_by_model.rb
2329
2333
  - app/services/hyrax/custom_queries/find_many_by_alternate_ids.rb
2334
+ - app/services/hyrax/custom_queries/find_models_by_access.rb
2330
2335
  - app/services/hyrax/custom_queries/navigators/child_collections_navigator.rb
2331
2336
  - app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb
2332
2337
  - app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb
@@ -2337,6 +2342,7 @@ files:
2337
2342
  - app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb
2338
2343
  - app/services/hyrax/database_migrator.rb
2339
2344
  - app/services/hyrax/default_middleware_stack.rb
2345
+ - app/services/hyrax/derivative_bucketed_storage.rb
2340
2346
  - app/services/hyrax/derivative_path.rb
2341
2347
  - app/services/hyrax/derivative_service.rb
2342
2348
  - app/services/hyrax/edit_permissions_service.rb
@@ -2415,6 +2421,7 @@ files:
2415
2421
  - app/services/hyrax/statistics/system_stats.rb
2416
2422
  - app/services/hyrax/statistics/term_query.rb
2417
2423
  - app/services/hyrax/statistics/users/over_time.rb
2424
+ - app/services/hyrax/statistics/valkyrie_query_service.rb
2418
2425
  - app/services/hyrax/statistics/works/by_depositor.rb
2419
2426
  - app/services/hyrax/statistics/works/by_resource_type.rb
2420
2427
  - app/services/hyrax/statistics/works/count.rb
@@ -2562,6 +2569,7 @@ files:
2562
2569
  - app/views/hyrax/admin/stats/show.html.erb
2563
2570
  - app/views/hyrax/admin/users/index.html.erb
2564
2571
  - app/views/hyrax/admin/workflow_roles/index.html.erb
2572
+ - app/views/hyrax/admin/workflows/_tabs.html.erb
2565
2573
  - app/views/hyrax/admin/workflows/index.html.erb
2566
2574
  - app/views/hyrax/base/_actions.html.erb
2567
2575
  - app/views/hyrax/base/_attribute_rows.html.erb
@@ -2578,14 +2586,11 @@ files:
2578
2586
  - app/views/hyrax/base/_file_manager_thumbnail.html.erb
2579
2587
  - app/views/hyrax/base/_form.html.erb
2580
2588
  - app/views/hyrax/base/_form_child_work_relationships.html.erb
2581
- - app/views/hyrax/base/_form_collections_error.html.erb
2582
2589
  - app/views/hyrax/base/_form_files.html.erb
2583
2590
  - app/views/hyrax/base/_form_in_works.html.erb
2584
- - app/views/hyrax/base/_form_in_works_error.html.erb
2585
2591
  - app/views/hyrax/base/_form_media.html.erb
2586
2592
  - app/views/hyrax/base/_form_member_of_collections.html.erb
2587
2593
  - app/views/hyrax/base/_form_metadata.html.erb
2588
- - app/views/hyrax/base/_form_ordered_members_error.html.erb
2589
2594
  - app/views/hyrax/base/_form_permission.html.erb
2590
2595
  - app/views/hyrax/base/_form_permission_embargo.html.erb
2591
2596
  - app/views/hyrax/base/_form_permission_lease.html.erb
@@ -2598,7 +2603,6 @@ files:
2598
2603
  - app/views/hyrax/base/_form_share.html.erb
2599
2604
  - app/views/hyrax/base/_form_thumbnail.html.erb
2600
2605
  - app/views/hyrax/base/_form_visibility_component.html.erb
2601
- - app/views/hyrax/base/_form_visibility_error.html.erb
2602
2606
  - app/views/hyrax/base/_guts4form.html.erb
2603
2607
  - app/views/hyrax/base/_items.html.erb
2604
2608
  - app/views/hyrax/base/_member.html.erb
@@ -3192,6 +3196,7 @@ files:
3192
3196
  - lib/hyrax/transactions/steps/add_to_collections.rb
3193
3197
  - lib/hyrax/transactions/steps/add_to_parent.rb
3194
3198
  - lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
3199
+ - lib/hyrax/transactions/steps/apply_permission_template.rb
3195
3200
  - lib/hyrax/transactions/steps/change_depositor.rb
3196
3201
  - lib/hyrax/transactions/steps/check_for_empty_admin_set.rb
3197
3202
  - lib/hyrax/transactions/steps/delete_access_control.rb
@@ -3303,14 +3308,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
3303
3308
  requirements:
3304
3309
  - - ">="
3305
3310
  - !ruby/object:Gem::Version
3306
- version: '2.7'
3311
+ version: '3.2'
3307
3312
  required_rubygems_version: !ruby/object:Gem::Requirement
3308
3313
  requirements:
3309
3314
  - - ">"
3310
3315
  - !ruby/object:Gem::Version
3311
3316
  version: 1.3.1
3312
3317
  requirements: []
3313
- rubygems_version: 3.4.12
3318
+ rubygems_version: 3.4.17
3314
3319
  signing_key:
3315
3320
  specification_version: 4
3316
3321
  summary: Hyrax is a front-end based on the robust Samvera framework, providing a user
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
- module Hyrax
3
- module Forms
4
- class FileManagerForm
5
- include HydraEditor::Form
6
- self.terms = []
7
- delegate :id, :thumbnail_id, :representative_id, :to_s, to: :model
8
- attr_reader :current_ability, :request
9
-
10
- ##
11
- # @param work [Object] a work with members
12
- # @param ability [::Ability] the current ability
13
- # @param member_factory [Class] the member_presenter factory object to use
14
- # when constructing presenters
15
- def initialize(work, ability, member_factory: MemberPresenterFactory)
16
- super(work)
17
- @current_ability = ability
18
- @request = nil
19
- @member_factory = member_factory
20
- end
21
-
22
- def version
23
- model.etag
24
- end
25
-
26
- delegate :member_presenters, to: :member_presenter_factory
27
-
28
- private
29
-
30
- def member_presenter_factory
31
- @member_factory.new(model, current_ability)
32
- end
33
- end
34
- end
35
- end