hyrax 4.0.0.beta2 → 4.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +126 -53
  3. data/.dassie/Gemfile +1 -1
  4. data/.dassie/app/controllers/catalog_controller.rb +1 -1
  5. data/.dassie/config/initializers/hyrax.rb +4 -0
  6. data/.github/CONTRIBUTING.md +39 -27
  7. data/.github/SUPPORT.md +2 -3
  8. data/.github/workflows/main.yml +4 -4
  9. data/.github/workflows/release.yml +10 -4
  10. data/.koppie/Gemfile +1 -2
  11. data/.koppie/app/controllers/catalog_controller.rb +1 -1
  12. data/.koppie/config/authorities/licenses.yml +7 -7
  13. data/.koppie/config/initializers/file_services.rb +4 -0
  14. data/.koppie/db/schema.rb +2 -2
  15. data/.koppie/yarn.lock +1 -1
  16. data/.regen +1 -1
  17. data/CONTAINERS.md +5 -5
  18. data/CONTRIBUTING.md +2 -2
  19. data/Dockerfile +21 -9
  20. data/README.md +24 -97
  21. data/app/actors/hyrax/actors/create_with_files_actor.rb +1 -1
  22. data/app/assets/stylesheets/hyrax/_catalog.scss +4 -0
  23. data/app/assets/stylesheets/hyrax/_forms.scss +4 -0
  24. data/app/controllers/concerns/hyrax/controller.rb +3 -24
  25. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -0
  26. data/app/controllers/hyrax/admin/strategies_controller.rb +2 -2
  27. data/app/controllers/hyrax/dashboard/collections_controller.rb +1 -1
  28. data/app/controllers/hyrax/downloads_controller.rb +16 -1
  29. data/app/controllers/hyrax/file_sets_controller.rb +9 -2
  30. data/app/controllers/hyrax/my/works_controller.rb +3 -1
  31. data/app/controllers/hyrax/transfers_controller.rb +4 -1
  32. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -2
  33. data/app/forms/hyrax/forms/administrative_set_form.rb +1 -1
  34. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  35. data/app/forms/hyrax/forms/file_set_form.rb +8 -35
  36. data/app/forms/hyrax/forms/pcdm_collection_form.rb +2 -2
  37. data/app/forms/hyrax/forms/pcdm_object_form.rb +46 -0
  38. data/app/forms/hyrax/forms/permission.rb +2 -2
  39. data/app/forms/hyrax/forms/resource_form.rb +19 -44
  40. data/app/forms/hyrax/forms/work_embargo_form.rb +3 -3
  41. data/app/forms/hyrax/forms/work_lease_form.rb +3 -3
  42. data/app/helpers/hyrax/content_block_helper_behavior.rb +1 -1
  43. data/app/helpers/hyrax/hyrax_helper_behavior.rb +1 -1
  44. data/app/helpers/hyrax/iiif_helper.rb +1 -1
  45. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +1 -1
  46. data/app/jobs/characterize_job.rb +3 -2
  47. data/app/jobs/valkyrie_create_derivatives_job.rb +0 -2
  48. data/app/models/collection_branding_info.rb +7 -13
  49. data/app/models/concerns/hyrax/ability.rb +1 -1
  50. data/app/models/concerns/hyrax/collection_behavior.rb +0 -47
  51. data/app/models/concerns/hyrax/solr_document/metadata.rb +1 -0
  52. data/app/models/concerns/hyrax/suppressible.rb +0 -8
  53. data/app/models/file_download_stat.rb +4 -4
  54. data/app/models/hyrax/collection_type.rb +0 -16
  55. data/app/models/hyrax/file_metadata.rb +5 -12
  56. data/app/models/hyrax/file_set.rb +1 -9
  57. data/app/models/hyrax/permission_template.rb +1 -1
  58. data/app/models/hyrax/statistic.rb +4 -4
  59. data/app/models/sipity.rb +27 -6
  60. data/app/presenters/hyrax/collection_presenter.rb +1 -1
  61. data/app/presenters/hyrax/iiif_manifest_presenter.rb +15 -5
  62. data/app/presenters/hyrax/presenter_factory.rb +2 -2
  63. data/app/presenters/hyrax/work_show_presenter.rb +1 -1
  64. data/app/presenters/hyrax/workflow_presenter.rb +1 -1
  65. data/app/search_builders/hyrax/collection_search_builder.rb +1 -0
  66. data/app/search_builders/hyrax/filter_suppressed_with_roles.rb +1 -1
  67. data/app/services/hyrax/admin_set_service.rb +1 -1
  68. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -2
  69. data/app/services/hyrax/database_migrator.rb +1 -1
  70. data/app/services/hyrax/edit_permissions_service.rb +21 -3
  71. data/app/services/hyrax/restriction_service.rb +1 -1
  72. data/app/services/hyrax/solr_query_service.rb +10 -2
  73. data/app/services/hyrax/solr_service.rb +24 -18
  74. data/app/services/hyrax/thumbnail_path_service.rb +10 -2
  75. data/app/services/hyrax/valkyrie_persist_derivatives.rb +26 -15
  76. data/app/services/hyrax/valkyrie_upload.rb +23 -30
  77. data/app/services/hyrax/visibility_propagator.rb +5 -5
  78. data/app/services/hyrax/visibility_reader.rb +1 -1
  79. data/app/services/hyrax/visibility_writer.rb +1 -1
  80. data/app/services/hyrax/workflow/permission_query.rb +5 -5
  81. data/app/services/hyrax/workflow/status_list_service.rb +1 -1
  82. data/app/validators/hyrax/collection_membership_validator.rb +2 -2
  83. data/app/views/hyrax/base/_attribute_rows.html.erb +2 -0
  84. data/app/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb +1 -1
  85. data/app/views/hyrax/file_sets/_permission.html.erb +1 -1
  86. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  87. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  88. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  89. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  90. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  91. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  92. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  93. data/app/views/hyrax/uploads/_js_templates.html.erb +8 -8
  94. data/app/views/hyrax/uploads/_js_templates_branding.html.erb +2 -2
  95. data/app/views/hyrax/users/_vitals.html.erb +4 -4
  96. data/chart/hyrax/Chart.yaml +7 -7
  97. data/chart/hyrax/README.md +5 -0
  98. data/chart/hyrax/templates/_helpers.tpl +14 -6
  99. data/chart/hyrax/templates/cron-embargo.yaml +1 -1
  100. data/chart/hyrax/templates/cron-lease.yaml +1 -1
  101. data/chart/hyrax/templates/deployment-worker.yaml +2 -2
  102. data/chart/hyrax/templates/extra-list.yaml +8 -0
  103. data/chart/hyrax/templates/secrets.yaml +3 -3
  104. data/chart/hyrax/values.yaml +22 -15
  105. data/config/initializers/kaminari_engine_patch.rb +16 -0
  106. data/config/locales/hyrax.de.yml +7 -7
  107. data/config/locales/hyrax.es.yml +7 -7
  108. data/config/locales/hyrax.fr.yml +8 -8
  109. data/config/locales/hyrax.it.yml +7 -7
  110. data/config/locales/hyrax.pt-BR.yml +7 -7
  111. data/config/locales/hyrax.zh.yml +8 -8
  112. data/config/metadata/file_set_metadata.yaml +130 -0
  113. data/documentation/MAINTENANCE.md +77 -0
  114. data/documentation/developing-your-hyrax-based-app.md +2 -2
  115. data/documentation/legacyREADME.md +3 -3
  116. data/hyrax.gemspec +7 -10
  117. data/lib/generators/hyrax/templates/catalog_controller.rb +1 -1
  118. data/lib/hyrax/configuration.rb +16 -0
  119. data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +1 -1
  120. data/lib/hyrax/engine.rb +2 -1
  121. data/lib/hyrax/transactions/container.rb +0 -2
  122. data/lib/hyrax/transactions/steps/save_collection_banner.rb +1 -1
  123. data/lib/hyrax/transactions/steps/save_collection_logo.rb +1 -1
  124. data/lib/hyrax/transactions/transaction.rb +3 -2
  125. data/lib/hyrax/version.rb +1 -1
  126. data/lib/hyrax.rb +0 -1
  127. data/lib/valkyrie/indexing/solr/indexing_adapter.rb +1 -1
  128. data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
  129. data/lib/wings/valkyrie/storage.rb +4 -1
  130. data/samvera-fall-TM3.svg +376 -0
  131. data/template.rb +1 -1
  132. metadata +43 -85
  133. data/app/conversions/power_converters/polymorphic_type.rb +0 -9
  134. data/app/conversions/power_converters/sipity_action.rb +0 -11
  135. data/app/conversions/power_converters/sipity_action_name.rb +0 -10
  136. data/app/conversions/power_converters/sipity_agent.rb +0 -9
  137. data/app/conversions/power_converters/sipity_entity.rb +0 -14
  138. data/app/conversions/power_converters/sipity_role.rb +0 -10
  139. data/app/conversions/power_converters/sipity_workflow_id.rb +0 -17
  140. data/app/conversions/power_converters/sipity_workflow_state.rb +0 -13
  141. data/app/conversions/power_converters.rb +0 -7
