cdm_migrator 3.2.1 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/README.md +41 -41
  4. data/Rakefile +38 -38
  5. data/app/assets/config/cdm_migrator_manifest.js +2 -2
  6. data/app/assets/javascripts/cdm_migrator/application.js +13 -13
  7. data/app/assets/stylesheets/cdm_migrator/application.css +15 -15
  8. data/app/assets/stylesheets/cdm_migrator/csv_checker.css +36 -36
  9. data/app/controllers/cdm_migrator/application_controller.rb +10 -10
  10. data/app/controllers/cdm_migrator/cdm_controller.rb +216 -213
  11. data/app/controllers/cdm_migrator/csv_controller.rb +428 -408
  12. data/app/helpers/cdm_migrator/application_helper.rb +4 -4
  13. data/app/jobs/cdm_migrator/application_job.rb +4 -4
  14. data/app/jobs/cdm_migrator/batch_create_files_job.rb +32 -20
  15. data/app/jobs/cdm_migrator/batch_create_files_with_ordered_members_job.rb +45 -0
  16. data/app/jobs/cdm_migrator/batch_create_works_job.rb +20 -14
  17. data/app/jobs/cdm_migrator/cdm_ingest_files_job.rb +35 -35
  18. data/app/jobs/cdm_migrator/create_work_job.rb +36 -25
  19. data/app/jobs/cdm_migrator/restart_upload_from_middle_job.rb +36 -0
  20. data/app/jobs/cdm_migrator/update_object_job.rb +10 -10
  21. data/app/mailers/cdm_migrator/application_mailer.rb +6 -6
  22. data/app/models/cdm_migrator/application_record.rb +5 -5
  23. data/app/models/cdm_migrator/batch_ingest.rb +33 -33
  24. data/app/models/cdm_migrator/ingest_work.rb +7 -16
  25. data/app/views/cdm_migrator/cdm/collection.html.erb +11 -11
  26. data/app/views/cdm_migrator/cdm/mappings.html.erb +54 -53
  27. data/app/views/cdm_migrator/csv/_batches_list.html.erb +4 -4
  28. data/app/views/cdm_migrator/csv/_default_group.html.erb +17 -17
  29. data/app/views/cdm_migrator/csv/_error_list.html.erb +20 -20
  30. data/app/views/cdm_migrator/csv/_list_batches.html.erb +21 -21
  31. data/app/views/cdm_migrator/csv/_tabs.html.erb +8 -8
  32. data/app/views/cdm_migrator/csv/csv_checker.html.erb +45 -45
  33. data/app/views/cdm_migrator/csv/edit.html.erb +17 -18
  34. data/app/views/cdm_migrator/csv/index.html.erb +19 -19
  35. data/app/views/cdm_migrator/csv/upload.html.erb +18 -18
  36. data/app/views/layouts/cdm_migrator/application.html.erb +14 -14
  37. data/config/routes.rb +19 -19
  38. data/db/migrate/20191211193859_create_batch_ingests.rb +19 -19
  39. data/db/migrate/20191212192315_create_ingest_works.rb +18 -18
  40. data/lib/cdm_migrator/engine.rb +29 -29
  41. data/lib/cdm_migrator/version.rb +3 -3
  42. data/lib/cdm_migrator.rb +5 -5
  43. data/lib/generators/cdm_migrator/install/install_generator.rb +79 -79
  44. data/lib/generators/cdm_migrator/install/templates/config/cdm_migrator.yml +53 -50
  45. data/lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb +47 -47
  46. data/lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb +66 -66
  47. data/lib/generators/cdm_migrator/install/templates/sidebar/_tasks.html.erb +55 -55
  48. data/lib/tasks/cdm_migrator_tasks.rake +4 -4
  49. metadata +7 -5
