hyrax 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +26 -17
  3. data/.dassie/.env +1 -1
  4. data/.dassie/Gemfile +1 -1
  5. data/.dassie/app/forms/collection_resource_form.rb +8 -0
  6. data/.dassie/app/indexers/collection_resource_indexer.rb +8 -0
  7. data/.dassie/app/models/collection_resource.rb +35 -0
  8. data/.dassie/config/initializers/file_services.rb +4 -0
  9. data/.dassie/config/initializers/hyrax.rb +2 -1
  10. data/.dassie/config/metadata/collection_resource.yaml +23 -0
  11. data/.dassie/db/seeds.rb +2 -0
  12. data/.dassie/spec/forms/collection_resource_form_spec.rb +13 -0
  13. data/.dassie/spec/indexers/collection_resource_indexer_spec.rb +14 -0
  14. data/.dassie/spec/models/collection_resource_spec.rb +13 -0
  15. data/.regen +1 -1
  16. data/.rubocop.yml +1 -1
  17. data/.rubocop_fixme.yml +19 -2
  18. data/CONTAINERS.md +18 -13
  19. data/Dockerfile +2 -2
  20. data/app/actors/hyrax/actors/collections_membership_actor.rb +1 -1
  21. data/app/actors/hyrax/actors/embargo_actor.rb +11 -4
  22. data/app/actors/hyrax/actors/lease_actor.rb +11 -4
  23. data/app/assets/javascripts/hyrax/app.js.erb +1 -1
  24. data/app/assets/javascripts/hyrax/collections_v2.es6 +13 -0
  25. data/app/assets/javascripts/hyrax/permissions/control.es6 +8 -1
  26. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +1 -3
  27. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +11 -2
  28. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +11 -2
  29. data/app/controllers/concerns/hyrax/manages_embargoes.rb +13 -1
  30. data/app/controllers/hyrax/dashboard/collections_controller.rb +159 -76
  31. data/app/controllers/hyrax/downloads_controller.rb +16 -1
  32. data/app/controllers/hyrax/file_sets_controller.rb +10 -1
  33. data/app/controllers/hyrax/permissions_controller.rb +1 -1
  34. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +1 -1
  35. data/app/controllers/hyrax/transfers_controller.rb +0 -2
  36. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -2
  37. data/app/forms/hyrax/forms/collection_form.rb +1 -1
  38. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +2 -0
  39. data/app/forms/hyrax/forms/embargo.rb +13 -0
  40. data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
  41. data/app/forms/hyrax/forms/file_set_form.rb +8 -35
  42. data/app/forms/hyrax/forms/lease.rb +13 -0
  43. data/app/forms/hyrax/forms/pcdm_collection_form.rb +29 -2
  44. data/app/forms/hyrax/forms/pcdm_object_form.rb +46 -0
  45. data/app/forms/hyrax/forms/resource_form.rb +39 -21
  46. data/app/forms/hyrax/forms/widgets/admin_set_visibility.rb +1 -1
  47. data/app/forms/hyrax/forms/work_embargo_form.rb +35 -0
  48. data/app/forms/hyrax/forms/work_lease_form.rb +35 -0
  49. data/app/helpers/hyrax/embargo_helper.rb +11 -0
  50. data/app/helpers/hyrax/lease_helper.rb +11 -0
  51. data/app/indexers/hyrax/pcdm_collection_indexer.rb +1 -1
  52. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +2 -8
  53. data/app/jobs/characterize_job.rb +5 -1
  54. data/app/jobs/content_event_job.rb +1 -1
  55. data/app/jobs/import_url_job.rb +4 -6
  56. data/app/jobs/valkyrie_ingest_job.rb +15 -77
  57. data/app/models/admin_set.rb +8 -0
  58. data/app/models/concerns/hyrax/collection_behavior.rb +3 -2
  59. data/app/models/concerns/hyrax/collection_nesting.rb +10 -1
  60. data/app/models/concerns/hyrax/file_set_behavior.rb +1 -0
  61. data/app/models/concerns/hyrax/user.rb +11 -0
  62. data/app/models/concerns/hyrax/work_behavior.rb +3 -2
  63. data/app/models/featured_work_list.rb +0 -1
  64. data/app/models/hyrax/embargo.rb +1 -1
  65. data/app/models/hyrax/file_metadata.rb +32 -2
  66. data/app/models/hyrax/file_set.rb +4 -6
  67. data/app/models/hyrax/group.rb +19 -0
  68. data/app/models/hyrax/lease.rb +1 -1
  69. data/app/models/hyrax/pcdm_collection.rb +0 -1
  70. data/app/models/job_io_wrapper.rb +1 -1
  71. data/app/models/proxy_deposit_request.rb +1 -1
  72. data/app/presenters/hyrax/member_presenter_factory.rb +2 -4
  73. data/app/presenters/hyrax/permission_badge.rb +3 -2
  74. data/app/presenters/hyrax/version_list_presenter.rb +6 -1
  75. data/app/presenters/hyrax/work_show_presenter.rb +3 -3
  76. data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +13 -5
  77. data/app/services/hyrax/access_control_list.rb +7 -6
  78. data/app/services/hyrax/adapters/nesting_index_adapter.rb +3 -3
  79. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +3 -5
  80. data/app/services/hyrax/collections/collection_member_service.rb +3 -5
  81. data/app/services/hyrax/collections/nested_collection_query_service.rb +1 -1
  82. data/app/services/hyrax/edit_permissions_service.rb +21 -3
  83. data/app/services/hyrax/embargo_manager.rb +9 -0
  84. data/app/services/hyrax/file_set_file_service.rb +55 -0
  85. data/app/services/hyrax/lease_manager.rb +9 -0
  86. data/app/services/hyrax/listeners/file_metadata_listener.rb +11 -0
  87. data/app/services/hyrax/listeners/member_cleanup_listener.rb +14 -18
  88. data/app/services/hyrax/multiple_membership_checker.rb +2 -0
  89. data/app/services/hyrax/user_stat_importer.rb +2 -0
  90. data/app/services/hyrax/valkyrie_persist_derivatives.rb +50 -0
  91. data/app/services/hyrax/valkyrie_upload.rb +94 -0
  92. data/app/services/hyrax/versioning_service.rb +77 -9
  93. data/app/services/hyrax/visibility_propagator.rb +5 -5
  94. data/app/services/hyrax/work_resource_query_service.rb +45 -0
  95. data/app/services/hyrax/workflow/workflow_importer.rb +7 -9
  96. data/app/services/hyrax/workflow/workflow_schema.rb +3 -5
  97. data/app/strategies/hyrax/strategies/yaml_strategy.rb +4 -6
  98. data/app/uploaders/hyrax/uploaded_file_uploader.rb +4 -4
  99. data/app/validators/hyrax/collection_membership_validator.rb +16 -15
  100. data/app/views/catalog/_index_header_list_default.html.erb +8 -1
  101. data/app/views/catalog/_thumbnail_list_default.html.erb +8 -3
  102. data/app/views/collections/edit_fields/_based_near.html.erb +7 -7
  103. data/app/views/hyrax/base/_form_progress.html.erb +1 -1
  104. data/app/views/hyrax/base/_form_visibility_component.html.erb +5 -1
  105. data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -2
  106. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -0
  107. data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +1 -1
  108. data/app/views/hyrax/embargoes/edit.html.erb +3 -3
  109. data/app/views/hyrax/file_sets/_permission.html.erb +1 -1
  110. data/app/views/hyrax/file_sets/_permission_form.html.erb +1 -6
  111. data/app/views/hyrax/file_sets/edit.html.erb +2 -2
  112. data/app/views/hyrax/leases/edit.html.erb +3 -3
  113. data/app/views/hyrax/my/works/_tabs.html.erb +6 -1
  114. data/app/views/hyrax/transfers/new.html.erb +1 -1
  115. data/chart/hyrax/Chart.yaml +10 -6
  116. data/chart/hyrax/templates/_helpers.tpl +4 -0
  117. data/chart/hyrax/templates/cron-embargo.yaml +5 -0
  118. data/chart/hyrax/templates/cron-lease.yaml +5 -0
  119. data/chart/hyrax/templates/deployment-worker.yaml +11 -0
  120. data/chart/hyrax/templates/ingress.yaml +7 -6
  121. data/chart/hyrax/values.yaml +152 -0
  122. data/config/features.rb +48 -50
  123. data/config/initializers/{valkryrie_storage.rb → storage_adapter_initializer.rb} +5 -0
  124. data/config/locales/hyrax.de.yml +14 -13
  125. data/config/locales/hyrax.en.yml +3 -0
  126. data/config/locales/hyrax.es.yml +1 -0
  127. data/config/locales/hyrax.fr.yml +2 -1
  128. data/config/locales/hyrax.it.yml +1 -0
  129. data/config/locales/hyrax.pt-BR.yml +1 -0
  130. data/config/locales/hyrax.zh.yml +1 -0
  131. data/config/metadata/file_set_metadata.yaml +130 -0
  132. data/docker-compose.yml +1 -0
  133. data/documentation/developing-your-hyrax-based-app.md +2 -2
  134. data/documentation/legacyREADME.md +3 -3
  135. data/hyrax.gemspec +7 -3
  136. data/lib/generators/hyrax/collection_resource/USAGE +20 -0
  137. data/lib/generators/hyrax/collection_resource/collection_resource_generator.rb +133 -0
  138. data/lib/generators/hyrax/collection_resource/templates/collection.rb.erb +34 -0
  139. data/lib/generators/hyrax/collection_resource/templates/collection_form.rb.erb +7 -0
  140. data/lib/generators/hyrax/collection_resource/templates/collection_form_spec.rb.erb +13 -0
  141. data/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +7 -0
  142. data/lib/generators/hyrax/collection_resource/templates/collection_indexer_spec.rb.erb +13 -0
  143. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +22 -0
  144. data/lib/generators/hyrax/collection_resource/templates/collection_spec.rb.erb +12 -0
  145. data/lib/generators/hyrax/install_generator.rb +9 -0
  146. data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
  147. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
  148. data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
  149. data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
  150. data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
  151. data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
  152. data/lib/hyrax/active_fedora_dummy_model.rb +13 -0
  153. data/lib/hyrax/configuration.rb +21 -2
  154. data/lib/hyrax/errors.rb +2 -0
  155. data/lib/hyrax/publisher.rb +4 -0
  156. data/lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb +6 -0
  157. data/lib/hyrax/specs/shared_specs/hydra_works.rb +0 -1
  158. data/lib/hyrax/specs/shared_specs/indexers.rb +5 -0
  159. data/lib/hyrax/transactions/collection_update.rb +2 -0
  160. data/lib/hyrax/transactions/container.rb +10 -0
  161. data/lib/hyrax/transactions/steps/save_collection_banner.rb +59 -0
  162. data/lib/hyrax/transactions/steps/save_collection_logo.rb +109 -0
  163. data/lib/hyrax/version.rb +1 -1
  164. data/lib/wings/active_fedora_converter/file_metadata_node.rb +48 -0
  165. data/lib/wings/active_fedora_converter/instance_builder.rb +68 -0
  166. data/lib/wings/active_fedora_converter.rb +3 -3
  167. data/lib/wings/services/custom_queries/find_file_metadata.rb +19 -8
  168. data/lib/wings/valkyrie/query_service.rb +4 -6
  169. data/lib/wings/valkyrie/storage.rb +6 -2
  170. data/template.rb +1 -1
  171. metadata +99 -13
  172. data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +0 -4