@@ -11,12 +11,16 @@ module Hyrax
11
11
  # # other WorkForm-like configuration here
12
12
  # end
13
13
  #
14
+ # @note The returned class will extend +Hyrax::Forms::PcdmObjectForm+, not
15
+ # only +Hyrax::Forms::ResourceForm+. This is for backwards‐compatibility
16
+ # with existing Hyrax instances and satisfies the expected general use
17
+ # case (building forms for various PCDM object classes), but is *not*
18
+ # necessarily suitable for other kinds of Hyrax resource, like
19
+ # +Hyrax::FileSet+s.
14
20
  def self.ResourceForm(work_class)
15
- Class.new(Hyrax::Forms::ResourceForm) do
21
+ Class.new(Hyrax::Forms::PcdmObjectForm) do
16
22
  self.model_class = work_class
17
23
 
18
- include Hyrax::FormFields(:core_metadata)
19
-
20
24
  ##
21
25
  # @return [String]
22
26
  def self.inspect
@@ -29,11 +33,11 @@ module Hyrax
29
33
  ##
30
34
  # @api public
31
35
  #
32
- # This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
36
+ # This form wraps +Hyrax::ChangeSet+ in the +HydraEditor::Form+ interface.
33
37
  class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength
34
38
  ##
35
39
  # @api private
