hyrax 3.4.2 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dassie/config/analytics.yml +4 -2
- data/.regen +2 -1
- data/app/actors/hyrax/actors/collections_membership_actor.rb +1 -1
- data/app/actors/hyrax/actors/embargo_actor.rb +11 -4
- data/app/actors/hyrax/actors/lease_actor.rb +11 -4
- data/app/assets/javascripts/hyrax/analytics_events.js +88 -38
- data/app/assets/javascripts/hyrax/app.js.erb +1 -1
- data/app/assets/javascripts/hyrax/permissions/control.es6 +8 -1
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +11 -2
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +11 -2
- data/app/controllers/concerns/hyrax/manages_embargoes.rb +13 -1
- data/app/controllers/hyrax/admin/analytics/collection_reports_controller.rb +2 -2
- data/app/controllers/hyrax/admin/analytics/work_reports_controller.rb +1 -1
- data/app/controllers/hyrax/admin/strategies_controller.rb +1 -1
- data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
- data/app/controllers/hyrax/dashboard/collections_controller.rb +1 -2
- data/app/controllers/hyrax/downloads_controller.rb +16 -1
- data/app/controllers/hyrax/file_sets_controller.rb +10 -1
- data/app/controllers/hyrax/permissions_controller.rb +1 -1
- data/app/controllers/hyrax/transfers_controller.rb +0 -2
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -2
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +2 -0
- data/app/forms/hyrax/forms/embargo.rb +13 -0
- data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/file_set_form.rb +8 -35
- data/app/forms/hyrax/forms/lease.rb +13 -0
- data/app/forms/hyrax/forms/pcdm_object_form.rb +46 -0
- data/app/forms/hyrax/forms/resource_form.rb +36 -32
- data/app/forms/hyrax/forms/work_embargo_form.rb +35 -0
- data/app/forms/hyrax/forms/work_lease_form.rb +35 -0
- data/app/helpers/hyrax/embargo_helper.rb +11 -0
- data/app/helpers/hyrax/lease_helper.rb +11 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +1 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +2 -8
- data/app/jobs/content_event_job.rb +1 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +2 -1
- data/app/models/concerns/hyrax/collection_nesting.rb +10 -1
- data/app/models/concerns/hyrax/file_set_behavior.rb +1 -0
- data/app/models/concerns/hyrax/work_behavior.rb +2 -1
- data/app/models/hyrax/embargo.rb +1 -1
- data/app/models/hyrax/file_set.rb +3 -3
- data/app/models/hyrax/lease.rb +1 -1
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/presenters/hyrax/permission_badge.rb +3 -2
- data/app/presenters/hyrax/version_list_presenter.rb +6 -1
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +13 -5
- data/app/services/hyrax/analytics/ga4.rb +204 -0
- data/app/services/hyrax/analytics/google.rb +23 -15
- data/app/services/hyrax/analytics/matomo.rb +4 -3
- data/app/services/hyrax/collections/nested_collection_query_service.rb +1 -1
- data/app/services/hyrax/edit_permissions_service.rb +21 -3
- data/app/services/hyrax/embargo_manager.rb +9 -0
- data/app/services/hyrax/file_set_file_service.rb +55 -0
- data/app/services/hyrax/lease_manager.rb +9 -0
- data/app/services/hyrax/solr_query_service.rb +4 -4
- data/app/services/hyrax/user_stat_importer.rb +2 -0
- data/app/services/hyrax/versioning_service.rb +77 -9
- data/app/services/hyrax/visibility_propagator.rb +5 -5
- data/app/services/hyrax/work_resource_query_service.rb +45 -0
- data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
- data/app/services/hyrax/workflow/permission_query.rb +23 -2
- data/app/views/hyrax/admin/analytics/collection_reports/index.html.erb +1 -1
- data/app/views/hyrax/admin/analytics/work_reports/index.html.erb +1 -1
- data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
- data/app/views/hyrax/admin/workflows/index.html.erb +53 -78
- data/app/views/hyrax/base/_form_progress.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_component.html.erb +5 -1
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
- data/app/views/hyrax/dashboard/_user_activity.html.erb +1 -1
- data/app/views/hyrax/dashboard/show_admin.html.erb +1 -1
- data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +1 -1
- data/app/views/hyrax/embargoes/edit.html.erb +3 -3
- data/app/views/hyrax/file_sets/_permission.html.erb +1 -1
- data/app/views/hyrax/file_sets/_permission_form.html.erb +1 -6
- data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -1
- data/app/views/hyrax/file_sets/edit.html.erb +2 -2
- data/app/views/hyrax/leases/edit.html.erb +3 -3
- data/app/views/hyrax/transfers/new.html.erb +1 -1
- data/app/views/layouts/_head_tag_content.html.erb +5 -2
- data/app/views/shared/_ga4.html.erb +10 -0
- data/config/locales/hyrax.de.yml +2 -1
- data/config/locales/hyrax.en.yml +11 -0
- data/config/locales/hyrax.es.yml +1 -0
- data/config/locales/hyrax.fr.yml +2 -1
- data/config/locales/hyrax.it.yml +1 -0
- data/config/locales/hyrax.pt-BR.yml +1 -0
- data/config/locales/hyrax.zh.yml +1 -0
- data/config/metadata/file_set_metadata.yaml +130 -0
- data/documentation/developing-your-hyrax-based-app.md +2 -2
- data/documentation/legacyREADME.md +3 -3
- data/hyrax.gemspec +3 -1
- data/lib/generators/hyrax/templates/config/analytics.yml +3 -0
- data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
- data/lib/hyrax/active_fedora_dummy_model.rb +13 -0
- data/lib/hyrax/configuration.rb +9 -2
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb +6 -0
- data/lib/hyrax/specs/shared_specs/indexers.rb +5 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings/valkyrie/storage.rb +6 -2
- data/template.rb +1 -1
- metadata +48 -5
- data/.github/workflows/main.yml +0 -17
- data/.github/workflows/release.yml +0 -17
@@ -3,44 +3,17 @@
|
|
3
3
|
module Hyrax
|
4
4
|
module Forms
|
5
5
|
##
|
6
|
-
#
|
7
|
-
class FileSetForm < Hyrax::
|
6
|
+
# A form for +Hyrax::FileSet+s.
|
7
|
+
class FileSetForm < Hyrax::Forms::ResourceForm
|
8
8
|
include Hyrax::FormFields(:core_metadata)
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
definitions
|
15
|
-
.select { |_, definition| definition[:required] }
|
16
|
-
.keys.map(&:to_sym)
|
17
|
-
end
|
18
|
-
end
|
10
|
+
# The fields in +:file_set_metadata+ were hardcoded into this form in a
|
11
|
+
# previous version of Hyrax, but ideally in the future this metadata will
|
12
|
+
# be configurable.
|
13
|
+
include Hyrax::FormFields(:file_set_metadata)
|
19
14
|
|
20
|
-
property :
|
21
|
-
property :
|
22
|
-
|
23
|
-
property :based_near
|
24
|
-
property :contributor
|
25
|
-
property :date_created
|
26
|
-
property :description
|
27
|
-
property :identifier
|
28
|
-
property :keyword
|
29
|
-
property :language
|
30
|
-
property :publisher
|
31
|
-
property :related_url
|
32
|
-
property :subject
|
33
|
-
|
34
|
-
property :permissions, virtual: true
|
35
|
-
property :visibility, default: VisibilityIntention::PRIVATE
|
36
|
-
|
37
|
-
# virtual properties for embargo/lease;
|
38
|
-
property :embargo_release_date, virtual: true
|
39
|
-
property :visibility_after_embargo, virtual: true
|
40
|
-
property :visibility_during_embargo, virtual: true
|
41
|
-
property :lease_expiration_date, virtual: true
|
42
|
-
property :visibility_after_lease, virtual: true
|
43
|
-
property :visibility_during_lease, virtual: true
|
15
|
+
property :representative_id, type: Valkyrie::Types::String
|
16
|
+
property :thumbnail_id, type: Valkyrie::Types::String
|
44
17
|
end
|
45
18
|
end
|
46
19
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Forms
|
4
|
+
##
|
5
|
+
# Nested form for leases.
|
6
|
+
class Lease < Hyrax::ChangeSet
|
7
|
+
property :visibility_after_lease
|
8
|
+
property :visibility_during_lease
|
9
|
+
property :lease_expiration_date
|
10
|
+
property :lease_history, default: []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module Forms
|
5
|
+
##
|
6
|
+
# A form for PCDM objects: resources which have collection relationships and
|
7
|
+
# generally resemble +Hyrax::Work+.
|
8
|
+
class PcdmObjectForm < Hyrax::Forms::ResourceForm
|
9
|
+
include Hyrax::FormFields(:core_metadata)
|
10
|
+
|
11
|
+
property :on_behalf_of
|
12
|
+
property :proxy_depositor
|
13
|
+
|
14
|
+
# pcdm relationships
|
15
|
+
property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s }
|
16
|
+
property :member_ids, default: [], type: Valkyrie::Types::Array
|
17
|
+
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
18
|
+
property :member_of_collections_attributes, virtual: true, populator: :in_collections_populator
|
19
|
+
validates_with CollectionMembershipValidator
|
20
|
+
|
21
|
+
property :representative_id, type: Valkyrie::Types::String
|
22
|
+
property :thumbnail_id, type: Valkyrie::Types::String
|
23
|
+
property :rendering_ids, default: [], type: Valkyrie::Types::Array
|
24
|
+
|
25
|
+
# backs the child work search element;
|
26
|
+
# @todo: look for a way for the view template not to depend on this
|
27
|
+
property :find_child_work, default: nil, virtual: true
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def in_collections_populator(fragment:, **_options)
|
32
|
+
adds = []
|
33
|
+
deletes = []
|
34
|
+
fragment.each do |_, h|
|
35
|
+
if h["_destroy"] == "true"
|
36
|
+
deletes << Valkyrie::ID.new(h["id"])
|
37
|
+
else
|
38
|
+
adds << Valkyrie::ID.new(h["id"])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
self.member_of_collection_ids = ((member_of_collection_ids + adds) - deletes).uniq
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -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::
|
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,7 +33,7 @@ module Hyrax
|
|
29
33
|
##
|
30
34
|
# @api public
|
31
35
|
#
|
32
|
-
# This form wraps
|
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
|
@@ -69,10 +73,8 @@ 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
|
-
property :visibility, default: VisibilityIntention::PRIVATE
|
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
|
@@ -85,6 +87,9 @@ module Hyrax
|
|
85
87
|
populator: :permission_populator,
|
86
88
|
prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
|
87
89
|
|
90
|
+
property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator
|
91
|
+
property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator
|
92
|
+
|
88
93
|
# virtual properties for embargo/lease;
|
89
94
|
property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date }
|
90
95
|
property :visibility_after_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
|
@@ -94,17 +99,7 @@ module Hyrax
|
|
94
99
|
property :visibility_after_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_after_lease = model.lease&.visibility_after_lease }
|
95
100
|
property :visibility_during_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_during_lease = model.lease&.visibility_during_lease }
|
96
101
|
|
97
|
-
# pcdm relationships
|
98
|
-
property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s }
|
99
102
|
property :in_works_ids, virtual: true, prepopulator: InWorksPrepopulator
|
100
|
-
property :member_ids, default: [], type: Valkyrie::Types::Array
|
101
|
-
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
102
|
-
property :member_of_collections_attributes, virtual: true, populator: :in_collections_populator
|
103
|
-
validates_with CollectionMembershipValidator
|
104
|
-
|
105
|
-
property :representative_id, type: Valkyrie::Types::String
|
106
|
-
property :thumbnail_id, type: Valkyrie::Types::String
|
107
|
-
property :rendering_ids, default: [], type: Valkyrie::Types::Array
|
108
103
|
|
109
104
|
# provide a lock token for optimistic locking; we name this `version` for
|
110
105
|
# backwards compatibility
|
@@ -116,10 +111,6 @@ module Hyrax
|
|
116
111
|
# @see https://github.com/samvera/valkyrie/wiki/Optimistic-Locking
|
117
112
|
property :version, virtual: true, prepopulator: LockKeyPrepopulator
|
118
113
|
|
119
|
-
# backs the child work search element;
|
120
|
-
# @todo: look for a way for the view template not to depend on this
|
121
|
-
property :find_child_work, default: nil, virtual: true
|
122
|
-
|
123
114
|
class << self
|
124
115
|
##
|
125
116
|
# @api public
|
@@ -140,6 +131,7 @@ module Hyrax
|
|
140
131
|
when Hyrax::PcdmCollection
|
141
132
|
Hyrax::Forms::PcdmCollectionForm.new(resource)
|
142
133
|
else
|
134
|
+
# NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
|
143
135
|
Hyrax::Forms::ResourceForm(resource.class).new(resource)
|
144
136
|
end
|
145
137
|
end
|
@@ -208,18 +200,12 @@ module Hyrax
|
|
208
200
|
|
209
201
|
private
|
210
202
|
|
211
|
-
def
|
212
|
-
|
213
|
-
|
214
|
-
fragment.each do |_, h|
|
215
|
-
if h["_destroy"] == "true"
|
216
|
-
deletes << Valkyrie::ID.new(h["id"])
|
217
|
-
else
|
218
|
-
adds << Valkyrie::ID.new(h["id"])
|
219
|
-
end
|
220
|
-
end
|
203
|
+
def embargo_populator(**)
|
204
|
+
self.embargo = Hyrax::EmbargoManager.embargo_for(resource: model)
|
205
|
+
end
|
221
206
|
|
222
|
-
|
207
|
+
def lease_populator(**)
|
208
|
+
self.lease = Hyrax::LeaseManager.lease_for(resource: model)
|
223
209
|
end
|
224
210
|
|
225
211
|
# https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
|
@@ -227,6 +213,24 @@ module Hyrax
|
|
227
213
|
Hyrax::Forms::Permission.new(collection[index])
|
228
214
|
end
|
229
215
|
|
216
|
+
def visibility_populator(fragment:, doc:, **)
|
217
|
+
case fragment
|
218
|
+
when "embargo"
|
219
|
+
self.visibility = doc['visibility_during_embargo']
|
220
|
+
|
221
|
+
doc['embargo'] = doc.slice('visibility_after_embargo',
|
222
|
+
'visibility_during_embargo',
|
223
|
+
'embargo_release_date')
|
224
|
+
when "lease"
|
225
|
+
self.visibility = doc['visibility_during_lease']
|
226
|
+
doc['lease'] = doc.slice('visibility_after_lease',
|
227
|
+
'visibility_during_lease',
|
228
|
+
'lease_expiration_date')
|
229
|
+
else
|
230
|
+
self.visibility = fragment
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
230
234
|
def _form_field_definitions
|
231
235
|
self.class.definitions
|
232
236
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module Forms
|
5
|
+
##
|
6
|
+
# Represents an embargo for edit through a work. That is, this form can
|
7
|
+
# be used to wrap a Work in order to capture state changes related only to
|
8
|
+
# its embargo, ignoring the work's other fields.
|
9
|
+
#
|
10
|
+
# @note this supports the edit functionality of
|
11
|
+
# +EmbargoesControllerBehavior+.
|
12
|
+
class WorkEmbargoForm < Hyrax::ChangeSet
|
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 }
|
17
|
+
|
18
|
+
def embargo_populator(**)
|
19
|
+
self.embargo = Hyrax::EmbargoManager.embargo_for(resource: model)
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [String]
|
24
|
+
def human_readable_type
|
25
|
+
model.to_model.human_readable_type
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# @return [ActiveModel::Name]
|
30
|
+
def model_name
|
31
|
+
model.to_model.model_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module Forms
|
5
|
+
##
|
6
|
+
# Represents a lease for edit through a work. That is, this form can
|
7
|
+
# be used to wrap a Work in order to capture state changes related only to
|
8
|
+
# its lease, ignoring the work's other fields.
|
9
|
+
#
|
10
|
+
# @note this supports the edit functionality of
|
11
|
+
# +LeasesControllerBehavior+.
|
12
|
+
class WorkLeaseForm < Hyrax::ChangeSet
|
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 }
|
17
|
+
|
18
|
+
def lease_populator(**)
|
19
|
+
self.lease = Hyrax::LeaseManager.lease_for(resource: model)
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [String]
|
24
|
+
def human_readable_type
|
25
|
+
model.to_model.human_readable_type
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# @return [ActiveModel::Name]
|
30
|
+
def model_name
|
31
|
+
model.to_model.model_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -40,5 +40,16 @@ module Hyrax
|
|
40
40
|
Hyrax::EmbargoManager.new(resource: resource).enforced?
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# @since 3.5.0
|
46
|
+
#
|
47
|
+
# @param [#embargo_history, #embargo] resource
|
48
|
+
#
|
49
|
+
# @return [Array]
|
50
|
+
def embargo_history(resource)
|
51
|
+
resource.try(:embargo_history) ||
|
52
|
+
Array(resource.embargo&.embargo_history)
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
@@ -40,5 +40,16 @@ module Hyrax
|
|
40
40
|
Hyrax::LeaseManager.new(resource: resource).enforced?
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# @since 3.5.0
|
46
|
+
#
|
47
|
+
# @param [#lease_history, #lease] resource
|
48
|
+
#
|
49
|
+
# @return [Array]
|
50
|
+
def lease_history(resource)
|
51
|
+
resource.try(:lease_history) ||
|
52
|
+
Array(resource.lease&.lease_history)
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
@@ -16,6 +16,7 @@ module Hyrax
|
|
16
16
|
super.tap do |index_document|
|
17
17
|
index_document[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
|
18
18
|
index_document[:generic_type_sim] = ['Collection']
|
19
|
+
index_document[:member_of_collection_ids_ssim] = resource.member_of_collection_ids.map(&:to_s)
|
19
20
|
index_document[:depositor_ssim] = [resource.depositor]
|
20
21
|
index_document[:depositor_tesim] = [resource.depositor]
|
21
22
|
end
|
@@ -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(:
|
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
|
@@ -23,7 +23,7 @@ module Hyrax
|
|
23
23
|
solr_doc['hasRelatedImage_ssim'] = resource.thumbnail_id.to_s
|
24
24
|
|
25
25
|
# Add in metadata from the original file.
|
26
|
-
file_metadata = original_file
|
26
|
+
file_metadata = Hyrax::FileSetFileService.new(file_set: resource).original_file
|
27
27
|
return solr_doc unless file_metadata
|
28
28
|
|
29
29
|
# Label is the actual file name. It's not editable by the user.
|
@@ -99,12 +99,6 @@ module Hyrax
|
|
99
99
|
|
100
100
|
private
|
101
101
|
|
102
|
-
def original_file
|
103
|
-
Hyrax.custom_queries.find_original_file(file_set: resource)
|
104
|
-
rescue Valkyrie::Persistence::ObjectNotFoundError
|
105
|
-
Hyrax.custom_queries.find_files(file_set: resource).first
|
106
|
-
end
|
107
|
-
|
108
102
|
def file_format(file)
|
109
103
|
if file.mime_type.present? && file.format_label.present?
|
110
104
|
"#{file.mime_type.split('/').last} (#{file.format_label.join(', ')})"
|
@@ -10,7 +10,8 @@ module Hyrax
|
|
10
10
|
include Hyrax::HumanReadableType
|
11
11
|
include Hyrax::HasRepresentative
|
12
12
|
include Hyrax::Permissions
|
13
|
-
include
|
13
|
+
include(Hyrax::CollectionNesting) unless
|
14
|
+
Hyrax.config.use_solr_graph_for_collection_nesting
|
14
15
|
|
15
16
|
included do
|
16
17
|
validates_with HasOneTitleValidator
|
@@ -3,11 +3,20 @@ module Hyrax
|
|
3
3
|
# Responsible for adding the necessary callbacks for updating the nested collection information
|
4
4
|
# This is part of the after update index because it is a potentially very expensive process.
|
5
5
|
#
|
6
|
-
# @
|
6
|
+
# @deprecation deprecated for removal in 4.0.0; nested reindexing is replaced by solr
|
7
|
+
# graph query. if you want to drop this behavior now, you can set
|
8
|
+
# +HYRAX_USE_SOLR_GRAPH_NESTING+ to +true+ in the environment.
|
7
9
|
module CollectionNesting
|
8
10
|
extend ActiveSupport::Concern
|
9
11
|
|
10
12
|
included do
|
13
|
+
Deprecation.warn "Hyrax::CollectionNesting is deprecated for removal in " \
|
14
|
+
"4.0.0. Nested reindexing behavior can be replaced " \
|
15
|
+
"by a Solr graph traversal query. Legacy nested " \
|
16
|
+
"indexing behavior is retained by default, but can be " \
|
17
|
+
"replaced with the 4.0.0 default by setting " \
|
18
|
+
"HYRAX_USE_SOLR_GRAPH_NESTING to `true` in the environment."
|
19
|
+
|
11
20
|
extend ActiveModel::Callbacks
|
12
21
|
include ActiveModel::Validations::Callbacks
|
13
22
|
|
@@ -35,6 +35,7 @@ module Hyrax
|
|
35
35
|
|
36
36
|
# Cast to a SolrDocument by querying from Solr
|
37
37
|
def to_presenter
|
38
|
+
Deprecation.warn "Method #to_presenter will be removed in Hyrax 5.0. Use Hyrax::FileSetsController#presenter.solr_document or `@presenter.solr_document` from a view instead."
|
38
39
|
CatalogController.new.fetch(id).last
|
39
40
|
end
|
40
41
|
end
|
@@ -21,7 +21,8 @@ module Hyrax
|
|
21
21
|
include ProxyDeposit
|
22
22
|
include Works::Metadata
|
23
23
|
include WithEvents
|
24
|
-
include
|
24
|
+
include(Hyrax::CollectionNesting) unless
|
25
|
+
Hyrax.config.use_solr_graph_for_collection_nesting
|
25
26
|
|
26
27
|
included do
|
27
28
|
property :owner, predicate: RDF::URI.new('http://opaquenamespace.org/ns/hydra/owner'), multiple: false
|
data/app/models/hyrax/embargo.rb
CHANGED
@@ -15,7 +15,7 @@ module Hyrax
|
|
15
15
|
attribute :embargo_history, Valkyrie::Types::Array
|
16
16
|
|
17
17
|
def active?
|
18
|
-
(embargo_release_date.present? &&
|
18
|
+
(embargo_release_date.present? && Hyrax::TimeService.time_in_utc < embargo_release_date)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -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(:
|
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')
|
@@ -42,8 +42,8 @@ module Hyrax
|
|
42
42
|
|
43
43
|
attribute :file_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID) # id for FileMetadata resources
|
44
44
|
attribute :thumbnail_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
|
45
|
-
attribute :original_file_id, Valkyrie::Types::ID # id for FileMetadata resource
|
46
|
-
attribute :extracted_text_id, Valkyrie::Types::ID # id for FileMetadata resource
|
45
|
+
attribute :original_file_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
|
46
|
+
attribute :extracted_text_id, Valkyrie::Types::ID.optional # id for FileMetadata resource
|
47
47
|
|
48
48
|
##
|
49
49
|
# @return [Valkyrie::ID]
|
data/app/models/hyrax/lease.rb
CHANGED
@@ -15,7 +15,7 @@ module Hyrax
|
|
15
15
|
attribute :lease_history, Valkyrie::Types::Array
|
16
16
|
|
17
17
|
def active?
|
18
|
-
(lease_expiration_date.present? &&
|
18
|
+
(lease_expiration_date.present? && Hyrax::TimeService.time_in_utc < lease_expiration_date)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -7,7 +7,7 @@ class ProxyDepositRequest < ActiveRecord::Base
|
|
7
7
|
include ActionView::Helpers::UrlHelper
|
8
8
|
|
9
9
|
class_attribute :work_query_service_class
|
10
|
-
self.work_query_service_class = Hyrax::WorkQueryService
|
10
|
+
self.work_query_service_class = Hyrax.config.use_valkyrie? ? Hyrax::WorkResourceQueryService : Hyrax::WorkQueryService
|
11
11
|
|
12
12
|
delegate :deleted_work?, :work, :to_s, to: :work_query_service
|
13
13
|
|
@@ -24,14 +24,15 @@ module Hyrax
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def dom_label_class
|
27
|
-
VISIBILITY_LABEL_CLASS.fetch(@visibility
|
27
|
+
VISIBILITY_LABEL_CLASS.fetch(@visibility&.to_sym, 'label-info')
|
28
28
|
end
|
29
29
|
|
30
30
|
def text
|
31
31
|
if registered?
|
32
32
|
Institution.name
|
33
33
|
else
|
34
|
-
|
34
|
+
visibility_key = @visibility || 'unknown'
|
35
|
+
I18n.t("hyrax.visibility.#{visibility_key}.text")
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -19,7 +19,12 @@ module Hyrax
|
|
19
19
|
#
|
20
20
|
# @raise [ArgumentError] if we can't build an enu
|
21
21
|
def self.for(file_set:)
|
22
|
-
|
22
|
+
original_file = if file_set.respond_to?(:original_file)
|
23
|
+
file_set.original_file
|
24
|
+
else
|
25
|
+
Hyrax::FileSetFileService.new(file_set: file_set).original_file
|
26
|
+
end
|
27
|
+
new(Hyrax::VersioningService.new(resource: original_file).versions)
|
23
28
|
rescue NoMethodError
|
24
29
|
raise ArgumentError
|
25
30
|
end
|
@@ -26,11 +26,19 @@ module Hyrax
|
|
26
26
|
|
27
27
|
def show_only_other_collections_of_the_same_collection_type(solr_parameters)
|
28
28
|
solr_parameters[:fq] ||= []
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
if Hyrax.config.use_solr_graph_for_collection_nesting
|
30
|
+
solr_parameters[:fq] += [
|
31
|
+
Hyrax::SolrQueryBuilderService.construct_query(Hyrax.config.collection_type_index_field => @collection.collection_type_gid),
|
32
|
+
"-{!graph from=id to=member_of_collection_ids_ssim#{' maxDepth=1' if @nest_direction == :as_parent}}id:#{@collection.id}",
|
33
|
+
"-{!graph to=id from=member_of_collection_ids_ssim#{' maxDepth=1' if @nest_direction == :as_child}}id:#{@collection.id}"
|
34
|
+
]
|
35
|
+
else
|
36
|
+
solr_parameters[:fq] += [
|
37
|
+
"-" + Hyrax::SolrQueryBuilderService.construct_query_for_ids([limit_ids]),
|
38
|
+
Hyrax::SolrQueryBuilderService.construct_query(Hyrax.config.collection_type_index_field => @collection.collection_type_gid)
|
39
|
+
]
|
40
|
+
solr_parameters[:fq] += limit_clause if limit_clause # add limits to prevent illegal nesting arrangements
|
41
|
+
end
|
34
42
|
end
|
35
43
|
|
36
44
|
private
|