hyrax 3.4.1 → 3.4.2
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 +26 -17
- data/.dassie/.env +1 -1
- data/.dassie/Gemfile +1 -1
- data/.dassie/app/forms/collection_resource_form.rb +8 -0
- data/.dassie/app/indexers/collection_resource_indexer.rb +8 -0
- data/.dassie/app/models/collection_resource.rb +35 -0
- data/.dassie/config/initializers/file_services.rb +4 -0
- data/.dassie/config/initializers/hyrax.rb +2 -1
- data/.dassie/config/metadata/collection_resource.yaml +23 -0
- data/.dassie/db/seeds.rb +2 -0
- data/.dassie/spec/forms/collection_resource_form_spec.rb +13 -0
- data/.dassie/spec/indexers/collection_resource_indexer_spec.rb +14 -0
- data/.dassie/spec/models/collection_resource_spec.rb +13 -0
- data/.regen +1 -1
- data/.rubocop.yml +1 -1
- data/.rubocop_fixme.yml +19 -2
- data/CONTAINERS.md +18 -13
- data/Dockerfile +2 -2
- data/app/assets/javascripts/hyrax/collections_v2.es6 +13 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +1 -3
- data/app/controllers/hyrax/dashboard/collections_controller.rb +159 -75
- data/app/controllers/hyrax/single_use_links_viewer_controller.rb +1 -1
- data/app/forms/hyrax/forms/collection_form.rb +1 -1
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +29 -2
- data/app/forms/hyrax/forms/resource_form.rb +15 -1
- data/app/forms/hyrax/forms/widgets/admin_set_visibility.rb +1 -1
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +0 -1
- data/app/jobs/characterize_job.rb +5 -1
- data/app/jobs/import_url_job.rb +4 -6
- data/app/jobs/valkyrie_ingest_job.rb +15 -77
- data/app/models/admin_set.rb +8 -0
- data/app/models/concerns/hyrax/collection_behavior.rb +1 -1
- data/app/models/concerns/hyrax/user.rb +11 -0
- data/app/models/concerns/hyrax/work_behavior.rb +1 -1
- data/app/models/featured_work_list.rb +0 -1
- data/app/models/hyrax/file_metadata.rb +32 -2
- data/app/models/hyrax/file_set.rb +1 -3
- data/app/models/hyrax/group.rb +19 -0
- data/app/models/hyrax/pcdm_collection.rb +0 -1
- data/app/models/job_io_wrapper.rb +1 -1
- data/app/presenters/hyrax/member_presenter_factory.rb +2 -4
- data/app/presenters/hyrax/work_show_presenter.rb +3 -3
- data/app/services/hyrax/access_control_list.rb +7 -6
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +3 -3
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +3 -5
- data/app/services/hyrax/collections/collection_member_service.rb +3 -5
- data/app/services/hyrax/listeners/file_metadata_listener.rb +11 -0
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +14 -18
- data/app/services/hyrax/multiple_membership_checker.rb +2 -0
- data/app/services/hyrax/valkyrie_persist_derivatives.rb +50 -0
- data/app/services/hyrax/valkyrie_upload.rb +94 -0
- data/app/services/hyrax/workflow/workflow_importer.rb +7 -9
- data/app/services/hyrax/workflow/workflow_schema.rb +3 -5
- data/app/strategies/hyrax/strategies/yaml_strategy.rb +4 -6
- data/app/uploaders/hyrax/uploaded_file_uploader.rb +4 -4
- data/app/validators/hyrax/collection_membership_validator.rb +16 -15
- data/app/views/catalog/_index_header_list_default.html.erb +8 -1
- data/app/views/catalog/_thumbnail_list_default.html.erb +8 -3
- data/app/views/collections/edit_fields/_based_near.html.erb +7 -7
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -2
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -0
- data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +1 -1
- data/app/views/hyrax/my/works/_tabs.html.erb +6 -1
- data/chart/hyrax/Chart.yaml +10 -6
- data/chart/hyrax/templates/_helpers.tpl +4 -0
- data/chart/hyrax/templates/cron-embargo.yaml +5 -0
- data/chart/hyrax/templates/cron-lease.yaml +5 -0
- data/chart/hyrax/templates/deployment-worker.yaml +11 -0
- data/chart/hyrax/templates/ingress.yaml +7 -6
- data/chart/hyrax/values.yaml +152 -0
- data/config/features.rb +48 -50
- data/config/initializers/{valkryrie_storage.rb → storage_adapter_initializer.rb} +5 -0
- data/config/locales/hyrax.de.yml +12 -12
- data/docker-compose.yml +1 -0
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/hyrax.gemspec +5 -3
- data/lib/generators/hyrax/collection_resource/USAGE +20 -0
- data/lib/generators/hyrax/collection_resource/collection_resource_generator.rb +133 -0
- data/lib/generators/hyrax/collection_resource/templates/collection.rb.erb +34 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_form.rb.erb +7 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_form_spec.rb.erb +13 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +7 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_indexer_spec.rb.erb +13 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +22 -0
- data/lib/generators/hyrax/collection_resource/templates/collection_spec.rb.erb +12 -0
- data/lib/generators/hyrax/install_generator.rb +9 -0
- data/lib/hyrax/configuration.rb +12 -0
- data/lib/hyrax/publisher.rb +4 -0
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +0 -1
- data/lib/hyrax/transactions/collection_update.rb +2 -0
- data/lib/hyrax/transactions/container.rb +10 -0
- data/lib/hyrax/transactions/steps/save_collection_banner.rb +59 -0
- data/lib/hyrax/transactions/steps/save_collection_logo.rb +109 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings/active_fedora_converter/file_metadata_node.rb +48 -0
- data/lib/wings/active_fedora_converter/instance_builder.rb +68 -0
- data/lib/wings/active_fedora_converter.rb +3 -3
- data/lib/wings/services/custom_queries/find_file_metadata.rb +19 -8
- data/lib/wings/valkyrie/query_service.rb +4 -6
- data/template.rb +1 -1
- metadata +63 -13
- data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +0 -4
|
@@ -84,26 +84,13 @@ module Hyrax
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def after_create
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
set_default_permissions
|
|
90
|
-
# if we are creating the new collection as a subcollection (via the nested collections controller),
|
|
91
|
-
# we pass the parent_id through a hidden field in the form and link the two after the create.
|
|
92
|
-
link_parent_collection(params[:parent_id]) unless params[:parent_id].nil?
|
|
93
|
-
end
|
|
94
|
-
respond_to do |format|
|
|
95
|
-
Hyrax::SolrService.commit
|
|
96
|
-
format.html { redirect_to edit_dashboard_collection_path(@collection), notice: t('hyrax.dashboard.my.action.collection_create_success') }
|
|
97
|
-
format.json { render json: @collection, status: :created, location: dashboard_collection_path(@collection) }
|
|
98
|
-
end
|
|
87
|
+
Deprecation.warn("Method `#after_create` will be removed in Hyrax 4.0.")
|
|
88
|
+
after_create_response # call private method for processing
|
|
99
89
|
end
|
|
100
90
|
|
|
101
91
|
def after_create_error
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
format.html { render action: 'new' }
|
|
105
|
-
format.json { render json: @collection.errors, status: :unprocessable_entity }
|
|
106
|
-
end
|
|
92
|
+
Deprecation.warn("Method `#after_create_error` will be removed in Hyrax 4.0.")
|
|
93
|
+
after_create_errors("") # call private method for processing
|
|
107
94
|
end
|
|
108
95
|
|
|
109
96
|
def create
|
|
@@ -112,57 +99,39 @@ module Hyrax
|
|
|
112
99
|
# collection is saved without a value for `has_model.`
|
|
113
100
|
@collection = Hyrax.config.collection_class.new
|
|
114
101
|
authorize! :create, @collection
|
|
115
|
-
return valkyrie_create if @collection.is_a?(Valkyrie::Resource)
|
|
116
102
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@collection.attributes = collection_params.except(:members, :parent_id, :collection_type_gid)
|
|
121
|
-
@collection.apply_depositor_metadata(current_user.user_key)
|
|
122
|
-
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
|
|
123
|
-
if @collection.save
|
|
124
|
-
after_create
|
|
125
|
-
add_members_to_collection unless batch.empty?
|
|
103
|
+
case @collection
|
|
104
|
+
when ActiveFedora::Base
|
|
105
|
+
create_active_fedora_collection
|
|
126
106
|
else
|
|
127
|
-
|
|
107
|
+
create_valkyrie_collection
|
|
128
108
|
end
|
|
129
109
|
end
|
|
130
110
|
|
|
131
111
|
def after_update
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
format.json { render json: @collection, status: :updated, location: dashboard_collection_path(@collection) }
|
|
135
|
-
end
|
|
112
|
+
Deprecation.warn("Method `#after_update` will be removed in Hyrax 4.0.")
|
|
113
|
+
after_update_response # call private method for processing
|
|
136
114
|
end
|
|
137
115
|
|
|
138
116
|
def after_update_error
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
format.html { render action: 'edit' }
|
|
142
|
-
format.json { render json: @collection.errors, status: :unprocessable_entity }
|
|
143
|
-
end
|
|
117
|
+
Deprecation.warn("Method `#after_update_error` will be removed in Hyrax 4.0.")
|
|
118
|
+
after_update_errors(@collection.errors) # call private method for processing
|
|
144
119
|
end
|
|
145
120
|
|
|
146
121
|
def update
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
process_member_changes
|
|
153
|
-
|
|
154
|
-
return valkyrie_update if @collection.is_a?(Valkyrie::Resource)
|
|
155
|
-
|
|
156
|
-
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
|
|
157
|
-
# we don't have to reindex the full graph when updating collection
|
|
158
|
-
@collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
|
|
159
|
-
if @collection.update(collection_params.except(:members))
|
|
160
|
-
after_update
|
|
122
|
+
case @collection
|
|
123
|
+
when ActiveFedora::Base
|
|
124
|
+
update_active_fedora_collection
|
|
161
125
|
else
|
|
162
|
-
|
|
126
|
+
update_valkyrie_collection
|
|
163
127
|
end
|
|
164
128
|
end
|
|
165
129
|
|
|
130
|
+
def process_branding
|
|
131
|
+
process_banner_input
|
|
132
|
+
process_logo_input
|
|
133
|
+
end
|
|
134
|
+
|
|
166
135
|
def after_destroy(_id)
|
|
167
136
|
# leaving id to avoid changing the method's parameters prior to release
|
|
168
137
|
respond_to do |format|
|
|
@@ -215,28 +184,66 @@ module Hyrax
|
|
|
215
184
|
|
|
216
185
|
private
|
|
217
186
|
|
|
218
|
-
def
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
187
|
+
def create_active_fedora_collection
|
|
188
|
+
# Coming from the UI, a collection type gid should always be present. Coming from the API, if a collection type gid is not specified,
|
|
189
|
+
# use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)
|
|
190
|
+
@collection.collection_type_gid = params[:collection_type_gid].presence || default_collection_type.to_global_id
|
|
191
|
+
@collection.attributes = collection_params.except(:members, :parent_id, :collection_type_gid)
|
|
192
|
+
@collection.apply_depositor_metadata(current_user.user_key)
|
|
193
|
+
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
|
|
194
|
+
if @collection.save
|
|
195
|
+
after_create_response
|
|
196
|
+
else
|
|
197
|
+
after_create_errors(@collection.errors)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
228
200
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
201
|
+
def create_valkyrie_collection
|
|
202
|
+
return after_create_errors(form_err_msg(form)) unless form.validate(collection_params)
|
|
203
|
+
|
|
204
|
+
result =
|
|
205
|
+
transactions['change_set.create_collection']
|
|
206
|
+
.with_step_args(
|
|
207
|
+
'change_set.set_user_as_depositor' => { user: current_user },
|
|
208
|
+
'change_set.add_to_collections' => { collection_ids: Array(params[:parent_id]) },
|
|
209
|
+
'collection_resource.apply_collection_type_permissions' => { user: current_user }
|
|
210
|
+
)
|
|
211
|
+
.call(form)
|
|
212
|
+
|
|
213
|
+
@collection = result.value_or { return after_create_errors(result.failure.first) }
|
|
214
|
+
after_create_response
|
|
232
215
|
end
|
|
233
216
|
|
|
234
|
-
def
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
217
|
+
def update_active_fedora_collection
|
|
218
|
+
process_member_changes
|
|
219
|
+
process_branding
|
|
220
|
+
|
|
221
|
+
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
|
|
222
|
+
# we don't have to reindex the full graph when updating collection
|
|
223
|
+
@collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
|
|
224
|
+
if @collection.update(collection_params.except(:members))
|
|
225
|
+
after_update_response
|
|
226
|
+
else
|
|
227
|
+
after_update_errors(@collection.errors)
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def update_valkyrie_collection
|
|
232
|
+
return after_update_errors(form_err_msg(form)) unless form.validate(collection_params)
|
|
233
|
+
|
|
234
|
+
result = transactions['change_set.update_collection']
|
|
235
|
+
.with_step_args(
|
|
236
|
+
'collection_resource.save_collection_banner' => { update_banner_file_ids: params["banner_files"],
|
|
237
|
+
banner_unchanged_indicator: params["banner_unchanged"] },
|
|
238
|
+
'collection_resource.save_collection_logo' => { update_logo_file_ids: params["logo_files"],
|
|
239
|
+
alttext_values: params["alttext"],
|
|
240
|
+
linkurl_values: params["linkurl"] }
|
|
241
|
+
)
|
|
242
|
+
.call(form)
|
|
243
|
+
@collection = result.value_or { return after_update_errors(result.failure.first) }
|
|
244
|
+
|
|
245
|
+
process_member_changes
|
|
246
|
+
after_update_response
|
|
240
247
|
end
|
|
241
248
|
|
|
242
249
|
def valkyrie_destroy
|
|
@@ -247,6 +254,14 @@ module Hyrax
|
|
|
247
254
|
end
|
|
248
255
|
end
|
|
249
256
|
|
|
257
|
+
def form_err_msg(form)
|
|
258
|
+
errmsg = []
|
|
259
|
+
form.errors.messages.each do |fld, err|
|
|
260
|
+
errmsg << "#{fld} #{err.to_sentence}"
|
|
261
|
+
end
|
|
262
|
+
errmsg.to_sentence
|
|
263
|
+
end
|
|
264
|
+
|
|
250
265
|
def default_collection_type
|
|
251
266
|
Hyrax::CollectionType.find_or_create_default_collection_type
|
|
252
267
|
end
|
|
@@ -376,9 +391,7 @@ module Hyrax
|
|
|
376
391
|
end
|
|
377
392
|
|
|
378
393
|
def presenter
|
|
379
|
-
@presenter ||=
|
|
380
|
-
presenter_class.new(curation_concern, current_ability)
|
|
381
|
-
end
|
|
394
|
+
@presenter ||= presenter_class.new(curation_concern, current_ability)
|
|
382
395
|
end
|
|
383
396
|
|
|
384
397
|
def curation_concern
|
|
@@ -499,7 +512,9 @@ module Hyrax
|
|
|
499
512
|
@form ||=
|
|
500
513
|
case @collection
|
|
501
514
|
when Valkyrie::Resource
|
|
502
|
-
Hyrax::Forms::ResourceForm.for(@collection)
|
|
515
|
+
form = Hyrax::Forms::ResourceForm.for(@collection)
|
|
516
|
+
form.prepopulate!
|
|
517
|
+
form
|
|
503
518
|
else
|
|
504
519
|
form_class.new(@collection, current_ability, repository)
|
|
505
520
|
end
|
|
@@ -562,6 +577,75 @@ module Hyrax
|
|
|
562
577
|
def valid_url?(url)
|
|
563
578
|
(url =~ URI.regexp(['http', 'https']))
|
|
564
579
|
end
|
|
580
|
+
|
|
581
|
+
def after_create_response
|
|
582
|
+
if @collection.is_a?(ActiveFedora::Base)
|
|
583
|
+
form
|
|
584
|
+
set_default_permissions
|
|
585
|
+
# if we are creating the new collection as a subcollection (via the nested collections controller),
|
|
586
|
+
# we pass the parent_id through a hidden field in the form and link the two after the create.
|
|
587
|
+
link_parent_collection(params[:parent_id]) unless params[:parent_id].nil?
|
|
588
|
+
end
|
|
589
|
+
respond_to do |format|
|
|
590
|
+
Hyrax::SolrService.commit
|
|
591
|
+
format.html { redirect_to edit_dashboard_collection_path(@collection), notice: t('hyrax.dashboard.my.action.collection_create_success') }
|
|
592
|
+
format.json { render json: @collection, status: :created, location: dashboard_collection_path(@collection) }
|
|
593
|
+
end
|
|
594
|
+
add_members_to_collection unless batch.empty?
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
def after_create_errors_for_active_fedora(errors)
|
|
598
|
+
form
|
|
599
|
+
respond_to do |format|
|
|
600
|
+
format.html do
|
|
601
|
+
flash[:error] = errors.to_s
|
|
602
|
+
render action: 'new'
|
|
603
|
+
end
|
|
604
|
+
format.json { render json: @collection.errors, status: :unprocessable_entity }
|
|
605
|
+
end
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
def after_create_errors(errors) # for valkyrie
|
|
609
|
+
return after_create_errors_for_active_fedora(errors) if @collection.is_a? ActiveFedora::Base
|
|
610
|
+
respond_to do |wants|
|
|
611
|
+
wants.html do
|
|
612
|
+
flash[:error] = errors.to_s
|
|
613
|
+
render 'new', status: :unprocessable_entity
|
|
614
|
+
end
|
|
615
|
+
wants.json do
|
|
616
|
+
render_json_response(response_type: :unprocessable_entity, options: { errors: errors })
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
def after_update_response
|
|
622
|
+
respond_to do |format|
|
|
623
|
+
format.html { redirect_to update_referer, notice: t('hyrax.dashboard.my.action.collection_update_success') }
|
|
624
|
+
format.json { render json: @collection, status: :updated, location: dashboard_collection_path(@collection) }
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
def after_update_errors_for_active_fedora(errors)
|
|
629
|
+
form
|
|
630
|
+
respond_to do |format|
|
|
631
|
+
format.html do
|
|
632
|
+
flash[:error] = errors.to_s
|
|
633
|
+
render action: 'edit'
|
|
634
|
+
end
|
|
635
|
+
format.json { render json: @collection.errors, status: :unprocessable_entity }
|
|
636
|
+
end
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
def after_update_errors(errors) # for valkyrie
|
|
640
|
+
return after_update_errors_for_active_fedora(errors) if @collection.is_a? ActiveFedora::Base
|
|
641
|
+
respond_to do |wants|
|
|
642
|
+
wants.html do
|
|
643
|
+
flash[:error] = errors.to_s
|
|
644
|
+
render 'edit', status: :unprocessable_entity
|
|
645
|
+
end
|
|
646
|
+
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
|
|
647
|
+
end
|
|
648
|
+
end
|
|
565
649
|
end
|
|
566
650
|
end
|
|
567
651
|
end
|
|
@@ -75,7 +75,7 @@ module Hyrax
|
|
|
75
75
|
|
|
76
76
|
def render_single_use_error(exception)
|
|
77
77
|
logger.error("Rendering PAGE due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}")
|
|
78
|
-
render 'single_use_error', layout: "error", status:
|
|
78
|
+
render 'single_use_error', layout: "error", status: :not_found
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def _prefixes
|
|
@@ -6,7 +6,32 @@ module Hyrax
|
|
|
6
6
|
# @api public
|
|
7
7
|
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
|
|
8
8
|
class PcdmCollectionForm < Valkyrie::ChangeSet # rubocop:disable Metrics/ClassLength
|
|
9
|
-
|
|
9
|
+
include Hyrax::FormFields(:core_metadata)
|
|
10
|
+
|
|
11
|
+
BannerInfoPrepopulator = lambda do |_options|
|
|
12
|
+
self.banner_info ||= begin
|
|
13
|
+
banner_info = CollectionBrandingInfo.where(collection_id: id.to_s, role: "banner")
|
|
14
|
+
banner_file = File.split(banner_info.first.local_path).last unless banner_info.empty?
|
|
15
|
+
alttext = banner_info.first.alt_text unless banner_info.empty?
|
|
16
|
+
file_location = banner_info.first.local_path unless banner_info.empty?
|
|
17
|
+
relative_path = "/" + banner_info.first.local_path.split("/")[-4..-1].join("/") unless banner_info.empty?
|
|
18
|
+
{ file: banner_file, full_path: file_location, relative_path: relative_path, alttext: alttext }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
LogoInfoPrepopulator = lambda do |_options|
|
|
23
|
+
self.logo_info ||= begin
|
|
24
|
+
logos_info = CollectionBrandingInfo.where(collection_id: id.to_s, role: "logo")
|
|
25
|
+
|
|
26
|
+
logos_info.map do |logo_info|
|
|
27
|
+
logo_file = File.split(logo_info.local_path).last
|
|
28
|
+
relative_path = "/" + logo_info.local_path.split("/")[-4..-1].join("/")
|
|
29
|
+
alttext = logo_info.alt_text
|
|
30
|
+
linkurl = logo_info.target_url
|
|
31
|
+
{ file: logo_file, full_path: logo_info.local_path, relative_path: relative_path, alttext: alttext, linkurl: linkurl }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
10
35
|
|
|
11
36
|
property :human_readable_type, writable: false
|
|
12
37
|
property :date_modified, readable: false
|
|
@@ -18,9 +43,11 @@ module Hyrax
|
|
|
18
43
|
|
|
19
44
|
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
|
20
45
|
|
|
21
|
-
validates :title, presence: true
|
|
22
46
|
validates :collection_type_gid, presence: true
|
|
23
47
|
|
|
48
|
+
property :banner_info, virtual: true, prepopulator: BannerInfoPrepopulator
|
|
49
|
+
property :logo_info, virtual: true, prepopulator: LogoInfoPrepopulator
|
|
50
|
+
|
|
24
51
|
class << self
|
|
25
52
|
def model_class
|
|
26
53
|
Hyrax::PcdmCollection
|
|
@@ -99,7 +99,7 @@ module Hyrax
|
|
|
99
99
|
property :in_works_ids, virtual: true, prepopulator: InWorksPrepopulator
|
|
100
100
|
property :member_ids, default: [], type: Valkyrie::Types::Array
|
|
101
101
|
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
|
102
|
-
property :member_of_collections_attributes, virtual: true
|
|
102
|
+
property :member_of_collections_attributes, virtual: true, populator: :in_collections_populator
|
|
103
103
|
validates_with CollectionMembershipValidator
|
|
104
104
|
|
|
105
105
|
property :representative_id, type: Valkyrie::Types::String
|
|
@@ -208,6 +208,20 @@ module Hyrax
|
|
|
208
208
|
|
|
209
209
|
private
|
|
210
210
|
|
|
211
|
+
def in_collections_populator(fragment:, **_options)
|
|
212
|
+
adds = []
|
|
213
|
+
deletes = []
|
|
214
|
+
fragment.each do |_, h|
|
|
215
|
+
if h["_destroy"] == "true"
|
|
216
|
+
deletes << Valkyrie::ID.new(h["id"])
|
|
217
|
+
else
|
|
218
|
+
adds << Valkyrie::ID.new(h["id"])
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
self.member_of_collection_ids = ((member_of_collection_ids + adds) - deletes).uniq
|
|
223
|
+
end
|
|
224
|
+
|
|
211
225
|
# https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
|
|
212
226
|
def permission_populator(collection:, index:, **)
|
|
213
227
|
Hyrax::Forms::Permission.new(collection[index])
|
|
@@ -6,7 +6,7 @@ module Hyrax
|
|
|
6
6
|
# Visibility options for permission templates
|
|
7
7
|
def options
|
|
8
8
|
i18n_prefix = "hyrax.admin.admin_sets.form_visibility.visibility"
|
|
9
|
-
#
|
|
9
|
+
# NOTE: Visibility 'varies' = '' implies no constraints
|
|
10
10
|
[[Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC, I18n.t('.everyone', scope: i18n_prefix)],
|
|
11
11
|
['', I18n.t('.varies', scope: i18n_prefix)],
|
|
12
12
|
[Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED, I18n.t('.institution', scope: i18n_prefix)],
|
|
@@ -31,7 +31,11 @@ class CharacterizeJob < Hyrax::ApplicationJob
|
|
|
31
31
|
raise "#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy?
|
|
32
32
|
filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)
|
|
33
33
|
characterize(file_set, file_id, filepath)
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
Hyrax.publisher.publish('file.characterized',
|
|
36
|
+
file_set: file_set,
|
|
37
|
+
file_id: file_id,
|
|
38
|
+
path_hint: filepath)
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
private
|
data/app/jobs/import_url_job.rb
CHANGED
|
@@ -80,12 +80,10 @@ class ImportUrlJob < Hyrax::ApplicationJob
|
|
|
80
80
|
Rails.logger.debug("ImportUrlJob: Copying <#{uri}> to #{dir}")
|
|
81
81
|
|
|
82
82
|
File.open(File.join(dir, filename), 'wb') do |f|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
send_error(e.message)
|
|
88
|
-
end
|
|
83
|
+
write_file(f)
|
|
84
|
+
yield f
|
|
85
|
+
rescue StandardError => e
|
|
86
|
+
send_error(e.message)
|
|
89
87
|
end
|
|
90
88
|
Rails.logger.debug("ImportUrlJob: Closing #{File.join(dir, filename)}")
|
|
91
89
|
end
|
|
@@ -21,104 +21,42 @@ class ValkyrieIngestJob < Hyrax::ApplicationJob
|
|
|
21
21
|
#
|
|
22
22
|
# @param [Hyrax::UploadedFile] file
|
|
23
23
|
# @param [RDF::URI] pcdm_use
|
|
24
|
-
|
|
25
24
|
# @return [void]
|
|
26
25
|
def ingest(file:, pcdm_use:)
|
|
27
26
|
file_set_uri = Valkyrie::ID.new(file.file_set_uri)
|
|
28
27
|
file_set = Hyrax.query_service.find_by(id: file_set_uri)
|
|
29
28
|
|
|
30
|
-
updated_metadata = upload_file(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
updated_metadata = upload_file(
|
|
30
|
+
file: file,
|
|
31
|
+
file_set: file_set,
|
|
32
|
+
pcdm_use: pcdm_use,
|
|
33
|
+
user: file.user
|
|
34
|
+
)
|
|
35
35
|
|
|
36
36
|
ValkyrieCreateDerivativesJob.perform_later(file_set.id.to_s, updated_metadata.id.to_s)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
##
|
|
40
|
-
# @api private
|
|
41
|
-
#
|
|
42
|
-
# @param [Hyrax::FileSet] file_set the file set to add to
|
|
43
|
-
# @param [Hyrax::FileMetadata] file_metadata the metadata object representing
|
|
44
|
-
# the file to add
|
|
45
|
-
# @param [::User] user the user performing the add
|
|
46
|
-
#
|
|
47
|
-
# @return [Hyrax::FileSet] updated file set
|
|
48
|
-
def add_file_to_file_set(file_set:, file_metadata:, user:)
|
|
49
|
-
file_set.file_ids << file_metadata.id
|
|
50
|
-
set_file_use_ids(file_set, file_metadata)
|
|
51
|
-
|
|
52
|
-
Hyrax.persister.save(resource: file_set)
|
|
53
|
-
Hyrax.publisher.publish('object.membership.updated', object: file_set, user: user)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
39
|
##
|
|
57
40
|
# @api private
|
|
58
41
|
#
|
|
59
42
|
# @param [Hyrax::UploadedFile] file
|
|
60
43
|
# @param [Hyrax::FileSet] file_set
|
|
61
44
|
# @param [RDF::URI] pcdm_use the use/type to apply to the created FileMetadata
|
|
45
|
+
# @param [User] user
|
|
62
46
|
#
|
|
63
47
|
# @return [Hyrax::FileMetadata] the metadata representing the uploaded file
|
|
64
|
-
def upload_file(file:, file_set:, pcdm_use
|
|
48
|
+
def upload_file(file:, file_set:, pcdm_use:, user: nil)
|
|
65
49
|
carrier_wave_sanitized_file = file.uploader.file
|
|
66
50
|
# Pull file, since carrierwave files don't respond to a proper IO #read. See
|
|
67
51
|
# https://github.com/carrierwaveuploader/carrierwave/issues/1959
|
|
68
52
|
file_io = carrier_wave_sanitized_file.to_file
|
|
69
|
-
uploaded = Hyrax.storage_adapter
|
|
70
|
-
.upload(resource: file_set,
|
|
71
|
-
file: file_io,
|
|
72
|
-
original_filename: carrier_wave_sanitized_file.original_filename)
|
|
73
|
-
|
|
74
|
-
file_metadata = find_or_create_metadata(id: uploaded.id, file: carrier_wave_sanitized_file)
|
|
75
|
-
|
|
76
|
-
file_metadata.type << pcdm_use
|
|
77
|
-
file_metadata.file_set_id = file.file_set_uri
|
|
78
|
-
file_metadata.file_identifier = uploaded.id
|
|
79
|
-
file_metadata.size = uploaded.size
|
|
80
53
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# set title to label if that's how it was before this characterization
|
|
89
|
-
file_set.title = file_metadata.original_filename if reset_title
|
|
90
|
-
# always set the label to the original_name
|
|
91
|
-
file_set.label = file_metadata.original_filename
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
saved_metadata
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
##
|
|
98
|
-
# @api private
|
|
99
|
-
def find_or_create_metadata(id:, file:)
|
|
100
|
-
Hyrax.custom_queries.find_file_metadata_by(id: id)
|
|
101
|
-
rescue Valkyrie::Persistence::ObjectNotFoundError => e
|
|
102
|
-
Hyrax.logger.warn "Failed to find existing metadata for #{id}:"
|
|
103
|
-
Hyrax.logger.warn e.message
|
|
104
|
-
Hyrax.logger.warn "Creating Hyrax::FileMetadata now"
|
|
105
|
-
Hyrax::FileMetadata.for(file: file)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
##
|
|
109
|
-
# @api private
|
|
110
|
-
def set_file_use_ids(file_set, file_metadata)
|
|
111
|
-
file_metadata.type.each do |type|
|
|
112
|
-
case type
|
|
113
|
-
when Hyrax::FileMetadata::Use::ORIGINAL_FILE
|
|
114
|
-
file_set.original_file_id = file_metadata.id
|
|
115
|
-
when Hyrax::FileMetadata::Use::THUMBNAIL
|
|
116
|
-
file_set.thumbnail_id = file_metadata.id
|
|
117
|
-
when Hyrax::FileMetadata::Use::EXTRACTED_TEXT
|
|
118
|
-
file_set.extracted_text_id = file_metadata.id
|
|
119
|
-
else
|
|
120
|
-
Rails.logger.warn "Unknown file use #{file_metadata.type} specified for #{file_metadata.file_identifier}"
|
|
121
|
-
end
|
|
122
|
-
end
|
|
54
|
+
::Hyrax::ValkyrieUpload.file(
|
|
55
|
+
io: file_io,
|
|
56
|
+
filename: carrier_wave_sanitized_file.original_filename,
|
|
57
|
+
file_set: file_set,
|
|
58
|
+
use: pcdm_use,
|
|
59
|
+
user: user
|
|
60
|
+
)
|
|
123
61
|
end
|
|
124
62
|
end
|
data/app/models/admin_set.rb
CHANGED
|
@@ -97,6 +97,14 @@ class AdminSet < ActiveFedora::Base
|
|
|
97
97
|
permission_template.reset_access_controls_for(collection: self)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
+
# @api public
|
|
101
|
+
#
|
|
102
|
+
# return an id for the AdminSet.
|
|
103
|
+
# defaults to calling Hyrax::Noid, but needs a fall back if noid is off
|
|
104
|
+
def assign_id
|
|
105
|
+
super || SecureRandom.uuid
|
|
106
|
+
end
|
|
107
|
+
|
|
100
108
|
private
|
|
101
109
|
|
|
102
110
|
def destroy_permission_template
|
|
@@ -87,7 +87,7 @@ module Hyrax
|
|
|
87
87
|
|
|
88
88
|
module ClassMethods
|
|
89
89
|
# This governs which partial to draw when you render this type of object
|
|
90
|
-
def _to_partial_path
|
|
90
|
+
def _to_partial_path # :nodoc:
|
|
91
91
|
@_to_partial_path ||= begin
|
|
92
92
|
element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(name))
|
|
93
93
|
collection = ActiveSupport::Inflector.tableize(name)
|
|
@@ -53,6 +53,13 @@ module Hyrax::User
|
|
|
53
53
|
public_send(self.class.user_key_field)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
##
|
|
57
|
+
# @return [String] a local identifier for this user; for use (e.g.) in ACL
|
|
58
|
+
# data
|
|
59
|
+
def agent_key
|
|
60
|
+
user_key
|
|
61
|
+
end
|
|
62
|
+
|
|
56
63
|
# Look for, in order:
|
|
57
64
|
# A cached version of the agent
|
|
58
65
|
# A non-cached version (direct read of the database)
|
|
@@ -177,6 +184,10 @@ module Hyrax::User
|
|
|
177
184
|
User.find_by_user_key(user_key) || User.create!(user_key_field => user_key, password: Devise.friendly_token[0, 20])
|
|
178
185
|
end
|
|
179
186
|
|
|
187
|
+
def from_agent_key(key)
|
|
188
|
+
User.find_by_user_key(key)
|
|
189
|
+
end
|
|
190
|
+
|
|
180
191
|
def from_url_component(component)
|
|
181
192
|
User.find_by_user_key(component.gsub(/-dot-/, '.'))
|
|
182
193
|
end
|
|
@@ -34,7 +34,7 @@ module Hyrax
|
|
|
34
34
|
|
|
35
35
|
module ClassMethods
|
|
36
36
|
# This governs which partial to draw when you render this type of object
|
|
37
|
-
def _to_partial_path
|
|
37
|
+
def _to_partial_path # :nodoc:
|
|
38
38
|
@_to_partial_path ||= begin
|
|
39
39
|
element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(name))
|
|
40
40
|
collection = ActiveSupport::Inflector.tableize(name)
|