36
- InWorksPrepopulator = lambda do |_options|
40
+ InWorksPrepopulator = proc do |_options|
37
41
  self.in_works_ids =
38
42
  if persisted?
39
43
  Hyrax.query_service
@@ -52,7 +56,7 @@ module Hyrax
52
56
  # with `etag`-driven, application-side lock checks. for non-wings adapters
53
57
  # we want to move away from application side lock validation and rely
54
58
  # on the adapter/database features instead.
55
- LockKeyPrepopulator = lambda do |_options|
59
+ LockKeyPrepopulator = proc do |_options|
56
60
  if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
57
61
  Hyrax.logger.info "trying to prepopulate a lock token for " \
58
62
  "#{self.class.inspect}, but optimistic locking isn't " \
@@ -69,45 +73,33 @@ module Hyrax
69
73
  property :human_readable_type, writable: false
70
74
 
71
75
  property :depositor
72
- property :on_behalf_of
73
- property :proxy_depositor
74
76
 
75
77
  property :visibility, default: VisibilityIntention::PRIVATE, populator: :visibility_populator
76
78
 
77
79
  property :date_modified, readable: false
78
80
  property :date_uploaded, readable: false
79
- property :agreement_accepted, virtual: true, default: false, prepopulator: ->(_opts) { self.agreement_accepted = !model.new_record }
81
+ property :agreement_accepted, virtual: true, default: false, prepopulator: proc { |_opts| self.agreement_accepted = !model.new_record }
80
82
 
81
83
  collection(:permissions,
82
84
  virtual: true,
83
85
  default: [],
84
86
  form: Hyrax::Forms::Permission,
85
87
  populator: :permission_populator,
86
- prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
88
+ prepopulator: proc { |_opts| self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
87
89
 
88
90
  property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator
89
91
  property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator
90
92
 
91
93
  # virtual properties for embargo/lease;
92
- property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date }
93
- property :visibility_after_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
94
- property :visibility_during_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_during_embargo = model.embargo&.visibility_during_embargo }
94
+ property :embargo_release_date, virtual: true, prepopulator: proc { |_opts| self.embargo_release_date = model.embargo&.embargo_release_date }
95
+ property :visibility_after_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
96
+ property :visibility_during_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_during_embargo = model.embargo&.visibility_during_embargo }
95
97
 
96
- property :lease_expiration_date, virtual: true, prepopulator: ->(_opts) { self.lease_expiration_date = model.lease&.lease_expiration_date }
97
- property :visibility_after_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_after_lease = model.lease&.visibility_after_lease }
98
- property :visibility_during_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_during_lease = model.lease&.visibility_during_lease }
98
+ property :lease_expiration_date, virtual: true, prepopulator: proc { |_opts| self.lease_expiration_date = model.lease&.lease_expiration_date }
99
+ property :visibility_after_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_after_lease = model.lease&.visibility_after_lease }
100
+ property :visibility_during_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_during_lease = model.lease&.visibility_during_lease }
99
101
 
100
- # pcdm relationships
101
- property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s }
102
102
  property :in_works_ids, virtual: true, prepopulator: InWorksPrepopulator
103
- property :member_ids, default: [], type: Valkyrie::Types::Array
104
- property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
105
- property :member_of_collections_attributes, virtual: true, populator: :in_collections_populator
106
- validates_with CollectionMembershipValidator
107
-
108
- property :representative_id, type: Valkyrie::Types::String
109
- property :thumbnail_id, type: Valkyrie::Types::String
110
- property :rendering_ids, default: [], type: Valkyrie::Types::Array
111
103
 
112
104
  # provide a lock token for optimistic locking; we name this `version` for
113
105
  # backwards compatibility