@@ -1,4 +1,4 @@
1
- module CdmMigrator
2
- module ApplicationHelper
3
- end
4
- end
1
+ module CdmMigrator
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -1,4 +1,4 @@
1
- module CdmMigrator
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end
1
+ module CdmMigrator
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -1,21 +1,33 @@
1
- module CdmMigrator
2
- class BatchCreateFilesJob < ActiveJob::Base
3
- queue_as Hyrax.config.ingest_queue_name
4
-
5
- def perform work, ingest_work, user
6
- ingest_work.files.each do |file|
7
- url = file[:url]
8
- last_file = ingest_work.files.last==file
9
- ::FileSet.new(import_url: url, label: file[:title]) do |fs|
10
- fs.save
11
- actor = Hyrax::Actors::FileSetActor.new(fs, user)
12
- actor.create_metadata#(work, visibility: work.visibility)
13
- actor.attach_file_to_work(work)
14
- fs.attributes = file[:metadata]
15
- fs.save!
16
- CdmIngestFilesJob.perform_later(fs, url, user, ingest_work, last_file)
17
- end
18
- end
19
- end
20
- end
1
+ module CdmMigrator
2
+ class BatchCreateFilesJob < ActiveJob::Base
3
+ queue_as Hyrax.config.ingest_queue_name
4
+
5
+ def perform work, ingest_work, user
6
+ unless work.ordered_members.to_a.empty?
7
+ # This only executes if the job failed before adding any file sets and is now retrying
8
+ ordered_members = work.ordered_members.to_a
9
+ # If the last file set's file was never ingested, do that now
10
+ last_file_set = ordered_members.last
11
+ if last_file_set.present? and last_file_set.files.none?
12
+ CdmMigrator::CdmIngestFilesJob.perform_later(last_file_set, last_file_set.import_url, user)
13
+ end
14
+ files = ingest_work.files[ordered_members.length..-1]
15
+ else
16
+ files = ingest_work.files
17
+ end
18
+ files.each do |file|
19
+ url = file[:url]
20
+ last_file = ingest_work.files.last==file
21
+ ::FileSet.new(import_url: url, label: file[:title]) do |fs|
22
+ fs.save
23
+ actor = Hyrax::Actors::FileSetActor.new(fs, user)
24
+ actor.create_metadata
25
+ actor.attach_file_to_work(work)
26
+ fs.attributes = file[:metadata]
27
+ fs.save!
28
+ CdmIngestFilesJob.perform_later(fs, url, user, ingest_work, last_file)
29
+ end
30
+ end
31
+ end
32
+ end
21
33
  end
