hyrax 4.0.0 → 5.0.0.rc1
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 +116 -231
- data/.dassie/.env +3 -1
- data/.dassie/config/environments/test.rb +1 -0
- data/.dassie/config/initializers/hyrax.rb +3 -1
- data/.dassie/config/initializers/riiif.rb +13 -3
- data/.dassie/db/schema.rb +2 -2
- data/.dockerignore +6 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +10 -7
- data/.github/release.yml +5 -2
- data/.koppie/.env +3 -0
- data/.koppie/app/forms/collection_resource_form.rb +1 -0
- data/.koppie/app/indexers/collection_resource_indexer.rb +1 -0
- data/.koppie/app/models/collection_resource.rb +1 -0
- data/.koppie/config/environments/test.rb +1 -0
- data/.koppie/config/initializers/hyrax.rb +8 -2
- data/.koppie/config/initializers/riiif.rb +13 -4
- data/.koppie/config/metadata/collection_resource.yaml +1 -128
- data/.koppie/yarn.lock +23 -23
- data/.regen +1 -1
- data/CONTAINERS.md +1 -1
- data/Dockerfile +6 -11
- data/app/actors/hyrax/actors/base_actor.rb +4 -3
- data/app/actors/hyrax/actors/embargo_actor.rb +5 -2
- data/app/actors/hyrax/actors/lease_actor.rb +5 -2
- data/app/assets/javascripts/hyrax/file_manager/sorting.es6 +3 -2
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +1 -1
- data/app/controllers/concerns/hyrax/valkyrie_downloads_controller_behavior.rb +74 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +14 -5
- data/app/controllers/hyrax/admin/workflows_controller.rb +48 -3
- data/app/controllers/hyrax/batch_edits_controller.rb +33 -4
- data/app/controllers/hyrax/downloads_controller.rb +8 -1
- data/app/controllers/hyrax/file_sets_controller.rb +1 -0
- data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/permission_template_form.rb +2 -0
- data/app/forms/hyrax/forms/resource_batch_edit_form.rb +90 -0
- data/app/forms/hyrax/forms/work_embargo_form.rb +1 -0
- data/app/forms/hyrax/forms/work_form.rb +1 -1
- data/app/forms/hyrax/forms/work_lease_form.rb +1 -0
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +17 -9
- data/app/helpers/hyrax/membership_helper.rb +13 -1
- data/app/helpers/hyrax/work_form_helper.rb +0 -107
- data/app/indexers/hyrax/file_set_indexer.rb +6 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +8 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +41 -5
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +8 -2
- data/app/jobs/valkyrie_create_derivatives_job.rb +8 -7
- data/app/jobs/valkyrie_ingest_job.rb +0 -1
- data/app/models/admin_set.rb +1 -31
- data/app/models/concerns/hyrax/file_set/derivatives.rb +3 -2
- data/app/models/concerns/hyrax/solr_document_behavior.rb +1 -1
- data/app/models/hyrax/collection_type.rb +5 -14
- data/app/models/hyrax/file_metadata.rb +6 -7
- data/app/models/hyrax/file_set.rb +8 -0
- data/app/models/hyrax/resource.rb +30 -2
- data/app/presenters/hyrax/file_set_presenter.rb +6 -0
- data/app/presenters/hyrax/iiif_manifest_presenter.rb +3 -7
- data/app/presenters/hyrax/presenter_renderer.rb +0 -7
- data/app/presenters/hyrax/work_show_presenter.rb +6 -11
- data/app/search_builders/hyrax/file_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/valkyrie_abstract_type_relation.rb +37 -0
- data/app/search_builders/hyrax/valkyrie_work_relation.rb +9 -0
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +11 -9
- data/app/services/hyrax/custom_queries/find_by_date_range.rb +55 -0
- data/app/services/hyrax/custom_queries/find_count_by.rb +62 -0
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +1 -1
- data/app/services/hyrax/custom_queries/find_models_by_access.rb +59 -0
- data/app/services/hyrax/derivative_bucketed_storage.rb +25 -0
- data/app/services/hyrax/derivative_path.rb +14 -4
- data/app/services/hyrax/embargo_manager.rb +76 -10
- data/app/services/hyrax/file_set_derivatives_service.rb +3 -2
- data/app/services/hyrax/lease_manager.rb +88 -8
- data/app/services/hyrax/listeners/file_metadata_listener.rb +2 -2
- data/app/services/hyrax/listeners/workflow_listener.rb +8 -11
- data/app/services/hyrax/persist_directly_contained_output_file_service.rb +24 -2
- data/app/services/hyrax/solr_query_service.rb +7 -6
- data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
- data/app/services/hyrax/statistics/over_time.rb +1 -1
- data/app/services/hyrax/statistics/users/over_time.rb +3 -1
- data/app/services/hyrax/statistics/valkyrie_query_service.rb +49 -0
- data/app/services/hyrax/statistics/works/count.rb +1 -1
- data/app/services/hyrax/thumbnail_path_service.rb +5 -0
- data/app/services/hyrax/valkyrie_persist_derivatives.rb +16 -11
- data/app/services/hyrax/valkyrie_upload.rb +5 -3
- data/app/services/hyrax/versioning_service.rb +1 -0
- data/app/services/hyrax/visibility_intention.rb +1 -4
- data/app/services/hyrax/visibility_propagator.rb +1 -1
- data/app/services/hyrax/workflow/actionable_objects.rb +28 -3
- data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +1 -1
- data/app/services/hyrax/workflow/grant_read_to_depositor.rb +1 -1
- data/app/services/hyrax/workflow/permission_query.rb +23 -2
- data/app/views/hyrax/admin/workflows/_tabs.html.erb +9 -0
- data/app/views/hyrax/admin/workflows/index.html.erb +53 -76
- data/app/views/hyrax/base/_file_manager_members.html.erb +2 -2
- data/app/views/hyrax/base/_form.html.erb +0 -10
- data/app/views/hyrax/base/_form_permission_embargo.html.erb +1 -1
- data/app/views/hyrax/base/_form_permission_lease.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_component.html.erb +2 -2
- data/app/views/hyrax/base/_items.html.erb +1 -1
- data/app/views/hyrax/base/file_manager.html.erb +1 -1
- data/app/views/hyrax/base/show.json.jbuilder +2 -2
- data/app/views/hyrax/file_sets/show.html.erb +5 -3
- data/app/views/hyrax/homepage/_explore_collections.html.erb +1 -1
- data/chart/hyrax/Chart.yaml +18 -14
- data/chart/hyrax/README.md +34 -21
- data/chart/hyrax/templates/_helpers.tpl +26 -1
- data/chart/hyrax/templates/configmap-env.yaml +12 -2
- data/chart/hyrax/templates/secrets.yaml +1 -1
- data/chart/hyrax/values.yaml +36 -14
- data/config/initializers/listeners.rb +4 -10
- data/config/initializers/storage_adapter_initializer.rb +1 -1
- data/config/locales/hyrax.en.yml +8 -0
- data/config/metadata/file_set_metadata.yaml +1 -1
- data/docker-compose-koppie.yml +17 -4
- data/docker-compose.yml +19 -6
- data/documentation/developing-your-hyrax-based-app.md +6 -14
- data/documentation/legacyREADME.md +3 -1
- data/hyrax.gemspec +2 -2
- data/karma.conf.js +8 -9
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +15 -5
- data/lib/hyrax/active_fedora_dummy_model.rb +6 -1
- data/lib/hyrax/configuration.rb +6 -0
- data/lib/hyrax/engine.rb +2 -0
- data/lib/hyrax/publisher.rb +19 -3
- data/lib/hyrax/specs/capybara.rb +9 -4
- data/lib/hyrax/transactions/container.rb +5 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +6 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +40 -0
- data/lib/hyrax/transactions/steps/save.rb +21 -0
- data/lib/hyrax/transactions/work_create.rb +1 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +1 -0
- data/lib/wings/active_fedora_converter/default_work.rb +7 -2
- data/lib/wings/active_fedora_converter/file_metadata_node.rb +1 -1
- data/lib/wings/active_fedora_converter.rb +47 -11
- data/lib/wings/model_transformer.rb +23 -4
- data/lib/wings/setup.rb +21 -1
- data/lib/wings/valkyrie/persister.rb +4 -2
- data/package.json +3 -1
- data/template.rb +1 -1
- metadata +17 -12
- data/app/forms/hyrax/forms/file_manager_form.rb +0 -35
- data/app/services/hyrax/collections/migration_service.rb +0 -113
- data/app/views/hyrax/base/_form_collections_error.html.erb +0 -1
- data/app/views/hyrax/base/_form_in_works_error.html.erb +0 -3
- data/app/views/hyrax/base/_form_ordered_members_error.html.erb +0 -3
- data/app/views/hyrax/base/_form_visibility_error.html.erb +0 -19
@@ -266,6 +266,8 @@ module Hyrax
|
|
266
266
|
# rubocop:disable Metrics/CyclomaticComplexity
|
267
267
|
# rubocop:disable Metrics/PerceivedComplexity
|
268
268
|
def permission_template_update_params
|
269
|
+
return attributes unless attributes.key?(:release_varies) || attributes.key?(:release_embargo)
|
270
|
+
|
269
271
|
filtered_attributes = attributes.except(:release_varies, :release_embargo)
|
270
272
|
# If 'varies' before date option selected, then set release_period='before' and save release_date as-is
|
271
273
|
if attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Forms
|
4
|
+
class ResourceBatchEditForm < Hyrax::Forms::ResourceForm
|
5
|
+
include Hyrax::FormFields(:basic_metadata)
|
6
|
+
|
7
|
+
self.required_fields = []
|
8
|
+
self.model_class = Hyrax.primary_work_type
|
9
|
+
|
10
|
+
# Contains a list of titles of all the works in the batch
|
11
|
+
attr_accessor :names
|
12
|
+
|
13
|
+
# @param [Hyrax::Work] model the model backing the form
|
14
|
+
# @param [Ability] current_ability the user authorization model
|
15
|
+
# @param [Array<String>] batch_document_ids a list of document ids in the batch
|
16
|
+
def initialize(model, _current_ability, batch_document_ids)
|
17
|
+
@names = []
|
18
|
+
@batch_document_ids = batch_document_ids
|
19
|
+
if @batch_document_ids.present?
|
20
|
+
super(model.class.new(initialize_combined_fields))
|
21
|
+
else
|
22
|
+
super(model)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def terms
|
27
|
+
[:creator, :contributor, :description,
|
28
|
+
:keyword, :resource_type, :license, :publisher, :date_created,
|
29
|
+
:subject, :language, :identifier, :based_near,
|
30
|
+
:related_url]
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_reader :batch_document_ids
|
34
|
+
|
35
|
+
# Returns a list of parameters we accept from the form
|
36
|
+
# rubocop:disable Metrics/MethodLength
|
37
|
+
def self.build_permitted_params
|
38
|
+
[{ creator: [] },
|
39
|
+
{ contributor: [] },
|
40
|
+
{ description: [] },
|
41
|
+
{ keyword: [] },
|
42
|
+
{ resource_type: [] },
|
43
|
+
{ license: [] },
|
44
|
+
{ publisher: [] },
|
45
|
+
{ date_created: [] },
|
46
|
+
{ subject: [] },
|
47
|
+
{ language: [] },
|
48
|
+
{ identifier: [] },
|
49
|
+
{ based_near: [] },
|
50
|
+
{ related_url: [] },
|
51
|
+
{ permissions_attributes: [:type, :name, :access, :id, :_destroy] },
|
52
|
+
:on_behalf_of,
|
53
|
+
:version,
|
54
|
+
:add_works_to_collection,
|
55
|
+
:visibility_during_embargo,
|
56
|
+
:embargo_release_date,
|
57
|
+
:visibility_after_embargo,
|
58
|
+
:visibility_during_lease,
|
59
|
+
:lease_expiration_date,
|
60
|
+
:visibility_after_lease,
|
61
|
+
:visibility,
|
62
|
+
{ based_near_attributes: [:id, :_destroy] }]
|
63
|
+
end
|
64
|
+
# rubocop:enable Metrics/MethodLength
|
65
|
+
|
66
|
+
# @param name [Symbol]
|
67
|
+
# @return [Symbol]
|
68
|
+
# @note Added for ActiveModel compatibility.
|
69
|
+
def column_for_attribute(name)
|
70
|
+
name
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
76
|
+
# @return [Hash<String, Array>] the list of unique values per field
|
77
|
+
def initialize_combined_fields
|
78
|
+
# For each of the files in the batch, set the attributes to be the concatenation of all the attributes
|
79
|
+
batch_document_ids.each_with_object({}) do |doc_id, combined_attributes|
|
80
|
+
work = Hyrax.query_service.find_by(id: doc_id)
|
81
|
+
terms.each do |field|
|
82
|
+
combined_attributes[field] ||= []
|
83
|
+
combined_attributes[field] = (combined_attributes[field] + work[field].to_a).uniq
|
84
|
+
end
|
85
|
+
names << work.to_s
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -11,6 +11,7 @@ module Hyrax
|
|
11
11
|
# +EmbargoesControllerBehavior+.
|
12
12
|
class WorkEmbargoForm < Hyrax::ChangeSet
|
13
13
|
property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator, prepopulator: :embargo_populator
|
14
|
+
property :embargo_history, virtual: true, prepopulator: proc { |_opts| self.embargo_history = model.embargo&.embargo_history }
|
14
15
|
property :embargo_release_date, virtual: true, prepopulator: proc { |_opts| self.embargo_release_date = model.embargo&.embargo_release_date }
|
15
16
|
property :visibility_after_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_after_embargo = model.embargo&.visibility_after_embargo }
|
16
17
|
property :visibility_during_embargo, virtual: true, prepopulator: proc { |_opts| self.visibility_during_embargo = model.embargo&.visibility_during_embargo }
|
@@ -158,7 +158,7 @@ module Hyrax
|
|
158
158
|
# In particular we are discarding any access grant parameters for works that
|
159
159
|
# are going into a mediated deposit workflow.
|
160
160
|
def self.sanitize_params(form_params)
|
161
|
-
admin_set_id = form_params[:admin_set_id]
|
161
|
+
admin_set_id = Array(form_params[:admin_set_id]).first
|
162
162
|
return super if admin_set_id && workflow_for(admin_set_id: admin_set_id).allows_access_grant?
|
163
163
|
params_without_permissions = permitted_params.reject { |arg| arg.respond_to?(:key?) && arg.key?(:permissions_attributes) }
|
164
164
|
form_params.permit(*params_without_permissions)
|
@@ -11,6 +11,7 @@ module Hyrax
|
|
11
11
|
# +LeasesControllerBehavior+.
|
12
12
|
class WorkLeaseForm < Hyrax::ChangeSet
|
13
13
|
property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator, prepopulator: :lease_populator
|
14
|
+
property :lease_history, virtual: true, prepopulator: proc { |_opts| self.lease_history = model.lease&.lease_history }
|
14
15
|
property :lease_expiration_date, virtual: true, prepopulator: proc { |_opts| self.lease_expiration_date = model.lease&.lease_expiration_date }
|
15
16
|
property :visibility_after_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_after_lease = model.lease&.visibility_after_lease }
|
16
17
|
property :visibility_during_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_during_lease = model.lease&.visibility_during_lease }
|
@@ -6,13 +6,13 @@ module Hyrax
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# @param user [User]
|
9
|
-
# @
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @return [Integer] number of works that the user deposited
|
10
|
+
def number_of_works(user = current_user)
|
11
|
+
Hyrax::SolrQueryService
|
12
|
+
.new
|
13
|
+
.with_field_pairs(field_pairs: field_pairs(user))
|
14
|
+
.with_generic_type(generic_type: 'Work')
|
15
|
+
.count
|
16
16
|
rescue RSolr::Error::ConnectionRefused
|
17
17
|
'n/a'
|
18
18
|
end
|
@@ -20,7 +20,11 @@ module Hyrax
|
|
20
20
|
# @param user [User]
|
21
21
|
# @return [Integer] number of FileSets the user deposited
|
22
22
|
def number_of_files(user = current_user)
|
23
|
-
Hyrax::SolrQueryService
|
23
|
+
Hyrax::SolrQueryService
|
24
|
+
.new
|
25
|
+
.with_field_pairs(field_pairs: field_pairs(user))
|
26
|
+
.with_generic_type(generic_type: 'FileSet')
|
27
|
+
.count
|
24
28
|
rescue RSolr::Error::ConnectionRefused
|
25
29
|
'n/a'
|
26
30
|
end
|
@@ -28,7 +32,11 @@ module Hyrax
|
|
28
32
|
# @param user [User]
|
29
33
|
# @return [Integer] number of Collections the user created
|
30
34
|
def number_of_collections(user = current_user)
|
31
|
-
Hyrax::SolrQueryService
|
35
|
+
Hyrax::SolrQueryService
|
36
|
+
.new
|
37
|
+
.with_field_pairs(field_pairs: field_pairs(user))
|
38
|
+
.with_generic_type(generic_type: 'Collection')
|
39
|
+
.count
|
32
40
|
rescue RSolr::Error::ConnectionRefused
|
33
41
|
'n/a'
|
34
42
|
end
|
@@ -14,18 +14,30 @@ module Hyrax
|
|
14
14
|
#
|
15
15
|
# @see app/assets/javascripts/hyrax/relationships.js
|
16
16
|
def member_of_collections_json(resource)
|
17
|
+
# this is where we return for dassie
|
17
18
|
return resource.member_of_collections_json if
|
18
19
|
resource.respond_to?(:member_of_collections_json)
|
19
20
|
|
20
21
|
resource = resource.model if resource.respond_to?(:model)
|
21
22
|
|
22
|
-
Hyrax.custom_queries.find_collections_for(resource: resource)
|
23
|
+
existing_collections_array = Hyrax.custom_queries.find_collections_for(resource: resource) + add_collection_from_params
|
24
|
+
existing_collections_array.map do |collection|
|
23
25
|
{ id: collection.id.to_s,
|
24
26
|
label: collection.title.first,
|
25
27
|
path: url_for(collection) }
|
26
28
|
end.to_json
|
27
29
|
end
|
28
30
|
|
31
|
+
def add_collection_from_params
|
32
|
+
# avoid errors when creating Valkyrie resources from Dashboard >> Works
|
33
|
+
return [] if controller.params[:add_works_to_collection].blank?
|
34
|
+
|
35
|
+
# new valkyrie works need the collection from params when depositing directly into an existing collection
|
36
|
+
return [Hyrax.metadata_adapter.query_service.find_by(id: Valkyrie::ID.new(controller.params[:add_works_to_collection]))] if Hyrax.config.use_valkyrie?
|
37
|
+
|
38
|
+
[::Collection.find(@controller.params[:add_works_to_collection])]
|
39
|
+
end
|
40
|
+
|
29
41
|
##
|
30
42
|
# @param resource [#work_members_json]
|
31
43
|
#
|
@@ -97,112 +97,5 @@ module Hyrax
|
|
97
97
|
hash[presenter.title_or_label] = presenter.id
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
101
|
-
##
|
102
|
-
# This helper retrieves errors based on form type.
|
103
|
-
#
|
104
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
105
|
-
# @return [String] specific error message
|
106
|
-
def in_works_ids_errors_for(form:)
|
107
|
-
case form
|
108
|
-
when Hyrax::ChangeSet
|
109
|
-
form.errors[:in_works_ids]
|
110
|
-
else
|
111
|
-
form.model.errors[:in_works_ids]
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
##
|
116
|
-
# This helper retrieves errors based on form type.
|
117
|
-
#
|
118
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
119
|
-
# @return [String] specific error message
|
120
|
-
def ordered_member_ids_errors_for(form:)
|
121
|
-
case form
|
122
|
-
when Hyrax::ChangeSet
|
123
|
-
form.errors[:ordered_member_ids]
|
124
|
-
else
|
125
|
-
form.model.errors[:ordered_member_ids]
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
##
|
130
|
-
# This helper retrieves errors based on form type.
|
131
|
-
#
|
132
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
133
|
-
# @return [String] specific error message
|
134
|
-
def visibility_errors_for(form:)
|
135
|
-
case form
|
136
|
-
when Hyrax::ChangeSet
|
137
|
-
form.errors[:visibility]
|
138
|
-
else
|
139
|
-
form.model.errors[:visibility]
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
##
|
144
|
-
# This helper retrieves errors based on form type.
|
145
|
-
#
|
146
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
147
|
-
# @return [String] specific error message
|
148
|
-
def embargo_release_date_errors_for(form:)
|
149
|
-
case form
|
150
|
-
when Hyrax::ChangeSet
|
151
|
-
form.errors[:embargo_release_date]
|
152
|
-
else
|
153
|
-
form.model.errors[:embargo_release_date]
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
##
|
158
|
-
# This helper retrieves errors based on form type.
|
159
|
-
#
|
160
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
161
|
-
# @return [String] specific error message
|
162
|
-
def visibility_after_embargo_errors_for(form:)
|
163
|
-
case form
|
164
|
-
when Hyrax::ChangeSet
|
165
|
-
form.errors[:visibility_after_embargo]
|
166
|
-
else
|
167
|
-
form.model.errors[:visibility_after_embargo]
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
##
|
172
|
-
# This helper retrieves errors based on form type.
|
173
|
-
#
|
174
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
175
|
-
# @return [String] specific error message
|
176
|
-
def lease_expiration_date_errors_for(form:)
|
177
|
-
case form
|
178
|
-
when Hyrax::ChangeSet
|
179
|
-
form.errors[:lease_expiration_date_errors]
|
180
|
-
else
|
181
|
-
form.model.errors[:lease_expiration_date_errors]
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
##
|
186
|
-
# This helper retrieves errors based on form type.
|
187
|
-
#
|
188
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
189
|
-
# @return [String] specific error message
|
190
|
-
def visibility_after_lease_errors_for(form:)
|
191
|
-
case form
|
192
|
-
when Hyrax::ChangeSet
|
193
|
-
form.errors[:visibility_after_lease]
|
194
|
-
else
|
195
|
-
form.model.errors[:visibility_after_lease]
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
##
|
200
|
-
# This helper retrieves errors based on form type.
|
201
|
-
#
|
202
|
-
# @param form [Hyrax::Forms::WorkForm] or Hyrax::ChangeSet
|
203
|
-
# @return [String] specific error message
|
204
|
-
def full_collections_errors(form:)
|
205
|
-
form.full_error(:collections) || form.full_error(:member_of_collection_ids)
|
206
|
-
end
|
207
100
|
end
|
208
101
|
end
|
@@ -30,6 +30,7 @@ module Hyrax
|
|
30
30
|
solr_doc['original_checksum_tesim'] = object.original_checksum
|
31
31
|
solr_doc['alpha_channels_ssi'] = object.alpha_channels
|
32
32
|
solr_doc['original_file_id_ssi'] = original_file_id
|
33
|
+
solr_doc['extracted_text_id_ssi'] = extracted_text_id
|
33
34
|
solr_doc['generic_type_si'] = 'FileSet'
|
34
35
|
end
|
35
36
|
end
|
@@ -46,6 +47,11 @@ module Hyrax
|
|
46
47
|
Hyrax::VersioningService.versioned_file_id object.original_file
|
47
48
|
end
|
48
49
|
|
50
|
+
def extracted_text_id
|
51
|
+
return unless object.extracted_text
|
52
|
+
Hyrax::VersioningService.versioned_file_id object.extracted_text
|
53
|
+
end
|
54
|
+
|
49
55
|
def file_format
|
50
56
|
if object.mime_type.present? && object.format_label.present?
|
51
57
|
"#{object.mime_type.split('/').last} (#{object.format_label.join(', ')})"
|
@@ -19,6 +19,14 @@ 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
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Hyrax
|
4
4
|
##
|
5
5
|
# Indexes Hyrax::FileSet objects
|
6
|
-
class ValkyrieFileSetIndexer < Hyrax::ValkyrieIndexer
|
6
|
+
class ValkyrieFileSetIndexer < Hyrax::ValkyrieIndexer # rubocop:disable Metrics/ClassLength
|
7
7
|
include Hyrax::ResourceIndexer
|
8
8
|
include Hyrax::PermissionIndexer
|
9
9
|
include Hyrax::VisibilityIndexer
|
@@ -17,11 +17,14 @@ 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'] = original_file_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
|
24
24
|
|
25
|
+
index_lease(solr_doc)
|
26
|
+
index_embargo(solr_doc)
|
27
|
+
|
25
28
|
# Add in metadata from the original file.
|
26
29
|
file_metadata = Hyrax::FileSetFileService.new(file_set: resource).original_file
|
27
30
|
return solr_doc unless file_metadata
|
@@ -36,12 +39,13 @@ module Hyrax
|
|
36
39
|
|
37
40
|
solr_doc['file_format_tesim'] = file_format(file_metadata)
|
38
41
|
solr_doc['file_format_sim'] = file_format(file_metadata)
|
39
|
-
solr_doc['file_size_lts'] = file_metadata.
|
40
|
-
solr_doc['type_tesim'] = file_metadata.
|
42
|
+
solr_doc['file_size_lts'] = file_metadata.recorded_size[0]
|
43
|
+
solr_doc['type_tesim'] = file_metadata.pcdm_use.map(&:to_s) if file_metadata.pcdm_use.present?
|
44
|
+
solr_doc['pcdm_use_tesim'] = file_metadata.pcdm_use.map(&:to_s) if file_metadata.pcdm_use.present?
|
41
45
|
|
42
46
|
# attributes set by fits
|
43
47
|
solr_doc['format_label_tesim'] = file_metadata.format_label if file_metadata.format_label.present?
|
44
|
-
solr_doc['size_tesim'] = file_metadata.
|
48
|
+
solr_doc['size_tesim'] = file_metadata.recorded_size if file_metadata.recorded_size.present?
|
45
49
|
solr_doc['well_formed_tesim'] = file_metadata.well_formed if file_metadata.well_formed.present?
|
46
50
|
solr_doc['valid_tesim'] = file_metadata.valid if file_metadata.valid.present?
|
47
51
|
solr_doc['fits_version_tesim'] = file_metadata.fits_version if file_metadata.fits_version.present?
|
@@ -56,10 +60,13 @@ module Hyrax
|
|
56
60
|
|
57
61
|
solr_doc['height_tesim'] = file_metadata.height if file_metadata.height.present? # image, video
|
58
62
|
solr_doc['width_tesim'] = file_metadata.width if file_metadata.width.present? # image, video
|
63
|
+
solr_doc['height_is'] = Integer(file_metadata.height.first) if file_metadata.height.present?
|
64
|
+
solr_doc['width_is'] = Integer(file_metadata.width.first) if file_metadata.width.present?
|
59
65
|
|
60
66
|
# attributes set by fits for audio files
|
61
67
|
solr_doc['bit_depth_tesim'] = file_metadata.bit_depth if file_metadata.bit_depth.present?
|
62
68
|
solr_doc['channels_tesim'] = file_metadata.channels if file_metadata.channels.present?
|
69
|
+
solr_doc['alpha_channels_ssi'] = file_metadata.channels.first if file_metadata.channels.present?
|
63
70
|
solr_doc['data_format_tesim'] = file_metadata.data_format if file_metadata.data_format.present?
|
64
71
|
solr_doc['offset_tesim'] = file_metadata.offset if file_metadata.offset.present?
|
65
72
|
|
@@ -99,6 +106,11 @@ module Hyrax
|
|
99
106
|
|
100
107
|
private
|
101
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
|
+
|
102
114
|
def file_format(file)
|
103
115
|
if file.mime_type.present? && file.format_label.present?
|
104
116
|
"#{file.mime_type.split('/').last} (#{file.format_label.join(', ')})"
|
@@ -108,5 +120,29 @@ module Hyrax
|
|
108
120
|
file.format_label
|
109
121
|
end
|
110
122
|
end
|
123
|
+
|
124
|
+
def index_lease(doc)
|
125
|
+
if resource.lease&.active?
|
126
|
+
doc['lease_expiration_date_dtsi'] = resource.lease.lease_expiration_date&.to_datetime
|
127
|
+
doc['visibility_after_lease_ssim'] = resource.lease.visibility_after_lease
|
128
|
+
doc['visibility_during_lease_ssim'] = resource.lease.visibility_during_lease
|
129
|
+
else
|
130
|
+
doc['lease_history_ssim'] = resource&.lease&.lease_history
|
131
|
+
end
|
132
|
+
|
133
|
+
doc
|
134
|
+
end
|
135
|
+
|
136
|
+
def index_embargo(doc)
|
137
|
+
if resource.embargo&.active?
|
138
|
+
doc['embargo_release_date_dtsi'] = resource.embargo.embargo_release_date&.to_datetime
|
139
|
+
doc['visibility_after_embargo_ssim'] = resource.embargo.visibility_after_embargo
|
140
|
+
doc['visibility_during_embargo_ssim'] = resource.embargo.visibility_during_embargo
|
141
|
+
else
|
142
|
+
doc['embargo_history_ssim'] = resource&.embargo&.embargo_history
|
143
|
+
end
|
144
|
+
|
145
|
+
doc
|
146
|
+
end
|
111
147
|
end
|
112
148
|
end
|
@@ -25,6 +25,7 @@ module Hyrax
|
|
25
25
|
solr_doc['depositor_tesim'] = [resource.depositor]
|
26
26
|
solr_doc['hasRelatedMediaFragment_ssim'] = [resource.representative_id.to_s]
|
27
27
|
solr_doc['hasRelatedImage_ssim'] = [resource.thumbnail_id.to_s]
|
28
|
+
solr_doc['hasFormat_ssim'] = resource.rendering_ids.map(&:to_s) if resource.rendering_ids.present?
|
28
29
|
index_embargo(solr_doc)
|
29
30
|
index_lease(solr_doc)
|
30
31
|
end
|
@@ -43,19 +44,24 @@ module Hyrax
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def index_embargo(doc)
|
46
|
-
if
|
47
|
+
if resource.embargo&.active?
|
47
48
|
doc['embargo_release_date_dtsi'] = resource.embargo.embargo_release_date&.to_datetime
|
48
49
|
doc['visibility_after_embargo_ssim'] = resource.embargo.visibility_after_embargo
|
49
50
|
doc['visibility_during_embargo_ssim'] = resource.embargo.visibility_during_embargo
|
51
|
+
else
|
52
|
+
doc['embargo_history_ssim'] = resource&.embargo&.embargo_history
|
50
53
|
end
|
54
|
+
|
51
55
|
doc
|
52
56
|
end
|
53
57
|
|
54
58
|
def index_lease(doc)
|
55
|
-
if
|
59
|
+
if resource.lease&.active?
|
56
60
|
doc['lease_expiration_date_dtsi'] = resource.lease.lease_expiration_date&.to_datetime
|
57
61
|
doc['visibility_after_lease_ssim'] = resource.lease.visibility_after_lease
|
58
62
|
doc['visibility_during_lease_ssim'] = resource.lease.visibility_during_lease
|
63
|
+
else
|
64
|
+
doc['lease_history_ssim'] = resource&.lease&.lease_history
|
59
65
|
end
|
60
66
|
|
61
67
|
doc
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
|
3
3
|
queue_as Hyrax.config.ingest_queue_name
|
4
|
-
def perform(
|
4
|
+
def perform(file_set_id, file_id, _filepath = nil)
|
5
5
|
file_metadata = Hyrax.custom_queries.find_file_metadata_by(id: file_id)
|
6
6
|
return if file_metadata.video? && !Hyrax.config.enable_ffmpeg
|
7
7
|
# Get file into a local path.
|
@@ -9,15 +9,16 @@ class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
|
|
9
9
|
# Call derivatives with the file_set.
|
10
10
|
derivative_service = Hyrax::DerivativeService.for(file_metadata)
|
11
11
|
derivative_service.create_derivatives(file.disk_path)
|
12
|
+
reindex_parent(file_set_id)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
|
-
def
|
17
|
-
Hyrax.query_service
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Hyrax.
|
17
|
+
def reindex_parent(file_set_id)
|
18
|
+
file_set = Hyrax.query_service.find_by(id: file_set_id)
|
19
|
+
parent = Hyrax.custom_queries.find_parent_work(resource: file_set)
|
20
|
+
return unless parent.thumbnail_id == file_set.id
|
21
|
+
Hyrax.logger.debug { "Reindexing #{parent.id} due to creation of thumbnail derivatives." }
|
22
|
+
Hyrax.index_adapter.save(resource: parent)
|
22
23
|
end
|
23
24
|
end
|
@@ -25,7 +25,6 @@ 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
|
-
|
29
28
|
updated_metadata = upload_file(
|
30
29
|
file: file,
|
31
30
|
file_set: file_set,
|
data/app/models/admin_set.rb
CHANGED
@@ -42,25 +42,6 @@ class AdminSet < ActiveFedora::Base
|
|
42
42
|
before_destroy :check_if_not_default_set, :check_if_empty
|
43
43
|
after_destroy :destroy_permission_template
|
44
44
|
|
45
|
-
def self.default_set?(id)
|
46
|
-
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
47
|
-
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
|
48
|
-
Hyrax::AdminSetCreateService.default_admin_set?(id: id)
|
49
|
-
end
|
50
|
-
|
51
|
-
def default_set?
|
52
|
-
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
53
|
-
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
|
54
|
-
self.class.default_set?(id)
|
55
|
-
end
|
56
|
-
|
57
|
-
# Creates the default AdminSet and an associated PermissionTemplate with workflow
|
58
|
-
def self.find_or_create_default_admin_set_id
|
59
|
-
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
60
|
-
"Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id'.")
|
61
|
-
Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
62
|
-
end
|
63
|
-
|
64
45
|
def collection_type_gid
|
65
46
|
# allow AdminSet to behave more like a regular Collection
|
66
47
|
Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id
|
@@ -86,17 +67,6 @@ class AdminSet < ActiveFedora::Base
|
|
86
67
|
Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
|
87
68
|
end
|
88
69
|
|
89
|
-
##
|
90
|
-
# @deprecated use PermissionTemplate#reset_access_controls_for instead
|
91
|
-
#
|
92
|
-
# Calculate and update who should have edit access based on who
|
93
|
-
# has "manage" access in the PermissionTemplateAccess
|
94
|
-
def reset_access_controls!
|
95
|
-
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")
|
96
|
-
|
97
|
-
permission_template.reset_access_controls_for(collection: self)
|
98
|
-
end
|
99
|
-
|
100
70
|
# @api public
|
101
71
|
#
|
102
72
|
# return an id for the AdminSet.
|
@@ -120,7 +90,7 @@ class AdminSet < ActiveFedora::Base
|
|
120
90
|
end
|
121
91
|
|
122
92
|
def check_if_not_default_set
|
123
|
-
return true unless
|
93
|
+
return true unless Hyrax::AdminSetCreateService.default_admin_set?(id: id)
|
124
94
|
errors[:base] << I18n.t('hyrax.admin.admin_sets.delete.error_default_set')
|
125
95
|
throw :abort
|
126
96
|
end
|
@@ -43,8 +43,9 @@ module Hyrax
|
|
43
43
|
# # ./spec/jobs/create_derivatives_job_spec.rb:7:in `block (2 levels) in <top (required)>'
|
44
44
|
#
|
45
45
|
Hydra::Derivatives.source_file_service = Hyrax::LocalFileService
|
46
|
-
Hydra::Derivatives.output_file_service = Hyrax::
|
47
|
-
Hydra::Derivatives::FullTextExtract.output_file_service = Hyrax::PersistDirectlyContainedOutputFileService
|
46
|
+
Hydra::Derivatives.output_file_service = Hyrax::ValkyriePersistDerivatives
|
47
|
+
# Hydra::Derivatives::FullTextExtract.output_file_service = Hyrax::PersistDirectlyContainedOutputFileService
|
48
|
+
Hydra::Derivatives::FullTextExtract.output_file_service = Hyrax::ValkyriePersistDerivatives
|
48
49
|
before_destroy :cleanup_derivatives
|
49
50
|
# This completely overrides the version in Hydra::Works so that we
|
50
51
|
# read and write to a local file. It's important that characterization runs
|
@@ -49,7 +49,10 @@ module Hyrax
|
|
49
49
|
# @return [Hyrax::PcdmCollection | ::Collection] an instance of Hyrax::CollectionType with id = the model_id portion of the gid (e.g. 3)
|
50
50
|
# @raise [ActiveRecord::RecordNotFound] if record matching gid is not found
|
51
51
|
def self.for(collection:)
|
52
|
-
|
52
|
+
gid = collection.collection_type_gid
|
53
|
+
gid = gid.first if gid.is_a?(Enumerable)
|
54
|
+
|
55
|
+
find_by_gid!(gid)
|
53
56
|
end
|
54
57
|
|
55
58
|
# Find the collection type associated with the Global Identifier (gid)
|
@@ -67,7 +70,7 @@ module Hyrax
|
|
67
70
|
# @see #gid
|
68
71
|
# @see Hyrax::MultipleMembershipChecker
|
69
72
|
def self.gids_that_do_not_allow_multiple_membership
|
70
|
-
where(allow_multiple_membership: false).map
|
73
|
+
where(allow_multiple_membership: false).map { |c| c.to_global_id.to_s }
|
71
74
|
end
|
72
75
|
|
73
76
|
# Find the collection type associated with the Global Identifier (gid)
|
@@ -95,18 +98,6 @@ module Hyrax
|
|
95
98
|
SETTINGS_ATTRIBUTES
|
96
99
|
end
|
97
100
|
|
98
|
-
##
|
99
|
-
# @deprecation use #to_global_id
|
100
|
-
#
|
101
|
-
# Return the Global Identifier for this collection type.
|
102
|
-
# @return [String, nil] Global Identifier (gid) for this collection_type (e.g. gid://internal/hyrax-collectiontype/3)
|
103
|
-
#
|
104
|
-
# @see https://github.com/rails/globalid#usage
|
105
|
-
def gid
|
106
|
-
Deprecation.warn('use #to_global_id.')
|
107
|
-
to_global_id.to_s if id
|
108
|
-
end
|
109
|
-
|
110
101
|
##
|
111
102
|
# @return [Enumerable<Collection, PcdmCollection>]
|
112
103
|
def collections(use_valkyrie: Hyrax.config.use_valkyrie?)
|