@@ -119,10 +111,6 @@ module Hyrax
119
111
  # @see https://github.com/samvera/valkyrie/wiki/Optimistic-Locking
120
112
  property :version, virtual: true, prepopulator: LockKeyPrepopulator
121
113
 
122
- # backs the child work search element;
123
- # @todo: look for a way for the view template not to depend on this
124
- property :find_child_work, default: nil, virtual: true
125
-
126
114
  class << self
127
115
  ##
128
116
  # @api public
@@ -143,6 +131,7 @@ module Hyrax
143
131
  when Hyrax::PcdmCollection
144
132
  Hyrax::Forms::PcdmCollectionForm.new(resource)
145
133
  else
134
+ # NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
146
135
  Hyrax::Forms::ResourceForm(resource.class).new(resource)
147
136
  end
148
137
  end
@@ -219,20 +208,6 @@ module Hyrax
219
208
  self.lease = Hyrax::LeaseManager.lease_for(resource: model)
220
209
  end
221
210
 
222
- def in_collections_populator(fragment:, **_options)
223
- adds = []
224
- deletes = []
225
- fragment.each do |_, h|
226
- if h["_destroy"] == "true"
227
- deletes << Valkyrie::ID.new(h["id"])
228
- else
229
- adds << Valkyrie::ID.new(h["id"])
230
- end
231
- end
232
-
233
- self.member_of_collection_ids = ((member_of_collection_ids + adds) - deletes).uniq
234
- end
235
-
236
211
  # https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
237
212
  def permission_populator(collection:, index:, **)
238
213
  Hyrax::Forms::Permission.new(collection[index])
@@ -11,9 +11,9 @@ module Hyrax
11
11
  # +EmbargoesControllerBehavior+.
12
12
  class WorkEmbargoForm < Hyrax::ChangeSet
13
13
  property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator, prepopulator: :embargo_populator
14
- property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date }
15
- property :visibility_after_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
16
- property :visibility_during_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_during_embargo = model.embargo&.visibility_during_embargo }
14
+ property :embargo_release_date, virtual: true, prepopulator: proc { |_opts| self.embargo_release_date = model.embargo&.embargo_release_date }
15
+ property :visibility_after_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
16
+ property :visibility_during_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_during_embargo = model.embargo&.visibility_during_embargo }
17
17
 
18
18
  def embargo_populator(**)
19
19
  self.embargo = Hyrax::EmbargoManager.embargo_for(resource: model)
@@ -11,9 +11,9 @@ module Hyrax
11
11
  # +LeasesControllerBehavior+.
12
12
  class WorkLeaseForm < Hyrax::ChangeSet
13
13
  property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator, prepopulator: :lease_populator
14
- property :lease_expiration_date, virtual: true, prepopulator: ->(_opts) { self.lease_expiration_date = model.lease&.lease_expiration_date }
15
- property :visibility_after_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_after_lease = model.lease&.visibility_after_lease }
16
- property :visibility_during_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_during_lease = model.lease&.visibility_during_lease }
14
+ property :lease_expiration_date, virtual: true, prepopulator: proc { |_opts| self.lease_expiration_date = model.lease&.lease_expiration_date }
15
+ property :visibility_after_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_after_lease = model.lease&.visibility_after_lease }
16
+ property :visibility_during_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_during_lease = model.lease&.visibility_during_lease }
17
17
 
18
18
  def lease_populator(**)
19
19
  self.lease = Hyrax::LeaseManager.lease_for(resource: model)
@@ -3,7 +3,7 @@ module Hyrax
3
3
  module ContentBlockHelperBehavior
4
4
  def displayable_content_block(content_block, **options)
5
5
  return unless display_content_block? content_block
6
- tag.div raw(content_block.value), options
6
+ tag.div(raw(content_block.value), **options)
7
7
  end
8
8
 
9
9
  def display_content_block?(content_block)
@@ -289,7 +289,7 @@ module Hyrax
289
289
  end
290
290
 
291
291
  def collection_title_by_id(id)
292
- solr_docs = controller.repository.find(id).docs
292
+ solr_docs = controller.blacklight_config.repository.find(id).docs
293
293
  return nil if solr_docs.empty?
294
294
  solr_field = solr_docs.first["title_tesim"]
295
295
  return nil if solr_field.nil?
@@ -3,7 +3,7 @@ module Hyrax
3
3
  module IiifHelper
4
4
  def iiif_viewer_display(work_presenter, locals = {})
5
5
  render iiif_viewer_display_partial(work_presenter),
6
- locals.merge(presenter: work_presenter)
6
+ **locals.merge(presenter: work_presenter)
7
7
  end
8
8
 
9
9
  def iiif_viewer_display_partial(work_presenter)
@@ -9,7 +9,7 @@ module Hyrax
9
9
  include Hyrax::VisibilityIndexer
