zizia 3.1.0.alpha.01 → 4.0.0.alpha.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -3
  3. data/lib/zizia/engine.rb +8 -0
  4. data/lib/zizia/{hyrax_basic_metadata_mapper.rb → hyrax/hyrax_basic_metadata_mapper.rb} +0 -0
  5. data/lib/zizia/hyrax/hyrax_default_updater.rb +11 -0
  6. data/lib/zizia/hyrax/hyrax_delete_files_updater.rb +16 -0
  7. data/lib/zizia/hyrax/hyrax_metadata_only_updater.rb +58 -0
  8. data/lib/zizia/{hyrax_record_importer.rb → hyrax/hyrax_record_importer.rb} +45 -56
  9. data/lib/zizia/{metadata_only_stack.rb → hyrax/metadata_only_stack.rb} +0 -0
  10. data/lib/zizia/version.rb +1 -1
  11. data/lib/zizia.rb +6 -3
  12. metadata +371 -213
  13. data/.circleci/config.yml +0 -44
  14. data/.gitignore +0 -16
  15. data/.rubocop.yml +0 -81
  16. data/.rubocop_todo.yml +0 -21
  17. data/.solr_wrapper +0 -8
  18. data/.travis.yml +0 -12
  19. data/Gemfile +0 -14
  20. data/Rakefile +0 -38
  21. data/app/assets/config/zizia_manifest.js +0 -2
  22. data/app/assets/images/zizia/.keep +0 -0
  23. data/app/assets/javascripts/zizia/DisplayUploadedFile.es6 +0 -43
  24. data/app/assets/javascripts/zizia/application.js +0 -13
  25. data/app/assets/javascripts/zizia/zizia.js +0 -6
  26. data/app/assets/stylesheets/zizia/_file_upload.scss +0 -17
  27. data/app/assets/stylesheets/zizia/application.css +0 -15
  28. data/app/assets/stylesheets/zizia/zizia.scss +0 -1
  29. data/app/controllers/zizia/application_controller.rb +0 -6
  30. data/app/controllers/zizia/csv_imports_controller.rb +0 -53
  31. data/app/controllers/zizia/importer_documentation_controller.rb +0 -11
  32. data/app/helpers/importer_documentation_helper.rb +0 -13
  33. data/app/helpers/zizia/application_helper.rb +0 -14
  34. data/app/importers/modular_importer.rb +0 -31
  35. data/app/jobs/zizia/application_job.rb +0 -5
  36. data/app/jobs/zizia/start_csv_import_job.rb +0 -14
  37. data/app/models/zizia/application_record.rb +0 -6
  38. data/app/models/zizia/csv_import.rb +0 -21
  39. data/app/models/zizia/csv_import_detail.rb +0 -13
  40. data/app/models/zizia/pre_ingest_file.rb +0 -6
  41. data/app/models/zizia/pre_ingest_work.rb +0 -6
  42. data/app/uploaders/zizia/csv_manifest_uploader.rb +0 -62
  43. data/app/uploaders/zizia/csv_manifest_validator.rb +0 -163
  44. data/app/views/layouts/zizia/application.html.erb +0 -14
  45. data/app/views/zizia/csv_imports/_actions.html.erb +0 -3
  46. data/app/views/zizia/csv_imports/_collection_selection.html.erb +0 -3
  47. data/app/views/zizia/csv_imports/_error.html.erb +0 -10
  48. data/app/views/zizia/csv_imports/_file_upload.html.erb +0 -3
  49. data/app/views/zizia/csv_imports/_form.html.erb +0 -75
  50. data/app/views/zizia/csv_imports/_no_collection.html.erb +0 -7
  51. data/app/views/zizia/csv_imports/_record_count.html.erb +0 -7
  52. data/app/views/zizia/csv_imports/_start_import_form.html.erb +0 -9
  53. data/app/views/zizia/csv_imports/index.html.erb +0 -21
  54. data/app/views/zizia/csv_imports/new.html.erb +0 -2
  55. data/app/views/zizia/csv_imports/preview.html.erb +0 -76
  56. data/app/views/zizia/csv_imports/show.html.erb +0 -31
  57. data/app/views/zizia/importer_documentation/guide.html.erb +0 -1
  58. data/bin/rails +0 -15
  59. data/config/routes.rb +0 -9
  60. data/db/migrate/201901162141281_create_zizia_csv_imports.rb +0 -10
  61. data/db/migrate/201901162203121_add_manifest_to_zizia_csv_imports.rb +0 -6
  62. data/db/migrate/201901241536541_add_fedora_collection_id_to_zizia_csv_imports.rb +0 -5
  63. data/db/migrate/20190911133657_create_zizia_pre_ingest_files.rb +0 -12
  64. data/db/migrate/20190911134002_create_zizia_pre_ingest_works.rb +0 -9
  65. data/db/migrate/20190911142616_create_zizia_csv_import_details.rb +0 -8
  66. data/docs/_config.yml +0 -1
  67. data/docs/customizing_metadata.md +0 -41
  68. data/docs/index.md +0 -113
  69. data/log/.keep +0 -0
  70. data/solr/config/_rest_managed.json +0 -3
  71. data/solr/config/admin-extra.html +0 -31
  72. data/solr/config/elevate.xml +0 -36
  73. data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
  74. data/solr/config/protwords.txt +0 -21
  75. data/solr/config/routes.rb +0 -9
  76. data/solr/config/schema.xml +0 -366
  77. data/solr/config/scripts.conf +0 -24
  78. data/solr/config/solrconfig.xml +0 -322
  79. data/solr/config/spellings.txt +0 -2
  80. data/solr/config/stopwords.txt +0 -58
  81. data/solr/config/stopwords_en.txt +0 -58
  82. data/solr/config/synonyms.txt +0 -31
  83. data/solr/config/xslt/example.xsl +0 -132
  84. data/solr/config/xslt/example_atom.xsl +0 -67
  85. data/solr/config/xslt/example_rss.xsl +0 -66
  86. data/solr/config/xslt/luke.xsl +0 -337
  87. data/spec/controllers/importer_documentation_controller_spec.rb +0 -14
  88. data/spec/dummy/.gitignore +0 -23
  89. data/spec/dummy/Gemfile +0 -57
  90. data/spec/dummy/README.md +0 -24
  91. data/spec/dummy/Rakefile +0 -6
  92. data/spec/dummy/app/assets/config/manifest.js +0 -3
  93. data/spec/dummy/app/assets/csv/import_manifest.csv +0 -1
  94. data/spec/dummy/app/assets/images/.keep +0 -0
  95. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  96. data/spec/dummy/app/assets/javascripts/cable.js +0 -13
  97. data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
  98. data/spec/dummy/app/assets/markdown/importer_guide.md +0 -256
  99. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  100. data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
  101. data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
  102. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  103. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  104. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  105. data/spec/dummy/app/jobs/application_job.rb +0 -2
  106. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  107. data/spec/dummy/app/models/application_record.rb +0 -3
  108. data/spec/dummy/app/models/concerns/.keep +0 -0
  109. data/spec/dummy/app/models/user.rb +0 -2
  110. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  111. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  112. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  113. data/spec/dummy/bin/bundle +0 -3
  114. data/spec/dummy/bin/rails +0 -9
  115. data/spec/dummy/bin/rake +0 -9
  116. data/spec/dummy/bin/setup +0 -38
  117. data/spec/dummy/bin/spring +0 -17
  118. data/spec/dummy/bin/update +0 -29
  119. data/spec/dummy/bin/yarn +0 -11
  120. data/spec/dummy/config/application.rb +0 -18
  121. data/spec/dummy/config/boot.rb +0 -3
  122. data/spec/dummy/config/cable.yml +0 -10
  123. data/spec/dummy/config/database.yml +0 -25
  124. data/spec/dummy/config/environment.rb +0 -5
  125. data/spec/dummy/config/environments/development.rb +0 -54
  126. data/spec/dummy/config/environments/production.rb +0 -91
  127. data/spec/dummy/config/environments/test.rb +0 -42
  128. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
  129. data/spec/dummy/config/initializers/assets.rb +0 -14
  130. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  131. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
  132. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  133. data/spec/dummy/config/initializers/inflections.rb +0 -16
  134. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  135. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  136. data/spec/dummy/config/locales/en.yml +0 -33
  137. data/spec/dummy/config/puma.rb +0 -56
  138. data/spec/dummy/config/routes.rb +0 -4
  139. data/spec/dummy/config/secrets.yml +0 -32
  140. data/spec/dummy/config/spring.rb +0 -6
  141. data/spec/dummy/config.ru +0 -5
  142. data/spec/dummy/db/migrate/20190911165049_create_users.rb +0 -8
  143. data/spec/dummy/db/schema.rb +0 -55
  144. data/spec/dummy/db/seeds.rb +0 -7
  145. data/spec/dummy/lib/assets/.keep +0 -0
  146. data/spec/dummy/lib/tasks/.keep +0 -0
  147. data/spec/dummy/log/.keep +0 -0
  148. data/spec/dummy/package.json +0 -5
  149. data/spec/dummy/public/404.html +0 -67
  150. data/spec/dummy/public/422.html +0 -67
  151. data/spec/dummy/public/500.html +0 -66
  152. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  153. data/spec/dummy/public/apple-touch-icon.png +0 -0
  154. data/spec/dummy/public/favicon.ico +0 -0
  155. data/spec/dummy/public/robots.txt +0 -1
  156. data/spec/dummy/test/application_system_test_case.rb +0 -5
  157. data/spec/dummy/test/controllers/.keep +0 -0
  158. data/spec/dummy/test/fixtures/.keep +0 -0
  159. data/spec/dummy/test/fixtures/files/.keep +0 -0
  160. data/spec/dummy/test/fixtures/users.yml +0 -11
  161. data/spec/dummy/test/helpers/.keep +0 -0
  162. data/spec/dummy/test/integration/.keep +0 -0
  163. data/spec/dummy/test/mailers/.keep +0 -0
  164. data/spec/dummy/test/models/.keep +0 -0
  165. data/spec/dummy/test/models/user_test.rb +0 -7
  166. data/spec/dummy/test/system/.keep +0 -0
  167. data/spec/dummy/test/test_helper.rb +0 -10
  168. data/spec/dummy/vendor/.keep +0 -0
  169. data/spec/fixtures/bad_example.csv +0 -2
  170. data/spec/fixtures/dog.jpg +0 -0
  171. data/spec/fixtures/example.csv +0 -4
  172. data/spec/fixtures/hyrax/example.csv +0 -3
  173. data/spec/fixtures/images/animals/cat.png +0 -0
  174. data/spec/fixtures/images/zizia.png +0 -0
  175. data/spec/fixtures/zizia.png +0 -0
  176. data/spec/integration/csv_import_detail_spec.rb +0 -48
  177. data/spec/integration/import_csv_spec.rb +0 -27
  178. data/spec/integration/import_hyrax_csv.rb +0 -71
  179. data/spec/models/csv_import_spec.rb +0 -18
  180. data/spec/spec_helper.rb +0 -31
  181. data/spec/support/hyrax/basic_metadata.rb +0 -30
  182. data/spec/support/hyrax/core_metadata.rb +0 -15
  183. data/spec/support/shared_contexts/with_work_type.rb +0 -101
  184. data/spec/uploaders/csv_manifest_uploader_spec.rb +0 -30
  185. data/spec/views/zizia/importer_documentation/guide.html.erb_spec.rb +0 -13
  186. data/spec/zizia/csv_format_validator_spec.rb +0 -38
  187. data/spec/zizia/csv_parser_spec.rb +0 -73
  188. data/spec/zizia/csv_template_spec.rb +0 -15
  189. data/spec/zizia/hash_mapper_spec.rb +0 -8
  190. data/spec/zizia/hyrax_basic_metadata_mapper_spec.rb +0 -190
  191. data/spec/zizia/hyrax_record_importer_spec.rb +0 -176
  192. data/spec/zizia/importer_spec.rb +0 -46
  193. data/spec/zizia/input_record_spec.rb +0 -71
  194. data/spec/zizia/record_importer_spec.rb +0 -53
  195. data/spec/zizia/title_validator_spec.rb +0 -23
  196. data/spec/zizia/validator_spec.rb +0 -9
  197. data/spec/zizia/version_spec.rb +0 -7
  198. data/spec/zizia_spec.rb +0 -20
  199. data/zizia.gemspec +0 -42
