From c49ca0c03a2abdbeeeaa62baf3bbbe24bcf5e923 Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Fri, 4 Jan 2019 11:59:00 -0800 Subject: [PATCH] Implement changes for Valkyrie 2.0 RC1 --- Gemfile | 2 +- Gemfile.lock | 58 ++++++++++--------- .../concerns/resource_controller.rb | 2 +- app/models/pending_upload.rb | 2 +- .../file_sets/file_sets_controller.rb | 4 +- .../media_resources/media_resource.rb | 2 +- .../raster_resources/raster_resource.rb | 2 +- app/resources/scanned_maps/scanned_map.rb | 2 +- .../scanned_resources/scanned_resource.rb | 2 +- .../vector_resources/vector_resource.rb | 2 +- app/services/file_appender.rb | 2 +- 11 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Gemfile b/Gemfile index 66c05489c9..fffd58bade 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem "simple_form" gem "sprockets", ">= 3.7.2" gem "title" gem "uglifier" -gem "valkyrie", "1.5.0" +gem "valkyrie", "2.0.0.RC1", github: "samvera-labs/valkyrie", branch: "update_dry_struct_again" gem "valkyrie-derivatives", git: "https://github.com/samvera-labs/valkyrie-derivatives.git" gem "webpacker", ">= 4.0.x" diff --git a/Gemfile.lock b/Gemfile.lock index fae7950cbb..c746f5536a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,29 @@ GIT sequel_pg valkyrie (~> 1.5.0.RC1) +GIT + remote: git://github.com/samvera-labs/valkyrie.git + revision: a3da11e9785c7628062935a7785ec40cb26fe4cf + branch: update_dry_struct_again + specs: + valkyrie (2.0.0.RC1) + active-triples + activemodel + activerecord + activesupport + draper + dry-struct + dry-types (~> 0.13.0) + json + json-ld + ldp + pg + railties + rdf + reform + reform-rails + rsolr + GIT remote: git://github.com/yob/pdf-reader.git revision: bb7747a3cb4279ecd963185f357dbd718f9d20f3 @@ -301,23 +324,23 @@ GEM dry-core (0.4.7) concurrent-ruby (~> 1.0) dry-equalizer (0.2.1) - dry-logic (0.5.0) + dry-inflector (0.1.2) + dry-logic (0.4.2) dry-container (~> 0.2, >= 0.2.6) dry-core (~> 0.2) dry-equalizer (~> 0.2) - dry-struct (0.4.0) - dry-core (~> 0.4, >= 0.4.1) + dry-struct (0.6.0) + dry-core (~> 0.4, >= 0.4.3) dry-equalizer (~> 0.2) - dry-types (~> 0.12, >= 0.12.2) + dry-types (~> 0.13) ice_nine (~> 0.11) - dry-types (0.12.3) + dry-types (0.13.4) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1) dry-container (~> 0.3) - dry-core (~> 0.2, >= 0.2.1) + dry-core (~> 0.4, >= 0.4.4) dry-equalizer (~> 0.2) + dry-inflector (~> 0.1, >= 0.1.2) dry-logic (~> 0.4, >= 0.4.2) - inflecto (~> 0.0.0, >= 0.0.2) ebnf (1.1.1) rdf (~> 2.2) sxp (~> 1.0) @@ -415,7 +438,6 @@ GEM ice_nine (0.11.2) iiif_manifest (0.5.0) activesupport (>= 4) - inflecto (0.0.2) io-like (0.3.0) iso-639 (0.2.8) jbuilder (2.7.0) @@ -766,22 +788,6 @@ GEM unf_ext (0.0.7.5) unicode-display_width (1.3.0) validatable (1.6.7) - valkyrie (1.5.0) - active-fedora - active-triples - activemodel - activerecord - activesupport - draper - dry-struct - dry-types (~> 0.12.0) - json - json-ld - pg - railties - rdf - reform - reform-rails warden (1.2.7) rack (>= 1.0) web-console (3.5.1) @@ -902,7 +908,7 @@ DEPENDENCIES tiny_tds title uglifier - valkyrie (= 1.5.0) + valkyrie (= 2.0.0.RC1)! valkyrie-derivatives! valkyrie-sequel! web-console diff --git a/app/controllers/concerns/resource_controller.rb b/app/controllers/concerns/resource_controller.rb index 3cbf2d8cb6..af990609e9 100644 --- a/app/controllers/concerns/resource_controller.rb +++ b/app/controllers/concerns/resource_controller.rb @@ -121,7 +121,7 @@ def _prefixes end def resource_params - params[resource_class.to_s.underscore.to_sym]&.to_unsafe_h + params[resource_class.to_s.underscore.to_sym]&.to_unsafe_h&.deep_symbolize_keys end def find_resource(id) diff --git a/app/models/pending_upload.rb b/app/models/pending_upload.rb index cc3f150447..d69a6e4be8 100644 --- a/app/models/pending_upload.rb +++ b/app/models/pending_upload.rb @@ -6,7 +6,7 @@ class PendingUpload < Valkyrie::Resource attribute :auth_header def original_filename - @file_name.first + file_name.first end def content_type diff --git a/app/resources/file_sets/file_sets_controller.rb b/app/resources/file_sets/file_sets_controller.rb index 91f5641296..fc0e03aecb 100644 --- a/app/resources/file_sets/file_sets_controller.rb +++ b/app/resources/file_sets/file_sets_controller.rb @@ -59,13 +59,13 @@ def filtered_file_params(file_filter:) filtered = resource_params files = filtered.fetch(file_filter, []) return {} if files.empty? - filtered["files"] = files + filtered[:files] = files filtered.delete(file_filter) filtered end def derivative_resource_params - @derivative_resource_params ||= filtered_file_params(file_filter: "derivative_files") + @derivative_resource_params ||= filtered_file_params(file_filter: :derivative_files) end def update_derivatives diff --git a/app/resources/media_resources/media_resource.rb b/app/resources/media_resources/media_resource.rb index bb3574b9d6..d540cd9378 100644 --- a/app/resources/media_resources/media_resource.rb +++ b/app/resources/media_resources/media_resource.rb @@ -15,7 +15,7 @@ def primary_imported_metadata end def title - primary_imported_metadata.title.present? ? primary_imported_metadata.title : @title + primary_imported_metadata.title.present? ? primary_imported_metadata.title : attributes[:title] end # Determines if this is a media resource diff --git a/app/resources/raster_resources/raster_resource.rb b/app/resources/raster_resources/raster_resource.rb index bbd1b1dacc..3b19fe9c27 100644 --- a/app/resources/raster_resources/raster_resource.rb +++ b/app/resources/raster_resources/raster_resource.rb @@ -27,6 +27,6 @@ def primary_imported_metadata def title imported_title = primary_imported_metadata.title.present? ? primary_imported_metadata.title : [] - @title.present? ? @title : imported_title + attributes[:title].present? ? attributes[:title] : imported_title end end diff --git a/app/resources/scanned_maps/scanned_map.rb b/app/resources/scanned_maps/scanned_map.rb index c71f9fdc84..4335350191 100644 --- a/app/resources/scanned_maps/scanned_map.rb +++ b/app/resources/scanned_maps/scanned_map.rb @@ -39,6 +39,6 @@ def geo_resource? def title imported_title = primary_imported_metadata.title.present? ? primary_imported_metadata.title : [] - @title.present? ? @title : imported_title + attributes[:title].present? ? attributes[:title] : imported_title end end diff --git a/app/resources/scanned_resources/scanned_resource.rb b/app/resources/scanned_resources/scanned_resource.rb index d91f4dd28d..a83fb9fee9 100644 --- a/app/resources/scanned_resources/scanned_resource.rb +++ b/app/resources/scanned_resources/scanned_resource.rb @@ -34,7 +34,7 @@ def pdf_file end def title - primary_imported_metadata.title.present? ? primary_imported_metadata.title : @title + primary_imported_metadata.title.present? ? primary_imported_metadata.title : attributes[:title] end # Determines if this is an image resource diff --git a/app/resources/vector_resources/vector_resource.rb b/app/resources/vector_resources/vector_resource.rb index 85435387ea..e9d0179ba5 100644 --- a/app/resources/vector_resources/vector_resource.rb +++ b/app/resources/vector_resources/vector_resource.rb @@ -27,6 +27,6 @@ def primary_imported_metadata def title imported_title = primary_imported_metadata.title.present? ? primary_imported_metadata.title : [] - @title.present? ? @title : imported_title + attributes[:title].present? ? attributes[:title] : imported_title end end diff --git a/app/services/file_appender.rb b/app/services/file_appender.rb index eb0a5d1822..b5cde350a2 100644 --- a/app/services/file_appender.rb +++ b/app/services/file_appender.rb @@ -58,7 +58,7 @@ def append_to(resource) # @return [Array] def update_files(resource) updated = files.select { |file| file.is_a?(Hash) }.map do |file| - node = resource.file_metadata.select { |x| x.id.to_s == file.keys.first }.first + node = resource.file_metadata.select { |x| x.id.to_s == file.keys.first.to_s }.first node.updated_at = Time.current # Uses the UploadDecorator to abstract the interface for the File Object during persistence by the storage_adapter file_wrapper = UploadDecorator.new(file.values.first, node.original_filename.first)