10
10
  include Hyrax::ThumbnailIndexer
11
11
  include Hyrax::Indexer(:core_metadata)
12
- include Hyrax::Indexer(:basic_metadata)
12
+ include Hyrax::Indexer(:file_set_metadata)
13
13
 
14
14
  def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
15
15
  super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength
@@ -65,8 +65,9 @@ class CharacterizeJob < Hyrax::ApplicationJob
65
65
  # mod time. This is done in the versioning code.
66
66
  file_set.date_modified = Hyrax::TimeService.time_in_utc if file_set.characterization_proxy.original_checksum.first != previous_checksum
67
67
 
68
- # set title to label if that's how it was before this characterization
69
- file_set.title = [file_set.characterization_proxy.original_name.force_encoding("UTF-8")] if reset_title
68
+ file_set.characterization_proxy.original_name.force_encoding("UTF-8")
69
+ # set title to label (i.e. file name, `original_name`) if that's how it was before this characterization
70
+ file_set.title = [file_set.characterization_proxy.original_name] if reset_title
70
71
  # always set the label to the original_name
71
72
  file_set.label = file_set.characterization_proxy.original_name
72
73
 
@@ -9,8 +9,6 @@ class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
9
9
  # Call derivatives with the file_set.
10
10
  derivative_service = Hyrax::DerivativeService.for(file_metadata)
11
11
  derivative_service.create_derivatives(file.disk_path)
12
- # Trigger a reindex to get the thumbnail path.
13
- Hyrax.publisher.publish('file.metadata.updated', metadata: file_metadata, user: nil)
14
12
  end
15
13
 
16
14
  private
@@ -1,18 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  class CollectionBrandingInfo < ApplicationRecord
3
- def initialize(collection_id:,
4
- filename:,
5
- role:,
6
- alt_txt: "",
7
- target_url: "")
8
-
9
- super()
10
- self.collection_id = collection_id
11
- self.role = role
12
- self.alt_text = alt_txt
13
- self.target_url = target_url
14
- self.local_path = File.join(role, filename)
15
- end
3
+ attr_accessor :filename, :alt_txt
4
+ after_initialize :set_collection_attributes
16
5
 
17
6
  def save(file_location, upload_file = true)
18
7
  filename = File.split(local_path).last
@@ -52,6 +41,11 @@ class CollectionBrandingInfo < ApplicationRecord
52
41
 
53
42
  private
54
43
 
44
+ def set_collection_attributes
45
+ self.alt_text ||= alt_txt || ''
46
+ self.local_path ||= File.join(role, filename)
47
+ end
48
+
55
49
  def storage
56
50
  Hyrax.config.branding_storage_adapter
57
51
  end
@@ -414,7 +414,7 @@ module Hyrax
414
414
  # @param document_id [String] the id of the document.
415
415
  def user_is_depositor?(document_id)
416
416
  doc = Hyrax::SolrService.search_by_id(document_id, fl: 'depositor_ssim')
417
- current_user.user_key == doc.fetch('depositor_ssim').first
417
+ current_user.user_key == doc['depositor_ssim']&.first
418
418
  end
419
419
 
420
420
  def curation_concerns_models
@@ -52,25 +52,6 @@ module Hyrax
52
52
  self.collection_type_gid = new_collection_type.to_global_id
53
53
  end
54
54
 
55
- # Add members using the members association.
56
- def add_members(new_member_ids)
57
- Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
58
- "Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
59
- Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
60
- new_member_ids: new_member_ids,
61
- user: nil)
62
- end
63
-
64
- # Add member objects by adding this collection to the objects' member_of_collection association.
65
- # @param [Enumerable<String>] the ids of the new child collections and works collection ids
66
- def add_member_objects(new_member_ids)
67
- Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
68
- "Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
69
- Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
70
- new_member_ids: new_member_ids,
71
- user: nil)
72
- end
73
-
74
55
  # @return [Enumerable<ActiveFedora::Base>] an enumerable over the children of this collection
75
56
  def member_objects
76
57
  ActiveFedora::Base.where("member_of_collection_ids_ssim:#{id}")
@@ -96,22 +77,6 @@ module Hyrax
96
77
  "hyrax/#{collection}/#{element}"
97
78
  end
98
79
  end
99
-
100
- def collection_type_gid_document_field_name
101
- Deprecation.warn('use Hyrax.config.collection_type_index_field instead')
102
- Hyrax.config.collection_type_index_field
103
- end
104
- end
105
-
106
- # @deprecated to be removed in 4.0.0; this feature was replaced with a
107
- # hard-coded null implementation
108
- # @return [Fixnum] 0
109
- def bytes
110
- Deprecation.warn('#bytes has been deprecated for removal in Hyrax 4.0.0; ' \
111
- 'The implementation of the indexed Collection size ' \
112
- 'feature is extremely inefficient, so it has been removed. ' \
113
- 'This method now returns a hard-coded `0` for compatibility.')
114
- 0
115
80
  end