@@ -0,0 +1,45 @@
1
+ module CdmMigrator
2
+ class BatchCreateFilesWithOrderedMembersJob < ActiveJob::Base
3
+ queue_as Hyrax.config.ingest_queue_name
4
+
5
+ # From documentation at https://tinyurl.com/nh4c5e9j:
6
+ # When adding member {FileSetBehavior}s to a {WorkBehavior}, {Hyrax} saves
7
+ # and reloads the work for each new member FileSet. This can significantly
8
+ # slow down ingest for Works with many member FileSets. The saving and
9
+ # reloading happens in {FileSetActor#attach_to_work}.
10
+ # See the url for more details.
11
+
12
+ # With this job, the member association is saved once
13
+ # at the very end instead, which can speed up the upload process. This job takes
14
+ # advantage of the same strategy as Hyrax::Actors::FileSetOrderedMembersActor
15
+ # but you don't need the OrderedMembersActor constant initialized.
16
+
17
+ # This rescue is a safeguard against creating lots of orphan file sets if there
18
+ # are recurring errors (see https://tinyurl.com/nh4c5e9j). Instead, CdmMigrator
19
+ # will fall back to creating file sets one-by-one if this job fails once.
20
+ rescue_from(StandardError) do |exception|
21
+ Rails.logger.error "BatchCreateFilesWithOrderedMembersJob error: #{exception.to_s}"
22
+ RestartUploadFromMiddleJob.perform_later(arguments[0], arguments[1], arguments[2])
23
+ end
24
+
25
+ def perform work, ingest_work, user
26
+ ordered_members = []
27
+ ingest_work.files.each do |file|
28
+ url = file[:url]
29
+ last_file = ingest_work.files.last==file
30
+ ::FileSet.new(import_url: url, label: file[:title]) do |fs|
31
+ fs.attributes = file[:metadata]
32
+ fs.save!
33
+ ordered_members << fs
34
+ end
35
+ end
36
+ actor = Hyrax::Actors::OrderedMembersActor.new(ordered_members, user)
37
+ actor.attach_ordered_members_to_work(work)
38
+ work.representative = work.ordered_members.to_a.first
39
+ work.thumbnail_id = work.ordered_member_ids.first
40
+ work.save!
41
+ work.file_sets.each { |fs| CdmIngestFilesJob.perform_later(fs, fs.import_url, user, ingest_work) }
42
+ end
43
+
44
+ end
45
+ end
@@ -1,14 +1,20 @@
1
- module CdmMigrator
2
- class BatchCreateWorksJob < ActiveJob::Base
3
- queue_as Hyrax.config.ingest_queue_name
4
-
5
- def perform(ingest, user)
6
- ingest.data.each do |w|
7
- ingest_work = IngestWork.new(w, ingest.id)
8
- ingest_work.save!
9
- CreateWorkJob.perform_later ingest_work, user, ingest.admin_set_id, ingest.collection_id
10
- end
11
-
12
- end
13
- end
14
- end
1
+ module CdmMigrator
2
+ class BatchCreateWorksJob < ActiveJob::Base
3
+ queue_as Hyrax.config.ingest_queue_name
4
+
5
+ def perform(ingest, user)
6
+ ingest.data.each do |w|
7
+ ingest_work = IngestWork.new({
8
+ work_type: w[:type],
9
+ data: w[:metadata],
10
+ files: w[:files],
11
+ batch_ingest_id: ingest.id
12
+ })
13
+ ingest_work.save!
14
+ # puts ingest_work.inspect
15
+ CreateWorkJob.perform_later ingest_work, user, ingest.admin_set_id, ingest.collection_id
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -1,35 +1,35 @@
1
- module CdmMigrator
2
- class CdmIngestFilesJob < ActiveJob::Base
3
- queue_as Hyrax.config.ingest_queue_name
4
-
5
- def perform(fs, url, user, ingest_work = nil, last_file = false)
6
- if url.include?("http") && File.extname(url).include?("pdf")
7
- download = open(url)
8
- dir = Rails.root.join('public', 'uploads', 'csv_pdfs')
9
- FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
10
- filename = download.base_uri.to_s.split('/').last
11
- url = dir.join(filename)
12
- if fs.title.empty?
13
- fs.title << filename.split('.').first
14
- fs.save
15
- end
16
- IO.copy_stream(download, url)
17
- url = "file://"+url.to_s
18
- end
19
- uri = URI.parse(url.gsub(' ','%20').gsub(/[\[\]@#\$\*{}]/, ""))
20
- if uri.scheme == 'file'
21
- IngestLocalFileJob.perform_now(fs, url.gsub('file://',''), user)
22
- else
23
- URI.parse(url.gsub(' ','%20'))
24
- ImportUrlJob.perform_now(fs, log(user))
25
- end
26
- ingest_work.update_attribute('complete', true) if last_file
27
- end
28
-
29
- def log(user)
30
- Hyrax::Operation.create!(user: user,
31
- operation_type: "Attach Remote File")
32
- end
33
-
34
- end
35
- end
1
+ module CdmMigrator
2
+ class CdmIngestFilesJob < ActiveJob::Base
3
+ queue_as Hyrax.config.ingest_queue_name
4
+
5
+ def perform(fs, url, user, ingest_work = nil, last_file = false)
6
+ if url.include?("http") && File.extname(url).include?("pdf")
7
+ download = open(url)
8
+ dir = Rails.root.join('public', 'uploads', 'csv_pdfs')
9
+ FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
10
+ filename = download.base_uri.to_s.split('/').last
11
+ url = dir.join(filename)
12
+ if fs.title.empty?
13
+ fs.title << filename.split('.').first
14
+ fs.save
15
+ end
16
+ IO.copy_stream(download, url)
17
+ url = "file://"+url.to_s
18
+ end
19
+ uri = URI.parse(url.gsub(' ','%20').gsub(/[\[\]@#\$\*{}]/, ""))
20
+ if uri.scheme == 'file'
21
+ IngestLocalFileJob.perform_now(fs, url.gsub('file://',''), user)
22
+ else
23
+ URI.parse(url.gsub(' ','%20'))
24
+ ImportUrlJob.perform_now(fs, log(user))
25
+ end
26
+ ingest_work.update_attribute('complete', true) if last_file
27
+ end
28
+
29
+ def log(user)
30
+ Hyrax::Operation.create!(user: user,
31
+ operation_type: "Attach Remote File")
32
+ end
33
+
34
+ end
35
+ end
@@ -1,26 +1,37 @@
1
- module CdmMigrator
2
- class CreateWorkJob < ActiveJob::Base
3
- queue_as Hyrax.config.ingest_queue_name
4
-
5
- def perform(ingest_work, user, admin_set_id, collection_id)
6
- admin_set = ::AdminSet.find(admin_set_id) rescue nil
7
- collection = ::Collection.find(collection_id) rescue nil
8
- work = Object.const_get(ingest_work.work_type).new
9
- #status_after, embargo_date, lease_date = nil, nil, nil
10
- work.apply_depositor_metadata(user)
11
- work.attributes = ingest_work.data
12
- if ingest_work.data.has_key? 'downloadable'
13
- # Convert string to boolean
14
- work.downloadable = ActiveModel::Type::Boolean.new.cast(ingest_work.data['downloadable'])
15
- elsif work.attributes.include? 'downloadable' # Set work to downloadable by default
16
- work.downloadable = true
17
- end
18
- work.member_of_collections = [collection] if collection
19
- work.admin_set = admin_set if admin_set
20
- work.date_uploaded = DateTime.now
21
- work.save
22
- BatchCreateFilesJob.perform_later work, ingest_work, user
23
-
24
- end
25
- end
1
+ module CdmMigrator
2
+ class CreateWorkJob < ActiveJob::Base
3
+ queue_as Hyrax.config.ingest_queue_name
4
+
5
+ def perform(ingest_work, user, admin_set_id, collection_id)
6
+ admin_set = ::AdminSet.find(admin_set_id) rescue nil
7
+ collection = ::Collection.find(collection_id) rescue nil
8
+ work = Object.const_get(ingest_work.work_type).new
9
+ #status_after, embargo_date, lease_date = nil, nil, nil
10
+ work.apply_depositor_metadata(user)
11
+ work.attributes = ingest_work.data
12
+ if ingest_work.data.has_key? 'downloadable'
13
+ # Convert string to boolean
14
+ work.downloadable = ActiveModel::Type::Boolean.new.cast(ingest_work.data['downloadable'])
15
+ elsif work.attributes.include? 'downloadable' # Set work to downloadable by default
16
+ work.downloadable = true
17
+ end
18
+ work.member_of_collections = [collection] if collection
19
+ work.admin_set = admin_set if admin_set
20
+ work.date_uploaded = DateTime.now
21
+ begin
22
+ work.save!
23
+ # Weird error where descriptions with whitespace chars \n or \r don't save the 1st time
24
+ # but do on the second
25
+ rescue Ldp::BadRequest
26
+ old_descr = work.description.clone.to_a
27
+ work.description = work.description.map { |w| w.gsub("\n","").gsub("\r","") }
28
+ work.save!
29
+ work.description = old_descr
30
+ work.save!
31
+ end
32
+ # To use the BatchCreateFilesWithOrderedMembersJob instead, replace the following line
33
+ # with BatchCreateFilesWithOrderedMembersJob.perform_later(work, ingest_work, user)
34
+ BatchCreateFilesJob.perform_later(work, ingest_work, user)
35
+ end
36
+ end
26
37
  end
@@ -0,0 +1,36 @@
1
+ module CdmMigrator
2
+ class RestartUploadFromMiddleJob < ActiveJob::Base
3
+
4
+ # For restarting failed CdmMigrator::BatchCreateFilesJobs
5
+ # from the middle instead of from the beginning (default
6
+ # behaviour in Sidekiq). This prevents duplicating file
7
+ # sets within a work.
8
+ #
9
+ retry_on Net::OpenTimeout, attempts: 20
10
+ retry_on Errno::ECONNRESET, attempts: 20
11
+
12
+ def perform(work, ingest_work, user)
13
+ ordered_members = work.ordered_members.to_a
14
+ last_file_set = ordered_members.last
15
+ # If the last file set's file was never ingested, do that now
16
+ if last_file_set.present? and last_file_set.files.none?
17
+ CdmMigrator::CdmIngestFilesJob.perform_later(last_file_set, last_file_set.import_url, user)
18
+ end
19
+ files = ingest_work.files[ordered_members.length..-1]
20
+ files.each do |file|
21
+ url = file[:url]
22
+ last_file = ingest_work.files.last==file
23
+ ::FileSet.new(import_url: url, label: file[:title]) do |fs|
24
+ fs.save
25
+ actor = Hyrax::Actors::FileSetActor.new(fs, user)
26
+ actor.create_metadata
27
+ actor.attach_file_to_work(work)
28
+ fs.attributes = file[:metadata]
29
+ fs.save!
30
+ CdmMigrator::CdmIngestFilesJob.perform_later(fs, url, user, ingest_work, last_file)
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -1,10 +1,10 @@
1
- module CdmMigrator
2
- class UpdateObjectJob < ActiveJob::Base
3
-
4
-
5
- def perform(attributes)
6
- obj = ActiveFedora::Base.find
7
-
8
- end
9
- end
10
- end
1
+ module CdmMigrator
2
+ class UpdateObjectJob < ActiveJob::Base
3
+
4
+
5
+ def perform(attributes)
6
+ obj = ActiveFedora::Base.find
7
+
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,6 @@
1
- module CdmMigrator
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
5
- end
6
- end
1
+ module CdmMigrator
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
- module CdmMigrator
2
- class ApplicationRecord < ActiveRecord::Base
3
- self.abstract_class = true
4
- end
5
- end
1
+ module CdmMigrator
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -1,33 +1,33 @@
1
- module CdmMigrator
2
- class BatchIngest < ActiveRecord::Base
3
- serialize :data
4
-
5
- def name
6
- csv.split('/').last.gsub(/[0-9]{10}/,"")
7
- end
8
-
9
- def progress
10
- return "Complete" if complete?
11
- completed = IngestWork.where(batch_ingest_id: id, complete: true ).length
12
- if completed==data.length
13
- complete=true
14
- save
15
- "Complete"
16
- else
17
- "#{completed.to_s}/#{size}"
18
- end
19
- end
20
-
21
- def username
22
- @username ||= User.find(user_id).name
23
- end
24
-
25
- def complete?
26
- complete
27
- end
28
-
29
- def message?
30
- not(message.nil?||message.empty?)
31
- end
32
- end
33
- end
1
+ module CdmMigrator
2
+ class BatchIngest < ActiveRecord::Base
3
+ serialize :data
4
+
5
+ def name
6
+ csv.split('/').last.gsub(/[0-9]{10}/,"")
7
+ end
8
+
9
+ def progress
10
+ return "Complete" if complete?
11
+ completed = IngestWork.where(batch_ingest_id: id, complete: true ).length
12
+ if completed==data.length
13
+ complete=true
14
+ save
15
+ "Complete"
16
+ else
17
+ "#{completed.to_s}/#{size}"
18
+ end
19
+ end
20
+
21
+ def username
22
+ @username ||= User.find(user_id).name
23
+ end
24
+
25
+ def complete?
26
+ complete
27
+ end
28
+
29
+ def message?
30
+ not(message.nil?||message.empty?)
31
+ end
32
+ end
33
+ end
@@ -1,16 +1,7 @@
1
- module CdmMigrator
2
- class IngestWork < ActiveRecord::Base
3
-
4
- def initialize(work, ingest_id)
5
- super({
6
- work_type: work[:type],
7
- data: work[:metadata],
8
- files: work[:files],
9
- batch_ingest_id: ingest_id
10
- })
11
- end
12
-
13
- serialize :data
14
- serialize :files
15
- end
16
- end
1
+ module CdmMigrator
2
+ class IngestWork < ApplicationRecord
3
+
4
+ serialize :data
5
+ serialize :files
6
+ end
7
+ end
@@ -1,12 +1,12 @@
1
- <h1><span class="fa fa-map"></span> <%= default_page_title %></h1>
2
-
3
- <h5>ContentDM API address: <%= @cdm_url %></h5>
4
- <%= form_tag cdm_mappings_path, method: "post", multipart: true do %>
5
- <table>
6
- <tr><td>Collection: </td><td><%= select_tag 'collection', options_for_select(@collections) %></td></tr>
7
- <tr><td>Work: </td><td><%= select_tag 'work', options_for_select(@available_concerns) %></td></tr>
8
- <tr><td>Use Local File Storage: </td><td><%= check_box_tag 'file_system', 'true', false %></td></tr>
9
- <tr><td>Template to Apply: </td><td><%= file_field_tag 'template' %> (.yml file)</td></tr>
10
- </table>
11
- <%= submit_tag 'choose mappings' %>
1
+ <h1><span class="fa fa-map"></span> <%= default_page_title %></h1>
2
+
3
+ <h5>ContentDM API address: <%= @cdm_url %></h5>
4
+ <%= form_tag cdm_mappings_path, method: "post", multipart: true do %>
5
+ <table>
6
+ <tr><td>Collection: </td><td><%= select_tag 'collection', options_for_select(@collections) %></td></tr>
7
+ <tr><td>Work: </td><td><%= select_tag 'work', options_for_select(@available_concerns) %></td></tr>
8
+ <tr><td>Use Local File Storage: </td><td><%= check_box_tag 'file_system', 'true', false %></td></tr>
9
+ <tr><td>Template to Apply: </td><td><%= file_field_tag 'template' %> (.yml file)</td></tr>
10
+ </table>
11
+ <%= submit_tag 'choose mappings' %>
12
12
  <% end %>
@@ -1,53 +1,54 @@
1
- <style type="text/css" media="screen">
2
-
3
- table{
4
- border-collapse:collapse;
5
- border:1px solid black;
6
- }
7
-
8
- table td{
9
- border:1px solid black;
10
- }
11
- </style>
12
-
13
- <h1><span class="fa fa-map"></span> <%= default_page_title %></h1>
14
-
15
- <%= form_tag cdm_generate_path.gsub("generate","generate.csv") do %>
16
- <%= hidden_field_tag "collection", params[:collection] %>
17
- <%= hidden_field_tag "file_system", params[:file_system] %>
18
- <table>
19
- <% @cdm_terms.each_with_index do |t,i| %>
20
- <tr>
21
- <td>
22
- <%= label_tag t.first %>
23
- <%= hidden_field_tag "mappings[#{i}][cdm]", t.last %>
24
- </td>
25
- <td>
26
- <h3>Choose one</h3>
27
- <%= label_tag 'applies to boths compound objects and children:' %><%= select_tag "mappings[#{i}][hydra]", options_for_select(@terms, @yaml.nil? ? "" : @yaml[t.last]['hydra']), include_blank: true %><br>
28
- <%= label_tag 'applies only to compound objects: ' %><%= select_tag "mappings[#{i}][hydrac]", options_for_select(@work_only, @yaml.nil? ? "" : @yaml[t.last]['hydrac']), include_blank: true %>
29
- </td>
30
- </tr>
31
- <% end %>
32
- </table>
33
- <%= select_tag "mappings_url", options_for_select(@dirs.sort { |x,y| x[0].downcase <=> y[0].downcase }) if @cdm_dirs %>
34
- <%= hidden_field_tag "work", params[:work] %>
35
- <%= submit_tag 'generate csv'%>
36
- <% end %>
37
-
38
- <%= button_tag "Download Template", { "onclick" => "template()" } %>
39
-
40
- <script type="text/javascript">
41
- function template() {
42
- document.getElementsByTagName("form")[0].action = "<%= cdm_template_path.gsub("template","template.yml") %>";
43
- document.getElementsByName("commit")[0].click();
44
- document.getElementsByTagName("form")[0].action = "<%= cdm_generate_path.gsub("generate","generate.csv") %>";
45
- }
46
-
47
- inputs = document.getElementsByTagName('option');
48
- for (var i = 0; i < inputs.length; i++) {
49
- if (inputs[i].hasAttribute('selected')) {
50
- inputs[i].selected = true;
51
- }
52
- }
53
- </script>
1
+ <style type="text/css" media="screen">
2
+
3
+ table{
4
+ border-collapse:collapse;
5
+ border:1px solid black;
6
+ }
7
+
8
+ table td{
9
+ border:1px solid black;
10
+ }
11
+ </style>
12
+
13
+ <h1><span class="fa fa-map"></span> <%= default_page_title %></h1>
14
+
15
+ <%= form_tag cdm_generate_path.gsub("generate","generate.csv") do %>
16
+ <%= hidden_field_tag "collection", params[:collection] %>
17
+ <%= hidden_field_tag "file_system", params[:file_system] %>
18
+ <table>
19
+ <% @cdm_terms.each_with_index do |t,i| %>
20
+ <tr>
21
+ <td>
22
+ <%= label_tag t.first %>
23
+ <%= hidden_field_tag "mappings[#{i}][cdm]", t.last %>
24
+ </td>
25
+ <td>
26
+ <h3>Choose one</h3>
27
+ <%= label_tag 'applies to boths compound objects and children:' %><%= select_tag "mappings[#{i}][hydra]", options_for_select(@terms, @yaml.nil? ? "" : @yaml[t.last]['hydra']), include_blank: true %><br>
28
+ <%= label_tag 'applies only to compound objects: ' %><%= select_tag "mappings[#{i}][hydrac]", options_for_select(@work_only, @yaml.nil? ? "" : @yaml[t.last]['hydrac']), include_blank: true %>
29
+ </td>
30
+ </tr>
31
+ <% end %>
32
+ </table>
33
+ <%= select_tag "mappings_url", options_for_select(@dirs.sort { |x,y| x[0].downcase <=> y[0].downcase }) if @cdm_dirs %>
34
+ <%= hidden_field_tag "work", params[:work] %>
35
+ <%= submit_tag 'generate csv'%>
36
+ <% end %>
37
+
38
+ <%= button_tag "Download Template", { "onclick" => "template()" } %>
39
+ <%= link_to "Map Another Collection", cdm_start_path, class: 'btn btn-primary' %>
40
+
41
+ <script type="text/javascript">
42
+ function template() {
43
+ document.getElementsByTagName("form")[0].action = "<%= cdm_template_path.gsub("template","template.yml") %>";
44
+ document.getElementsByName("commit")[0].click();
45
+ document.getElementsByTagName("form")[0].action = "<%= cdm_generate_path.gsub("generate","generate.csv") %>";
46
+ }
47
+
48
+ inputs = document.getElementsByTagName('option');
49
+ for (var i = 0; i < inputs.length; i++) {
50
+ if (inputs[i].hasAttribute('selected')) {
51
+ inputs[i].selected = true;
52
+ }
53
+ }
54
+ </script>
@@ -1,4 +1,4 @@
1
- <% # container for all batches in index view -%>
2
- <div class="table-responsive" id="batches">
3
- <%= render 'default_group', batches: @batches %>
4
- </div>
1
+ <% # container for all batches in index view -%>
2
+ <div class="table-responsive" id="batches">
3
+ <%= render 'default_group', batches: @batches %>
4
+ </div>
@@ -1,17 +1,17 @@
1
- <table class="table table-striped works-list">
2
- <thead>
3
- <tr>
4
- <th><%= "Name" %></th>
5
- <th><%= "Uploaded" %></th>
6
- <th><%= "User" %></th>
7
- <th><%= "Progress" %></th>
8
- <th><%= "Message" %></th>
9
- <th><%= "Actions" %></th>
10
- </tr>
11
- </thead>
12
- <tbody>
13
- <% batches.each do |batch| %>
14
- <%= render 'list_batches', batch: batch %>
15
- <% end %>
16
- </tbody>
17
- </table>
1
+ <table class="table table-striped works-list">
2
+ <thead>
3
+ <tr>
4
+ <th><%= "Name" %></th>
5
+ <th><%= "Uploaded" %></th>
6
+ <th><%= "User" %></th>
7
+ <th><%= "Progress" %></th>
8
+ <th><%= "Message" %></th>
9
+ <th><%= "Actions" %></th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% batches.each do |batch| %>
14
+ <%= render 'list_batches', batch: batch %>
15
+ <% end %>
16
+ </tbody>
17
+ </table>