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.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/lib/zizia/engine.rb +8 -0
- data/lib/zizia/{hyrax_basic_metadata_mapper.rb → hyrax/hyrax_basic_metadata_mapper.rb} +0 -0
- data/lib/zizia/hyrax/hyrax_default_updater.rb +11 -0
- data/lib/zizia/hyrax/hyrax_delete_files_updater.rb +16 -0
- data/lib/zizia/hyrax/hyrax_metadata_only_updater.rb +58 -0
- data/lib/zizia/{hyrax_record_importer.rb → hyrax/hyrax_record_importer.rb} +45 -56
- data/lib/zizia/{metadata_only_stack.rb → hyrax/metadata_only_stack.rb} +0 -0
- data/lib/zizia/version.rb +1 -1
- data/lib/zizia.rb +6 -3
- metadata +371 -213
- data/.circleci/config.yml +0 -44
- data/.gitignore +0 -16
- data/.rubocop.yml +0 -81
- data/.rubocop_todo.yml +0 -21
- data/.solr_wrapper +0 -8
- data/.travis.yml +0 -12
- data/Gemfile +0 -14
- data/Rakefile +0 -38
- data/app/assets/config/zizia_manifest.js +0 -2
- data/app/assets/images/zizia/.keep +0 -0
- data/app/assets/javascripts/zizia/DisplayUploadedFile.es6 +0 -43
- data/app/assets/javascripts/zizia/application.js +0 -13
- data/app/assets/javascripts/zizia/zizia.js +0 -6
- data/app/assets/stylesheets/zizia/_file_upload.scss +0 -17
- data/app/assets/stylesheets/zizia/application.css +0 -15
- data/app/assets/stylesheets/zizia/zizia.scss +0 -1
- data/app/controllers/zizia/application_controller.rb +0 -6
- data/app/controllers/zizia/csv_imports_controller.rb +0 -53
- data/app/controllers/zizia/importer_documentation_controller.rb +0 -11
- data/app/helpers/importer_documentation_helper.rb +0 -13
- data/app/helpers/zizia/application_helper.rb +0 -14
- data/app/importers/modular_importer.rb +0 -31
- data/app/jobs/zizia/application_job.rb +0 -5
- data/app/jobs/zizia/start_csv_import_job.rb +0 -14
- data/app/models/zizia/application_record.rb +0 -6
- data/app/models/zizia/csv_import.rb +0 -21
- data/app/models/zizia/csv_import_detail.rb +0 -13
- data/app/models/zizia/pre_ingest_file.rb +0 -6
- data/app/models/zizia/pre_ingest_work.rb +0 -6
- data/app/uploaders/zizia/csv_manifest_uploader.rb +0 -62
- data/app/uploaders/zizia/csv_manifest_validator.rb +0 -163
- data/app/views/layouts/zizia/application.html.erb +0 -14
- data/app/views/zizia/csv_imports/_actions.html.erb +0 -3
- data/app/views/zizia/csv_imports/_collection_selection.html.erb +0 -3
- data/app/views/zizia/csv_imports/_error.html.erb +0 -10
- data/app/views/zizia/csv_imports/_file_upload.html.erb +0 -3
- data/app/views/zizia/csv_imports/_form.html.erb +0 -75
- data/app/views/zizia/csv_imports/_no_collection.html.erb +0 -7
- data/app/views/zizia/csv_imports/_record_count.html.erb +0 -7
- data/app/views/zizia/csv_imports/_start_import_form.html.erb +0 -9
- data/app/views/zizia/csv_imports/index.html.erb +0 -21
- data/app/views/zizia/csv_imports/new.html.erb +0 -2
- data/app/views/zizia/csv_imports/preview.html.erb +0 -76
- data/app/views/zizia/csv_imports/show.html.erb +0 -31
- data/app/views/zizia/importer_documentation/guide.html.erb +0 -1
- data/bin/rails +0 -15
- data/config/routes.rb +0 -9
- data/db/migrate/201901162141281_create_zizia_csv_imports.rb +0 -10
- data/db/migrate/201901162203121_add_manifest_to_zizia_csv_imports.rb +0 -6
- data/db/migrate/201901241536541_add_fedora_collection_id_to_zizia_csv_imports.rb +0 -5
- data/db/migrate/20190911133657_create_zizia_pre_ingest_files.rb +0 -12
- data/db/migrate/20190911134002_create_zizia_pre_ingest_works.rb +0 -9
- data/db/migrate/20190911142616_create_zizia_csv_import_details.rb +0 -8
- data/docs/_config.yml +0 -1
- data/docs/customizing_metadata.md +0 -41
- data/docs/index.md +0 -113
- data/log/.keep +0 -0
- data/solr/config/_rest_managed.json +0 -3
- data/solr/config/admin-extra.html +0 -31
- data/solr/config/elevate.xml +0 -36
- data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
- data/solr/config/protwords.txt +0 -21
- data/solr/config/routes.rb +0 -9
- data/solr/config/schema.xml +0 -366
- data/solr/config/scripts.conf +0 -24
- data/solr/config/solrconfig.xml +0 -322
- data/solr/config/spellings.txt +0 -2
- data/solr/config/stopwords.txt +0 -58
- data/solr/config/stopwords_en.txt +0 -58
- data/solr/config/synonyms.txt +0 -31
- data/solr/config/xslt/example.xsl +0 -132
- data/solr/config/xslt/example_atom.xsl +0 -67
- data/solr/config/xslt/example_rss.xsl +0 -66
- data/solr/config/xslt/luke.xsl +0 -337
- data/spec/controllers/importer_documentation_controller_spec.rb +0 -14
- data/spec/dummy/.gitignore +0 -23
- data/spec/dummy/Gemfile +0 -57
- data/spec/dummy/README.md +0 -24
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/csv/import_manifest.csv +0 -1
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/javascripts/cable.js +0 -13
- data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy/app/assets/markdown/importer_guide.md +0 -256
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +0 -2
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/user.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -38
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/bin/update +0 -29
- data/spec/dummy/bin/yarn +0 -11
- data/spec/dummy/config/application.rb +0 -18
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -54
- data/spec/dummy/config/environments/production.rb +0 -91
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/assets.rb +0 -14
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/puma.rb +0 -56
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/secrets.yml +0 -32
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/db/migrate/20190911165049_create_users.rb +0 -8
- data/spec/dummy/db/schema.rb +0 -55
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/package.json +0 -5
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +0 -1
- data/spec/dummy/test/application_system_test_case.rb +0 -5
- data/spec/dummy/test/controllers/.keep +0 -0
- data/spec/dummy/test/fixtures/.keep +0 -0
- data/spec/dummy/test/fixtures/files/.keep +0 -0
- data/spec/dummy/test/fixtures/users.yml +0 -11
- data/spec/dummy/test/helpers/.keep +0 -0
- data/spec/dummy/test/integration/.keep +0 -0
- data/spec/dummy/test/mailers/.keep +0 -0
- data/spec/dummy/test/models/.keep +0 -0
- data/spec/dummy/test/models/user_test.rb +0 -7
- data/spec/dummy/test/system/.keep +0 -0
- data/spec/dummy/test/test_helper.rb +0 -10
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/fixtures/bad_example.csv +0 -2
- data/spec/fixtures/dog.jpg +0 -0
- data/spec/fixtures/example.csv +0 -4
- data/spec/fixtures/hyrax/example.csv +0 -3
- data/spec/fixtures/images/animals/cat.png +0 -0
- data/spec/fixtures/images/zizia.png +0 -0
- data/spec/fixtures/zizia.png +0 -0
- data/spec/integration/csv_import_detail_spec.rb +0 -48
- data/spec/integration/import_csv_spec.rb +0 -27
- data/spec/integration/import_hyrax_csv.rb +0 -71
- data/spec/models/csv_import_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -31
- data/spec/support/hyrax/basic_metadata.rb +0 -30
- data/spec/support/hyrax/core_metadata.rb +0 -15
- data/spec/support/shared_contexts/with_work_type.rb +0 -101
- data/spec/uploaders/csv_manifest_uploader_spec.rb +0 -30
- data/spec/views/zizia/importer_documentation/guide.html.erb_spec.rb +0 -13
- data/spec/zizia/csv_format_validator_spec.rb +0 -38
- data/spec/zizia/csv_parser_spec.rb +0 -73
- data/spec/zizia/csv_template_spec.rb +0 -15
- data/spec/zizia/hash_mapper_spec.rb +0 -8
- data/spec/zizia/hyrax_basic_metadata_mapper_spec.rb +0 -190
- data/spec/zizia/hyrax_record_importer_spec.rb +0 -176
- data/spec/zizia/importer_spec.rb +0 -46
- data/spec/zizia/input_record_spec.rb +0 -71
- data/spec/zizia/record_importer_spec.rb +0 -53
- data/spec/zizia/title_validator_spec.rb +0 -23
- data/spec/zizia/validator_spec.rb +0 -9
- data/spec/zizia/version_spec.rb +0 -7
- data/spec/zizia_spec.rb +0 -20
- 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,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,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,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,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
|
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.
|