bulkrax 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +205 -0
- data/README.md +202 -0
- data/Rakefile +42 -0
- data/app/assets/config/bulkrax_manifest.js +2 -0
- data/app/assets/javascripts/bulkrax/application.js +14 -0
- data/app/assets/javascripts/bulkrax/bulkrax.js +11 -0
- data/app/assets/javascripts/bulkrax/entries.js +15 -0
- data/app/assets/javascripts/bulkrax/exporters.js +60 -0
- data/app/assets/javascripts/bulkrax/importers.js.erb +166 -0
- data/app/assets/stylesheets/bulkrax/accordion.scss +40 -0
- data/app/assets/stylesheets/bulkrax/application.css +15 -0
- data/app/assets/stylesheets/bulkrax/coderay.scss +264 -0
- data/app/assets/stylesheets/bulkrax/import_export.scss +37 -0
- data/app/controllers/bulkrax/application_controller.rb +8 -0
- data/app/controllers/bulkrax/entries_controller.rb +44 -0
- data/app/controllers/bulkrax/exporters_controller.rb +125 -0
- data/app/controllers/bulkrax/importers_controller.rb +315 -0
- data/app/controllers/concerns/bulkrax/api.rb +29 -0
- data/app/factories/bulkrax/object_factory.rb +230 -0
- data/app/helpers/bulkrax/application_helper.rb +15 -0
- data/app/helpers/bulkrax/exporters_helper.rb +6 -0
- data/app/helpers/bulkrax/importers_helper.rb +13 -0
- data/app/helpers/bulkrax/validation_helper.rb +153 -0
- data/app/jobs/bulkrax/application_job.rb +6 -0
- data/app/jobs/bulkrax/child_relationships_job.rb +128 -0
- data/app/jobs/bulkrax/delete_work_job.rb +16 -0
- data/app/jobs/bulkrax/download_cloud_file_job.rb +18 -0
- data/app/jobs/bulkrax/export_work_job.rb +37 -0
- data/app/jobs/bulkrax/exporter_job.rb +14 -0
- data/app/jobs/bulkrax/import_work_collection_job.rb +41 -0
- data/app/jobs/bulkrax/import_work_job.rb +32 -0
- data/app/jobs/bulkrax/importer_job.rb +26 -0
- data/app/mailers/bulkrax/application_mailer.rb +8 -0
- data/app/matchers/bulkrax/application_matcher.rb +113 -0
- data/app/matchers/bulkrax/bagit_matcher.rb +6 -0
- data/app/matchers/bulkrax/csv_matcher.rb +6 -0
- data/app/matchers/bulkrax/oai_matcher.rb +6 -0
- data/app/models/bulkrax/application_record.rb +7 -0
- data/app/models/bulkrax/csv_collection_entry.rb +19 -0
- data/app/models/bulkrax/csv_entry.rb +163 -0
- data/app/models/bulkrax/entry.rb +104 -0
- data/app/models/bulkrax/exporter.rb +122 -0
- data/app/models/bulkrax/exporter_run.rb +7 -0
- data/app/models/bulkrax/import_failed.rb +13 -0
- data/app/models/bulkrax/importer.rb +155 -0
- data/app/models/bulkrax/importer_run.rb +8 -0
- data/app/models/bulkrax/oai_dc_entry.rb +6 -0
- data/app/models/bulkrax/oai_entry.rb +74 -0
- data/app/models/bulkrax/oai_qualified_dc_entry.rb +6 -0
- data/app/models/bulkrax/oai_set_entry.rb +19 -0
- data/app/models/bulkrax/rdf_collection_entry.rb +19 -0
- data/app/models/bulkrax/rdf_entry.rb +90 -0
- data/app/models/bulkrax/status.rb +25 -0
- data/app/models/bulkrax/xml_entry.rb +73 -0
- data/app/models/concerns/bulkrax/download_behavior.rb +61 -0
- data/app/models/concerns/bulkrax/errored_entries.rb +45 -0
- data/app/models/concerns/bulkrax/export_behavior.rb +58 -0
- data/app/models/concerns/bulkrax/file_factory.rb +140 -0
- data/app/models/concerns/bulkrax/has_local_processing.rb +7 -0
- data/app/models/concerns/bulkrax/has_matchers.rb +155 -0
- data/app/models/concerns/bulkrax/import_behavior.rb +90 -0
- data/app/models/concerns/bulkrax/importer_exporter_behavior.rb +34 -0
- data/app/models/concerns/bulkrax/status_info.rb +56 -0
- data/app/parsers/bulkrax/application_parser.rb +299 -0
- data/app/parsers/bulkrax/bagit_parser.rb +157 -0
- data/app/parsers/bulkrax/csv_parser.rb +266 -0
- data/app/parsers/bulkrax/oai_dc_parser.rb +130 -0
- data/app/parsers/bulkrax/oai_qualified_dc_parser.rb +9 -0
- data/app/parsers/bulkrax/xml_parser.rb +103 -0
- data/app/views/bulkrax/entries/_parsed_metadata.html.erb +19 -0
- data/app/views/bulkrax/entries/_raw_metadata.html.erb +19 -0
- data/app/views/bulkrax/entries/show.html.erb +63 -0
- data/app/views/bulkrax/exporters/_form.html.erb +120 -0
- data/app/views/bulkrax/exporters/edit.html.erb +23 -0
- data/app/views/bulkrax/exporters/index.html.erb +67 -0
- data/app/views/bulkrax/exporters/new.html.erb +23 -0
- data/app/views/bulkrax/exporters/show.html.erb +124 -0
- data/app/views/bulkrax/importers/_bagit_fields.html.erb +54 -0
- data/app/views/bulkrax/importers/_browse_everything.html.erb +12 -0
- data/app/views/bulkrax/importers/_csv_fields.html.erb +39 -0
- data/app/views/bulkrax/importers/_edit_form_buttons.html.erb +16 -0
- data/app/views/bulkrax/importers/_form.html.erb +35 -0
- data/app/views/bulkrax/importers/_oai_fields.html.erb +42 -0
- data/app/views/bulkrax/importers/_xml_fields.html.erb +60 -0
- data/app/views/bulkrax/importers/edit.html.erb +20 -0
- data/app/views/bulkrax/importers/index.html.erb +77 -0
- data/app/views/bulkrax/importers/new.html.erb +25 -0
- data/app/views/bulkrax/importers/show.html.erb +175 -0
- data/app/views/bulkrax/importers/upload_corrected_entries.html.erb +37 -0
- data/app/views/bulkrax/shared/_bulkrax_errors.html.erb +52 -0
- data/app/views/bulkrax/shared/_bulkrax_field_mapping.html.erb +39 -0
- data/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb +6 -0
- data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +19 -0
- data/app/views/layouts/bulkrax/application.html.erb +14 -0
- data/config/locales/bulkrax.en.yml +36 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20181011230201_create_bulkrax_importers.rb +18 -0
- data/db/migrate/20181011230228_create_bulkrax_importer_runs.rb +16 -0
- data/db/migrate/20190325183136_create_bulkrax_entries.rb +16 -0
- data/db/migrate/20190601221109_add_status_to_entry.rb +9 -0
- data/db/migrate/20190715161939_add_collections_to_importer_runs.rb +6 -0
- data/db/migrate/20190715162044_change_collection_ids_on_entries.rb +5 -0
- data/db/migrate/20190729124607_create_bulkrax_exporters.rb +19 -0
- data/db/migrate/20190729134158_create_bulkrax_exporter_runs.rb +14 -0
- data/db/migrate/20190731114016_change_importer_and_exporter_to_polymorphic.rb +12 -0
- data/db/migrate/20191203225129_add_total_collection_records_to_importer_runs.rb +5 -0
- data/db/migrate/20191204191623_add_children_to_importer_runs.rb +6 -0
- data/db/migrate/20191204223857_change_total_records_to_total_work_entries.rb +6 -0
- data/db/migrate/20191212155530_change_entry_last_error.rb +19 -0
- data/db/migrate/20200108194557_add_validate_only_to_bulkrax_importers.rb +5 -0
- data/db/migrate/20200301232856_add_status_to_importers.rb +9 -0
- data/db/migrate/20200312190638_remove_foreign_key_from_bulkrax_entries.rb +5 -0
- data/db/migrate/20200326235838_add_status_to_exporters.rb +7 -0
- data/db/migrate/20200601204556_add_invalid_record_to_importer_run.rb +5 -0
- data/db/migrate/20200818055819_create_bulkrax_statuses.rb +18 -0
- data/db/migrate/20200819054016_move_to_statuses.rb +30 -0
- data/db/migrate/20201106014204_add_date_filter_and_status_to_bulkrax_exporters.rb +7 -0
- data/db/migrate/20201117220007_add_workflow_status_to_bulkrax_exporter.rb +5 -0
- data/db/migrate/20210806044408_remove_unused_last_error.rb +7 -0
- data/db/migrate/20210806065737_increase_text_sizes.rb +12 -0
- data/lib/bulkrax.rb +161 -0
- data/lib/bulkrax/engine.rb +37 -0
- data/lib/bulkrax/version.rb +5 -0
- data/lib/generators/bulkrax/install_generator.rb +80 -0
- data/lib/generators/bulkrax/templates/README +3 -0
- data/lib/generators/bulkrax/templates/app/assets/images/bulkrax/removed.png +0 -0
- data/lib/generators/bulkrax/templates/app/models/concerns/bulkrax/has_local_processing.rb +8 -0
- data/lib/generators/bulkrax/templates/bin/importer +140 -0
- data/lib/generators/bulkrax/templates/config/bulkrax_api.yml +84 -0
- data/lib/generators/bulkrax/templates/config/initializers/bulkrax.rb +72 -0
- data/lib/tasks/bulkrax_tasks.rake +6 -0
- metadata +388 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateBulkraxImporterRuns < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
unless table_exists?(:bulkrax_importer_runs)
|
4
|
+
create_table :bulkrax_importer_runs do |t|
|
5
|
+
t.references :importer, foreign_key: {to_table: :bulkrax_importers}
|
6
|
+
t.integer :total_records, default: 0
|
7
|
+
t.integer :enqueued_records, default: 0
|
8
|
+
t.integer :processed_records, default: 0
|
9
|
+
t.integer :deleted_records, default: 0
|
10
|
+
t.integer :failed_records, default: 0
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateBulkraxEntries < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
unless table_exists?(:bulkrax_entries)
|
4
|
+
create_table :bulkrax_entries do |t|
|
5
|
+
t.string :identifier
|
6
|
+
t.string :collection_id
|
7
|
+
t.string :type
|
8
|
+
t.references :importer, foreign_key: {to_table: :bulkrax_importers}
|
9
|
+
t.text :raw_metadata
|
10
|
+
t.text :parsed_metadata
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddStatusToEntry < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :bulkrax_entries, :last_error, :text unless column_exists?(:bulkrax_entries, :last_error)
|
4
|
+
add_column :bulkrax_entries, :last_error_at, :datetime unless column_exists?(:bulkrax_entries, :last_error_at)
|
5
|
+
|
6
|
+
add_column :bulkrax_entries, :last_succeeded_at, :datetime unless column_exists?(:bulkrax_entries, :last_succeeded_at)
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class AddCollectionsToImporterRuns < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :bulkrax_importer_runs, :processed_collections, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :processed_collections)
|
4
|
+
add_column :bulkrax_importer_runs, :failed_collections, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :failed_collections)
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateBulkraxExporters < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
unless table_exists?(:bulkrax_exporters)
|
4
|
+
create_table :bulkrax_exporters do |t|
|
5
|
+
t.string :name
|
6
|
+
t.references :user, foreign_key: false
|
7
|
+
t.string :parser_klass
|
8
|
+
t.integer :limit
|
9
|
+
t.text :parser_fields
|
10
|
+
t.text :field_mapping
|
11
|
+
t.string :export_source
|
12
|
+
t.string :export_from
|
13
|
+
t.string :export_type
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateBulkraxExporterRuns < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
unless table_exists?(:bulkrax_exporter_runs)
|
4
|
+
create_table :bulkrax_exporter_runs do |t|
|
5
|
+
t.references :exporter, foreign_key: { to_table: :bulkrax_exporters }
|
6
|
+
t.integer :total_records, default: 0
|
7
|
+
t.integer :enqueued_records, default: 0
|
8
|
+
t.integer :processed_records, default: 0
|
9
|
+
t.integer :deleted_records, default: 0
|
10
|
+
t.integer :failed_records, default: 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Bulkrax
|
2
|
+
class Entry < ApplicationRecord
|
3
|
+
belongs_to :importer
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class ChangeImporterAndExporterToPolymorphic < ActiveRecord::Migration[5.1]
|
8
|
+
def change
|
9
|
+
rename_column :bulkrax_entries, :importer_id, :importerexporter_id if column_exists?(:bulkrax_entries, :importer_id)
|
10
|
+
add_column :bulkrax_entries, :importerexporter_type, :string, after: :id, default: 'Bulkrax::Importer' unless column_exists?(:bulkrax_entries, :importerexporter_type)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class AddChildrenToImporterRuns < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :bulkrax_importer_runs, :processed_children, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :processed_children)
|
4
|
+
add_column :bulkrax_importer_runs, :failed_children, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :failed_children)
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class ChangeTotalRecordsToTotalWorkEntries < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
rename_column :bulkrax_importer_runs, :total_records, :total_work_entries if column_exists?(:bulkrax_importer_runs, :total_records)
|
4
|
+
rename_column :bulkrax_exporter_runs, :total_records, :total_work_entries if column_exists?(:bulkrax_exporter_runs, :total_records)
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ChangeEntryLastError < ActiveRecord::Migration[5.1]
|
2
|
+
|
3
|
+
def up
|
4
|
+
# Use raw query to change text to JSON as last_error field is now serialized
|
5
|
+
results = ActiveRecord::Base.connection.execute("SELECT id, last_error from bulkrax_entries WHERE last_error IS NOT null AND last_error LIKE '%\n\n%'")
|
6
|
+
results.each do | error |
|
7
|
+
old_errors = error['last_error'].gsub("'","''").split("\n\n")
|
8
|
+
new_error = {
|
9
|
+
'error_class' => 'unknown',
|
10
|
+
'error_message' => old_errors.first,
|
11
|
+
'error_trace' => old_errors.last
|
12
|
+
}
|
13
|
+
ActiveRecord::Base.connection.execute("UPDATE bulkrax_entries SET last_error = '#{new_error.to_json}' WHERE id = '#{error['id']}'")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def down; end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddStatusToImporters < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
if table_exists?(:bulkrax_importers)
|
4
|
+
add_column :bulkrax_importers, :last_error, :text unless column_exists?(:bulkrax_importers, :last_error)
|
5
|
+
add_column :bulkrax_importers, :last_error_at, :datetime unless column_exists?(:bulkrax_importers, :last_error_at)
|
6
|
+
add_column :bulkrax_importers, :last_succeeded_at, :datetime unless column_exists?(:bulkrax_importers, :last_succeeded_at)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class AddStatusToExporters < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :bulkrax_exporters, :last_error, :text unless column_exists?(:bulkrax_exporters, :last_error)
|
4
|
+
add_column :bulkrax_exporters, :last_error_at, :datetime unless column_exists?(:bulkrax_exporters, :last_error_at)
|
5
|
+
add_column :bulkrax_exporters, :last_succeeded_at, :datetime unless column_exists?(:bulkrax_exporters, :last_succeeded_at)
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateBulkraxStatuses < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
unless table_exists?(:bulkrax_statuses)
|
4
|
+
create_table :bulkrax_statuses do |t|
|
5
|
+
t.string :status_message
|
6
|
+
t.string :error_class
|
7
|
+
t.string :error_message
|
8
|
+
t.text :error_backtrace
|
9
|
+
t.integer :statusable_id
|
10
|
+
t.string :statusable_type
|
11
|
+
t.integer :runnable_id
|
12
|
+
t.string :runnable_type
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class MoveToStatuses < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
Bulkrax::Importer.find_each do |i|
|
4
|
+
add_status(i)
|
5
|
+
end
|
6
|
+
|
7
|
+
Bulkrax::Exporter.find_each do |i|
|
8
|
+
add_status(i)
|
9
|
+
end
|
10
|
+
|
11
|
+
Bulkrax::Entry.find_each do |i|
|
12
|
+
add_status(i)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_status(i)
|
17
|
+
return if i.statuses.present?
|
18
|
+
if i.last_error
|
19
|
+
i.statuses.create(
|
20
|
+
status_message: 'Failed',
|
21
|
+
runnable: i.last_run,
|
22
|
+
error_class: i.last_error['error_class'],
|
23
|
+
error_message: i.last_error['error_message'],
|
24
|
+
error_backtrace: i.last_error['error_trace']
|
25
|
+
)
|
26
|
+
else
|
27
|
+
i.statuses.create(status_message: 'Complete', runnable: i.last_run)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class AddDateFilterAndStatusToBulkraxExporters < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :bulkrax_exporters, :start_date, :date unless column_exists?(:bulkrax_exporters, :start_date)
|
4
|
+
add_column :bulkrax_exporters, :finish_date, :date unless column_exists?(:bulkrax_exporters, :finish_date)
|
5
|
+
add_column :bulkrax_exporters, :work_visibility, :string unless column_exists?(:bulkrax_exporters, :work_visibility)
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class IncreaseTextSizes < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
change_column :bulkrax_entries, :raw_metadata, :text, limit: 16777215
|
4
|
+
change_column :bulkrax_entries, :parsed_metadata, :text, limit: 16777215
|
5
|
+
change_column :bulkrax_exporters, :parser_fields, :text, limit: 16777215
|
6
|
+
change_column :bulkrax_exporters, :field_mapping, :text, limit: 16777215
|
7
|
+
change_column :bulkrax_importers, :parser_fields, :text, limit: 16777215
|
8
|
+
change_column :bulkrax_importers, :field_mapping, :text, limit: 16777215
|
9
|
+
change_column :bulkrax_importer_runs, :invalid_records, :text, limit: 16777215
|
10
|
+
change_column :bulkrax_statuses, :error_backtrace, :text, limit: 16777215
|
11
|
+
end
|
12
|
+
end
|
data/lib/bulkrax.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bulkrax/engine"
|
4
|
+
require 'active_support/all'
|
5
|
+
|
6
|
+
module Bulkrax
|
7
|
+
class << self
|
8
|
+
mattr_accessor :parsers,
|
9
|
+
:default_work_type,
|
10
|
+
:default_field_mapping,
|
11
|
+
:collection_field_mapping,
|
12
|
+
:fill_in_blank_source_identifiers,
|
13
|
+
:parent_child_field_mapping,
|
14
|
+
:reserved_properties,
|
15
|
+
:field_mappings,
|
16
|
+
:import_path,
|
17
|
+
:export_path,
|
18
|
+
:removed_image_path,
|
19
|
+
:server_name,
|
20
|
+
:api_definition,
|
21
|
+
:removed_image_path
|
22
|
+
|
23
|
+
self.parsers = [
|
24
|
+
{ name: "OAI - Dublin Core", class_name: "Bulkrax::OaiDcParser", partial: "oai_fields" },
|
25
|
+
{ name: "OAI - Qualified Dublin Core", class_name: "Bulkrax::OaiQualifiedDcParser", partial: "oai_fields" },
|
26
|
+
{ name: "CSV - Comma Separated Values", class_name: "Bulkrax::CsvParser", partial: "csv_fields" },
|
27
|
+
{ name: "Bagit", class_name: "Bulkrax::BagitParser", partial: "bagit_fields" },
|
28
|
+
{ name: "XML", class_name: "Bulkrax::XmlParser", partial: "xml_fields" }
|
29
|
+
]
|
30
|
+
|
31
|
+
self.import_path = 'tmp/imports'
|
32
|
+
self.export_path = 'tmp/exports'
|
33
|
+
self.removed_image_path = Bulkrax::Engine.root.join('spec', 'fixtures', 'removed.png').to_s
|
34
|
+
self.server_name = 'bulkrax@example.com'
|
35
|
+
|
36
|
+
# @todo, merge parent_child_field_mapping and collection_field_mapping into field_mappings,
|
37
|
+
# or make them settable per import some other way.
|
38
|
+
|
39
|
+
# Field_mapping for establishing a parent-child relationship (FROM parent TO child)
|
40
|
+
# This can be a Collection to Work, or Work to Work relationship
|
41
|
+
# This value IS NOT used for OAI, so setting the OAI Entries here will have no effect
|
42
|
+
# The mapping is supplied per Entry, provide the full class name as a string, eg. 'Bulkrax::CsvEntry'
|
43
|
+
# Example:
|
44
|
+
# {
|
45
|
+
# 'Bulkrax::RdfEntry' => 'http://opaquenamespace.org/ns/contents',
|
46
|
+
# 'Bulkrax::CsvEntry' => 'children'
|
47
|
+
# }
|
48
|
+
# By default no parent-child relationships are added
|
49
|
+
self.parent_child_field_mapping = {}
|
50
|
+
|
51
|
+
# Field_mapping for establishing a collection relationship (FROM work TO collection)
|
52
|
+
# This value IS NOT used for OAI, so setting the OAI Entries here will have no effect
|
53
|
+
# The mapping is supplied per Entry, provide the full class name as a string, eg. 'Bulkrax::CsvEntry'
|
54
|
+
# The default value for CSV is collection
|
55
|
+
self.collection_field_mapping = {}
|
56
|
+
|
57
|
+
# Hash of Generic field_mappings for use in the view
|
58
|
+
# There must be one field_mappings hash per view parial
|
59
|
+
# Based on Hyrax CoreMetadata && BasicMetadata
|
60
|
+
# Override at application level to change
|
61
|
+
self.field_mappings = {
|
62
|
+
"Bulkrax::OaiDcParser" => {
|
63
|
+
"contributor" => { from: ["contributor"] },
|
64
|
+
# no appropriate mapping for coverage (based_near needs id)
|
65
|
+
# ""=>{:from=>["coverage"]},
|
66
|
+
"creator" => { from: ["creator"] },
|
67
|
+
"date_created" => { from: ["date"] },
|
68
|
+
"description" => { from: ["description"] },
|
69
|
+
# no appropriate mapping for format
|
70
|
+
# ""=>{:from=>["format"]},
|
71
|
+
"identifier" => { from: ["identifier"] },
|
72
|
+
"language" => { from: ["language"], parsed: true },
|
73
|
+
"publisher" => { from: ["publisher"] },
|
74
|
+
"related_url" => { from: ["relation"] },
|
75
|
+
"rights_statement" => { from: ["rights"] },
|
76
|
+
"source" => { from: ["source"] },
|
77
|
+
"subject" => { from: ["subject"], parsed: true },
|
78
|
+
"title" => { from: ["title"] },
|
79
|
+
"resource_type" => { from: ["type"], parsed: true },
|
80
|
+
"remote_files" => { from: ["thumbnail_url"], parsed: true }
|
81
|
+
},
|
82
|
+
"Bulkrax::OaiQualifiedDcParser" => {
|
83
|
+
"abstract" => { from: ["abstract"] },
|
84
|
+
"alternative_title" => { from: ["alternative"] },
|
85
|
+
"bibliographic_citation" => { from: ["bibliographicCitation"] },
|
86
|
+
"contributor" => { from: ["contributor"] },
|
87
|
+
"creator" => { from: ["creator"] },
|
88
|
+
"date_created" => { from: ["created"] },
|
89
|
+
"description" => { from: ["description"] },
|
90
|
+
"language" => { from: ["language"] },
|
91
|
+
"license" => { from: ["license"] },
|
92
|
+
"publisher" => { from: ["publisher"] },
|
93
|
+
"related_url" => { from: ["relation"] },
|
94
|
+
"rights_holder" => { from: ["rightsHolder"] },
|
95
|
+
"rights_statement" => { from: ["rights"] },
|
96
|
+
"source" => { from: ["source"] },
|
97
|
+
"subject" => { from: ["subject"], parsed: true },
|
98
|
+
"title" => { from: ["title"] },
|
99
|
+
"resource_type" => { from: ["type"], parsed: true },
|
100
|
+
"remote_files" => { from: ["thumbnail_url"], parsed: true }
|
101
|
+
},
|
102
|
+
# When empty, a default_field_mapping will be generated
|
103
|
+
"Bulkrax::CsvParser" => {},
|
104
|
+
'Bulkrax::BagitParser' => {},
|
105
|
+
'Bulkrax::XmlParser' => {}
|
106
|
+
}
|
107
|
+
|
108
|
+
# Lambda to set the default field mapping
|
109
|
+
self.default_field_mapping = lambda do |field|
|
110
|
+
return if field.blank?
|
111
|
+
{
|
112
|
+
field.to_s =>
|
113
|
+
{
|
114
|
+
from: [field.to_s],
|
115
|
+
split: false,
|
116
|
+
parsed: Bulkrax::ApplicationMatcher.method_defined?("parse_#{field}"),
|
117
|
+
if: nil,
|
118
|
+
excluded: false
|
119
|
+
}
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
# Properties that should not be used in imports. They are reserved for use by Hyrax.
|
124
|
+
self.reserved_properties = %w[
|
125
|
+
create_date
|
126
|
+
modified_date
|
127
|
+
date_modified
|
128
|
+
date_uploaded
|
129
|
+
depositor
|
130
|
+
arkivo_checksum
|
131
|
+
has_model
|
132
|
+
head
|
133
|
+
label
|
134
|
+
import_url
|
135
|
+
on_behalf_of
|
136
|
+
proxy_depositor
|
137
|
+
owner
|
138
|
+
state
|
139
|
+
tail
|
140
|
+
original_url
|
141
|
+
relative_path
|
142
|
+
]
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.api_definition
|
146
|
+
@api_definition ||= ActiveSupport::HashWithIndifferentAccess.new(
|
147
|
+
YAML.safe_load(
|
148
|
+
ERB.new(
|
149
|
+
File.read(Rails.root.join('config', 'bulkrax_api.yml'))
|
150
|
+
).result
|
151
|
+
)
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
155
|
+
self.removed_image_path = 'app/assets/images/bulkrax/removed.png'
|
156
|
+
|
157
|
+
# this function maps the vars from your app into your engine
|
158
|
+
def self.setup
|
159
|
+
yield self
|
160
|
+
end
|
161
|
+
end
|