116
81
 
117
82
  # @api public
@@ -122,18 +87,6 @@ module Hyrax
122
87
  Hyrax::PermissionTemplate.find_by!(source_id: id)
123
88
  end
124
89
 
125
- ##
126
- # @deprecated use PermissionTemplate#reset_access_controls_for instead
127
- #
128
- # Calculate and update who should have read/edit access to the collections based on who
129
- # has access in PermissionTemplateAccess
130
- def reset_access_controls!
131
- Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
132
-
133
- permission_template
134
- .reset_access_controls_for(collection: self, interpret_visibility: true)
135
- end
136
-
137
90
  private
138
91
 
139
92
  # Solr field name works use to index member ids
@@ -69,6 +69,7 @@ module Hyrax
69
69
  attribute :date_created, Solr::Array, "date_created_tesim"
70
70
  attribute :rights_statement, Solr::Array, "rights_statement_tesim"
71
71
  attribute :rights_notes, Solr::Array, "rights_notes_tesim"
72
+ attribute :bibliographic_citation, Solr::Array, "bibliographic_citation_tesim"
72
73
  attribute :access_right, Solr::Array, "access_right_tesim"
73
74
  attribute :mime_type, Solr::String, "mime_type_ssi"
74
75
  attribute :workflow_state, Solr::String, "workflow_state_name_ssim"
@@ -22,13 +22,5 @@ module Hyrax
22
22
  def suppressed?
23
23
  Hyrax::ResourceStatus.new(resource: self).inactive?
24
24
  end
25
-
26
- ##
27
- # @deprecated Use `Sipity::Entity(entity)` instead.
28
- def to_sipity_entity
29
- Deprecation.warn "Use `Sipity::Entity(entity)` instead."
30
- raise "Can't create an entity until the model has been persisted" unless persisted?
31
- @sipity_entity ||= Sipity::Entity(to_global_id)
32
- end
33
25
  end
34
26
  end
@@ -12,10 +12,10 @@ class FileDownloadStat < Hyrax::Statistic
12
12
  Hyrax.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
13
13
  return []
14
14
  end
15
- profile.hyrax__analytics__google__download(sort: 'date',
16
- start_date: start_date,
17
- end_date: Date.yesterday,
18
- limit: 10_000)
15
+ profile.hyrax__download(sort: 'date',
16
+ start_date: start_date,
17
+ end_date: Date.yesterday,
18
+ limit: 10_000)
19
19
  .for_file(file.id)
20
20
  end
21
21
 
@@ -36,14 +36,6 @@ module Hyrax
36
36
  assign_machine_id
37
37
  end
38
38
 
39
- # this class attribute is deprecated in favor of {.settings_attributes}
40
- # these need to carefully align with boolean flag attributes/table columns,
41
- # so making it settable is a liability. deprecating is challenging because
42
- # +class_attribute+ calls +singleton_class.class_eval { redefine_method }+
43
- # as the +name=+ implementation. there should be few callers outside hyrax.
44
- class_attribute :collection_type_settings_methods, instance_writer: false
45
- self.collection_type_settings_methods = SETTINGS_ATTRIBUTES
46
-
47
39
  # These are provided as a convenience method based on prior design discussions.
48
40
  alias_attribute :discovery, :discoverable
49
41
  alias_attribute :sharing, :sharable
@@ -123,14 +115,6 @@ module Hyrax
123
115
  ActiveFedora::Base.where(Hyrax.config.collection_type_index_field.to_sym => to_global_id.to_s)
124
116
  end
125
117
 
126
- ##
127
- # @deprecated Use #collections.any? instead
128
- #
129
- # @return [Boolean] True if there is at least one collection of this type
130
- def collections?
131
- Deprecation.warn('Use #collections.any? instead.') && collections.any?
132
- end
133
-
134
118
  # @return [Boolean] True if this is the Admin Set type
135
119
  def admin_set?
136
120
  machine_id == ADMIN_SET_MACHINE_ID
@@ -13,11 +13,13 @@ module Hyrax
13
13
  file.is_a?(Valkyrie::Resource)
14
14
 
15
15
  Hyrax.custom_queries.find_file_metadata_by(id: file.id)
16
- rescue Hyrax::ObjectNotFoundError, Ldp::BadRequest
16
+ rescue Hyrax::ObjectNotFoundError, Ldp::BadRequest, Valkyrie::Persistence::ObjectNotFoundError
17
17
  Hyrax.logger.debug('Could not find an existing metadata node for file ' \
18
18
  "with id #{file.id}. Initializing a new one")
