hyrax 4.0.0 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +116 -231
  3. data/.dassie/.env +3 -1
  4. data/.dassie/config/environments/test.rb +1 -0
  5. data/.dassie/config/initializers/hyrax.rb +3 -1
  6. data/.dassie/config/initializers/riiif.rb +13 -3
  7. data/.dassie/db/schema.rb +2 -2
  8. data/.dockerignore +6 -0
  9. data/.github/PULL_REQUEST_TEMPLATE.md +10 -7
  10. data/.github/release.yml +5 -2
  11. data/.koppie/.env +3 -0
  12. data/.koppie/app/forms/collection_resource_form.rb +1 -0
  13. data/.koppie/app/indexers/collection_resource_indexer.rb +1 -0
  14. data/.koppie/app/models/collection_resource.rb +1 -0
  15. data/.koppie/config/environments/test.rb +1 -0
  16. data/.koppie/config/initializers/hyrax.rb +8 -2
  17. data/.koppie/config/initializers/riiif.rb +13 -4
  18. data/.koppie/config/metadata/collection_resource.yaml +1 -128
  19. data/.koppie/yarn.lock +23 -23
  20. data/.regen +1 -1
  21. data/CONTAINERS.md +1 -1
  22. data/Dockerfile +6 -11
  23. data/app/actors/hyrax/actors/base_actor.rb +4 -3
  24. data/app/actors/hyrax/actors/embargo_actor.rb +5 -2
  25. data/app/actors/hyrax/actors/lease_actor.rb +5 -2
  26. data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
  27. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +1 -1
  28. data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +74 -0
  29. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +14 -5
  30. data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
  31. data/app/controllers/hyrax/batch_edits_controller.rb +33 -4
  32. data/app/controllers/hyrax/downloads_controller.rb +8 -1
  33. data/app/controllers/hyrax/file_sets_controller.rb +1 -0
  34. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  35. data/app/forms/hyrax/forms/permission_template_form.rb +2 -0
  36. data/app/forms/hyrax/forms/resource_batch_edit_form.rb +90 -0
  37. data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
  38. data/app/forms/hyrax/forms/work_form.rb +1 -1
  39. data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
  40. data/app/helpers/hyrax/dashboard_helper_behavior.rb +17 -9
  41. data/app/helpers/hyrax/membership_helper.rb +13 -1
  42. data/app/helpers/hyrax/work_form_helper.rb +0 -107
  43. data/app/indexers/hyrax/file_set_indexer.rb +6 -0
  44. data/app/indexers/hyrax/pcdm_collection_indexer.rb +8 -0
  45. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +41 -5
  46. data/app/indexers/hyrax/valkyrie_work_indexer.rb +8 -2
  47. data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
  48. data/app/jobs/valkyrie_ingest_job.rb +0 -1
  49. data/app/models/admin_set.rb +1 -31
  50. data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
  51. data/app/models/concerns/hyrax/solr_document_behavior.rb +1 -1
  52. data/app/models/hyrax/collection_type.rb +5 -14
  53. data/app/models/hyrax/file_metadata.rb +6 -7
  54. data/app/models/hyrax/file_set.rb +8 -0
  55. data/app/models/hyrax/resource.rb +30 -2
  56. data/app/presenters/hyrax/file_set_presenter.rb +6 -0
  57. data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
  58. data/app/presenters/hyrax/presenter_renderer.rb +0 -7
  59. data/app/presenters/hyrax/work_show_presenter.rb +6 -11
  60. data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
  61. data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
  62. data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
  63. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +11 -9
  64. data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
  65. data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
  66. data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
  67. data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
  68. data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
  69. data/app/services/hyrax/derivative_path.rb +14 -4
  70. data/app/services/hyrax/embargo_manager.rb +76 -10
  71. data/app/services/hyrax/file_set_derivatives_service.rb +3 -2
  72. data/app/services/hyrax/lease_manager.rb +88 -8
  73. data/app/services/hyrax/listeners/file_metadata_listener.rb +2 -2
  74. data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
  75. data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
  76. data/app/services/hyrax/solr_query_service.rb +7 -6
  77. data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
  78. data/app/services/hyrax/statistics/over_time.rb +1 -1
  79. data/app/services/hyrax/statistics/users/over_time.rb +3 -1
  80. data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
  81. data/app/services/hyrax/statistics/works/count.rb +1 -1
  82. data/app/services/hyrax/thumbnail_path_service.rb +5 -0
  83. data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
  84. data/app/services/hyrax/valkyrie_upload.rb +5 -3
  85. data/app/services/hyrax/versioning_service.rb +1 -0
  86. data/app/services/hyrax/visibility_intention.rb +1 -4
  87. data/app/services/hyrax/visibility_propagator.rb +1 -1
  88. data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
  89. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
  90. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
  91. data/app/services/hyrax/workflow/permission_query.rb +23 -2
  92. data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
  93. data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
  94. data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
  95. data/app/views/hyrax/base/_form.html.erb +0 -10
  96. data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
  97. data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
  98. data/app/views/hyrax/base/_form_visibility_component.html.erb +2 -2
  99. data/app/views/hyrax/base/_items.html.erb +1 -1
  100. data/app/views/hyrax/base/file_manager.html.erb +1 -1
  101. data/app/views/hyrax/base/show.json.jbuilder +2 -2
  102. data/app/views/hyrax/file_sets/show.html.erb +5 -3
  103. data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
  104. data/chart/hyrax/Chart.yaml +18 -14
  105. data/chart/hyrax/README.md +34 -21
  106. data/chart/hyrax/templates/_helpers.tpl +26 -1
  107. data/chart/hyrax/templates/configmap-env.yaml +12 -2
  108. data/chart/hyrax/templates/secrets.yaml +1 -1
  109. data/chart/hyrax/values.yaml +36 -14
  110. data/config/initializers/listeners.rb +4 -10
  111. data/config/initializers/storage_adapter_initializer.rb +1 -1
  112. data/config/locales/hyrax.en.yml +8 -0
  113. data/config/metadata/file_set_metadata.yaml +1 -1
  114. data/docker-compose-koppie.yml +17 -4
  115. data/docker-compose.yml +19 -6
  116. data/documentation/developing-your-hyrax-based-app.md +6 -14
  117. data/documentation/legacyREADME.md +3 -1
  118. data/hyrax.gemspec +2 -2
  119. data/karma.conf.js +8 -9
  120. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  121. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +15 -5
  122. data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
  123. data/lib/hyrax/configuration.rb +6 -0
  124. data/lib/hyrax/engine.rb +2 -0
  125. data/lib/hyrax/publisher.rb +19 -3
  126. data/lib/hyrax/specs/capybara.rb +9 -4
  127. data/lib/hyrax/transactions/container.rb +5 -0
  128. data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
  129. data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
  130. data/lib/hyrax/transactions/steps/save.rb +21 -0
  131. data/lib/hyrax/transactions/work_create.rb +1 -0
  132. data/lib/hyrax/version.rb +1 -1
  133. data/lib/hyrax.rb +1 -0
  134. data/lib/wings/active_fedora_converter/default_work.rb +7 -2
  135. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  136. data/lib/wings/active_fedora_converter.rb +47 -11
  137. data/lib/wings/model_transformer.rb +23 -4
  138. data/lib/wings/setup.rb +21 -1
  139. data/lib/wings/valkyrie/persister.rb +4 -2
  140. data/package.json +3 -1
  141. data/template.rb +1 -1
  142. metadata +17 -12
  143. data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
  144. data/app/services/hyrax/collections/migration_service.rb +0 -113
  145. data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
  146. data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
  147. data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
  148. data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
