hyrax 5.0.0.rc1 → 5.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +11 -4
- data/.dassie/.env +5 -1
- data/.dassie/Gemfile +27 -42
- data/.dassie/Gemfile.dassie +2 -0
- data/.dassie/app/assets/config/manifest.js +2 -0
- data/.dassie/app/assets/stylesheets/hyrax.scss +1 -0
- data/.dassie/config/initializers/riiif.rb +5 -11
- data/.dassie/config/metadata/collection_resource.yaml +3 -0
- data/.dassie/config/metadata/monograph.yaml +8 -0
- data/.dassie/config/metadata/sample_metadata.yaml +1 -0
- data/.dassie/config/redis.yml +2 -0
- data/.dassie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
- data/.dassie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
- data/.dassie/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.hyrax.rb +8 -0
- data/.dassie/db/migrate/20230821153635_add_fields_to_counter_metric.rb +8 -0
- data/.dassie/db/schema.rb +20 -1
- data/.dockerignore +2 -1
- data/.gitignore +1 -1
- data/.koppie/.env +10 -4
- data/.koppie/Gemfile +10 -12
- data/.koppie/Gemfile.koppie +2 -0
- data/.koppie/Rakefile +0 -2
- data/.koppie/app/forms/collection_resource_form.rb +0 -1
- data/.koppie/app/indexers/collection_resource_indexer.rb +0 -1
- data/.koppie/app/models/ability.rb +1 -5
- data/.koppie/app/models/collection_resource.rb +0 -1
- data/.koppie/app/models/user.rb +0 -2
- data/.koppie/config/application.rb +2 -1
- data/.koppie/config/arkivo.yml +6 -0
- data/.koppie/config/blacklight.yml +2 -2
- data/.koppie/config/features.yml +2 -0
- data/.koppie/config/initializers/1_valkyrie.rb +29 -6
- data/.koppie/config/initializers/arkivo_constraint.rb +12 -0
- data/.koppie/config/initializers/hyrax.rb +2 -2
- data/.koppie/config/initializers/riiif.rb +6 -11
- data/.koppie/config/metadata/collection_resource.yaml +177 -1
- data/.koppie/config/metadata/generic_work.yaml +2 -0
- data/.koppie/config/metadata/monograph.yaml +10 -0
- data/.koppie/config/role_map.yml +3 -25
- data/.koppie/config/routes.rb +1 -2
- data/.koppie/config/solr.yml +1 -1
- data/.koppie/config/valkyrie_index.yml +4 -10
- data/.koppie/config/zotero.yml +6 -0
- data/.koppie/db/migrate/20230725222727_create_hyrax_counter_metrics.hyrax.rb +14 -0
- data/.koppie/db/migrate/20230803165135_change_work_id_to_string.rb +5 -0
- data/.koppie/db/schema.rb +12 -1
- data/CONTAINERS.md +1 -3
- data/Dockerfile +11 -2
- data/Gemfile +4 -21
- data/Gemfile.dassie +2 -0
- data/Gemfile.koppie +2 -0
- data/README.md +0 -1
- data/Rakefile +0 -11
- data/app/actors/hyrax/actors/embargo_actor.rb +3 -6
- data/app/assets/javascripts/hyrax/batch_select_all.js +1 -1
- data/app/assets/javascripts/hyrax/file_manager/member.es6 +1 -1
- data/app/assets/stylesheets/hyrax/_file-listing.scss +0 -2
- data/app/assets/stylesheets/hyrax/_work-show.scss +19 -3
- data/app/assets/stylesheets/hyrax/sidebar.scss +23 -0
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +7 -1
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +7 -1
- data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +14 -9
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +50 -9
- data/app/controllers/hyrax/api/items_controller.rb +2 -3
- data/app/controllers/hyrax/batch_edits_controller.rb +6 -6
- data/app/controllers/hyrax/batch_uploads_controller.rb +5 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
- data/app/controllers/hyrax/file_sets_controller.rb +49 -6
- data/app/controllers/hyrax/my/collections_controller.rb +2 -0
- data/app/controllers/hyrax/single_use_links_viewer_controller.rb +16 -2
- data/app/forms/concerns/hyrax/basic_metadata_form_fields_behavior.rb +38 -0
- data/app/forms/hyrax/forms/collection_form.rb +0 -15
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +0 -34
- data/app/forms/hyrax/forms/file_set_form.rb +2 -2
- data/app/forms/hyrax/forms/pcdm_object_form.rb +21 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +0 -7
- data/app/forms/hyrax/forms/resource_batch_edit_form.rb +49 -21
- data/app/forms/hyrax/forms/resource_form.rb +21 -34
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +13 -0
- data/app/indexers/hyrax/location_indexer.rb +29 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +0 -8
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +1 -6
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -0
- data/app/inputs/controlled_vocabulary_input.rb +1 -1
- data/app/jobs/characterize_job.rb +1 -1
- data/app/jobs/create_work_job.rb +36 -4
- data/app/jobs/valkyrie_characterization_job.rb +9 -0
- data/app/jobs/valkyrie_ingest_job.rb +1 -3
- data/app/models/collection_branding_info.rb +2 -9
- data/app/models/concerns/hyrax/ability.rb +2 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +4 -12
- data/app/models/concerns/hyrax/riiif_file.rb +30 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +19 -2
- data/app/models/hyrax/counter_metric.rb +7 -0
- data/app/models/hyrax/file_metadata.rb +3 -2
- data/app/models/hyrax/file_set.rb +75 -22
- data/app/models/hyrax/orcid_validator.rb +0 -6
- data/app/models/hyrax/work.rb +2 -5
- data/app/presenters/hyrax/collection_presenter.rb +0 -17
- data/app/presenters/hyrax/embargo_presenter.rb +4 -0
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +6 -4
- data/app/presenters/hyrax/version_list_presenter.rb +19 -10
- data/app/presenters/hyrax/version_presenter.rb +19 -4
- data/app/services/hyrax/admin_set_create_service.rb +0 -17
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +5 -0
- data/app/services/hyrax/collections/collection_member_service.rb +1 -1
- data/app/services/hyrax/embargo_manager.rb +45 -18
- data/app/services/hyrax/embargo_service.rb +12 -10
- data/app/services/hyrax/file_set_derivatives_service.rb +11 -11
- data/app/services/hyrax/fixity_check_failure_service.rb +1 -1
- data/app/services/hyrax/identifier/dispatcher.rb +9 -2
- data/app/services/hyrax/listeners/file_metadata_listener.rb +14 -6
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +2 -28
- data/app/services/hyrax/listeners/metadata_index_listener.rb +11 -0
- data/app/services/hyrax/lock_manager.rb +1 -2
- data/app/services/hyrax/riiif_file_resolver.rb +50 -0
- data/app/services/hyrax/simple_schema_loader.rb +31 -0
- data/app/services/hyrax/valkyrie_persist_derivatives.rb +1 -1
- data/app/services/hyrax/valkyrie_upload.rb +12 -26
- data/app/services/hyrax/versioning_service.rb +29 -15
- data/app/services/hyrax/work_uploads_handler.rb +1 -1
- data/app/validators/hyrax/collection_membership_validator.rb +1 -1
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/base/_file_manager_resource_form.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_component.html.erb +4 -4
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/base/_workflow_actions.html.erb +25 -23
- data/app/views/hyrax/base/show.json.jbuilder +2 -1
- data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +3 -3
- data/app/views/hyrax/file_sets/_versioning.html.erb +5 -5
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +4 -4
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
- data/app/views/hyrax/my/_search_form.html.erb +1 -1
- data/app/views/hyrax/notifications/_notifications.html.erb +1 -1
- data/app/views/hyrax/users/_vitals.html.erb +1 -1
- data/bin/dev-entrypoint.sh +13 -0
- data/chart/hyrax/Chart.yaml +3 -3
- data/chart/hyrax/templates/_helpers.tpl +8 -0
- data/chart/hyrax/templates/configmap-env.yaml +1 -1
- data/chart/hyrax/values.yaml +3 -0
- data/config/initializers/file_length_patch.rb +10 -0
- data/config/metadata/basic_metadata.yaml +52 -0
- data/config/metadata/core_metadata.yaml +4 -0
- data/config/metadata/file_set_metadata.yaml +19 -0
- data/config/metadata/hyrax_internal_metadata.yaml +57 -0
- data/docker-compose-koppie.yml +23 -22
- data/docker-compose-sirenia.yml +202 -0
- data/docker-compose.yml +27 -24
- data/documentation/developing-your-hyrax-based-app.md +2 -2
- data/hyrax.gemspec +10 -11
- data/karma.conf.js +1 -1
- data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +2 -0
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +13 -19
- data/lib/generators/hyrax/templates/db/migrate/20230725222727_create_hyrax_counter_metrics.rb.erb +14 -0
- data/lib/generators/hyrax/templates/db/migrate/20230803165135_change_work_id_to_string.rb.erb +5 -0
- data/lib/generators/hyrax/templates/db/migrate/20230808102105_add_indices_to_hyrax_counter_metrics.rb.erb +8 -0
- data/lib/generators/hyrax/templates/db/migrate/20230821153635_add_fields_to_counter_metric.rb.erb +8 -0
- data/lib/generators/hyrax/templates/db/seeds.rb +1 -1
- data/lib/generators/hyrax/work_resource/templates/form.rb.erb +1 -1
- data/lib/generators/hyrax/work_resource/templates/metadata.yaml +2 -0
- data/lib/hyrax/configuration.rb +147 -49
- data/lib/hyrax/controlled_vocabularies/location.rb +7 -1
- data/lib/hyrax/engine.rb +0 -1
- data/lib/hyrax/form_fields.rb +6 -0
- data/lib/hyrax/publisher.rb +4 -0
- data/lib/hyrax/redis_event_store.rb +7 -8
- data/lib/hyrax/resource_name.rb +4 -0
- data/lib/hyrax/specs/capybara.rb +25 -42
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +34 -7
- data/lib/hyrax/specs/shared_specs/indexers.rb +24 -6
- data/lib/hyrax/transactions/collection_destroy.rb +3 -2
- data/lib/hyrax/transactions/container.rb +42 -0
- data/lib/hyrax/transactions/file_metadata_destroy.rb +20 -0
- data/lib/hyrax/transactions/file_set_destroy.rb +3 -1
- data/lib/hyrax/transactions/file_set_update.rb +21 -0
- data/lib/hyrax/transactions/steps/add_to_parent.rb +1 -1
- data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +46 -0
- data/lib/hyrax/transactions/steps/delete_all_file_sets.rb +46 -0
- data/lib/hyrax/transactions/steps/file_metadata_delete.rb +40 -0
- data/lib/hyrax/transactions/steps/remove_from_membership.rb +45 -0
- data/lib/hyrax/transactions/work_destroy.rb +3 -2
- data/lib/hyrax/version.rb +1 -1
- data/lib/tasks/collection_type_global_id.rake +9 -4
- data/lib/tasks/embargo_lease.rake +1 -0
- data/lib/valkyrie/indexing/solr/indexing_adapter.rb +2 -0
- data/lib/wings/active_fedora_converter.rb +6 -0
- data/lib/wings/attribute_transformer.rb +24 -17
- data/lib/wings/model_transformer.rb +0 -8
- data/lib/wings/orm_converter.rb +23 -18
- data/lib/wings/setup.rb +2 -2
- data/lib/wings/valkyrie/storage.rb +8 -90
- data/lib/wings.rb +5 -0
- data/tasks/hyrax_dev.rake +2 -33
- data/template.rb +1 -1
- metadata +90 -72
- data/.engine_cart.yml +0 -3
- data/app/views/hyrax/users/_user_util_links_extra.html.erb +0 -0
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +0 -9
@@ -7,6 +7,10 @@ module Hyrax
|
|
7
7
|
self.required_fields = []
|
8
8
|
self.model_class = Hyrax.primary_work_type
|
9
9
|
|
10
|
+
# Terms that need to exclude from batch edit
|
11
|
+
class_attribute :terms_excluded
|
12
|
+
self.terms_excluded = [:abstract, :label, :source]
|
13
|
+
|
10
14
|
# Contains a list of titles of all the works in the batch
|
11
15
|
attr_accessor :names
|
12
16
|
|
@@ -17,38 +21,39 @@ module Hyrax
|
|
17
21
|
@names = []
|
18
22
|
@batch_document_ids = batch_document_ids
|
19
23
|
if @batch_document_ids.present?
|
20
|
-
|
24
|
+
combined_fields = model_attributes(model, initialize_combined_fields)
|
25
|
+
super(model.class.new(combined_fields))
|
21
26
|
else
|
22
27
|
super(model)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
26
31
|
def terms
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
self.class.terms
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.terms
|
36
|
+
return Hyrax::Forms::BatchEditForm.terms if model_class < ActiveFedora::Base
|
37
|
+
|
38
|
+
terms_primary = definitions.select { |_, definition| definition[:primary] }
|
39
|
+
.keys.map(&:to_sym)
|
40
|
+
terms_secondary = definitions.select { |_, definition| definition[:display] && !definition[:primary] }
|
41
|
+
.keys.map(&:to_sym)
|
42
|
+
|
43
|
+
(terms_primary + terms_secondary) - terms_excluded
|
31
44
|
end
|
32
45
|
|
33
46
|
attr_reader :batch_document_ids
|
34
47
|
|
35
48
|
# Returns a list of parameters we accept from the form
|
36
|
-
# rubocop:disable Metrics/MethodLength
|
37
49
|
def self.build_permitted_params
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
{ date_created: [] },
|
46
|
-
{ subject: [] },
|
47
|
-
{ language: [] },
|
48
|
-
{ identifier: [] },
|
49
|
-
{ based_near: [] },
|
50
|
-
{ related_url: [] },
|
51
|
-
{ permissions_attributes: [:type, :name, :access, :id, :_destroy] },
|
50
|
+
terms_permitted_params + additional_permitted_params
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns a list of parameters other than those terms for the form
|
54
|
+
# rubocop:disable Metrics/MethodLength
|
55
|
+
def self.additional_permitted_params
|
56
|
+
[{ permissions_attributes: [:type, :name, :access, :id, :_destroy] },
|
52
57
|
:on_behalf_of,
|
53
58
|
:version,
|
54
59
|
:add_works_to_collection,
|
@@ -63,6 +68,19 @@ module Hyrax
|
|
63
68
|
end
|
64
69
|
# rubocop:enable Metrics/MethodLength
|
65
70
|
|
71
|
+
# Returns a list of permitted parameters for the terms
|
72
|
+
# @param terms Array[Symbol]
|
73
|
+
# @return Array[Hash]
|
74
|
+
def self.terms_permitted_params
|
75
|
+
[].tap do |params|
|
76
|
+
terms.each do |term|
|
77
|
+
h = {}
|
78
|
+
h[term] = []
|
79
|
+
params << h
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
66
84
|
# @param name [Symbol]
|
67
85
|
# @return [Symbol]
|
68
86
|
# @note Added for ActiveModel compatibility.
|
@@ -80,11 +98,21 @@ module Hyrax
|
|
80
98
|
work = Hyrax.query_service.find_by(id: doc_id)
|
81
99
|
terms.each do |field|
|
82
100
|
combined_attributes[field] ||= []
|
83
|
-
combined_attributes[field] = (combined_attributes[field] + work[field]
|
101
|
+
combined_attributes[field] = (combined_attributes[field] + Array.wrap(work[field])).uniq
|
84
102
|
end
|
85
103
|
names << work.to_s
|
86
104
|
end
|
87
105
|
end
|
106
|
+
|
107
|
+
# Model attributes for ActiveFedora compatibility
|
108
|
+
def model_attributes(model, attrs)
|
109
|
+
return attrs unless model.is_a? ActiveFedora::Base
|
110
|
+
|
111
|
+
attrs.keys.each do |k|
|
112
|
+
attrs[k] = Array.wrap(attrs[k]).first unless model.class.properties[k.to_s]&.multiple?
|
113
|
+
end
|
114
|
+
attrs
|
115
|
+
end
|
88
116
|
end
|
89
117
|
end
|
90
118
|
end
|
@@ -5,29 +5,26 @@ module Hyrax
|
|
5
5
|
##
|
6
6
|
# @api public
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# class MonographForm < Hyrax::Forms::ResourceForm(Monograph)
|
10
|
-
# self.required_fields = [:title, :creator, :rights_statement]
|
11
|
-
# # other WorkForm-like configuration here
|
12
|
-
# end
|
8
|
+
# Returns the form class associated with a given model.
|
13
9
|
#
|
14
|
-
# @note The
|
15
|
-
#
|
16
|
-
# with existing Hyrax instances
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
10
|
+
# @note The default case assumes that the provided model class is for a
|
11
|
+
# PCDM object and returns a +Hyrax::Forms::PcdmObjectForm+. This is for
|
12
|
+
# backwards‐compatibility with existing Hyrax instances. However, a
|
13
|
+
# different +Hyrax::Forms::ResourceForm+ subclass will be returned in
|
14
|
+
# some known cases where that is preferable.
|
15
|
+
def self.ResourceForm(model_class)
|
16
|
+
@resource_forms ||= {}.compare_by_identity
|
17
|
+
@resource_forms[model_class] ||=
|
18
|
+
if model_class <= Hyrax::AdministrativeSet
|
19
|
+
Hyrax::Forms::AdministrativeSetForm
|
20
|
+
elsif model_class <= Hyrax::FileSet
|
21
|
+
Hyrax::Forms::FileSetForm
|
22
|
+
elsif model_class <= Hyrax::PcdmCollection
|
23
|
+
Hyrax::Forms::PcdmCollectionForm
|
24
|
+
else
|
25
|
+
"Hyrax::Forms::PcdmObjectForm".constantize # autoload
|
26
|
+
Hyrax::Forms::PcdmObjectForm(model_class)
|
29
27
|
end
|
30
|
-
end
|
31
28
|
end
|
32
29
|
|
33
30
|
##
|
@@ -121,19 +118,9 @@ module Hyrax
|
|
121
118
|
# monograph = Monograph.new
|
122
119
|
# change_set = Hyrax::Forms::ResourceForm.for(monograph)
|
123
120
|
def for(resource)
|
124
|
-
"#{resource.class.name}Form".
|
125
|
-
|
126
|
-
|
127
|
-
when Hyrax::AdministrativeSet
|
128
|
-
Hyrax::Forms::AdministrativeSetForm.new(resource)
|
129
|
-
when Hyrax::FileSet
|
130
|
-
Hyrax::Forms::FileSetForm.new(resource)
|
131
|
-
when Hyrax::PcdmCollection
|
132
|
-
Hyrax::Forms::PcdmCollectionForm.new(resource)
|
133
|
-
else
|
134
|
-
# NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
|
135
|
-
Hyrax::Forms::ResourceForm(resource.class).new(resource)
|
136
|
-
end
|
121
|
+
klass = "#{resource.class.name}Form".safe_constantize
|
122
|
+
klass ||= Hyrax::Forms::ResourceForm(resource.class)
|
123
|
+
klass.new(resource)
|
137
124
|
end
|
138
125
|
|
139
126
|
##
|
@@ -17,6 +17,19 @@ module Hyrax
|
|
17
17
|
'n/a'
|
18
18
|
end
|
19
19
|
|
20
|
+
def link_to_works(user = current_user)
|
21
|
+
state = Blacklight::SearchState.new(params, CatalogController.blacklight_config)
|
22
|
+
facet_type = if Hyrax.config.use_valkyrie?
|
23
|
+
state.add_facet_params('generic_type_si', 'Work')
|
24
|
+
else
|
25
|
+
state.add_facet_params('generic_type_sim', 'Work')
|
26
|
+
end
|
27
|
+
facet_depositor = state.add_facet_params('depositor_ssim', user.to_s)
|
28
|
+
state = Hash.new {}
|
29
|
+
state["f"] = facet_type["f"].merge(facet_depositor["f"])
|
30
|
+
link_to(t("hyrax.dashboard.stats.works"), main_app.search_catalog_path(state))
|
31
|
+
end
|
32
|
+
|
20
33
|
# @param user [User]
|
21
34
|
# @return [Integer] number of FileSets the user deposited
|
22
35
|
def number_of_files(user = current_user)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
##
|
5
|
+
# Indexes properties common to Hyrax::Resource types
|
6
|
+
module LocationIndexer
|
7
|
+
def to_solr
|
8
|
+
super.tap do |index_document|
|
9
|
+
index_document[:based_near_label_tesim] = based_near_label_lookup(resource.based_near) if resource.respond_to? :based_near
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def based_near_label_lookup(locations)
|
16
|
+
locations.map do |loc|
|
17
|
+
if URI.parse(loc)
|
18
|
+
location_service.full_label(loc)
|
19
|
+
else
|
20
|
+
loc
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def location_service
|
26
|
+
Hyrax.config.location_service
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -19,14 +19,6 @@ module Hyrax
|
|
19
19
|
index_document[:member_of_collection_ids_ssim] = resource.member_of_collection_ids.map(&:to_s)
|
20
20
|
index_document[:depositor_ssim] = [resource.depositor]
|
21
21
|
index_document[:depositor_tesim] = [resource.depositor]
|
22
|
-
# add all attributes that should be indexed for collections here
|
23
|
-
tesim_and_ssim_attributes = ['abstract', 'access_right', 'alternative_title', 'based_near',
|
24
|
-
'bibliographic_citation', 'contributor', 'identifier', 'import_url', 'publisher', 'label',
|
25
|
-
'language', 'license', 'publisher', 'rights_notes', 'rights_statement', 'source', 'subject']
|
26
|
-
tesim_and_ssim_attributes.each do |attribute|
|
27
|
-
index_document["#{attribute}_ssim"] = resource[attribute.to_s]
|
28
|
-
index_document["#{attribute}_tesim"] = resource[attribute.to_s]
|
29
|
-
end
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end
|
@@ -17,7 +17,7 @@ module Hyrax
|
|
17
17
|
|
18
18
|
# Metadata from the FileSet
|
19
19
|
solr_doc['file_ids_ssim'] = resource.file_ids&.map(&:to_s)
|
20
|
-
solr_doc['original_file_id_ssi'] =
|
20
|
+
solr_doc['original_file_id_ssi'] = resource.iiif_id
|
21
21
|
solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s
|
22
22
|
solr_doc['hasRelatedMediaFragment_ssim'] = resource.representative_id.to_s
|
23
23
|
solr_doc['hasRelatedImage_ssim'] = resource.thumbnail_id.to_s
|
@@ -106,11 +106,6 @@ module Hyrax
|
|
106
106
|
|
107
107
|
private
|
108
108
|
|
109
|
-
# Convert Valkyrie Original File Pointer to versioned url syntax expected by the iiif_presenter
|
110
|
-
def original_file_id
|
111
|
-
"#{resource.id}/files/#{resource.original_file_id}"
|
112
|
-
end
|
113
|
-
|
114
109
|
def file_format(file)
|
115
110
|
if file.mime_type.present? && file.format_label.present?
|
116
111
|
"#{file.mime_type.split('/').last} (#{file.format_label.join(', ')})"
|
@@ -44,7 +44,7 @@ class ControlledVocabularyInput < MultiValueInput
|
|
44
44
|
def hidden_id_field(value, index)
|
45
45
|
name = name_for(attribute_name, index, 'id')
|
46
46
|
id = id_for(attribute_name, index, 'id')
|
47
|
-
hidden_value = value.node? ? '' : value.rdf_subject
|
47
|
+
hidden_value = value.try(:node?) ? '' : value.rdf_subject
|
48
48
|
@builder.hidden_field(attribute_name, name: name, id: id, value: hidden_value, data: { id: 'remote' })
|
49
49
|
end
|
50
50
|
|
@@ -51,7 +51,7 @@ class CharacterizeJob < Hyrax::ApplicationJob
|
|
51
51
|
# value. So later we'll ensure it's set to the new file's filename.
|
52
52
|
reset_title = file_set.title.first == file_set.label
|
53
53
|
|
54
|
-
characterization_service.run(file_set.characterization_proxy, filepath)
|
54
|
+
characterization_service.run(file_set.characterization_proxy, filepath, **Hyrax.config.characterization_options)
|
55
55
|
Hyrax.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
|
56
56
|
file_set.characterization_proxy.alpha_channels = channels(filepath) if file_set.image? && Hyrax.config.iiif_image_server?
|
57
57
|
file_set.characterization_proxy.save!
|
data/app/jobs/create_work_job.rb
CHANGED
@@ -17,15 +17,47 @@ class CreateWorkJob < Hyrax::ApplicationJob
|
|
17
17
|
def perform(user, model, attributes, operation)
|
18
18
|
operation.performing!
|
19
19
|
work = model.constantize.new
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
if model.constantize < ActiveFedora::Base
|
21
|
+
status = batch_create_af_work(work, attributes, user)
|
22
|
+
errors = work.errors
|
23
|
+
else
|
24
|
+
result = batch_create_valkyrie_work(work, attributes, user)
|
25
|
+
status = result.success?
|
26
|
+
errors = result.failure&.last
|
27
|
+
end
|
28
|
+
|
23
29
|
return operation.success! if status
|
24
|
-
operation.fail!(
|
30
|
+
operation.fail!(errors.full_messages.join(' '))
|
25
31
|
end
|
26
32
|
|
27
33
|
private
|
28
34
|
|
35
|
+
def batch_create_af_work(work, attributes, user)
|
36
|
+
current_ability = Ability.new(user)
|
37
|
+
env = Hyrax::Actors::Environment.new(work, current_ability, attributes)
|
38
|
+
work_actor.create(env)
|
39
|
+
end
|
40
|
+
|
41
|
+
def batch_create_valkyrie_work(work, attributes, user)
|
42
|
+
uploaded_file_ids = attributes.delete(:uploaded_files)
|
43
|
+
files = Hyrax::UploadedFile.find(uploaded_file_ids)
|
44
|
+
permissions_params = attributes.delete(:permissions_attributes)
|
45
|
+
form = Hyrax::FormFactory.new.build(work, nil, nil)
|
46
|
+
form.validate(attributes)
|
47
|
+
|
48
|
+
transactions['change_set.create_work']
|
49
|
+
.with_step_args(
|
50
|
+
'work_resource.add_file_sets' => { uploaded_files: files },
|
51
|
+
'change_set.set_user_as_depositor' => { user: user },
|
52
|
+
'work_resource.save_acl' => { permissions_params: permissions_params }
|
53
|
+
)
|
54
|
+
.call(form)
|
55
|
+
end
|
56
|
+
|
57
|
+
def transactions
|
58
|
+
Hyrax::Transactions::Container
|
59
|
+
end
|
60
|
+
|
29
61
|
def work_actor
|
30
62
|
Hyrax::CurationConcern.actor
|
31
63
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class ValkyrieCharacterizationJob < Hyrax::ApplicationJob
|
3
|
+
queue_as Hyrax.config.ingest_queue_name
|
4
|
+
def perform(file_metadata_id)
|
5
|
+
file_metadata = Hyrax.custom_queries.find_file_metadata_by(id: file_metadata_id)
|
6
|
+
Hyrax.config.characterization_service
|
7
|
+
.run(metadata: file_metadata, file: file_metadata.file, **Hyrax.config.characterization_options)
|
8
|
+
end
|
9
|
+
end
|
@@ -25,14 +25,12 @@ class ValkyrieIngestJob < Hyrax::ApplicationJob
|
|
25
25
|
def ingest(file:, pcdm_use:)
|
26
26
|
file_set_uri = Valkyrie::ID.new(file.file_set_uri)
|
27
27
|
file_set = Hyrax.query_service.find_by(id: file_set_uri)
|
28
|
-
|
28
|
+
upload_file(
|
29
29
|
file: file,
|
30
30
|
file_set: file_set,
|
31
31
|
pcdm_use: pcdm_use,
|
32
32
|
user: file.user
|
33
33
|
)
|
34
|
-
|
35
|
-
ValkyrieCreateDerivativesJob.perform_later(file_set.id.to_s, updated_metadata.id.to_s)
|
36
34
|
end
|
37
35
|
|
38
36
|
##
|
@@ -19,15 +19,8 @@ class CollectionBrandingInfo < ApplicationRecord
|
|
19
19
|
super()
|
20
20
|
end
|
21
21
|
|
22
|
-
def delete(
|
23
|
-
id
|
24
|
-
Deprecation.warn('Passing an explict location path is ' \
|
25
|
-
'deprecated. Call without arguments instead.')
|
26
|
-
location_path
|
27
|
-
else
|
28
|
-
local_path
|
29
|
-
end
|
30
|
-
storage.delete(id: id)
|
22
|
+
def delete(_location_path = nil)
|
23
|
+
storage.delete(id: local_path)
|
31
24
|
end
|
32
25
|
|
33
26
|
def find_local_filename(collection_id, role, filename)
|
@@ -370,6 +370,7 @@ module Hyrax
|
|
370
370
|
can :manage, curation_concerns_models
|
371
371
|
can :manage, Sipity::WorkflowResponsibility
|
372
372
|
can :manage, :collection_types
|
373
|
+
can :manage, ::FileSet
|
373
374
|
end
|
374
375
|
|
375
376
|
##
|
@@ -418,7 +419,7 @@ module Hyrax
|
|
418
419
|
end
|
419
420
|
|
420
421
|
def curation_concerns_models
|
421
|
-
[::FileSet, Hyrax.config.collection_class] + Hyrax.config.curation_concerns
|
422
|
+
[::FileSet, ::Hyrax::FileSet, Hyrax.config.collection_class] + Hyrax.config.curation_concerns
|
422
423
|
end
|
423
424
|
|
424
425
|
def can_review_submissions?
|
@@ -28,9 +28,11 @@ module Hyrax
|
|
28
28
|
validates :collection_type_gid, presence: true
|
29
29
|
|
30
30
|
# Need to define here in order to override setter defined by ActiveTriples
|
31
|
-
def collection_type_gid=(new_collection_type_gid
|
31
|
+
def collection_type_gid=(new_collection_type_gid)
|
32
32
|
new_collection_type_gid = new_collection_type_gid&.to_s
|
33
|
-
raise "Can't modify collection type of this collection" if
|
33
|
+
raise "Can't modify collection type of this collection" if
|
34
|
+
!Thread.current[:force_collection_type_gid] && # Used by update_collection_type_global_ids rake task
|
35
|
+
persisted? && !collection_type_gid_was.nil? && collection_type_gid_was != new_collection_type_gid
|
34
36
|
new_collection_type = Hyrax::CollectionType.find_by_gid!(new_collection_type_gid)
|
35
37
|
super(new_collection_type_gid)
|
36
38
|
@collection_type = new_collection_type
|
@@ -38,16 +40,6 @@ module Hyrax
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
delegate(*Hyrax::CollectionType.settings_attributes, to: :collection_type)
|
42
|
-
ActiveSupport::Deprecation.deprecate_methods(self, *Hyrax::CollectionType.settings_attributes)
|
43
|
-
|
44
|
-
# Get the collection_type when accessed
|
45
|
-
def collection_type
|
46
|
-
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
47
|
-
"Instead, use Hyrax::CollectionType.for(collection: collection).")
|
48
|
-
@collection_type ||= Hyrax::CollectionType.find_by_gid!(collection_type_gid)
|
49
|
-
end
|
50
|
-
|
51
43
|
def collection_type=(new_collection_type)
|
52
44
|
self.collection_type_gid = new_collection_type.to_global_id
|
53
45
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
# Adds file locking to Riiif::File
|
4
|
+
# @see RiiifFileResolver
|
5
|
+
class RiiifFile < Riiif::File
|
6
|
+
include ActiveSupport::Benchmarkable
|
7
|
+
|
8
|
+
attr_reader :id
|
9
|
+
def initialize(input_path, tempfile = nil, id:)
|
10
|
+
super(input_path, tempfile)
|
11
|
+
raise(ArgumentError, "must specify id") if id.blank?
|
12
|
+
@id = id
|
13
|
+
end
|
14
|
+
|
15
|
+
# Wrap extract in a read lock and benchmark it
|
16
|
+
def extract(transformation, image_info = nil)
|
17
|
+
Riiif::Image.file_resolver.file_locks[id].with_read_lock do
|
18
|
+
benchmark "RiiifFile extracted #{path} with #{transformation.to_params}", level: :debug do
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def logger
|
27
|
+
Hyrax.logger
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -91,9 +91,9 @@ module Hyrax
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def visibility
|
94
|
-
@visibility ||= if
|
94
|
+
@visibility ||= if embargo_enforced?
|
95
95
|
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
|
96
|
-
elsif
|
96
|
+
elsif lease_enforced?
|
97
97
|
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
|
98
98
|
elsif public?
|
99
99
|
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
@@ -108,6 +108,23 @@ module Hyrax
|
|
108
108
|
first(Hyrax.config.collection_type_index_field)
|
109
109
|
end
|
110
110
|
|
111
|
+
def embargo_enforced?
|
112
|
+
return false if embargo_release_date.blank?
|
113
|
+
|
114
|
+
indexed_embargo_visibility = first('visibility_during_embargo_ssim')
|
115
|
+
# if we didn't index an embargo visibility, assume the release date means
|
116
|
+
# it's enforced
|
117
|
+
return true if indexed_embargo_visibility.blank?
|
118
|
+
|
119
|
+
# if the visibility and the visibility during embargo are the same, we're
|
120
|
+
# enforcing the embargo
|
121
|
+
self['visibility_ssi'] == indexed_embargo_visibility
|
122
|
+
end
|
123
|
+
|
124
|
+
def lease_enforced?
|
125
|
+
lease_expiration_date.present?
|
126
|
+
end
|
127
|
+
|
111
128
|
private
|
112
129
|
|
113
130
|
def model_classifier(classifier)
|
@@ -18,7 +18,7 @@ module Hyrax
|
|
18
18
|
"with id #{file.id}. Initializing a new one")
|
19
19
|
|
20
20
|
FileMetadata.new(file_identifier: file.id,
|
21
|
-
original_filename: File.basename(file.
|
21
|
+
original_filename: File.basename(file.disk_path))
|
22
22
|
end
|
23
23
|
|
24
24
|
class FileMetadata < Valkyrie::Resource
|
@@ -35,6 +35,7 @@ module Hyrax
|
|
35
35
|
ORIGINAL_FILE = ::Valkyrie::Vocab::PCDMUse.OriginalFile
|
36
36
|
EXTRACTED_TEXT = ::Valkyrie::Vocab::PCDMUse.ExtractedText
|
37
37
|
THUMBNAIL = ::Valkyrie::Vocab::PCDMUse.ThumbnailImage
|
38
|
+
SERVICE_FILE = ::Valkyrie::Vocab::PCDMUse.ServiceFile
|
38
39
|
|
39
40
|
##
|
40
41
|
# @param use [RDF::URI, Symbol]
|
@@ -58,7 +59,7 @@ module Hyrax
|
|
58
59
|
module_function :uri_for
|
59
60
|
end
|
60
61
|
|
61
|
-
attribute :file_identifier, Valkyrie::Types::ID # id of the file stored by the storage adapter
|
62
|
+
attribute :file_identifier, ::Valkyrie::Types::ID # id of the file stored by the storage adapter
|
62
63
|
attribute :alternate_ids, Valkyrie::Types::Set.of(Valkyrie::Types::ID) # id of the file, populated for queryability
|
63
64
|
attribute :file_set_id, ::Valkyrie::Types::ID # id of parent file set resource
|
64
65
|
|