hyrax 3.0.2 → 3.1.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/.circleci/config.yml +22 -0
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dockerignore +3 -0
- data/.env +0 -1
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +1 -1
- data/Dockerfile +12 -6
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
- data/app/forms/hyrax/forms/collection_form.rb +7 -3
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/permission.rb +23 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
- data/app/forms/hyrax/forms/resource_form.rb +10 -17
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
- data/app/helpers/hyrax/collections_helper.rb +88 -2
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/work_form_helper.rb +53 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
- data/app/inputs/controlled_vocabulary_input.rb +2 -5
- data/app/jobs/attach_files_to_work_job.rb +19 -10
- data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/models/admin_set.rb +6 -25
- data/app/models/concerns/hyrax/ability.rb +3 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/hyrax/file_set.rb +6 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission_template.rb +98 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +42 -0
- data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
- data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +31 -6
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
- data/app/presenters/hyrax/trophy_presenter.rb +33 -4
- data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
- data/app/presenters/hyrax/version_list_presenter.rb +19 -0
- data/app/presenters/hyrax/version_presenter.rb +3 -2
- data/app/presenters/hyrax/work_show_presenter.rb +25 -4
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +3 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +112 -27
- data/app/services/hyrax/collections/migration_service.rb +4 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
- data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
- data/app/services/hyrax/contextual_path.rb +23 -0
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
- data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
- data/app/services/hyrax/edit_permissions_service.rb +27 -20
- data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
- data/app/services/hyrax/multiple_membership_checker.rb +51 -31
- data/app/services/hyrax/resource_status.rb +7 -0
- data/app/services/hyrax/search_service.rb +4 -2
- data/app/services/hyrax/solr_query_builder_service.rb +29 -6
- data/app/services/hyrax/solr_query_service.rb +224 -0
- data/app/services/hyrax/solr_service.rb +8 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/work_uploads_handler.rb +17 -2
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
- data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
- data/app/views/hyrax/base/_form_representative.html.erb +1 -1
- data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_guts4form.html.erb +2 -2
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
- data/app/views/hyrax/file_sets/edit.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/file_sets/show.html.erb +1 -1
- data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
- data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
- data/bin/solrcloud-assign-configset.sh +8 -5
- data/bin/solrcloud-upload-configset.sh +4 -2
- data/chart/hyrax/Chart.yaml +3 -3
- data/chart/hyrax/README.md +47 -1
- data/chart/hyrax/templates/_helpers.tpl +1 -1
- data/chart/hyrax/templates/configmap-env.yaml +1 -3
- data/chart/hyrax/templates/deployment-worker.yaml +6 -3
- data/chart/hyrax/templates/deployment.yaml +8 -3
- data/chart/hyrax/values.yaml +12 -0
- data/config/brakeman.ignore +2 -2
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +1 -1
- data/config/locales/hyrax.es.yml +1 -1
- data/config/locales/hyrax.fr.yml +1 -1
- data/config/locales/hyrax.it.yml +1 -1
- data/config/locales/hyrax.pt-BR.yml +1 -1
- data/config/locales/hyrax.zh.yml +1 -1
- data/docker-compose.yml +1 -0
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +8 -0
- data/lib/hyrax/engine.rb +1 -0
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/specs/capybara.rb +3 -1
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +21 -0
- data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +9 -0
- data/lib/tasks/collection_type_global_id.rake +1 -1
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/orm_converter.rb +18 -2
- data/lib/wings/setup.rb +1 -0
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/template.rb +1 -1
- metadata +17 -2
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module Hyrax
|
|
3
3
|
module WorkFormHelper
|
|
4
|
+
##
|
|
5
|
+
# @todo this implementation hits database backends (solr) and is invoked
|
|
6
|
+
# from views. refactor to avoid
|
|
7
|
+
# @return [Array<Array<String, String, Hash>] options for the admin set drop down.
|
|
8
|
+
def admin_set_options
|
|
9
|
+
return @admin_set_options.select_options if @admin_set_options
|
|
10
|
+
|
|
11
|
+
service = Hyrax::AdminSetService.new(controller)
|
|
12
|
+
Hyrax::AdminSetOptionsPresenter.new(service).select_options
|
|
13
|
+
end
|
|
14
|
+
|
|
4
15
|
##
|
|
5
16
|
# This helper allows downstream applications and engines to add/remove/reorder the tabs to be
|
|
6
17
|
# rendered on the work form.
|
|
@@ -26,6 +37,29 @@ module Hyrax
|
|
|
26
37
|
end
|
|
27
38
|
end
|
|
28
39
|
|
|
40
|
+
##
|
|
41
|
+
# This helper allows downstream applications and engines to change the label of tabs to be
|
|
42
|
+
# rendered on the work form.
|
|
43
|
+
#
|
|
44
|
+
# @example passing information from the form into the translations
|
|
45
|
+
# Override this helper and ensure that it loads after Hyrax's helpers.
|
|
46
|
+
# module WorksHelper
|
|
47
|
+
# def form_tab_label_for(form:, tab:)
|
|
48
|
+
# if tab == 'metadata'
|
|
49
|
+
# t("hyrax.works.form.tab.#{tab}", title: form.model.title.first)
|
|
50
|
+
# else
|
|
51
|
+
# super
|
|
52
|
+
# end
|
|
53
|
+
# end
|
|
54
|
+
# end
|
|
55
|
+
#
|
|
56
|
+
# @param form [Hyrax::Forms::WorkForm]
|
|
57
|
+
# @param tab [String]
|
|
58
|
+
# @return [String] the label of the tab to be rendered in the form
|
|
59
|
+
def form_tab_label_for(form:, tab:) # rubocop:disable Lint/UnusedMethodArgument
|
|
60
|
+
t("hyrax.works.form.tab.#{tab}")
|
|
61
|
+
end
|
|
62
|
+
|
|
29
63
|
##
|
|
30
64
|
# This helper allows downstream applications and engines to add additional sections to be
|
|
31
65
|
# rendered after the visibility section in the Save Work panel on the work form.
|
|
@@ -44,5 +78,24 @@ module Hyrax
|
|
|
44
78
|
def form_progress_sections_for(*)
|
|
45
79
|
[]
|
|
46
80
|
end
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# Constructs a hash for a form `select`.
|
|
84
|
+
#
|
|
85
|
+
# @param form [Object]
|
|
86
|
+
#
|
|
87
|
+
# @return [Array<Hash{String => String}>] a map from file set labels to ids for
|
|
88
|
+
# the parent object
|
|
89
|
+
def form_file_set_select_for(parent:)
|
|
90
|
+
return parent.select_files if parent.respond_to?(:select_files)
|
|
91
|
+
return {} unless parent.respond_to?(:member_ids)
|
|
92
|
+
|
|
93
|
+
file_sets =
|
|
94
|
+
Hyrax::PcdmMemberPresenterFactory.new(parent, nil).file_set_presenters
|
|
95
|
+
|
|
96
|
+
file_sets.each_with_object({}) do |presenter, hash|
|
|
97
|
+
hash[presenter.title_or_label] = presenter.id
|
|
98
|
+
end
|
|
99
|
+
end
|
|
47
100
|
end
|
|
48
101
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hyrax
|
|
4
|
+
##
|
|
5
|
+
# Indexes Hyrax::AdministrativeSet objects
|
|
6
|
+
class AdministrativeSetIndexer < Hyrax::ValkyrieIndexer
|
|
7
|
+
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
8
|
+
super.tap do |solr_doc|
|
|
9
|
+
solr_doc['generic_type_si'] = 'Admin Set'
|
|
10
|
+
solr_doc['alternative_title_tesim'] = resource.alternative_title
|
|
11
|
+
solr_doc['creator_ssim'] = resource.creator
|
|
12
|
+
solr_doc['description_tesim'] = resource.description
|
|
13
|
+
solr_doc['title_tesim'] = resource.title
|
|
14
|
+
solr_doc['title_sim'] = resource.title
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -68,8 +68,8 @@ module Hyrax
|
|
|
68
68
|
def to_solr
|
|
69
69
|
{
|
|
70
70
|
"id": resource.id.to_s,
|
|
71
|
-
"
|
|
72
|
-
"
|
|
71
|
+
"date_uploaded_dtsi": resource.created_at,
|
|
72
|
+
"date_modified_dtsi": resource.updated_at,
|
|
73
73
|
"has_model_ssim": resource.internal_resource
|
|
74
74
|
}
|
|
75
75
|
end
|
|
@@ -114,7 +114,7 @@ module Hyrax
|
|
|
114
114
|
|
|
115
115
|
return indexer_class if indexer_class.is_a?(Class) &&
|
|
116
116
|
indexer_class.instance_methods.include?(:to_solr)
|
|
117
|
-
ValkyrieIndexer
|
|
117
|
+
resource.try(:work?) ? Hyrax::ValkyrieWorkIndexer : ValkyrieIndexer
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
end
|
|
@@ -78,10 +78,7 @@ class ControlledVocabularyInput < MultiValueInput
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def collection
|
|
81
|
-
@collection ||=
|
|
82
|
-
|
|
83
|
-
col = val.respond_to?(:to_ary) ? val.to_ary : val
|
|
84
|
-
col.reject { |value| value.to_s.strip.blank? }
|
|
85
|
-
end
|
|
81
|
+
@collection ||=
|
|
82
|
+
Array(object[attribute_name]).reject { |v| v.to_s.strip.blank? }
|
|
86
83
|
end
|
|
87
84
|
end
|
|
@@ -23,19 +23,23 @@ class AttachFilesToWorkJob < Hyrax::ApplicationJob
|
|
|
23
23
|
user = User.find_by_user_key(depositor)
|
|
24
24
|
|
|
25
25
|
work, work_permissions = create_permissions work, depositor
|
|
26
|
-
metadata = visibility_attributes(work_attributes)
|
|
27
26
|
uploaded_files.each do |uploaded_file|
|
|
28
27
|
next if uploaded_file.file_set_uri.present?
|
|
29
|
-
|
|
30
|
-
actor = Hyrax::Actors::FileSetActor.new(FileSet.create, user)
|
|
31
|
-
uploaded_file.add_file_set!(actor.file_set)
|
|
32
|
-
actor.file_set.permissions_attributes = work_permissions
|
|
33
|
-
actor.create_metadata(metadata)
|
|
34
|
-
actor.create_content(uploaded_file)
|
|
35
|
-
actor.attach_to_work(work)
|
|
28
|
+
attach_work(user, work, work_attributes, work_permissions, uploaded_file)
|
|
36
29
|
end
|
|
37
30
|
end
|
|
38
31
|
|
|
32
|
+
def attach_work(user, work, work_attributes, work_permissions, uploaded_file)
|
|
33
|
+
actor = Hyrax::Actors::FileSetActor.new(FileSet.create, user)
|
|
34
|
+
file_set_attributes = file_set_attrs(work_attributes, uploaded_file)
|
|
35
|
+
metadata = visibility_attributes(work_attributes, file_set_attributes)
|
|
36
|
+
uploaded_file.add_file_set!(actor.file_set)
|
|
37
|
+
actor.file_set.permissions_attributes = work_permissions
|
|
38
|
+
actor.create_metadata(metadata)
|
|
39
|
+
actor.create_content(uploaded_file)
|
|
40
|
+
actor.attach_to_work(work, metadata)
|
|
41
|
+
end
|
|
42
|
+
|
|
39
43
|
def create_permissions(work, depositor)
|
|
40
44
|
work.edit_users += [depositor]
|
|
41
45
|
work.edit_users = work.edit_users.dup
|
|
@@ -44,13 +48,18 @@ class AttachFilesToWorkJob < Hyrax::ApplicationJob
|
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
# The attributes used for visibility - sent as initial params to created FileSets.
|
|
47
|
-
def visibility_attributes(attributes)
|
|
48
|
-
attributes.slice(:visibility, :visibility_during_lease,
|
|
51
|
+
def visibility_attributes(attributes, file_set_attributes)
|
|
52
|
+
attributes.merge(file_set_attributes).slice(:visibility, :visibility_during_lease,
|
|
49
53
|
:visibility_after_lease, :lease_expiration_date,
|
|
50
54
|
:embargo_release_date, :visibility_during_embargo,
|
|
51
55
|
:visibility_after_embargo)
|
|
52
56
|
end
|
|
53
57
|
|
|
58
|
+
def file_set_attrs(attributes, uploaded_file)
|
|
59
|
+
attrs = Array(attributes[:file_set]).find { |fs| fs[:uploaded_file_id].present? && (fs[:uploaded_file_id].to_i == uploaded_file&.id) }
|
|
60
|
+
Hash(attrs).symbolize_keys
|
|
61
|
+
end
|
|
62
|
+
|
|
54
63
|
def validate_files!(uploaded_files)
|
|
55
64
|
uploaded_files.each do |uploaded_file|
|
|
56
65
|
next if uploaded_file.is_a? Hyrax::UploadedFile
|
|
@@ -11,21 +11,22 @@ class AttachFilesToWorkWithOrderedMembersJob < AttachFilesToWorkJob
|
|
|
11
11
|
@ordered_members = work.ordered_members.to_a # Build array of ordered members
|
|
12
12
|
depositor = proxy_or_depositor(work)
|
|
13
13
|
user = User.find_by_user_key(depositor)
|
|
14
|
-
|
|
15
|
-
add_uploaded_files(user, metadata, work)
|
|
14
|
+
add_uploaded_files(user, work_attributes, work)
|
|
16
15
|
add_ordered_members(user, work)
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
private
|
|
20
19
|
|
|
21
|
-
def add_uploaded_files(user,
|
|
20
|
+
def add_uploaded_files(user, work_attributes, work)
|
|
22
21
|
work_permissions = work.permissions.map(&:to_hash)
|
|
23
22
|
uploaded_files.each do |uploaded_file|
|
|
23
|
+
file_set_attributes = file_set_attrs(work_attributes, uploaded_file)
|
|
24
|
+
metadata = visibility_attributes(work_attributes, file_set_attributes)
|
|
24
25
|
actor = file_set_actor_class.new(FileSet.create, user)
|
|
26
|
+
actor.file_set.permissions_attributes = work_permissions
|
|
25
27
|
actor.create_metadata(metadata)
|
|
26
28
|
actor.create_content(uploaded_file)
|
|
27
|
-
actor.attach_to_work(work)
|
|
28
|
-
actor.file_set.permissions_attributes = work_permissions
|
|
29
|
+
actor.attach_to_work(work, metadata)
|
|
29
30
|
ordered_members << actor.file_set
|
|
30
31
|
uploaded_file.update(file_set_uri: actor.file_set.uri)
|
|
31
32
|
end
|
|
@@ -5,12 +5,16 @@ class InheritPermissionsJob < Hyrax::ApplicationJob
|
|
|
5
5
|
# Perform the copy from the work to the contained filesets
|
|
6
6
|
#
|
|
7
7
|
# @param work containing access level and filesets
|
|
8
|
-
# @param use_valkyrie [Boolean] whether to use valkyrie support
|
|
9
|
-
def perform(work, use_valkyrie:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
# @param use_valkyrie [Boolean] whether to use valkyrie support (deprecated)
|
|
9
|
+
def perform(work, use_valkyrie: :DEFAULT)
|
|
10
|
+
Deprecation.warn("use_valkyrie argument is deprecated, behavior depends on deserialized resource") unless
|
|
11
|
+
use_valkyrie == :DEFAULT
|
|
12
|
+
|
|
13
|
+
case work
|
|
14
|
+
when ActiveFedora::Base
|
|
13
15
|
af_perform(work)
|
|
16
|
+
else
|
|
17
|
+
valkyrie_perform(work)
|
|
14
18
|
end
|
|
15
19
|
end
|
|
16
20
|
|
data/app/models/admin_set.rb
CHANGED
|
@@ -75,37 +75,18 @@ class AdminSet < ActiveFedora::Base
|
|
|
75
75
|
Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
##
|
|
79
|
+
# @deprecated use PermissionTemplate#reset_access_controls instead
|
|
80
|
+
#
|
|
78
81
|
# Calculate and update who should have edit access based on who
|
|
79
82
|
# has "manage" access in the PermissionTemplateAccess
|
|
80
83
|
def reset_access_controls!
|
|
81
|
-
|
|
82
|
-
# See also app/models/concerns/hyrax/collection_behavior.rb#reset_access_controls!
|
|
83
|
-
update!(edit_users: permission_template_edit_users,
|
|
84
|
-
edit_groups: permission_template_edit_groups,
|
|
85
|
-
read_users: permission_template_read_users,
|
|
86
|
-
read_groups: permission_template_read_groups)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
private
|
|
90
|
-
|
|
91
|
-
def permission_template_edit_users
|
|
92
|
-
permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def permission_template_edit_groups
|
|
96
|
-
permission_template.agent_ids_for(access: 'manage', agent_type: 'group')
|
|
97
|
-
end
|
|
84
|
+
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
|
|
98
85
|
|
|
99
|
-
|
|
100
|
-
(permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
|
|
101
|
-
permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
|
|
86
|
+
permission_template.reset_access_controls_for(collection: self)
|
|
102
87
|
end
|
|
103
88
|
|
|
104
|
-
|
|
105
|
-
(permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
|
|
106
|
-
permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
|
|
107
|
-
[::Ability.registered_group_name, ::Ability.public_group_name]
|
|
108
|
-
end
|
|
89
|
+
private
|
|
109
90
|
|
|
110
91
|
def destroy_permission_template
|
|
111
92
|
permission_template.destroy
|
|
@@ -417,8 +417,10 @@ module Hyrax
|
|
|
417
417
|
|
|
418
418
|
def extract_subjects(subject)
|
|
419
419
|
case subject
|
|
420
|
+
when Hyrax::WorkShowPresenter, FileSetPresenter, Hyrax::CollectionPresenter
|
|
421
|
+
extract_subjects(subject.solr_document)
|
|
420
422
|
when Draper::Decorator
|
|
421
|
-
|
|
423
|
+
extract_subjects(subject.model)
|
|
422
424
|
else
|
|
423
425
|
super
|
|
424
426
|
end
|
|
@@ -51,27 +51,22 @@ module Hyrax
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Add members using the members association.
|
|
54
|
-
# TODO: Confirm if this is ever used. I believe all relationships are done through
|
|
55
|
-
# add_member_objects using the member_of_collections relationship. Deprecate?
|
|
56
54
|
def add_members(new_member_ids)
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
|
56
|
+
"Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
|
|
57
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
|
|
58
|
+
new_member_ids: new_member_ids,
|
|
59
|
+
user: nil)
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
# Add member objects by adding this collection to the objects' member_of_collection association.
|
|
62
63
|
# @param [Enumerable<String>] the ids of the new child collections and works collection ids
|
|
63
64
|
def add_member_objects(new_member_ids)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else
|
|
70
|
-
member.member_of_collections << self
|
|
71
|
-
member.save!
|
|
72
|
-
end
|
|
73
|
-
member
|
|
74
|
-
end
|
|
65
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
|
66
|
+
"Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
|
|
67
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
|
|
68
|
+
new_member_ids: new_member_ids,
|
|
69
|
+
user: nil)
|
|
75
70
|
end
|
|
76
71
|
|
|
77
72
|
# @return [Enumerable<ActiveFedora::Base>] an enumerable over the children of this collection
|
|
@@ -125,41 +120,19 @@ module Hyrax
|
|
|
125
120
|
Hyrax::PermissionTemplate.find_by!(source_id: id)
|
|
126
121
|
end
|
|
127
122
|
|
|
123
|
+
##
|
|
124
|
+
# @deprecated use PermissionTemplate#reset_access_controls instead
|
|
125
|
+
#
|
|
128
126
|
# Calculate and update who should have read/edit access to the collections based on who
|
|
129
127
|
# has access in PermissionTemplateAccess
|
|
130
128
|
def reset_access_controls!
|
|
131
|
-
|
|
132
|
-
edit_groups: permission_template_edit_groups,
|
|
133
|
-
read_users: permission_template_read_users,
|
|
134
|
-
read_groups: (permission_template_read_groups + visibility_group).uniq)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
private
|
|
138
|
-
|
|
139
|
-
def permission_template_edit_users
|
|
140
|
-
permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
|
|
141
|
-
end
|
|
129
|
+
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
|
|
142
130
|
|
|
143
|
-
|
|
144
|
-
|
|
131
|
+
permission_template
|
|
132
|
+
.reset_access_controls_for(collection: self, interpret_visibility: true)
|
|
145
133
|
end
|
|
146
134
|
|
|
147
|
-
|
|
148
|
-
(permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
|
|
149
|
-
permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def permission_template_read_groups
|
|
153
|
-
(permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
|
|
154
|
-
permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
|
|
155
|
-
[::Ability.registered_group_name, ::Ability.public_group_name]
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def visibility_group
|
|
159
|
-
return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
|
160
|
-
return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
|
161
|
-
[]
|
|
162
|
-
end
|
|
135
|
+
private
|
|
163
136
|
|
|
164
137
|
# Solr field name works use to index member ids
|
|
165
138
|
def member_ids_field
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# By default, the file holding the metadata is :original_file and the terms
|
|
4
|
-
# are listed under ::characterization_terms.
|
|
5
|
-
# Implementations may define their own terms or use a different source file, but
|
|
6
|
-
# any terms must be set on the ::characterization_proxy by the Hydra::Works::CharacterizationService
|
|
7
|
-
#
|
|
8
|
-
# class MyFileSet
|
|
9
|
-
# include Hyrax::FileSetBehavior
|
|
10
|
-
# end
|
|
11
|
-
#
|
|
12
|
-
# MyFileSet.characterization_proxy = :master_file
|
|
13
|
-
# MyFileSet.characterization_terms = [:term1, :term2, :term3]
|
|
2
|
+
|
|
14
3
|
module Hyrax
|
|
15
4
|
class FileSet
|
|
5
|
+
##
|
|
6
|
+
# This module points the FileSet to the location of the technical metadata.
|
|
7
|
+
# By default, the file holding the metadata is +:original_file+ and the terms
|
|
8
|
+
# are listed under +.characterization_terms+.
|
|
9
|
+
#
|
|
10
|
+
# Implementations may define their own terms or use a different source file, but
|
|
11
|
+
# any terms must be set on the +.characterization_proxy+ by the
|
|
12
|
+
# +Hydra::Works::CharacterizationService+.
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# class MyFileSet
|
|
16
|
+
# include Hyrax::FileSetBehavior
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# MyFileSet.characterization_proxy = :master_file
|
|
20
|
+
# MyFileSet.characterization_terms = [:term1, :term2, :term3]
|
|
21
|
+
#
|
|
16
22
|
module Characterization
|
|
17
23
|
extend ActiveSupport::Concern
|
|
18
24
|
|
|
@@ -13,6 +13,8 @@ module Hyrax
|
|
|
13
13
|
#
|
|
14
14
|
# @see https://github.com/projectblacklight/blacklight/wiki/Understanding-Rails-and-Blacklight#models
|
|
15
15
|
module SolrDocumentBehavior
|
|
16
|
+
ModelWrapper = ActiveFedoraDummyModel # alias for backward compatibility
|
|
17
|
+
|
|
16
18
|
extend ActiveSupport::Concern
|
|
17
19
|
include Hydra::Works::MimeTypes
|
|
18
20
|
include Hyrax::Permissions::Readable
|
|
@@ -39,64 +41,13 @@ module Hyrax
|
|
|
39
41
|
title_or_label.to_s
|
|
40
42
|
end
|
|
41
43
|
|
|
42
|
-
##
|
|
43
|
-
# Given a model class and an +id+, provides +ActiveModel+ style model methods.
|
|
44
|
-
#
|
|
45
|
-
# @note access this via {SolrDocumentBehavior#to_model}.
|
|
46
|
-
class ModelWrapper
|
|
47
|
-
##
|
|
48
|
-
# @api private
|
|
49
|
-
#
|
|
50
|
-
# @param [Class] model
|
|
51
|
-
# @param [String, nil] id
|
|
52
|
-
def initialize(model, id)
|
|
53
|
-
@model = model
|
|
54
|
-
@id = id
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
##
|
|
58
|
-
# @api public
|
|
59
|
-
def persisted?
|
|
60
|
-
true
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
##
|
|
64
|
-
# @api public
|
|
65
|
-
def to_param
|
|
66
|
-
@id
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
##
|
|
70
|
-
# @api public
|
|
71
|
-
def model_name
|
|
72
|
-
@model.model_name
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
##
|
|
76
|
-
# @api public
|
|
77
|
-
#
|
|
78
|
-
# @note uses the @model's `._to_partial_path` if implemented, otherwise
|
|
79
|
-
# constructs a default
|
|
80
|
-
def to_partial_path
|
|
81
|
-
return @model._to_partial_path if
|
|
82
|
-
@model.respond_to?(:_to_partial_path)
|
|
83
|
-
|
|
84
|
-
"hyrax/#{model_name.collection}/#{model_name.element}"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
##
|
|
88
|
-
# @api public
|
|
89
|
-
def to_global_id
|
|
90
|
-
URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
44
|
##
|
|
94
45
|
# Offer the source model to Rails for some of the Rails methods (e.g. link_to).
|
|
95
46
|
#
|
|
96
47
|
# @example
|
|
97
48
|
# link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>
|
|
98
49
|
def to_model
|
|
99
|
-
@model ||=
|
|
50
|
+
@model ||= ActiveFedoraDummyModel.new(hydra_model, id)
|
|
100
51
|
end
|
|
101
52
|
|
|
102
53
|
##
|
|
@@ -117,6 +68,12 @@ module Hyrax
|
|
|
117
68
|
hydra_model == ::AdminSet
|
|
118
69
|
end
|
|
119
70
|
|
|
71
|
+
##
|
|
72
|
+
# @return [Boolean]
|
|
73
|
+
def work?
|
|
74
|
+
Hyrax.config.curation_concerns.include? hydra_model
|
|
75
|
+
end
|
|
76
|
+
|
|
120
77
|
# Method to return the model
|
|
121
78
|
def hydra_model(classifier: ActiveFedora.model_mapper)
|
|
122
79
|
"::#{first('has_model_ssim')}".safe_constantize ||
|