19
19
 
20
- FileMetadata.new(file_identifier: file.id, alternative_ids: [file.id])
20
+ FileMetadata.new(file_identifier: file.id,
21
+ alternative_ids: [file.id],
22
+ original_filename: File.basename(file.io))
21
23
  end
22
24
 
23
25
  class FileMetadata < Valkyrie::Resource
@@ -65,7 +67,7 @@ module Hyrax
65
67
  attribute :label, ::Valkyrie::Types::Set
66
68
  attribute :original_filename, ::Valkyrie::Types::String
67
69
  attribute :mime_type, ::Valkyrie::Types::String.default(GENERIC_MIME_TYPE)
68
- attribute :type, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze)
70
+ attribute :type, ::Valkyrie::Types::Set.default([Use::ORIGINAL_FILE].freeze) # Use += to add types, not <<
69
71
 
70
72
  # attributes set by fits
71
73
  attribute :format_label, ::Valkyrie::Types::Set
@@ -125,15 +127,6 @@ module Hyrax
125
127
  # attributes set by fits for video
126
128
  attribute :aspect_ratio, ::Valkyrie::Types::Set
127
129
 
128
- # @param [ActionDispatch::Http::UploadedFile] file
129
- # @deprecated Use #new instead; for removal in 4.0.0
130
- def self.for(file:)
131
- Deprecation.warn "#{self.class}##{__method__} is deprecated; use #new instead."
132
- new(label: file.original_filename,
133
- original_filename: file.original_filename,
134
- mime_type: file.content_type)
135
- end
136
-
137
130
  ##
138
131
  # @return [Boolean]
139
132
  def original_file?
@@ -31,7 +31,7 @@ module Hyrax
31
31
  # @see https://wiki.duraspace.org/display/samvera/Hydra%3A%3AWorks+Shared+Modeling
32
32
  class FileSet < Hyrax::Resource
33
33
  include Hyrax::Schema(:core_metadata)
34
- include Hyrax::Schema(:basic_metadata)
34
+ include Hyrax::Schema(:file_set_metadata)
35
35
 
36
36
  def self.model_name(name_class: Hyrax::Name)
37
37
  @_model_name ||= name_class.new(self, nil, 'FileSet')
@@ -51,14 +51,6 @@ module Hyrax
51
51
  id
52
52
  end
53
53
 
54
- ##
55
- # @return [Valkyrie::ID]
56
- # If one is set then return it, otherwise use self as the ID to allow for
57
- # derivative generators to find the on-disk path for the thumbnail.
58
- def thumbnail_id
59
- self.[](:thumbnail_id) || id
60
- end
61
-
62
54
  ##
63
55
  # @return [Boolean] true
64
56
  def pcdm_object?
@@ -204,7 +204,7 @@ module Hyrax
204
204
  interpreted_read_groups = read_groups
205
205
 
206
206
  if interpret_visibility
207
- visibilities = Hyrax::VisibilityMap.instance
207
+ visibilities = Hyrax.config.visibility_map
208
208
  interpreted_read_groups -= visibilities.deletions_for(visibility: collection.visibility)
209
209
  interpreted_read_groups += visibilities.additions_for(visibility: collection.visibility)
210
210
  end
@@ -34,10 +34,10 @@ module Hyrax
34
34
  Hyrax.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
35
35
  return []
36
36
  end
37
- profile.hyrax__analytics__google__pageviews(sort: 'date',
38
- start_date: start_date,
39
- end_date: Date.yesterday,
40
- limit: 10_000)
37
+ profile.hyrax__pageview(sort: 'date',
38
+ start_date: start_date,
39
+ end_date: Date.yesterday,
40
+ limit: 10_000)
41
41
  .for_path(path)
42
42
  end
43
43
 
data/app/models/sipity.rb CHANGED
@@ -104,10 +104,33 @@ module Sipity
104
104
  end
105
105
  module_function :Role
106
106
 
107
+ ##
108
+ # Cast an object to a Workflow id
109
+ # rubocop:disable Metrics/MethodLength
110
+ def WorkflowId(input, &block) # rubocop:disable Naming/MethodName
111
+ result = case input
112
+ when Sipity::Workflow
113
+ input.id
114
+ when Integer
115
+ input
116
+ when String
117
+ input.to_i
118
+ else
119
+ if input.respond_to?(workflow_id)
120
+ input.workflow_id
121
+ else
122
+ WorkflowId(Entity(input))
123
+ end
124
+ end
125
+ handle_conversion(input, result, :to_workflow_id, &block)
126
+ end
127
+ module_function :WorkflowId
128
+ # rubocop:enable Metrics/MethodLength
129
+
107
130
  ##
108
131
  # Cast an object to a WorkflowAction in a given workflow
