hyrax 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dassie/config/initializers/hyrax.rb +11 -1
- data/.gitignore +3 -0
- data/.regen +1 -1
- data/.rubocop_fixme.yml +3 -1
- data/Dockerfile +2 -1
- data/app/actors/hyrax/actors/file_actor.rb +6 -4
- data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
- data/app/assets/javascripts/hyrax/analytics_events.js +8 -2
- data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
- data/app/controllers/concerns/hyrax/controller.rb +21 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +12 -19
- data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
- data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
- data/app/controllers/hyrax/citations_controller.rb +1 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +19 -10
- data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +1 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +9 -5
- data/app/helpers/hyrax/collections_helper.rb +14 -0
- data/app/helpers/hyrax/membership_helper.rb +1 -1
- data/app/helpers/hyrax/trophy_helper.rb +1 -1
- data/app/helpers/hyrax/url_helper.rb +1 -1
- data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
- data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
- data/app/indexers/hyrax/file_set_indexer.rb +1 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -1
- data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +6 -6
- data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
- data/app/inputs/controlled_vocabulary_input.rb +2 -0
- data/app/jobs/change_depositor_event_job.rb +47 -0
- data/app/jobs/characterize_job.rb +38 -2
- data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +2 -1
- data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
- data/app/jobs/inherit_permissions_job.rb +1 -1
- data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
- data/app/jobs/valkyrie_ingest_job.rb +84 -16
- data/app/models/admin_set.rb +2 -2
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/collection_behavior.rb +2 -2
- data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
- data/app/models/concerns/hyrax/solr_document/metadata.rb +1 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
- data/app/models/hyrax/administrative_set.rb +36 -1
- data/app/models/hyrax/collection_type.rb +2 -2
- data/app/models/hyrax/file_metadata.rb +5 -1
- data/app/models/hyrax/file_set.rb +42 -1
- data/app/models/hyrax/pcdm_collection.rb +56 -0
- data/app/models/hyrax/permission_template.rb +11 -5
- data/app/models/hyrax/work.rb +91 -0
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
- data/app/presenters/hyrax/work_show_presenter.rb +7 -3
- data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +11 -4
- data/app/services/hyrax/access_control_list.rb +13 -0
- data/app/services/hyrax/admin_set_create_service.rb +21 -37
- data/app/services/hyrax/change_content_depositor_service.rb +2 -2
- data/app/services/hyrax/change_depositor_service.rb +70 -0
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +1 -1
- data/app/services/hyrax/collections/nested_collection_query_service.rb +23 -11
- data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
- data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
- data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
- data/app/services/hyrax/default_middleware_stack.rb +3 -0
- data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
- data/app/services/hyrax/file_set_type_service.rb +2 -5
- data/app/services/hyrax/listeners/file_metadata_listener.rb +20 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +23 -3
- data/app/services/hyrax/listeners/metadata_index_listener.rb +39 -0
- data/app/services/hyrax/listeners/proxy_deposit_listener.rb +14 -8
- data/app/services/hyrax/location_service.rb +33 -0
- data/app/services/hyrax/multiple_membership_checker.rb +44 -1
- data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
- data/app/services/hyrax/simple_schema_loader.rb +5 -1
- data/app/services/hyrax/solr_query_service.rb +12 -7
- data/app/services/hyrax/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/work_uploads_handler.rb +0 -10
- data/app/validators/hyrax/collection_membership_validator.rb +38 -0
- data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +4 -0
- data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/base/_form.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +21 -15
- data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +2 -2
- data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
- data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/my/collections/index.html.erb +3 -2
- data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
- data/app/views/hyrax/my/works/index.html.erb +4 -2
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/README.md +22 -1
- data/config/initializers/listeners.rb +0 -1
- data/config/locales/hyrax.de.yml +6 -5
- data/config/locales/hyrax.en.yml +30 -28
- data/config/locales/hyrax.es.yml +10 -9
- data/config/locales/hyrax.fr.yml +2 -1
- data/config/locales/hyrax.it.yml +3 -2
- data/config/locales/hyrax.pt-BR.yml +2 -1
- data/config/locales/hyrax.zh.yml +2 -1
- data/config/metadata/basic_metadata.yaml +2 -0
- data/config/metadata/core_metadata.yaml +1 -1
- data/docker-compose.yml +46 -42
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +2 -0
- data/lib/hyrax/configuration.rb +10 -0
- data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
- data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
- data/lib/hyrax/controlled_vocabularies.rb +1 -0
- data/lib/hyrax/publisher.rb +45 -0
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -4
- data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
- data/lib/hyrax/transactions/admin_set_create.rb +2 -1
- data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
- data/lib/hyrax/transactions/admin_set_update.rb +21 -0
- data/lib/hyrax/transactions/collection_destroy.rb +22 -0
- data/lib/hyrax/transactions/collection_update.rb +3 -2
- data/lib/hyrax/transactions/container.rb +87 -23
- data/lib/hyrax/transactions/create_work.rb +3 -0
- data/lib/hyrax/transactions/destroy_work.rb +3 -0
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
- data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
- data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
- data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
- data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/save.rb +24 -6
- data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
- data/lib/hyrax/transactions/steps/save_work.rb +3 -0
- data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
- data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
- data/lib/hyrax/transactions/update_work.rb +4 -3
- data/lib/hyrax/transactions/work_create.rb +1 -1
- data/lib/hyrax/transactions/work_destroy.rb +2 -1
- data/lib/hyrax/transactions/work_update.rb +19 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings/attribute_transformer.rb +5 -1
- data/lib/wings/setup.rb +3 -1
- data/lib/wings/valkyrie/query_service.rb +2 -1
- data/lib/wings/valkyrie/storage.rb +7 -1
- data/template.rb +1 -1
- metadata +24 -3
|
@@ -5,11 +5,11 @@ module Hyrax
|
|
|
5
5
|
load_and_authorize_resource class: 'Hyrax::PermissionTemplateAccess'
|
|
6
6
|
|
|
7
7
|
def destroy
|
|
8
|
+
authorize! :destroy, @permission_template_access
|
|
8
9
|
ActiveRecord::Base.transaction do
|
|
9
|
-
@permission_template_access.destroy
|
|
10
|
+
@permission_template_access.destroy
|
|
10
11
|
remove_access!
|
|
11
12
|
end
|
|
12
|
-
|
|
13
13
|
if @permission_template_access.destroyed?
|
|
14
14
|
after_destroy_success
|
|
15
15
|
else
|
|
@@ -19,38 +19,31 @@ module Hyrax
|
|
|
19
19
|
|
|
20
20
|
private
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
# because we don't want to prevent the ability to remove the whole
|
|
24
|
-
# PermissionTemplate and all of its associated PermissionTemplateAccesses
|
|
25
|
-
# @return [Boolean] true if it's valid
|
|
26
|
-
def valid_delete?
|
|
27
|
-
return true unless @permission_template_access.admin_group?
|
|
28
|
-
@permission_template_access.errors[:base] <<
|
|
29
|
-
t('hyrax.admin.admin_sets.form.permission_destroy_errors.admin_group')
|
|
30
|
-
false
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def after_destroy_success
|
|
22
|
+
def after_destroy_error
|
|
34
23
|
if source.admin_set?
|
|
24
|
+
@permission_template_access.errors[:base] <<
|
|
25
|
+
t('hyrax.admin.admin_sets.form.permission_destroy_errors.participants')
|
|
35
26
|
redirect_to hyrax.edit_admin_admin_set_path(source_id,
|
|
36
27
|
anchor: 'participants'),
|
|
37
|
-
|
|
28
|
+
alert: @permission_template_access.errors.full_messages.to_sentence
|
|
38
29
|
else
|
|
30
|
+
@permission_template_access.errors[:base] <<
|
|
31
|
+
t('hyrax.dashboard.collections.form.permission_update_errors.sharing')
|
|
39
32
|
redirect_to hyrax.edit_dashboard_collection_path(source_id,
|
|
40
33
|
anchor: 'sharing'),
|
|
41
|
-
|
|
34
|
+
alert: @permission_template_access.errors.full_messages.to_sentence
|
|
42
35
|
end
|
|
43
36
|
end
|
|
44
37
|
|
|
45
|
-
def
|
|
38
|
+
def after_destroy_success
|
|
46
39
|
if source.admin_set?
|
|
47
40
|
redirect_to hyrax.edit_admin_admin_set_path(source_id,
|
|
48
41
|
anchor: 'participants'),
|
|
49
|
-
|
|
42
|
+
notice: translate('participants', scope: 'hyrax.admin.admin_sets.form.permission_update_notices')
|
|
50
43
|
else
|
|
51
44
|
redirect_to hyrax.edit_dashboard_collection_path(source_id,
|
|
52
45
|
anchor: 'sharing'),
|
|
53
|
-
|
|
46
|
+
notice: translate('sharing', scope: 'hyrax.dashboard.collections.form.permission_update_notices')
|
|
54
47
|
end
|
|
55
48
|
end
|
|
56
49
|
|
|
@@ -39,8 +39,11 @@ module Hyrax
|
|
|
39
39
|
|
|
40
40
|
def destroy_collection
|
|
41
41
|
batch.each do |doc_id|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id))
|
|
43
|
+
transactions['collection_resource.destroy']
|
|
44
|
+
.with_step_args('collection_resource.delete' => { user: current_user })
|
|
45
|
+
.call(resource)
|
|
46
|
+
.value!
|
|
44
47
|
end
|
|
45
48
|
flash[:notice] = "Batch delete complete"
|
|
46
49
|
after_destroy_collection
|
|
@@ -83,7 +86,13 @@ module Hyrax
|
|
|
83
86
|
end
|
|
84
87
|
|
|
85
88
|
def destroy_batch
|
|
86
|
-
batch.each
|
|
89
|
+
batch.each do |id|
|
|
90
|
+
resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(id))
|
|
91
|
+
transactions['work_resource.destroy']
|
|
92
|
+
.with_step_args('work_resource.delete' => { user: current_user })
|
|
93
|
+
.call(resource)
|
|
94
|
+
.value!
|
|
95
|
+
end
|
|
87
96
|
after_update
|
|
88
97
|
end
|
|
89
98
|
|
|
@@ -44,6 +44,10 @@ module Hyrax
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def build_form
|
|
47
|
+
add_breadcrumb t('hyrax.controls.home'), root_path
|
|
48
|
+
add_breadcrumb t('hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
|
|
49
|
+
add_breadcrumb t('hyrax.admin.sidebar.works'), hyrax.my_works_path
|
|
50
|
+
add_breadcrumb t('hyrax.batch_uploads.new.breadcrumb'), request.path
|
|
47
51
|
super
|
|
48
52
|
@form.payload_concern = params[:payload_concern]
|
|
49
53
|
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
module Hyrax
|
|
3
3
|
class CitationsController < ApplicationController
|
|
4
4
|
include WorksControllerBehavior
|
|
5
|
+
include DenyAccessOverrideBehavior
|
|
5
6
|
include Breadcrumbs
|
|
6
|
-
include SingularSubresourceController
|
|
7
7
|
|
|
8
8
|
# Overrides decide_layout from WorksControllerBehavior
|
|
9
9
|
with_themed_layout '1_column'
|
|
@@ -43,13 +43,10 @@ module Hyrax
|
|
|
43
43
|
# The search builder to find the collections' members
|
|
44
44
|
self.membership_service_class = Collections::CollectionMemberSearchService
|
|
45
45
|
|
|
46
|
-
load_and_authorize_resource except: [:index],
|
|
46
|
+
load_and_authorize_resource except: [:index, :create],
|
|
47
47
|
instance_name: :collection,
|
|
48
48
|
class: Hyrax.config.collection_model
|
|
49
49
|
|
|
50
|
-
skip_load_resource only: :create if
|
|
51
|
-
Hyrax.config.collection_class < ActiveFedora::Base
|
|
52
|
-
|
|
53
50
|
def deny_collection_access(exception)
|
|
54
51
|
if exception.action == :edit
|
|
55
52
|
redirect_to(url_for(action: 'show'), alert: 'You do not have sufficient privileges to edit this document')
|
|
@@ -83,6 +80,7 @@ module Hyrax
|
|
|
83
80
|
|
|
84
81
|
def edit
|
|
85
82
|
form
|
|
83
|
+
collection_type
|
|
86
84
|
end
|
|
87
85
|
|
|
88
86
|
def after_create
|
|
@@ -109,12 +107,13 @@ module Hyrax
|
|
|
109
107
|
end
|
|
110
108
|
|
|
111
109
|
def create
|
|
112
|
-
return valkyrie_create if @collection.is_a?(Valkyrie::Resource)
|
|
113
110
|
# Manual load and authorize necessary because Cancan will pass in all
|
|
114
111
|
# form attributes. When `permissions_attributes` are present the
|
|
115
112
|
# collection is saved without a value for `has_model.`
|
|
116
113
|
@collection = Hyrax.config.collection_class.new
|
|
117
114
|
authorize! :create, @collection
|
|
115
|
+
return valkyrie_create if @collection.is_a?(Valkyrie::Resource)
|
|
116
|
+
|
|
118
117
|
# Coming from the UI, a collection type gid should always be present. Coming from the API, if a collection type gid is not specified,
|
|
119
118
|
# use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)
|
|
120
119
|
@collection.collection_type_gid = params[:collection_type_gid].presence || default_collection_type.to_global_id
|
|
@@ -168,10 +167,10 @@ module Hyrax
|
|
|
168
167
|
# leaving id to avoid changing the method's parameters prior to release
|
|
169
168
|
respond_to do |format|
|
|
170
169
|
format.html do
|
|
171
|
-
redirect_to my_collections_path,
|
|
170
|
+
redirect_to hyrax.my_collections_path,
|
|
172
171
|
notice: t('hyrax.dashboard.my.action.collection_delete_success')
|
|
173
172
|
end
|
|
174
|
-
format.json { head :no_content, location: my_collections_path }
|
|
173
|
+
format.json { head :no_content, location: hyrax.my_collections_path }
|
|
175
174
|
end
|
|
176
175
|
end
|
|
177
176
|
|
|
@@ -188,8 +187,7 @@ module Hyrax
|
|
|
188
187
|
def destroy
|
|
189
188
|
case @collection
|
|
190
189
|
when Valkyrie::Resource
|
|
191
|
-
|
|
192
|
-
after_destroy(params[:id])
|
|
190
|
+
valkyrie_destroy
|
|
193
191
|
else
|
|
194
192
|
if @collection.destroy
|
|
195
193
|
after_destroy(params[:id])
|
|
@@ -241,6 +239,14 @@ module Hyrax
|
|
|
241
239
|
after_update
|
|
242
240
|
end
|
|
243
241
|
|
|
242
|
+
def valkyrie_destroy
|
|
243
|
+
if transactions['collection_resource.destroy'].call(@collection).success?
|
|
244
|
+
after_destroy(params[:id])
|
|
245
|
+
else
|
|
246
|
+
after_destroy_error(params[:id])
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
244
250
|
def default_collection_type
|
|
245
251
|
Hyrax::CollectionType.find_or_create_default_collection_type
|
|
246
252
|
end
|
|
@@ -332,7 +338,10 @@ module Hyrax
|
|
|
332
338
|
def process_logo_records(uploaded_file_ids)
|
|
333
339
|
public_files = []
|
|
334
340
|
uploaded_file_ids.each_with_index do |ufi, i|
|
|
335
|
-
|
|
341
|
+
# If the user has chosen a new logo, the ufi will be an integer
|
|
342
|
+
# If the logo was previously chosen, the ufi will be a path
|
|
343
|
+
# If it is a path, update the rec, else create a new rec
|
|
344
|
+
if !ufi.match(/\D/).nil?
|
|
336
345
|
update_logo_info(ufi, params["alttext"][i], verify_linkurl(params["linkurl"][i]))
|
|
337
346
|
public_files << ufi
|
|
338
347
|
else # brand new one, insert in the database
|
|
@@ -6,6 +6,20 @@ module Hyrax
|
|
|
6
6
|
# @api public
|
|
7
7
|
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
|
|
8
8
|
class AdministrativeSetForm < Valkyrie::ChangeSet
|
|
9
|
+
##
|
|
10
|
+
# @api private
|
|
11
|
+
AdminSetMembersPopulator = lambda do |_options|
|
|
12
|
+
self.member_ids =
|
|
13
|
+
if model.new_record
|
|
14
|
+
[]
|
|
15
|
+
else
|
|
16
|
+
Hyrax
|
|
17
|
+
.query_service
|
|
18
|
+
.find_inverse_references_by(property: :admin_set_id, resource: model)
|
|
19
|
+
.map(&:id)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
9
23
|
property :title, required: true, primary: true
|
|
10
24
|
property :description, primary: true
|
|
11
25
|
|
|
@@ -13,7 +27,11 @@ module Hyrax
|
|
|
13
27
|
property :date_modified, readable: false
|
|
14
28
|
property :date_uploaded, readable: false
|
|
15
29
|
|
|
16
|
-
property :
|
|
30
|
+
property :creator
|
|
31
|
+
|
|
32
|
+
validates :title, presence: true
|
|
33
|
+
|
|
34
|
+
property :member_ids, virtual: true, default: [], prepopulator: AdminSetMembersPopulator
|
|
17
35
|
|
|
18
36
|
class << self
|
|
19
37
|
def model_class
|
|
@@ -65,7 +65,7 @@ module Hyrax
|
|
|
65
65
|
def initialize_combined_fields
|
|
66
66
|
# For each of the files in the batch, set the attributes to be the concatenation of all the attributes
|
|
67
67
|
batch_document_ids.each_with_object({}) do |doc_id, combined_attributes|
|
|
68
|
-
work =
|
|
68
|
+
work = Hyrax.query_service.find_by(id: doc_id)
|
|
69
69
|
terms.each do |field|
|
|
70
70
|
combined_attributes[field] ||= []
|
|
71
71
|
combined_attributes[field] = (combined_attributes[field] + work[field].to_a).uniq
|
|
@@ -26,11 +26,11 @@ module Hyrax
|
|
|
26
26
|
context:,
|
|
27
27
|
query_service: default_query_service,
|
|
28
28
|
persistence_service: default_persistence_service)
|
|
29
|
-
self.parent = parent || (parent_id.present? && Hyrax.config.collection_class.find(parent_id))
|
|
30
|
-
self.child = child || (child_id.present? && Hyrax.config.collection_class.find(child_id))
|
|
31
29
|
self.context = context
|
|
32
30
|
self.query_service = query_service
|
|
33
31
|
self.persistence_service = persistence_service
|
|
32
|
+
self.parent = parent || (parent_id.present? && find_parent(parent_id))
|
|
33
|
+
self.child = child || (child_id.present? && find_child(child_id))
|
|
34
34
|
end # rubocop:enable Metrics/ParameterLists
|
|
35
35
|
|
|
36
36
|
attr_accessor :parent, :child
|
|
@@ -83,7 +83,7 @@ module Hyrax
|
|
|
83
83
|
# rerouting to new_dashboard_collection_path to add the new collection as
|
|
84
84
|
# a child. Since we don't yet have a child collection, the valid? option can't be used here.
|
|
85
85
|
def validate_add
|
|
86
|
-
if
|
|
86
|
+
if nestable?(parent)
|
|
87
87
|
nesting_within_maximum_depth
|
|
88
88
|
else
|
|
89
89
|
errors.add(:parent, :cannot_have_child_nested)
|
|
@@ -116,15 +116,30 @@ module Hyrax
|
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
def parent_and_child_can_be_nested
|
|
119
|
-
if
|
|
119
|
+
if nestable?(parent) && nestable?(child)
|
|
120
120
|
return true if query_service.parent_and_child_can_nest?(parent: parent, child: child, scope: context)
|
|
121
121
|
errors.add(:parent, :cannot_have_child_nested)
|
|
122
122
|
errors.add(:child, :cannot_nest_in_parent)
|
|
123
123
|
else
|
|
124
|
-
errors.add(:parent, :is_not_nestable) unless
|
|
125
|
-
errors.add(:child, :is_not_nestable) unless
|
|
124
|
+
errors.add(:parent, :is_not_nestable) unless nestable?(parent)
|
|
125
|
+
errors.add(:child, :is_not_nestable) unless nestable?(child)
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
|
+
|
|
129
|
+
def find_parent(parent_id)
|
|
130
|
+
Hyrax.query_service.find_by(id: parent_id)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def find_child(child_id)
|
|
134
|
+
Hyrax.query_service.find_by(id: child_id)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def nestable?(collection)
|
|
138
|
+
return false if collection.blank?
|
|
139
|
+
return collection.nestable? if collection.respond_to? :nestable?
|
|
140
|
+
collection_type = Hyrax::CollectionType.find_by_gid!(collection.collection_type_gid)
|
|
141
|
+
collection_type.nestable?
|
|
142
|
+
end
|
|
128
143
|
end
|
|
129
144
|
end
|
|
130
145
|
end
|
|
@@ -7,16 +7,12 @@ module Hyrax
|
|
|
7
7
|
self.model_class = PermissionTemplate
|
|
8
8
|
self.terms = []
|
|
9
9
|
delegate :access_grants, :access_grants_attributes=, :release_date, :release_period, :visibility, to: :model
|
|
10
|
-
delegate :available_workflows, :active_workflow, :
|
|
11
|
-
|
|
12
|
-
# @return [#to_s] the primary key of the associated admin_set or collection
|
|
13
|
-
# def source_id (because you might come looking for this method)
|
|
14
|
-
delegate :id, to: :source_model, prefix: :source
|
|
10
|
+
delegate :available_workflows, :active_workflow, :source, :source_id, to: :model
|
|
15
11
|
|
|
16
12
|
##
|
|
17
|
-
# @deprecated use PermissionTemplate#
|
|
13
|
+
# @deprecated use PermissionTemplate#reset_access_controls_for instead.
|
|
18
14
|
def reset_access_controls!
|
|
19
|
-
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#
|
|
15
|
+
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
|
|
20
16
|
source_model.reset_access_controls!
|
|
21
17
|
end
|
|
22
18
|
|
|
@@ -73,8 +69,8 @@ module Hyrax
|
|
|
73
69
|
# Copy this access to the permissions of the Admin Set or Collection and to
|
|
74
70
|
# the WorkflowResponsibilities of the active workflow if this is an Admin Set
|
|
75
71
|
def update_access(remove_agent: false)
|
|
76
|
-
|
|
77
|
-
update_workflow_responsibilities(remove_agent: remove_agent) if
|
|
72
|
+
model.reset_access_controls_for(collection: source)
|
|
73
|
+
update_workflow_responsibilities(remove_agent: remove_agent) if source.is_a?(Hyrax::AdministrativeSet)
|
|
78
74
|
end
|
|
79
75
|
|
|
80
76
|
# This method is used to revoke access to a Collection or Admin Set and its workflows
|
|
@@ -85,6 +81,18 @@ module Hyrax
|
|
|
85
81
|
update_access(remove_agent: true)
|
|
86
82
|
end
|
|
87
83
|
|
|
84
|
+
##
|
|
85
|
+
# A bit of an analogue for a `belongs_to :source_model` as it crosses from Fedora to the DB
|
|
86
|
+
# @return [AdminSet, ::Collection]
|
|
87
|
+
# @raise [Hyrax::ObjectNotFoundError] when neither an AdminSet or Collection is found
|
|
88
|
+
# @note This method will eventually be replaced by #source which returns a Hyrax::Resource
|
|
89
|
+
# object. Many methods are equally able to process both Hyrax::Resource and
|
|
90
|
+
# ActiveFedora::Base. Only call this method if you need the ActiveFedora::Base object.
|
|
91
|
+
# @see #source
|
|
92
|
+
def source_model # rubocop:disable Rails/Delegate
|
|
93
|
+
model.source_model
|
|
94
|
+
end
|
|
95
|
+
|
|
88
96
|
private
|
|
89
97
|
|
|
90
98
|
# @return [String]
|
|
@@ -33,7 +33,7 @@ module Hyrax
|
|
|
33
33
|
class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength
|
|
34
34
|
##
|
|
35
35
|
# @api private
|
|
36
|
-
|
|
36
|
+
InWorksPrepopulator = lambda do |_options|
|
|
37
37
|
self.in_works_ids =
|
|
38
38
|
if persisted?
|
|
39
39
|
Hyrax.query_service
|
|
@@ -52,7 +52,7 @@ module Hyrax
|
|
|
52
52
|
# with `etag`-driven, application-side lock checks. for non-wings adapters
|
|
53
53
|
# we want to move away from application side lock validation and rely
|
|
54
54
|
# on the adapter/database features instead.
|
|
55
|
-
|
|
55
|
+
LockKeyPrepopulator = lambda do |_options|
|
|
56
56
|
if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
|
|
57
57
|
Hyrax.logger.info "trying to prepopulate a lock token for " \
|
|
58
58
|
"#{self.class.inspect}, but optimistic locking isn't " \
|
|
@@ -95,10 +95,12 @@ module Hyrax
|
|
|
95
95
|
property :visibility_during_lease, virtual: true, prepopulator: ->(_opts) { self.visibility_during_lease = model.lease&.visibility_during_lease }
|
|
96
96
|
|
|
97
97
|
# pcdm relationships
|
|
98
|
-
property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id =
|
|
99
|
-
property :in_works_ids, virtual: true, prepopulator:
|
|
98
|
+
property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s }
|
|
99
|
+
property :in_works_ids, virtual: true, prepopulator: InWorksPrepopulator
|
|
100
100
|
property :member_ids, default: [], type: Valkyrie::Types::Array
|
|
101
101
|
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
|
102
|
+
property :member_of_collections_attributes, virtual: true
|
|
103
|
+
validates_with CollectionMembershipValidator
|
|
102
104
|
|
|
103
105
|
property :representative_id, type: Valkyrie::Types::String
|
|
104
106
|
property :thumbnail_id, type: Valkyrie::Types::String
|
|
@@ -112,7 +114,7 @@ module Hyrax
|
|
|
112
114
|
# the model is disabled
|
|
113
115
|
#
|
|
114
116
|
# @see https://github.com/samvera/valkyrie/wiki/Optimistic-Locking
|
|
115
|
-
property :version, virtual: true, prepopulator:
|
|
117
|
+
property :version, virtual: true, prepopulator: LockKeyPrepopulator
|
|
116
118
|
|
|
117
119
|
# backs the child work search element;
|
|
118
120
|
# @todo: look for a way for the view template not to depend on this
|
|
@@ -131,6 +133,8 @@ module Hyrax
|
|
|
131
133
|
"#{resource.class.name}Form".constantize.new(resource)
|
|
132
134
|
rescue NameError => _err
|
|
133
135
|
case resource
|
|
136
|
+
when Hyrax::AdministrativeSet
|
|
137
|
+
Hyrax::Forms::AdministrativeSetForm.new(resource)
|
|
134
138
|
when Hyrax::FileSet
|
|
135
139
|
Hyrax::Forms::FileSetForm.new(resource)
|
|
136
140
|
when Hyrax::PcdmCollection
|
|
@@ -191,6 +191,20 @@ module Hyrax
|
|
|
191
191
|
CollectionType.find_or_create_default_collection_type.title
|
|
192
192
|
end
|
|
193
193
|
|
|
194
|
+
##
|
|
195
|
+
# @param collection [Object]
|
|
196
|
+
#
|
|
197
|
+
# @return [PermissionTemplateForm]
|
|
198
|
+
def collection_permission_template_form_for(form:)
|
|
199
|
+
case form
|
|
200
|
+
when Valkyrie::ChangeSet
|
|
201
|
+
template_model = Hyrax::PermissionTemplate.find_or_create_by(source_id: form.id.to_s)
|
|
202
|
+
Hyrax::Forms::PermissionTemplateForm.new(template_model)
|
|
203
|
+
else
|
|
204
|
+
form.permission_template
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
194
208
|
private
|
|
195
209
|
|
|
196
210
|
# add hidden fields to a form for performing an action on a single document on a collection
|
|
@@ -15,7 +15,7 @@ module Hyrax
|
|
|
15
15
|
args[:data]['remove-text'] = args[:remove_text]
|
|
16
16
|
|
|
17
17
|
args[:data][:url] = hyrax.trophy_work_path(id)
|
|
18
|
-
link_to '#', class: args[:class], data: args[:data] do
|
|
18
|
+
link_to '#', id: 'action-highlight-work', class: args[:class], data: args[:data] do
|
|
19
19
|
yield(text)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -3,7 +3,7 @@ module Hyrax
|
|
|
3
3
|
module UrlHelper
|
|
4
4
|
# generated models get registered as curation concerns and need a
|
|
5
5
|
# track_model_path to render Blacklight-related views
|
|
6
|
-
(['FileSet', 'Collection'] + Hyrax.config.registered_curation_concern_types).each do |concern|
|
|
6
|
+
(['FileSet', 'Collection', 'Hyrax::AdministrativeSet'] + Hyrax.config.registered_curation_concern_types).each do |concern|
|
|
7
7
|
model = concern.safe_constantize
|
|
8
8
|
model_name = model.respond_to?(:model_name) && model.model_name
|
|
9
9
|
next unless model_name
|
|
@@ -4,14 +4,20 @@ module Hyrax
|
|
|
4
4
|
##
|
|
5
5
|
# Indexes Hyrax::AdministrativeSet objects
|
|
6
6
|
class AdministrativeSetIndexer < Hyrax::ValkyrieIndexer
|
|
7
|
+
include Hyrax::ResourceIndexer
|
|
8
|
+
include Hyrax::PermissionIndexer
|
|
9
|
+
include Hyrax::VisibilityIndexer
|
|
7
10
|
include Hyrax::Indexer(:core_metadata)
|
|
8
11
|
|
|
9
12
|
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
10
13
|
super.tap do |solr_doc|
|
|
11
|
-
solr_doc[
|
|
14
|
+
solr_doc[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
|
|
12
15
|
solr_doc[:alternative_title_tesim] = resource.alternative_title
|
|
13
|
-
solr_doc[:creator_ssim] = resource.creator
|
|
16
|
+
solr_doc[:creator_ssim] = [resource.creator]
|
|
17
|
+
solr_doc[:creator_tesim] = [resource.creator]
|
|
14
18
|
solr_doc[:description_tesim] = resource.description
|
|
19
|
+
solr_doc[:generic_type_sim] = ['Admin Set']
|
|
20
|
+
solr_doc[:thumbnail_path_ss] = Hyrax::CollectionThumbnailPathService.call(resource)
|
|
15
21
|
end
|
|
16
22
|
end
|
|
17
23
|
end
|
|
@@ -41,7 +41,7 @@ module Hyrax
|
|
|
41
41
|
|
|
42
42
|
def fetch_with_persistence(resource)
|
|
43
43
|
old_label = resource.rdf_label.first
|
|
44
|
-
return unless old_label == resource.rdf_subject.to_s
|
|
44
|
+
return unless old_label == resource.rdf_subject.to_s
|
|
45
45
|
fetch_value(resource)
|
|
46
46
|
return if old_label == resource.rdf_label.first || resource.rdf_label.first == resource.rdf_subject.to_s
|
|
47
47
|
resource.persist! # Stores the fetched values into our marmotta triplestore
|
|
@@ -7,14 +7,16 @@ module Hyrax
|
|
|
7
7
|
include Hyrax::ResourceIndexer
|
|
8
8
|
include Hyrax::PermissionIndexer
|
|
9
9
|
include Hyrax::VisibilityIndexer
|
|
10
|
+
include Hyrax::ThumbnailIndexer
|
|
10
11
|
include Hyrax::Indexer(:core_metadata)
|
|
11
12
|
include Hyrax::Indexer(:basic_metadata)
|
|
12
13
|
|
|
14
|
+
self.thumbnail_path_service = CollectionThumbnailPathService
|
|
15
|
+
|
|
13
16
|
def to_solr
|
|
14
17
|
super.tap do |index_document|
|
|
15
18
|
index_document[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
|
|
16
19
|
index_document[:generic_type_sim] = ['Collection']
|
|
17
|
-
index_document[:thumbnail_path_ss] = Hyrax::CollectionThumbnailPathService.call(resource)
|
|
18
20
|
index_document[:depositor_ssim] = [resource.depositor]
|
|
19
21
|
index_document[:depositor_tesim] = [resource.depositor]
|
|
20
22
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Hyrax
|
|
3
|
+
module ThumbnailIndexer
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
included do
|
|
7
|
+
class_attribute :thumbnail_path_service
|
|
8
|
+
self.thumbnail_path_service = ThumbnailPathService
|
|
9
|
+
class_attribute :thumbnail_field
|
|
10
|
+
self.thumbnail_field = :thumbnail_path_ss
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Adds thumbnail indexing to the solr document of a valkyrie resource
|
|
14
|
+
def to_solr
|
|
15
|
+
super.tap do |solr_doc|
|
|
16
|
+
index_thumbnails(solr_doc)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Write the thumbnail paths into the solr_document
|
|
21
|
+
# @param [Hash] solr_document the solr document to add the field to
|
|
22
|
+
def index_thumbnails(solr_document)
|
|
23
|
+
solr_document[thumbnail_field] = thumbnail_path.to_s
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns the value for the thumbnail path to put into the solr document
|
|
27
|
+
def thumbnail_path
|
|
28
|
+
self.class.thumbnail_path_service.call(resource)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -7,20 +7,20 @@ module Hyrax
|
|
|
7
7
|
include Hyrax::ResourceIndexer
|
|
8
8
|
include Hyrax::PermissionIndexer
|
|
9
9
|
include Hyrax::VisibilityIndexer
|
|
10
|
+
include Hyrax::ThumbnailIndexer
|
|
10
11
|
include Hyrax::Indexer(:core_metadata)
|
|
11
12
|
include Hyrax::Indexer(:basic_metadata)
|
|
12
13
|
|
|
13
|
-
# include Hyrax::IndexesThumbnails # TODO: Is there a Valkyrie version of a thumbnail indexer?
|
|
14
|
-
|
|
15
14
|
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
16
15
|
super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength
|
|
17
16
|
solr_doc['generic_type_si'] = 'FileSet'
|
|
18
17
|
|
|
19
18
|
# Metadata from the FileSet
|
|
20
|
-
solr_doc['file_ids_ssim']
|
|
21
|
-
solr_doc['original_file_id_ssi']
|
|
22
|
-
solr_doc['
|
|
23
|
-
solr_doc['
|
|
19
|
+
solr_doc['file_ids_ssim'] = resource.file_ids&.map(&:to_s)
|
|
20
|
+
solr_doc['original_file_id_ssi'] = resource.original_file_id.to_s
|
|
21
|
+
solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s
|
|
22
|
+
solr_doc['hasRelatedMediaFragment_ssim'] = resource.representative_id.to_s
|
|
23
|
+
solr_doc['hasRelatedImage_ssim'] = resource.thumbnail_id.to_s
|
|
24
24
|
|
|
25
25
|
# Add in metadata from the original file.
|
|
26
26
|
file_metadata = original_file
|
|
@@ -64,14 +64,16 @@ module Hyrax
|
|
|
64
64
|
|
|
65
65
|
##
|
|
66
66
|
# @api public
|
|
67
|
-
# @return [
|
|
67
|
+
# @return [HashWithIndifferentAccess<Symbol, Object>]
|
|
68
68
|
def to_solr
|
|
69
69
|
{
|
|
70
70
|
"id": resource.id.to_s,
|
|
71
71
|
"date_uploaded_dtsi": resource.created_at,
|
|
72
72
|
"date_modified_dtsi": resource.updated_at,
|
|
73
|
+
"system_create_dtsi": resource.created_at,
|
|
74
|
+
"system_modified_dtsi": resource.updated_at,
|
|
73
75
|
"has_model_ssim": resource.internal_resource
|
|
74
|
-
}
|
|
76
|
+
}.with_indifferent_access
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
##
|
|
@@ -7,6 +7,7 @@ module Hyrax
|
|
|
7
7
|
include Hyrax::ResourceIndexer
|
|
8
8
|
include Hyrax::PermissionIndexer
|
|
9
9
|
include Hyrax::VisibilityIndexer
|
|
10
|
+
include Hyrax::ThumbnailIndexer
|
|
10
11
|
include Hyrax::Indexer(:core_metadata)
|
|
11
12
|
|
|
12
13
|
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
@@ -14,10 +15,16 @@ module Hyrax
|
|
|
14
15
|
solr_doc['generic_type_si'] = 'Work'
|
|
15
16
|
solr_doc['suppressed_bsi'] = suppressed?(resource)
|
|
16
17
|
solr_doc['admin_set_id_ssim'] = [resource.admin_set_id.to_s]
|
|
18
|
+
admin_set_label = admin_set_label(resource)
|
|
19
|
+
solr_doc['admin_set_sim'] = admin_set_label
|
|
20
|
+
solr_doc['admin_set_tesim'] = admin_set_label
|
|
21
|
+
solr_doc["#{Hyrax.config.admin_set_predicate.qname.last}_ssim"] = [resource.admin_set_id.to_s]
|
|
17
22
|
solr_doc['member_of_collection_ids_ssim'] = resource.member_of_collection_ids.map(&:to_s)
|
|
18
23
|
solr_doc['member_ids_ssim'] = resource.member_ids.map(&:to_s)
|
|
19
24
|
solr_doc['depositor_ssim'] = [resource.depositor]
|
|
20
25
|
solr_doc['depositor_tesim'] = [resource.depositor]
|
|
26
|
+
solr_doc['hasRelatedMediaFragment_ssim'] = [resource.representative_id.to_s]
|
|
27
|
+
solr_doc['hasRelatedImage_ssim'] = [resource.thumbnail_id.to_s]
|
|
21
28
|
end
|
|
22
29
|
end
|
|
23
30
|
|
|
@@ -26,5 +33,11 @@ module Hyrax
|
|
|
26
33
|
def suppressed?(resource)
|
|
27
34
|
Hyrax::ResourceStatus.new(resource: resource).inactive?
|
|
28
35
|
end
|
|
36
|
+
|
|
37
|
+
def admin_set_label(resource)
|
|
38
|
+
return if resource.admin_set_id.blank?
|
|
39
|
+
admin_set = Hyrax.query_service.find_by(id: resource.admin_set_id)
|
|
40
|
+
admin_set.title
|
|
41
|
+
end
|
|
29
42
|
end
|
|
30
43
|
end
|
|
@@ -62,10 +62,12 @@ class ControlledVocabularyInput < MultiValueInput
|
|
|
62
62
|
|
|
63
63
|
def build_options_for_new_row(_attribute_name, _index, options)
|
|
64
64
|
options[:value] = ''
|
|
65
|
+
options[:data][:label] = ''
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
def build_options_for_existing_row(_attribute_name, _index, value, options)
|
|
68
69
|
options[:value] = value.rdf_label.first || "Unable to fetch label for #{value.rdf_subject}"
|
|
70
|
+
options[:data][:label] = value.full_label || value.rdf_label
|
|
69
71
|
options[:readonly] = true
|
|
70
72
|
end
|
|
71
73
|
|