@@ -50,7 +50,7 @@ The Samvera community is here to help. Please see our [support guide](./.github/
50
50
  # Getting started
51
51
 
52
52
  This document contains instructions specific to setting up an app with __Hyrax
53
- v3.4.1__. If you are looking for instructions on installing a different
53
+ v3.5.0__. If you are looking for instructions on installing a different
54
54
  version, be sure to select the appropriate branch or tag from the drop-down
55
55
  menu above.
56
56
 
@@ -143,7 +143,7 @@ Hyrax requires Rails 5. We recommend the latest Rails 5.2 release.
143
143
 
144
144
  ```
145
145
  # If you don't already have Rails at your disposal...
146
- gem install rails -v 5.2.6
146
+ gem install rails -v 5.2.8.1
147
147
  ```
148
148
 
149
149
  ### JavaScript runtime
@@ -159,7 +159,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app.
159
159
  Generate a new Rails application using the template.
160
160
 
161
161
  ```
162
- rails _5.2.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v3.0.2/template.rb
162
+ rails _5.2.8.1_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v3.5.0/template.rb
163
163
  ```
164
164
 
165
165
  Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
data/hyrax.gemspec CHANGED
@@ -26,7 +26,7 @@ SUMMARY
26
26
 
27
27
  spec.required_ruby_version = '>= 2.5'
28
28
 
29
- # Note: rails does not follow sem-ver conventions, it's
29
+ # NOTE: rails does not follow sem-ver conventions, it's
30
30
  # minor version releases can include breaking changes; see
31
31
  # http://guides.rubyonrails.org/maintenance_policy.html
32
32
  spec.add_dependency 'rails', '~> 5.0'
@@ -44,6 +44,7 @@ SUMMARY
44
44
  spec.add_dependency 'dry-events', '~> 0.2.0'
45
45
  spec.add_dependency 'dry-equalizer', '~> 0.2'
46
46
  spec.add_dependency 'dry-struct', '~> 1.0'
47
+ spec.add_dependency 'dry-monads', '< 1.5'
47
48
  spec.add_dependency 'dry-transaction', '~> 0.11'
48
49
  spec.add_dependency 'dry-validation', '~> 1.3'
49
50
  spec.add_dependency 'flipflop', '~> 2.3'
@@ -58,6 +59,7 @@ SUMMARY
58
59
  spec.add_dependency 'iiif_manifest', '>= 0.3', '< 2.0'
59
60
  spec.add_dependency 'jquery-datatables-rails', '~> 3.4'
60
61
  spec.add_dependency 'jquery-ui-rails', '~> 6.0'
62
+ spec.add_dependency 'json-ld', '< 3.2'
61
63
  spec.add_dependency 'json-schema' # for Arkivo
62
64
  # Pin more tightly because 0.x gems are potentially unstable
63
65
  spec.add_dependency 'kaminari_route_prefix', '~> 0.1.1'
@@ -70,10 +72,12 @@ SUMMARY
70
72
  spec.add_dependency 'oauth2', '~> 1.2'
71
73
  spec.add_dependency 'posix-spawn'
72
74
  spec.add_dependency 'power_converter', '~> 0.1', '>= 0.1.2'
75
+ spec.add_dependency 'psych', '~> 3.3'
73
76
  spec.add_dependency 'qa', '~> 5.5', '>= 5.5.1' # questioning_authority
74
77
  spec.add_dependency 'rails_autolink', '~> 1.1'
75
78
  spec.add_dependency 'rdf-rdfxml' # controlled vocabulary importer
76
79
  spec.add_dependency 'rdf-vocab', '~> 3.0'
80
+ spec.add_dependency 'redis', '~> 4.0'
77
81
  spec.add_dependency 'redis-namespace', '~> 1.5'
78
82
  spec.add_dependency 'redlock', '>= 0.1.2'
79
83
  spec.add_dependency 'reform', '~> 2.3'
@@ -82,7 +86,7 @@ SUMMARY
82
86
  spec.add_dependency 'samvera-nesting_indexer', '~> 2.0'
83
87
  spec.add_dependency 'select2-rails', '~> 3.5'
84
88
  spec.add_dependency 'signet'
85
- spec.add_dependency 'tinymce-rails'
89
+ spec.add_dependency 'tinymce-rails', '~> 5.10'
86
90
  spec.add_dependency 'valkyrie', '~> 2', '>= 2.1.1'
87
91
 
88
92
  spec.add_development_dependency "capybara", '~> 3.29'
@@ -106,7 +110,7 @@ SUMMARY
106
110
  spec.add_development_dependency 'i18n_yaml_sorter'
107
111
  spec.add_development_dependency 'rails-controller-testing', '~> 1'
108
112
  # the hyrax style guide is based on `bixby`. see `.rubocop.yml`
109
- spec.add_development_dependency 'bixby', '~> 3.0', ">= 3.0.2"
113
+ spec.add_development_dependency 'bixby', '~> 5.0', '>= 5.0.2' # bixby 5 briefly dropped Ruby 2.5
110
114
  spec.add_development_dependency 'shoulda-callback-matchers', '~> 1.1.1'
111
115
  spec.add_development_dependency 'shoulda-matchers', '~> 3.1'
112
116
  spec.add_development_dependency 'webdrivers', '~> 4.4'
@@ -0,0 +1,20 @@
1
+ Description:
2
+ This generator creates the necessary files for a Hyrax::PcdmCollection.
3
+
4
+ Example:
5
+ Usage: rails generate hyrax:collection_resource MyCollection [with_basic_metadata]
6
+
7
+ Argument:
8
+ with_basic_metadata (optional) - if present, the collection resource will include basic metadata
9
+
10
+ This will create:
11
+ app/models/my_collection.rb
12
+ app/forms/my_collection_form.rb
13
+ app/indexers/my_collection_indexer.rb
14
+ config/metadata/my_collection.yaml
15
+ spec/models/my_collection_spec.rb
16
+ spec/forms/my_collection_form_spec.rb
17
+ spec/indexers/my_collection_indexer_spec.rb
18
+
19
+ This will also:
20
+ set Hyrax.config.collection_model = "MyCollection"
@@ -0,0 +1,133 @@
1
+ # frozen_string_literal: true
2
+ require 'rails/generators'
3
+ require 'rails/generators/model_helpers'
4
+
5
+ class Hyrax::CollectionResourceGenerator < Rails::Generators::NamedBase # rubocop:disable Metrics/ClassLength
6
+ # ActiveSupport can interpret models as plural which causes
7
+ # counter-intuitive route paths. Pull in ModelHelpers from
8
+ # Rails which warns users about pluralization when generating
9
+ # new models or scaffolds.
10
+ include Rails::Generators::ModelHelpers
11
+
12
+ source_root File.expand_path('../templates', __FILE__)
13
+
14
+ argument :with_basic_metadata, type: :string, default: "", banner: 'with_basic_metadata'
15
+
16
+ desc 'This generator makes the following changes to your application:
17
+ 1. Creates a collection model and model spec, optionally including basic metadata.
18
+ 2. Creates a collection form and spec.
19
+ 3. Creates a collection indexer and spec.
20
+ 4. Creates a collection metadata config.
21
+ 5. Sets this to be the collection class.
22
+ '
23
+
24
+ def self.exit_on_failure?
25
+ true
26
+ end
27
+
28
+ def validate_name
29
+ return unless name.strip.casecmp("collection").zero?
30
+ raise Thor::MalformattedArgumentError,
31
+ set_color("Error: A collection resource with the name '#{name}' would cause name-space clashes. "\
32
+ "Please use a different name.", :red)
33
+ end
34
+
35
+ def banner
36
+ if revoking?
37
+ say_status("info", "DESTROYING VALKYRIE COLLECTION MODEL: #{class_name}", :blue)
38
+ else
39
+ say_status("info", "GENERATING VALKYRIE COLLECTION MODEL: #{class_name}", :blue)
40
+ end
41
+ end
42
+
43
+ def create_metadata_config
44
+ template('collection_metadata.yaml', File.join('config/metadata/', "#{file_name}.yaml"))
45
+ end
46
+
47
+ def create_model
48
+ filepath = File.join('app/models', "#{file_name}.rb")
49
+ template('collection.rb.erb', filepath)
50
+ return unless include_basic_metadata?
51
+ inject_into_file filepath, before: /include Hyrax::Schema/ do
52
+ "include Hyrax::Schema(:basic_metadata)\n "
53
+ end
54
+ end
55
+
56
+ def create_model_spec
57
+ return unless rspec_installed?
58
+ filepath = File.join('spec/models/', "#{file_name}_spec.rb")
59
+ template('collection_spec.rb.erb', filepath)
60
+
61
+ return unless include_basic_metadata?
62
+ inject_into_file filepath, after: /it_behaves_like 'a Hyrax::PcdmCollection'/ do
63
+ "\n it_behaves_like 'a model with basic metadata'"
64
+ end
65
+ end
66
+
67
+ def create_form
68
+ filepath = File.join('app/forms/', "#{file_name}_form.rb")
69
+ template('collection_form.rb.erb', filepath)
70
+ return unless include_basic_metadata?
71
+ inject_into_file filepath, before: /include Hyrax::FormFields/ do
72
+ "include Hyrax::FormFields(:basic_metadata)\n "
73
+ end
74
+ end
75
+
76
+ # @todo If shared specs are expanded to test for basic metadata, inject calling that test here.
77
+ def create_form_spec
78
+ return unless rspec_installed?
79
+ template('collection_form_spec.rb.erb', File.join('spec/forms/', "#{file_name}_form_spec.rb"))
80
+ end
81
+
82
+ def create_indexer
83
+ filepath = File.join('app/indexers/', "#{file_name}_indexer.rb")
84
+ template('collection_indexer.rb.erb', filepath)
85
+ return unless include_basic_metadata?
86
+ inject_into_file filepath, before: /include Hyrax::Indexer/ do
87
+ "include Hyrax::Indexer(:basic_metadata)\n "
88
+ end
89
+ end
90
+
91
+ def create_indexer_spec
92
+ return unless rspec_installed?
93
+ filepath = File.join('spec/indexers/', "#{file_name}_indexer_spec.rb")
94
+ template('collection_indexer_spec.rb.erb', filepath)
95
+
96
+ return unless include_basic_metadata?
97
+ inject_into_file filepath, after: /it_behaves_like 'a Hyrax::Resource indexer'/ do
98
+ "\n it_behaves_like 'a Basic metadata indexer'"
99
+ end
100
+ end
101
+
102
+ # Inserts after the last registered work, or at the top of the config block
103
+ def set_as_the_collection_class
104
+ config = 'config/initializers/hyrax.rb'
105
+ lastmatch = nil
106
+ in_root do
107
+ File.open(config).each_line do |line|
108
+ lastmatch = line if line.match?(/config.collection_model = /)
109
+ end
110
+ content = " # Injected via `rails g hyrax:collection_resource #{class_name}`\n" \
111
+ " config.collection_model = '#{class_name}'\n"
112
+
113
+ anchor = lastmatch || "Hyrax.config do |config|\n"
114
+ inject_into_file config, after: anchor do
115
+ content
116
+ end
117
+ end
118
+ end
119
+
120
+ private
121
+
122
+ def include_basic_metadata?
123
+ with_basic_metadata.present? && with_basic_metadata == "with_basic_metadata"
124
+ end
125
+
126
+ def rspec_installed?
127
+ defined?(RSpec) && defined?(RSpec::Rails)
128
+ end
129
+
130
+ def revoking?
131
+ behavior == :revoke
132
+ end
133
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated via
4
+ # `rails generate hyrax:collection_resource <%= class_name %>`
5
+ class <%= class_name %> < Hyrax::PcdmCollection
6
+ # @note Do not directly update `basic_metadata.yaml`. It is also used by works.
7
+ #
8
+ # To change metadata for collections
9
+ # * extend by adding fields to `/config/metadata/<%= file_name %>.yaml`
10
+ # * remove all basic metadata
11
+ # * if you generated `with_basic_metadata` and now don't want any basic metadata,
12
+ # comment out or delete the schema include statement for `:basic_metadata`
13
+ # * update form and indexer classes to also remove the `:basic_metadata` schema include
14
+ # * remove some basic metadata
15
+ # * comment out or delete the schema include statement for `:basic_metadata`
16
+ # * update form and indexer classes to also remove the `:basic_metadata` schema include
17
+ # * copy fields you want to keep from `/config/metadata/basic_metadata.yaml`
18
+ # to `/config/metadata/<%= file_name %>.yaml`
19
+ # * override some basic metadata
20
+ # * fields are not allowed to repeat, so to override any basic metadata, you
21
+ # must first comment out or delete the schema include statement for `:basic_metadata`
22
+ # * update form and indexer classes to also remove the `:basic_metadata` schema include
23
+ # * copy all fields you want to keep unchanged or to override from `/config/metadata/basic_metadata.yaml`
24
+ # to `/config/metadata/<%= file_name %>.yaml`
25
+ # * update them in `config/metadata/<%= file_name %>.yaml to have the desired
26
+ # characteristics
27
+ #
28
+ # Alternative:
29
+ # * comment out or delete schema include statements
30
+ # * add Valkyrie attributes to this class
31
+ # * update form and indexer to process the attributes
32
+ #
33
+ include Hyrax::Schema(:<%= file_name %>)
34
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated via
4
+ # `rails generate hyrax:collection_resource <%= class_name %>`
5
+ class <%= class_name %>Form < Hyrax::Forms::PcdmCollectionForm
6
+ include Hyrax::FormFields(:<%= file_name %>)
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated via
4
+ # `rails generate hyrax:collection_resource <%= class_name %>`
5
+ require 'rails_helper'
6
+ require 'valkyrie/specs/shared_specs'
7
+
8
+ RSpec.describe <%= class_name %>Form do
9
+ let(:change_set) { described_class.new(resource) }
10
+ let(:resource) { <%= class_name %>.new }
11
+
12
+ it_behaves_like 'a Valkyrie::ChangeSet'
13
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated via
4
+ # `rails generate hyrax:collection_resource <%= class_name %>`
5
+ class <%= class_name %>Indexer < Hyrax::PcdmCollectionIndexer
6
+ include Hyrax::Indexer(:<%= file_name %>)
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated via
4
+ # `rails generate hyrax:collection_resource <%= class_name %>`
5
+ require 'rails_helper'
6
+ require 'hyrax/specs/shared_specs/indexers'
7
+
8
+ RSpec.describe <%= class_name %>Indexer do
9
+ let(:indexer_class) { described_class }
10
+ let(:resource) { <%= class_name %>.new }
11
+
12
+ it_behaves_like 'a Hyrax::Resource indexer'
13
+ end
@@ -0,0 +1,22 @@
1
+ # Simple yaml config-driven schema which is used to define model attributes,
2
+ # index key names, and form properties.
3
+ #
4
+ # Attributes must have a type but all other configuration options are optional.
5
+ #
6
+ # attributes:
7
+ # attribute_name:
8
+ # type: string
9
+ # multiple: false
10
+ # index_keys:
11
+ # - "attribute_name_sim"
12
+ # form:
13
+ # required: true
14
+ # primary: true
15
+ # multiple: false
16
+ #
17
+ # @see config/metadata/basic_metadata.yaml for an example configuration
18
+ #
19
+ # Generated via
20
+ # `rails generate hyrax:collection_resource <%= class_name %>`
21
+
22
+ attributes: {}
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated via
4
+ # `rails generate hyrax:collection_resource <%= class_name %>`
5
+ require 'rails_helper'
6
+ require 'hyrax/specs/shared_specs/hydra_works'
7
+
8
+ RSpec.describe <%= class_name %> do
9
+ subject(:collection) { described_class.new }
10
+
11
+ it_behaves_like 'a Hyrax::PcdmCollection'
12
+ end
@@ -35,6 +35,15 @@ module Hyrax
35
35
  18. Generates RIIIF image server implementation
36
36
  """
37
37
 
38
+ # browse-everything 1.2.0 is not compatible with Ruby 2.5
39
+ def pin_browse_everything
40
+ return unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6')
41
+ gem 'browse-everything', '~> 1.1.2'
42
+ Bundler.with_clean_env do
43
+ run "bundle update browse-everything"
44
+ end
45
+ end
46
+
38
47
  def run_required_generators
39
48
  say_status('info', '[Hyrax] GENERATING BLACKLIGHT', :blue)
40
49
  generate 'blacklight:install --devise'
@@ -50,7 +50,7 @@ de:
50
50
  directory:
51
51
  suffix: "@ Example.org"
52
52
  footer:
53
- copyright_html: "<strong>Copyright © 2018 Samvera lizenziert</strong> unter der Apache Lizenz, Version 2.0"
53
+ copyright_html: "<strong>Copyright © 2022 Samvera lizenziert</strong> unter der Apache Lizenz, Version 2.0"
54
54
  service_html: Ein Dienst von <a href="http://samvera.org/" class="navbar-link" target="_blank">Samvera</a> .
55
55
  institution_name: Institution
56
56
  institution_name_full: Name des Instituts
@@ -50,7 +50,7 @@ en:
50
50
  directory:
51
51
  suffix: "@example.org"
52
52
  footer:
53
- copyright_html: "<strong>Copyright &copy; 2018 Samvera</strong> Licensed under the Apache License, Version 2.0"
53
+ copyright_html: "<strong>Copyright &copy; 2022 Samvera</strong> Licensed under the Apache License, Version 2.0"
54
54
  service_html: A service of <a href="http://samvera.org/" class="navbar-link" target="_blank">Samvera</a>.
55
55
  institution_name: Institution
56
56
  institution_name_full: The Institution Name
@@ -50,7 +50,7 @@ es:
50
50
  directory:
51
51
  suffix: "@example.org"
52
52
  footer:
53
- copyright_html: "<strong>Copyright &copy; 2018 Samvera</strong> bajo licencia de Apache, Version 2.0"
53
+ copyright_html: "<strong>Copyright &copy; 2022 Samvera</strong> bajo licencia de Apache, Version 2.0"
54
54
  service_html: Un servicio de <a href="http://samvera.org/" class="navbar-link" target="_blank">Samvera</a>.
55
55
  institution_name: institución
56
56
  institution_name_full: El nombre de la institución
@@ -50,7 +50,7 @@ fr:
50
50
  directory:
51
51
  suffix: "@ Example.org"
52
52
  footer:
53
- copyright_html: "<strong>Copyright © 2018 Samvera</strong> Licence sous Licence Apache, Version 2.0"
53
+ copyright_html: "<strong>Copyright © 2022 Samvera</strong> Licence sous Licence Apache, Version 2.0"
54
54
  service_html: Un service de <a href="http://samvera.org/" class="navbar-link" target="_blank">Samvera</a> .
55
55
  institution_name: Institution
56
56
  institution_name_full: Nom de l'établissement
@@ -50,7 +50,7 @@ it:
50
50
  directory:
51
51
  suffix: "@ example.org"
52
52
  footer:
53
- copyright_html: "<strong>Copyright © 2018 Samvera</strong> Licenza sotto la licenza Apache, versione 2.0"
53
+ copyright_html: "<strong>Copyright © 2022 Samvera</strong> Licenza sotto la licenza Apache, versione 2.0"
54
54
  service_html: Un servizio di <a href="http://samvera.org/" class="navbar-link" target="_blank">Samvera</a> .
55
55
  institution_name: Istituzione
56
56
  institution_name_full: Nome dell'Istituzione
@@ -50,7 +50,7 @@ zh:
50
50
  directory:
51
51
  suffix: "@example.org"
52
52
  footer:
53
- copyright_html: "<strong>版权所有 &copy; 2018 Samvera</strong> 根据Apache许可证2.0版许可"
53
+ copyright_html: "<strong>版权所有 &copy; 2022 Samvera</strong> 根据Apache许可证2.0版许可"
54
54
  service_html: 的服务<a href="http://samvera.org/" class="navbar-link" target="_blank">Samvera</a>.
55
55
  institution_name: 机构
56
56
  institution_name_full: 机构名称
@@ -35,12 +35,25 @@ module Hyrax
35
35
  @id
36
36
  end
37
37
 
38
+ ##
39
+ # @api public
40
+ def to_key
41
+ [@id]
42
+ end
43
+
38
44
  ##
39
45
  # @api public
40
46
  def model_name
41
47
  @model.model_name
42
48
  end
43
49
 
50
+ ##
51
+ # @api public
52
+ # @return [String]
53
+ def human_readable_type
54
+ @model.human_readable_type
55
+ end
56
+
44
57
  ##
45
58
  # @api public
46
59
  #
@@ -427,6 +427,18 @@ module Hyrax
427
427
  @branding_storage_adapter = Valkyrie::StorageAdapter.find(adapter.to_sym)
428
428
  end
429
429
 
430
+ ##
431
+ # @return [Valkyrie::StorageAdapter]
432
+ def derivatives_storage_adapter
433
+ @derivatives_storage_adapter ||= Valkyrie::StorageAdapter.find(:derivatives_disk)
434
+ end
435
+
436
+ ##
437
+ # @param [#to_sym] adapter
438
+ def derivatives_storage_adapter=(adapter)
439
+ @derivatives_storage_adapter = Valkyrie::StorageAdapter.find(adapter.to_sym)
440
+ end
441
+
430
442
  ##
431
443
  # @return [#save, #save_all, #delete, #wipe!] an indexing adapter
432
444
  def index_adapter
@@ -863,10 +875,17 @@ module Hyrax
863
875
  end
864
876
  end
865
877
 
866
- attr_accessor :nested_relationship_reindexer
878
+ def use_solr_graph_for_collection_nesting
879
+ ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYRAX_USE_SOLR_GRAPH_NESTING', false))
880
+ end
867
881
 
882
+ attr_accessor :nested_relationship_reindexer
868
883
  def default_nested_relationship_reindexer
869
- ->(id:, extent:) { Samvera::NestingIndexer.reindex_relationships(id: id, extent: extent) }
884
+ if use_solr_graph_for_collection_nesting
885
+ ->(id:, extent:) {}
886
+ else
887
+ ->(id:, extent:) { Samvera::NestingIndexer.reindex_relationships(id: id, extent: extent) }
888
+ end
870
889
  end
871
890
 
872
891
  attr_writer :solr_select_path
data/lib/hyrax/errors.rb CHANGED
@@ -15,4 +15,6 @@ module Hyrax
15
15
  class SingleMembershipError < HyraxError; end
16
16
 
17
17
  class ObjectNotFoundError < ActiveFedora::ObjectNotFoundError; end
18
+
19
+ class ModelMismatchError < HyraxError; end
18
20
  end
@@ -119,6 +119,10 @@ module Hyrax
119
119
  # unique id), AND a `:user` (the ::User responsible for the update).
120
120
  register_event('collection.membership.updated')
121
121
 
122
+ # @since 3.5.0
123
+ # @macro a_registered_event
124
+ register_event('file.characterized')
125
+
122
126
  # @since 3.3.0
123
127
  # @macro a_registered_event
124
128
  register_event('file.downloaded')
@@ -3,6 +3,12 @@
3
3
  # @example
4
4
  # let(:resource) { FactoryBot.valkyrie_create(:hyrax_work) }
5
5
  class ValkyrieCreateStrategy
6
+ def initialize
7
+ @strategy = FactoryBot.strategy_by_name(:create).new
8
+ end
9
+
10
+ delegate :association, to: :@strategy
11
+
6
12
  def result(evaluation)
7
13
  evaluation.notify(:after_build, evaluation.object)
8
14
  evaluation.notify(:before_create, evaluation.object)
@@ -135,7 +135,6 @@ RSpec.shared_examples 'a Hyrax::PcdmCollection' do
135
135
 
136
136
  it_behaves_like 'a Hyrax::Resource'
137
137
  it_behaves_like 'a model with core metadata'
138
- it_behaves_like 'a model with basic metadata'
139
138
  it_behaves_like 'has members'
140
139
 
141
140
  describe '#collection_type_gid' do
@@ -266,6 +266,11 @@ RSpec.shared_examples 'a Collection indexer' do
266
266
  .to include(generic_type_sim: a_collection_containing_exactly('Collection'))
267
267
  end
268
268
 
269
+ it 'indexes member_of_collection_ids' do
270
+ expect(indexer.to_solr)
271
+ .to include(member_of_collection_ids_ssim: resource.member_of_collection_ids)
272
+ end
273
+
269
274
  it 'indexes depositor' do
270
275
  expect(indexer.to_solr)
271
276
  .to include(depositor_ssim: [resource.depositor],
@@ -9,6 +9,8 @@ module Hyrax
9
9
  # @since 3.2.0
10
10
  class CollectionUpdate < Transaction
11
11
  DEFAULT_STEPS = ['change_set.apply',
12
+ 'collection_resource.save_collection_banner',
13
+ 'collection_resource.save_collection_logo',
12
14
  'collection_resource.save_acl'].freeze
13
15
 
14
16
  ##
@@ -42,6 +42,8 @@ module Hyrax
42
42
  require 'hyrax/transactions/steps/remove_file_set_from_work'
43
43
  require 'hyrax/transactions/steps/save'
44
44
  require 'hyrax/transactions/steps/save_access_control'
45
+ require 'hyrax/transactions/steps/save_collection_banner'
46
+ require 'hyrax/transactions/steps/save_collection_logo'
45
47
  require 'hyrax/transactions/steps/set_default_admin_set'
46
48
  require 'hyrax/transactions/steps/set_modified_date'
47
49
  require 'hyrax/transactions/steps/set_uploaded_date_unless_present'
@@ -195,6 +197,14 @@ module Hyrax
195
197
  ops.register 'save_acl' do
196
198
  Steps::SaveAccessControl.new
197
199
  end
200
+
201
+ ops.register 'save_collection_banner' do
202
+ Steps::SaveCollectionBanner.new
203
+ end
204
+
205
+ ops.register 'save_collection_logo' do
206
+ Steps::SaveCollectionLogo.new
207
+ end
198
208
  end
199
209
 
200
210
  namespace 'work_resource' do |ops| # Hyrax::Work resource
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Transactions
4
+ module Steps
5
+ ##
6
+ # Adds banner info via `ChangeSet`.
7
+ #
8
+ # During the update collection process this step is called to update the file
9
+ # to be used as a the banner for the collection.
10
+ #
11
+ class SaveCollectionBanner
12
+ include Dry::Transaction::Operation
13
+
14
+ ##
15
+ # @param [Hyrax::ChangeSet] change_set
16
+ # @param [Array<Integer>] update_banner_file_ids
17
+ # @param [Boolean] banner_unchanged_indicator
18
+ #
19
+ # @return [Dry::Monads::Result] `Failure` if the banner info fails to save;
20
+ # `Success(input)`, otherwise.
21
+ def call(collection_resource, update_banner_file_ids: nil, banner_unchanged_indicator: true)
22
+ return Success(collection_resource) if ActiveModel::Type::Boolean.new.cast(banner_unchanged_indicator)
23
+ collection_id = collection_resource.id.to_s
24
+ process_banner_input(collection_id: collection_id, update_banner_file_ids: update_banner_file_ids)
25
+ Success(collection_resource)
26
+ end
27
+
28
+ private
29
+
30
+ def process_banner_input(collection_id:, update_banner_file_ids:)
31
+ remove_banner(collection_id: collection_id)
32
+ add_new_banner(collection_id: collection_id, uploaded_file_ids: update_banner_file_ids) if update_banner_file_ids
33
+ end
34
+
35
+ def remove_banner(collection_id:)
36
+ banner_info = CollectionBrandingInfo.where(collection_id: collection_id).where(role: "banner")
37
+ banner_info&.delete_all
38
+ end
39
+
40
+ def add_new_banner(collection_id:, uploaded_file_ids:)
41
+ f = uploaded_files(uploaded_file_ids).first
42
+ banner_info = CollectionBrandingInfo.new(
43
+ collection_id: collection_id,
44
+ filename: File.split(f.file_url).last,
45
+ role: "banner",
46
+ alt_txt: "",
47
+ target_url: ""
48
+ )
49
+ banner_info.save f.file_url
50
+ end
51
+
52
+ def uploaded_files(uploaded_file_ids)
53
+ return [] if uploaded_file_ids.empty?
54
+ UploadedFile.find(uploaded_file_ids)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end