@@ -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'
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'
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
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-30 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
- version: '0'
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
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
- module Hyrax
3
- module Collections
4
- ##
5
- # @deprecated this migration tool should no longer be useful after Hyrax 2.1.0; Removal is planned for 4.0
6
- # Responsible for migrating legacy collections. Legacy collections are those created before Hyrax 2.1.0 and
7
- # are identified by the lack of the collection having a collection type gid.
8
- class MigrationService
9
- # @api public
10
- #
11
- # Migrate all legacy collections to extended collections with collection type assigned. Legacy collections are those
12
- # created before Hyrax 2.1.0 and are identified by the lack of the collection having a collection type gid.
13
- def self.migrate_all_collections
14
- Deprecation.warn('This migration tool will be removed in Hyrax 4.0.0.')
15
-
16
- Hyrax.logger.info "*** Migrating #{::Collection.count} collections"
17
- ::Collection.all.each do |col|
18
- migrate_collection(col)
19
- Hyrax.logger.info " migrating collection - id: #{col.id}, title: #{col.title}"
20
- end
21
-
22
- AdminSet.all.each do |adminset|
23
- migrate_adminset(adminset)
24
- Hyrax.logger.info " migrating adminset - id: #{adminset.id}, title: #{adminset.title}"
25
- end
26
- Hyrax.logger.info "--- Migration Complete"
27
- end
28
-
29
- # @api private
30
- #
31
- # Migrate a single legacy collection to extended collections with collection type assigned. Legacy collections are those
32
- # created before Hyrax 2.1.0 and are identified by the lack of the collection having a collection type gid.
33
- #
34
- # @param collection [::Collection] collection object to be migrated
35
- def self.migrate_collection(collection)
36
- return if collection.collection_type_gid.present? # already migrated
37
- collection.collection_type_gid = Hyrax::CollectionType.find_or_create_default_collection_type.to_global_id
38
- create_permissions(collection)
39
- collection.save
40
- end
41
- private_class_method :migrate_collection
42
-
43
- ##
44
- # @api private
45
- #
46
- # Migrate a single adminset to grant depositors and viewers read access to the admin set unless the grant is for
47
- # registered (authenticated users) or public (anyone) groups. The adjustment is being made to adminsets created
48
- # before Hyrax 2.1.0. Migrating twice will not adversely impact the adminset.
49
- #
50
- # @param adminset [AdminSet] adminset object to be migrated
51
- def self.migrate_adminset(adminset)
52
- Hyrax::PermissionTemplateAccess.find_or_create_by(permission_template_id: adminset.permission_template.id,
53
- agent_type: "group", agent_id: "admin", access: "manage")
54
-
55
- adminset.permission_template.reset_access_controls_for(collection: adminset)
56
- end
57
- private_class_method :migrate_adminset
58
-
59
- # @api public
60
- #
61
- # Validate that migrated collections have both the collection type gid assigned and the permission template with
62
- # access created and associated with the collection. Any collection without collection type gid as nil or assigned
63
- # the default collection type are ignored.
64
- def self.repair_migrated_collections
65
- Deprecation.warn('This migration tool will be removed in Hyrax 4.0.0.')
66
-
67
- Hyrax.logger.info "*** Repairing migrated collections"
68
- ::Collection.all.each do |col|
69
- repair_migrated_collection(col)
70
- Hyrax.logger.info " repairing collection - id: #{col.id}, title: #{col.title}"
71
- end
72
- AdminSet.all.each do |adminset|
73
- migrate_adminset(adminset)
74
- Hyrax.logger.info " repairing adminset - id: #{adminset.id}, title: #{adminset.title}"
75
- end
76
- Hyrax.logger.info "--- Repairing Complete"
77
- end
78
-
79
- # @api private
80
- #
81
- # Validate and repair a migrated collection if needed.
82
- #
83
- # @param collection [::Collection] collection object to be migrated/repaired
84
- def self.repair_migrated_collection(collection)
85
- return if collection.collection_type_gid.present? && collection.collection_type_gid != Hyrax::CollectionType.find_or_create_default_collection_type.to_global_id
86
- collection.collection_type_gid = Hyrax::CollectionType.find_or_create_default_collection_type.to_global_id
87
- permission_template = Hyrax::PermissionTemplate.find_by(source_id: collection.id)
88
- if permission_template.present?
89
- permission_template.reset_access_controls_for(collection: collection, interpret_visibility: true)
90
- else
91
- create_permissions(collection)
92
- end
93
- collection.save
94
- end
95
- private_class_method :repair_migrated_collection
96
-
97
- # @api private
98
- #
99
- # Determine if collection was already migrated.
100
- #
101
- # @param [Collection] collection object to be validated
102
- def self.create_permissions(collection)
103
- grants = []
104
- collection.edit_groups.each { |g| grants << { agent_type: 'group', agent_id: g, access: Hyrax::PermissionTemplateAccess::MANAGE } }
105
- collection.edit_users.each { |u| grants << { agent_type: 'user', agent_id: u, access: Hyrax::PermissionTemplateAccess::MANAGE } }
106
- collection.read_groups.each { |g| grants << { agent_type: 'group', agent_id: g, access: Hyrax::PermissionTemplateAccess::VIEW } }
107
- collection.read_users.each { |u| grants << { agent_type: 'user', agent_id: u, access: Hyrax::PermissionTemplateAccess::VIEW } }
108
- Hyrax::Collections::PermissionsCreateService.create_default(collection: collection, creating_user: ::User.find_by_user_key(collection.depositor), grants: grants)
109
- end
110
- private_class_method :create_permissions
111
- end
112
- end
113
- end
@@ -1 +0,0 @@
1
- <%= full_collections_errors(form: f) %>