@@ -1,163 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Validate a CSV file.
4
- #
5
- # Don't put expensive validations in this class.
6
- # This is meant to be used for running a few quick
7
- # validations before starting a CSV-based import.
8
- # It will be called during the HTTP request/response,
9
- # so long-running validations will make the page load
10
- # slowly for the user. Any validations that are slow
11
- # should be run in background jobs during the import
12
- # instead of here.
13
- module Zizia
14
- class CsvManifestValidator
15
- # @param manifest_uploader [CsvManifestUploader] The manifest that's mounted to a CsvImport record. See carrierwave gem documentation. This is basically a wrapper for the CSV file.
16
- def initialize(manifest_uploader)
17
- @csv_file = manifest_uploader.file
18
- @errors = []
19
- @warnings = []
20
- end
21
-
22
- # Errors and warnings for the CSV file.
23
- attr_reader :errors, :warnings
24
- attr_reader :csv_file
25
-
26
- def validate
27
- parse_csv
28
- return unless @rows
29
-
30
- missing_headers
31
- duplicate_headers
32
- unrecognized_headers
33
- missing_values
34
- invalid_license
35
- invalid_resource_type
36
- invalid_rights_statement
37
- end
38
-
39
- # One record per row
40
- def record_count
41
- return nil unless @rows
42
- @rows.size - 1 # Don't include the header row
43
- end
44
-
45
- def delimiter
46
- @delimiter ||= default_delimiter
47
- end
48
- attr_writer :delimiter
49
-
50
- private
51
-
52
- def default_delimiter
53
- Zizia::HyraxBasicMetadataMapper.new.delimiter
54
- end
55
-
56
- def valid_headers
57
- ['title', 'files', 'representative media',
58
- 'thumbnail', 'rendering', 'depositor',
59
- 'date_uploaded', 'date_modified', 'label',
60
- 'relative_path', 'import url', 'resource type',
61
- 'creator', 'contributor', 'abstract or summary',
62
- 'keyword', 'license', 'rights statement',
63
- 'publisher', 'date created', 'subject',
64
- 'language', 'identifier', 'location',
65
- 'related url', 'bibliographic_citation',
66
- 'source', 'visibility']
67
- end
68
-
69
- def parse_csv
70
- @rows = CSV.read(csv_file.path)
71
- @headers = @rows.first || []
72
- @transformed_headers = @headers.map { |header| header.downcase.strip }
73
- rescue
74
- @errors << 'We are unable to read this CSV file.'
75
- end
76
-
77
- def missing_headers
78
- required_headers.each do |header|
79
- next if @transformed_headers.include?(header)
80
- @errors << "Missing required column: \"#{header.titleize}\". Your spreadsheet must have this column."
81
- end
82
- end
83
-
84
- def required_headers
85
- ['title', 'creator', 'keyword', 'rights statement', 'visibility', 'files']
86
- end
87
-
88
- def duplicate_headers
89
- duplicates = []
90
- sorted_headers = @transformed_headers.sort
91
- sorted_headers.each_with_index do |x, i|
92
- duplicates << x if x == sorted_headers[i + 1]
93
- end
94
- duplicates.uniq.each do |header|
95
- @errors << "Duplicate column names: You can have only one \"#{header.titleize}\" column."
96
- end
97
- end
98
-
99
- # Warn the user if we find any unexpected headers.
100
- def unrecognized_headers
101
- extra_headers = @transformed_headers - valid_headers
102
- extra_headers.each do |header|
103
- @warnings << "The field name \"#{header}\" is not supported. This field will be ignored, and the metadata for this field will not be imported."
104
- end
105
- end
106
-
107
- def missing_values
108
- column_numbers = required_headers.map { |header| @transformed_headers.find_index(header) }.compact
109
-
110
- @rows.each_with_index do |row, i|
111
- column_numbers.each_with_index do |column_number, j|
112
- next unless row[column_number].blank?
113
- @errors << "Missing required metadata in row #{i + 1}: \"#{required_headers[j].titleize}\" field cannot be blank"
114
- end
115
- end
116
- end
117
-
118
- # Only allow valid license values expected by Hyrax.
119
- # Otherwise the app throws an error when it displays the work.
120
- def invalid_license
121
- validate_values('license', :valid_licenses)
122
- end
123
-
124
- def invalid_resource_type
125
- validate_values('resource type', :valid_resource_types)
126
- end
127
-
128
- def invalid_rights_statement
129
- validate_values('rights statement', :valid_rights_statements)
130
- end
131
-
132
- def valid_licenses
133
- @valid_license_ids ||= Hyrax::LicenseService.new.authority.all.select { |license| license[:active] }.map { |license| license[:id] }
134
- end
135
-
136
- def valid_resource_types
137
- @valid_resource_type_ids ||= Qa::Authorities::Local.subauthority_for('resource_types').all.select { |term| term[:active] }.map { |term| term[:id] }
138
- end
139
-
140
- def valid_rights_statements
141
- @valid_rights_statement_ids ||= Qa::Authorities::Local.subauthority_for('rights_statements').all.select { |term| term[:active] }.map { |term| term[:id] }
142
- end
143
-
144
- # Make sure this column contains only valid values
145
- def validate_values(header_name, valid_values_method)
146
- column_number = @transformed_headers.find_index(header_name)
147
- return unless column_number
148
-
149
- @rows.each_with_index do |row, i|
150
- next if i.zero? # Skip the header row
151
- next unless row[column_number]
152
-
153
- values = row[column_number].split(delimiter)
154
- valid_values = method(valid_values_method).call
155
- invalid_values = values.select { |value| !valid_values.include?(value) }
156
-
157
- invalid_values.each do |value|
158
- @errors << "Invalid #{header_name.titleize} in row #{i + 1}: #{value}"
159
- end
160
- end
161
- end
162
- end
163
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Zizia</title>
5
- <%= stylesheet_link_tag "zizia/application", media: "all" %>
6
- <%= javascript_include_tag "zizia/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,3 +0,0 @@
1
- <div class="actions">
2
- <%= form.submit 'Preview Import', class: "btn btn-primary btn-lg" %>
3
- </div>
@@ -1,3 +0,0 @@
1
- <div class="form-group">
2
- <%= form.select :fedora_collection_id, options_for_select(collections_for_select), {}, class: "form-control", id: "fedora_collection_id" %>
3
- </div>
@@ -1,10 +0,0 @@
1
- <% if csv_import.errors.any? %>
2
- <div id="error_explanation">
3
- <h2><%= pluralize(csv_import.errors.size, "error") %> prohibited this csv_import from being saved:</h2>
4
- <ul>
5
- <% csv_import.errors.full_messages.each do |message| %>
6
- <li><%= message %></li>
7
- <% end %>
8
- </ul>
9
- </div>
10
- <% end %>
@@ -1,3 +0,0 @@
1
- <%= form.file_field :manifest, required: true, id: 'file-upload', class: "file-upload form-control", onchange: "Zizia.displayUploadedFile()" %>
2
- <label for="file-upload" class="btn btn-lg btn-primary"><span class="glyphicon glyphicon-upload"></span> Upload Your CSV</label>
3
- <div id="file-upload-display"></div>
@@ -1,75 +0,0 @@
1
- <%= form_with(model: csv_import, local: true, html: { multipart: true }, url: preview_csv_import_path) do |form| %>
2
- <div class="panel panel-default">
3
- <div class="panel-body">
4
- <div class="row">
5
- <div class="col-md-8">
6
- <h2> Getting Started </h2>
7
- </div>
8
- </div>
9
- <div class="row">
10
- <div class="col-md-4">
11
- <div class="well well-lg">
12
- <p><b>Read the CSV Field Guide</b> to learn what is required in your CSV.</p>
13
- <div class="text-center">
14
- <a href="/importer_documentation/guide" class="btn btn-default btn-lg"><i class="glyphicon glyphicon-book"></i> CSV Field Guide</a>
15
- </div>
16
- </div>
17
- </div>
18
- <div class="col-md-4">
19
- <div class="well well-lg">
20
- <p><b>Download a CSV template</b> to get started.</b></p>
21
- <div class="text-center">
22
- <a href="/importer_documentation/csv" data-turbolinks="false" class="btn btn-default btn-lg"><i class="glyphicon glyphicon-list"></i> Download a CSV Template</a>
23
- </div>
24
- </div>
25
- </div>
26
- </div>
27
- <hr/>
28
-
29
- <% if collections? %>
30
- <div class="row">
31
- <div class="col-md-8">
32
- <h2> Upload Your CSV </h2>
33
- </div>
34
- </div>
35
- <div class="row">
36
- <div class="col-md-4">
37
- <div class="well well-lg">
38
- <p> <b>Upload a CSV</b> that has your content. </p>
39
- <div class="text-center">
40
- <%= render "file_upload", form: form %>
41
- </div>
42
- </div>
43
- </div>
44
- <div class="col-md-4">
45
- <div class="well well-lg">
46
- <p> <b>Choose a collection</b>. All imports need to be associated with a collection. </p>
47
- <div class="text-center">
48
- <%= render "collection_selection", form: form %>
49
- </div>
50
- </div>
51
- </div>
52
- <div class="col-md-4">
53
- <div class="well well-lg">
54
- <p> <b>Preview your import</b> before starting the process. </p>
55
- <div class="text-center">
56
- <%= render "actions", form: form %>
57
- </div>
58
- </div>
59
- </div>
60
- </div>
61
-
62
- <div class="row">
63
- <div class="col-md-4">
64
- <%= render "error", csv_import: csv_import %>
65
- </div>
66
- <div class="col-md-4">
67
- </div>
68
- </div>
69
-
70
-
71
- <%= form.hidden_field :manifest_cache %>
72
- <% else %>
73
- <%= render 'no_collection' %>
74
- <% end %>
75
- <% end %>
@@ -1,7 +0,0 @@
1
- <div class="row">
2
- <div class="col-md-4">
3
- <div class="well well-lg no-collection">
4
- You must <a href="/dashboard/collections">create a collection</a> before importing content.
5
- </div>
6
- </div>
7
- </div>
@@ -1,7 +0,0 @@
1
- <div class="row">
2
- <div class="col-md-8">
3
- <div class="alert alert-success">
4
- <p> This import will add <%= @csv_import.manifest_records %> new records. </p>
5
- </div>
6
- </div>
7
- </div>
@@ -1,9 +0,0 @@
1
- <%= form_with(model: csv_import, local: true, html: { multipart: true }) do |form| %>
2
-
3
- <%= form.hidden_field :manifest_cache %>
4
- <%= form.hidden_field :fedora_collection_id, value: csv_import.fedora_collection_id %>
5
-
6
- <div class="actions">
7
- <%= form.submit 'Start Import', class: 'btn btn-lg btn-primary' %>
8
- </div>
9
- <% end %>
@@ -1,21 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <h2>CSV Imports</h2>
4
-
5
- <table>
6
- <thead>
7
- <tr>
8
- <th colspan="3"></th>
9
- </tr>
10
- </thead>
11
-
12
- <tbody>
13
- <% @csv_imports.each do |csv_import| %>
14
- <tr>
15
- <% link_text = csv_import.manifest.file ? File.basename(csv_import.manifest.to_s) : 'show' %>
16
- <td><%= link_to link_text, csv_import %></td>
17
- </tr>
18
- <% end %>
19
- </tbody>
20
- </table>
21
-
@@ -1,2 +0,0 @@
1
- <h2><span class="glyphicon glyphicon-cloud-upload"></span> Begin Your CSV Import </h2>
2
- <%= render 'form', csv_import: @csv_import %>
@@ -1,76 +0,0 @@
1
- <h2><span class="glyphicon glyphicon-cloud-upload"></span> Preview your CSV Import</h2>
2
- <div class="panel panel-default">
3
- <div class="panel-body">
4
- <div id='csv_info'>
5
- <% if @csv_import.manifest.file %>
6
- <div class="row">
7
- <div class="col-md-4">
8
- <label> CSV Manifest: </label>
9
- <%= File.basename(@csv_import.manifest.to_s) %>
10
- </div>
11
- <div class="col-md-4">
12
- <label> Collection: </label>
13
- <%= ActiveFedora::SolrService.query("id:#{@csv_import.fedora_collection_id}")[0]['title_tesim'][0] %>
14
- </div>
15
- </div>
16
- <% end %>
17
-
18
- <%= render 'record_count', locals: { csv_import: @csv_import } %>
19
-
20
- <% unless @csv_import.manifest_errors.empty? %>
21
- <div class="row">
22
- <div class="col-md-6">
23
- <div class="alert alert-danger">
24
- <div id='csv_errors'>
25
- <b><i class="glyphicon glyphicon-remove-sign"></i> The CSV file has the following errors:</b>
26
- <ul>
27
- <% @csv_import.manifest_errors.each do |error| %>
28
- <li> <%= error %> </li>
29
- <% end %>
30
- </ul>
31
- </div>
32
- </div>
33
- </div>
34
- </div>
35
- <% end %>
36
-
37
- <% unless @csv_import.manifest_warnings.empty? %>
38
- <div class="row">
39
- <div class="col-md-6">
40
- <div class="alert alert-warning">
41
- <div id='csv_warnings'>
42
- <b><i class="glyphicon glyphicon-exclamation-sign"></i> The CSV file has the following warnings:</b>
43
- <ul>
44
- <% @csv_import.manifest_warnings.each do |warning| %>
45
- <li> <%= warning %> </li>
46
- <% end %>
47
- </ul>
48
- </div>
49
- </div>
50
- </div>
51
- </div>
52
- <% end %>
53
-
54
- <% if @csv_import.manifest_errors.empty? %>
55
- <div class="row">
56
- <div class="col-md-2">
57
- <%= render 'start_import_form', csv_import: @csv_import, class: "btn btn-large btn-danger" %>
58
- </div>
59
- <div class="col-md-2">
60
- <%= link_to 'Cancel', new_csv_import_path, class: "btn btn-lg btn-danger" %>
61
- </div>
62
- </div>
63
- <% else %>
64
- <div class="row">
65
- <div class="col-md-4">
66
- <div class="well"><p>You will need to correct the errors with the CSV file before you can continue.</p></br>
67
- <div class="text-center"><%= link_to 'Try Again', new_csv_import_path, class: 'btn btn-lg btn-primary' %>
68
- </div>
69
- </div>
70
- </div>
71
- </div>
72
- <% end %>
73
- </div>
74
- </div>
75
- </div>
76
- </div>
@@ -1,31 +0,0 @@
1
- <h2> Importing Records from a CSV File </h2>
2
- <p id="notice"><%= notice %></p>
3
-
4
- <div class="panel panel-default">
5
- <div class="panel-body">
6
-
7
- <p>
8
- <label> CSV Manifest: </label>
9
- <span> <%= File.basename(@csv_import.manifest.to_s) %> </span>
10
- <br />
11
- <label> Collection: </label>
12
- <span> <%= ActiveFedora::SolrService.query("id:#{@csv_import.fedora_collection_id}")[0]['title_tesim'][0] %> </span>
13
- <br />
14
- <label> Uploaded by: </label>
15
- <span> <%= @csv_import.user.name %> </span>
16
- <br />
17
- <label> Start time: </label>
18
- <span> <%= @csv_import.created_at %> </span>
19
- </p>
20
-
21
- <div class="row">
22
- <div class="col-md-6">
23
- <div class='well'>
24
- <p> Your records will be imported in the background. To check the current status, please check the background job status page. </p><br />
25
- <div class="text-center"> <%= link_to 'Background Job Status', '/sidekiq', class: "btn btn-primary btn-lg" %> </div>
26
- </div>
27
- </div>
28
- </div>
29
-
30
- </div>
31
- </div>
@@ -1 +0,0 @@
1
- <%= render_guide.html_safe %>
data/bin/rails DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- # This command will automatically be run when you run "rails" with Rails gems
4
- # installed from the root of your application.
5
-
6
- ENGINE_ROOT = File.expand_path('../..', __FILE__)
7
- ENGINE_PATH = File.expand_path('../../lib/zizia/engine', __FILE__)
8
- APP_PATH = File.expand_path('../../spec/dummy/config/application', __FILE__)
9
-
10
- # Set up gems listed in the Gemfile.
11
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
12
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
13
-
14
- require 'rails/all'
15
- require 'rails/engine/commands'
data/config/routes.rb DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
- Zizia::Engine.routes.draw do
3
- get 'importer_documentation/guide'
4
- get 'importer_documentation/csv'
5
-
6
- post 'csv_imports/preview', as: 'preview_csv_import'
7
- get 'csv_imports/preview', to: redirect('csv_imports/new')
8
- resources :csv_imports, only: [:index, :show, :new, :create]
9
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- class CreateZiziaCsvImports < ActiveRecord::Migration[5.1]
3
- def change
4
- create_table :zizia_csv_imports do |t|
5
- t.references :user, foreign_key: true
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- class AddManifestToZiziaCsvImports < ActiveRecord::Migration[5.1]
3
- def change
4
- add_column :zizia_csv_imports, :manifest, :string
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class AddFedoraCollectionIdToZiziaCsvImports < ActiveRecord::Migration[5.1]
2
- def change
3
- add_column :zizia_csv_imports, :fedora_collection_id, :string
4
- end
5
- end
@@ -1,12 +0,0 @@
1
- class CreateZiziaPreIngestFiles < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :zizia_pre_ingest_files do |t|
4
- t.integer :size
5
- t.text :row
6
- t.integer :row_number
7
- t.string :filename
8
- t.belongs_to :pre_ingest_work
9
- t.timestamps
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- class CreateZiziaPreIngestWorks < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :zizia_pre_ingest_works do |t|
4
- t.integer :parent_object
5
- t.belongs_to :csv_import_detail
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,8 +0,0 @@
1
- class CreateZiziaCsvImportDetails < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :zizia_csv_import_details do |t|
4
- t.belongs_to :csv_import
5
- t.timestamps
6
- end
7
- end
8
- end
data/docs/_config.yml DELETED
@@ -1 +0,0 @@
1
- theme: jekyll-theme-minimal
@@ -1,41 +0,0 @@
1
- # Customizing metadata import
2
-
3
- Often the data you will want to import will not conform exactly to the fields you get from `Hyrax::BasicMetadata`, in which case you will need to make a custom mapper.
4
-
5
- Again, let's start with making a test. Make a file called `spec/importers/custom_mapper.rb`. Let's start by describing the CSV we expect to import:
6
-
7
- ```ruby
8
- # frozen_string_literal: true
9
-
10
- require 'rails_helper'
11
-
12
- RSpec.describe CustomMapper do
13
- subject(:mapper) { described_class.new }
14
-
15
- let(:metadata) do
16
- { "Name.architect" => "Imhotep", # architect
17
- "Type.genre" => "Journalism" # genre
18
- }
19
-
20
- describe '#fields' do
21
- it 'has expected fields' do
22
- expect(mapper.fields).to include(
23
- :architect,
24
- :genre
25
- )
26
- end
27
- end
28
- ```
29
- From this rspec test, I can conclude that I have two customized metadata fields, `architect` and `genre`. Actually adding custom metadata fields is covered elsewhere (See [this guide](https://samvera.github.io/customize-metadata-generate-work-type.html), for example), so here we are just going to assume that these fields exist already, and are defined as multi-valued strings.
30
-
31
-
32
- * Put a file in `config/initializers/zizia.rb`
33
-
34
- It should look like this:
35
-
36
- ```ruby
37
- Zizia.config do |config|
38
- config.metadata_mapper_class = CustomMapper
39
- end
40
- ```
41
- This tells zizia what class to use for metadata mappings. Output is logged to `Rails.logger` and all output is prefixed with `[zizia]` for easy log parsing.