109
132
  def WorkflowAction(input, workflow, &block) # rubocop:disable Naming/MethodName
110
- workflow_id = PowerConverter.convert_to_sipity_workflow_id(workflow)
133
+ workflow_id = WorkflowId(workflow)
111
134
 
112
135
  result = case input
113
136
  when WorkflowAction
@@ -138,11 +161,9 @@ module Sipity
138
161
  # A parent error class for all workflow errors caused by bad state
139
162
  class StateError < RuntimeError; end
140
163
 
141
- class ConversionError < PowerConverter::ConversionError
142
- def initialize(value, **options)
143
- options[:scope] ||= nil
144
- options[:to] ||= nil
145
- super(value, options)
164
+ class ConversionError < RuntimeError
165
+ def initialize(value)
166
+ super("Unable to convert #{value.inspect}")
146
167
  end
147
168
  end
148
169
 
@@ -43,7 +43,7 @@ module Hyrax
43
43
  # Terms is the list of fields displayed by
44
44
  # app/views/collections/_show_descriptions.html.erb
45
45
  def self.terms
46
- [:total_items, :size, :resource_type, :creator, :contributor, :keyword, :license, :publisher, :date_created, :subject,
46
+ [:total_items, :alternative_title, :size, :resource_type, :creator, :contributor, :keyword, :license, :publisher, :date_created, :subject,
47
47
  :language, :identifier, :based_near, :related_url]
48
48
  end
49
49
 
@@ -47,6 +47,12 @@ module Hyrax
47
47
  Array(super).first || ''
48
48
  end
49
49
 
50
+ ##
51
+ # @return [String]
52
+ def hostname
53
+ @hostname || 'localhost'
54
+ end
55
+
50
56
  ##
51
57
  # @return [Boolean]
52
58
  def file_set?
@@ -71,7 +77,7 @@ module Hyrax
71
77
  metadata_fields.map do |field_name|
72
78
  {
73
79
  'label' => I18n.t("simple_form.labels.defaults.#{field_name}"),
74
- 'value' => Array(self[field_name]).map { |value| scrub(value.to_s) }
80
+ 'value' => Array(send(field_name)).map { |value| scrub(value.to_s) }
75
81
  }
76
82
  end
77
83
  end
@@ -209,6 +215,14 @@ module Hyrax
209
215
  iiif_endpoint: iiif_endpoint(latest_file_id, base_url: hostname))
210
216
  end
211
217
 
218
+ ##
219
+ # @return [#can?]
220
+ def ability
221
+ @ability ||= NullAbility.new
222
+ end
223
+
224
+ ##
225
+ # @return [String]
212
226
  def hostname
213
227
  @hostname || 'localhost'
214
228
  end
@@ -222,10 +236,6 @@ module Hyrax
222
236
 
223
237
  private
224
238
 
225
- def hostname
226
- @hostname || 'localhost'
227
- end
228
-
229
239
  def metadata_fields
230
240
  Hyrax.config.iiif_metadata_fields
231
241
  end
@@ -44,8 +44,8 @@ module Hyrax
44
44
  end
45
45
 
46
46
  # Query solr using POST so that the query doesn't get too large for a URI
47
- def query(query, args = {})
48
- result = Hyrax::SolrService.post(query, args)
47
+ def query(query, **opts)
48
+ result = Hyrax::SolrService.post(query, **opts)
49
49
  result.fetch('response').fetch('docs')
50
50
  end
51
51
  end
@@ -45,7 +45,7 @@ module Hyrax
45
45
  delegate :title, :date_created, :description,
46
46
  :creator, :contributor, :subject, :publisher, :language, :embargo_release_date,
47
47
  :lease_expiration_date, :license, :source, :rights_statement, :thumbnail_id, :representative_id,
48
- :rendering_ids, :member_of_collection_ids, :alternative_title, to: :solr_document
48
+ :rendering_ids, :member_of_collection_ids, :alternative_title, :bibliographic_citation, to: :solr_document
49
49
 
50
50
  def workflow
51
51
  @workflow ||= WorkflowPresenter.new(solr_document, current_ability)
@@ -44,7 +44,7 @@ module Hyrax
44
44
 
45
45
  def sipity_entity
46
46
  Sipity::Entity(solr_document)
47
- rescue PowerConverter::ConversionError
47
+ rescue Sipity::ConversionError
48
48
  nil
49
49
  end
50
50
  end
@@ -37,6 +37,7 @@ module Hyrax
37
37
  # This overrides the default 'relevance' sort.
38
38
  def add_sorting_to_solr(solr_parameters)
39
39
  return if solr_parameters[:q]
40
+ solr_parameters[:sort] ||= sort
40
41
  solr_parameters[:sort] ||= "#{sort_field} asc"
41
42
  end
42
43