cdm_migrator 0.1.3 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cdm_migrator/cdm_controller.rb +105 -58
- data/app/controllers/cdm_migrator/csv_controller.rb +26 -10
- data/app/jobs/csv_upload_job.rb +23 -7
- data/app/views/cdm_migrator/cdm/collection.html.erb +8 -8
- data/app/views/cdm_migrator/cdm/mappings.html.erb +21 -3
- data/config/routes.rb +2 -1
- data/lib/cdm_migrator/engine.rb +1 -1
- data/lib/cdm_migrator/version.rb +1 -1
- data/lib/generators/cdm_migrator/install/templates/config/cdm_migrator.yml +17 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 543741596596c9894fcc9d0ddf51846967f9490f
|
4
|
+
data.tar.gz: 28cb8c449f50eaf3485d5d0dd41206428d84a364
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84902af620888db380ce8f76e0d5b26ae2671222f4110ef0f9a8e5183beb501ee4b6b2feb78d80c82e6bdde870e089c7a53a7805f14cc0cb6542d499deb6bf8d
|
7
|
+
data.tar.gz: 79194986455bc961472cfafba1a5d7f167ea53e81d71542e713785c247f14c7d419f4a0d29b5a626bbe37bc36fcd4dc2e72fe0351778ceab0bdac9b1f845552a
|
@@ -1,31 +1,19 @@
|
|
1
1
|
module CdmMigrator
|
2
2
|
class CdmController < ApplicationController
|
3
3
|
|
4
|
+
require 'csv'
|
5
|
+
|
4
6
|
def initialize
|
5
7
|
super
|
6
8
|
@cdm_url = CdmMigrator::Engine.config["cdm_url"]
|
7
9
|
@cdm_port = CdmMigrator::Engine.config["cdm_port"]
|
10
|
+
@default_fields = CdmMigrator::Engine.config["default_fields"]
|
8
11
|
@cdm_dirs = CdmMigrator::Engine.config["cdm_dirs"] || false
|
12
|
+
@cdm_api = CdmMigrator::Engine.config["api"]
|
9
13
|
end
|
10
|
-
|
14
|
+
|
11
15
|
before_action :set_exclusive_fields, only: [:generate, :mappings]
|
12
|
-
|
13
|
-
def secondary_terms file_form
|
14
|
-
file_form.terms - file_form.required_fields -
|
15
|
-
[:visibility_during_embargo, :embargo_release_date,
|
16
|
-
:visibility_after_embargo, :visibility_during_lease,
|
17
|
-
:lease_expiration_date, :visibility_after_lease, :visibility,
|
18
|
-
:thumbnail_id, :representative_id, :ordered_member_ids,
|
19
|
-
:collection_ids, :in_works_ids, :admin_set_id]
|
20
|
-
end
|
21
|
-
|
22
|
-
def set_exclusive_fields
|
23
|
-
#Module.const_get "Hyrax::GenericWorkForm" rescue false #.split('::').inject(Object) {|o,c| o.const_get c}
|
24
|
-
file_form = Module.const_get("Hyrax::FileSetForm") rescue nil || Module.const_get("Hyrax::Forms::FileSetEditForm")
|
25
|
-
work_form = Module.const_get("Hyrax::#{params[:work]}Form") rescue nil || Module.const_get("Hyrax::Forms::WorkForm")
|
26
|
-
@terms = file_form.required_fields + secondary_terms(file_form)
|
27
|
-
@work_only = work_form.required_fields + work_form.new(params[:work].constantize.new,nil,nil).secondary_terms - @terms
|
28
|
-
end
|
16
|
+
skip_before_action :verify_authenticity_token
|
29
17
|
|
30
18
|
def generate
|
31
19
|
@h_to_c = {}
|
@@ -54,25 +42,23 @@ module CdmMigrator
|
|
54
42
|
else
|
55
43
|
records = json["records"].map { |rec| [rec['pointer'], rec['filetype']] }
|
56
44
|
end
|
57
|
-
headers = CSV.generate_line (['object_type','url']+@terms+@work_only)
|
45
|
+
headers = ::CSV.generate_line (['object_type','url']+@terms+@work_only)
|
58
46
|
csv_lines = [] << headers
|
59
47
|
records.each do |rec|
|
60
48
|
if rec.last == "cpd"
|
61
49
|
json = JSON.parse(Net::HTTP.get_response(URI.parse("#{@cdm_url}:#{@cdm_port}/dmwebservices/index.php?q=dmGetItemInfo/#{params[:collection]}/#{rec.first}/json")).body)
|
62
|
-
csv_lines << create_line(
|
50
|
+
csv_lines << create_line(params[:work],"",json)
|
63
51
|
json = JSON.parse(Net::HTTP.get_response(URI.parse("#{@cdm_url}:#{@cdm_port}/dmwebservices/index.php?q=dmGetCompoundObjectInfo/#{params[:collection]}/#{rec.first}/json")).body)
|
64
52
|
rec_pages = json['page'] || json['node']['page']
|
65
53
|
rec_pages.each do |child|
|
66
54
|
child_json = JSON.parse(Net::HTTP.get_response(URI.parse("#{@cdm_url}:#{@cdm_port}/dmwebservices/index.php?q=dmGetItemInfo/#{params[:collection]}/#{child['pageptr']}/json")).body)
|
67
|
-
url =
|
68
|
-
url = "#{@cdm_url}/utils/getfile/collection/#{params[:collection]}/id/#{rec.first}/filename/#{child['pageptr']}.#{child['find']}" unless params[:file_system]=="true" #"file://#{file_path(rec.first)}"
|
55
|
+
url = api_check rec
|
69
56
|
csv_lines << create_line("File",url,child_json)
|
70
57
|
end
|
71
58
|
else
|
72
59
|
json = JSON.parse(Net::HTTP.get_response(URI.parse("#{@cdm_url}:#{@cdm_port}/dmwebservices/index.php?q=dmGetItemInfo/#{params[:collection]}/#{rec.first}/json")).body)
|
73
|
-
csv_lines << create_line(
|
74
|
-
url =
|
75
|
-
url = "#{@cdm_url}/utils/getfile/collection/#{params[:collection]}/id/#{rec.first}/filename/#{rec.first}.#{rec.last}" unless params[:file_system]=="true" #"file://#{file_path(rec.first)}"
|
60
|
+
csv_lines << create_line(params[:work],"",json)
|
61
|
+
url = api_check rec
|
76
62
|
csv_lines << create_line("File",url,{})
|
77
63
|
end
|
78
64
|
end
|
@@ -86,54 +72,115 @@ module CdmMigrator
|
|
86
72
|
if @cdm_dirs
|
87
73
|
get_dirs
|
88
74
|
end
|
75
|
+
@yaml = YAML.load_file(params['template'].tempfile) if params.has_key? 'template'
|
89
76
|
end
|
90
77
|
|
91
78
|
def collection
|
92
79
|
json = JSON.parse(Net::HTTP.get_response(URI.parse("#{@cdm_url}:#{@cdm_port}/dmwebservices/index.php?q=dmGetCollectionList/json")).body)
|
93
80
|
@collections = json.collect { |c| [c['name'],c['secondary_alias']] }
|
94
|
-
|
81
|
+
load_concerns
|
82
|
+
end
|
83
|
+
|
84
|
+
def template
|
85
|
+
hashed = params[:mappings].permit!.to_h
|
86
|
+
template = {}
|
87
|
+
hashed.each do |k,v|
|
88
|
+
template[v['cdm']] = {'hydra' => v['hydra'], 'hydrac' => v['hydrac']}
|
89
|
+
end
|
90
|
+
render plain: template.to_yaml, content_type: 'text/yaml'
|
95
91
|
end
|
96
92
|
|
97
93
|
protected
|
98
94
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
95
|
+
def api_check rec
|
96
|
+
if params[:file_system]=="true"
|
97
|
+
"file://#{file_path(rec.first)}"
|
98
|
+
elsif @cdm_api == "server"
|
99
|
+
"#{@cdm_url}:#{@cdm_port}/cgi-bin/showfile.exe?CISOROOT=/#{params[:collection]}&CISOPTR=#{rec.first}"
|
100
|
+
else
|
101
|
+
"#{@cdm_url}/utils/getfile/collection/#{params[:collection]}/id/#{rec.first}/filename/#{rec.first}.#{rec.last}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def standalone
|
106
|
+
Hyrax rescue nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def load_concerns
|
110
|
+
@available_concerns = []
|
111
|
+
unless @default_fields.nil?
|
112
|
+
@available_concerns += [['DefaultWork', 'DefaultWork']]
|
113
|
+
end
|
114
|
+
unless standalone.nil?
|
115
|
+
@available_concerns += Hyrax.config.curation_concerns.map { |c| [c.to_s, c.to_s]}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def work_form
|
120
|
+
Module.const_get("Hyrax::#{params[:work]}Form") rescue nil || Module.const_get("Hyrax::Forms::WorkForm")
|
121
|
+
end
|
122
|
+
|
123
|
+
def file_form
|
124
|
+
Module.const_get("Hyrax::FileSetForm") rescue nil || Module.const_get("Hyrax::Forms::FileSetEditForm")
|
125
|
+
end
|
126
|
+
|
127
|
+
def secondary_terms form_name
|
128
|
+
form_name.terms - form_name.required_fields -
|
129
|
+
[:visibility_during_embargo, :embargo_release_date,
|
130
|
+
:visibility_after_embargo, :visibility_during_lease,
|
131
|
+
:lease_expiration_date, :visibility_after_lease, :visibility,
|
132
|
+
:thumbnail_id, :representative_id, :ordered_member_ids,
|
133
|
+
:collection_ids, :in_works_ids, :admin_set_id, :files, :source, :member_of_collection_ids]
|
134
|
+
end
|
135
|
+
|
136
|
+
def set_exclusive_fields
|
137
|
+
if params[:work] != 'DefaultWork'
|
138
|
+
@terms = file_form.required_fields + secondary_terms(file_form)
|
139
|
+
@work_only = (secondary_terms work_form) - @terms
|
140
|
+
else
|
141
|
+
@terms = @default_fields
|
142
|
+
@work_only = []
|
117
143
|
end
|
144
|
+
end
|
118
145
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
146
|
+
def create_line type, url, json
|
147
|
+
line = [] << type
|
148
|
+
line << url
|
149
|
+
(@terms+@work_only).each do |term|
|
150
|
+
content = []
|
151
|
+
unless @h_to_c[term.to_s].nil?
|
152
|
+
@h_to_c[term.to_s].each do |cdm_term|
|
153
|
+
content << json[cdm_term] unless json[cdm_term].nil?
|
154
|
+
end
|
155
|
+
content.delete_if(&:empty?)
|
124
156
|
end
|
125
|
-
|
126
|
-
|
157
|
+
if content.nil? || content.empty? || content == [{}]
|
158
|
+
line << ""
|
159
|
+
else
|
160
|
+
line << content.join('|')
|
127
161
|
end
|
128
162
|
end
|
163
|
+
::CSV.generate_line line
|
164
|
+
end
|
129
165
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
166
|
+
def file_path pointer
|
167
|
+
file_types = ['tif','jpg','mp4','mp3']
|
168
|
+
files = []
|
169
|
+
file_types.each do |type|
|
170
|
+
files << Dir.glob("#{params['mappings_url']}/**/#{pointer}_*#{type}")
|
171
|
+
end
|
172
|
+
files.each do |file|
|
173
|
+
return file.first if file.count > 0
|
137
174
|
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def get_dirs
|
178
|
+
@dirs = []
|
179
|
+
@cdm_dirs.each do |name, dir|
|
180
|
+
ent = Dir.entries(dir).select {|entry| File.directory? File.join(dir,entry) and !(entry =='.' || entry == '..') }
|
181
|
+
ent = ent.map { |url| ["#{name}/#{url}", "#{dir}/#{url}"] }
|
182
|
+
@dirs += ent
|
183
|
+
end
|
184
|
+
end
|
138
185
|
end
|
139
186
|
end
|
@@ -21,8 +21,8 @@ module CdmMigrator
|
|
21
21
|
def create
|
22
22
|
#byebug
|
23
23
|
csv = CSV.parse(File.read(params[:csv_import][:csv_file].path), headers: true, encoding: 'utf-8')
|
24
|
-
CsvUploadJob.perform_later(params[:csv_import][:csv_file].path, params[:csv_import][:mvs],
|
25
|
-
#perform(params[:csv_import][:csv_file].path, params[:csv_import][:mvs],
|
24
|
+
CsvUploadJob.perform_later(params[:csv_import][:csv_file].path, params[:csv_import][:mvs], current_user)
|
25
|
+
#perform(params[:csv_import][:csv_file].path, params[:csv_import][:mvs], current_user)
|
26
26
|
flash[:notice] = "csv successfully uploaded"
|
27
27
|
redirect_to csv_upload_path
|
28
28
|
end
|
@@ -30,7 +30,6 @@ module CdmMigrator
|
|
30
30
|
def perform(csv, mvs, current_user)
|
31
31
|
@csv = CSV.parse(File.read(csv), headers: true, encoding: 'utf-8').map(&:to_hash)
|
32
32
|
@mvs = mvs
|
33
|
-
@current_user = current_user
|
34
33
|
@works = []
|
35
34
|
@files = {}
|
36
35
|
@csv.each do |row|
|
@@ -50,10 +49,27 @@ module CdmMigrator
|
|
50
49
|
|
51
50
|
private
|
52
51
|
|
52
|
+
def work_form
|
53
|
+
Module.const_get("Hyrax::#{params[:work]}Form") rescue nil || Module.const_get("Hyrax::Forms::WorkForm")
|
54
|
+
end
|
55
|
+
|
56
|
+
def file_form
|
57
|
+
Module.const_get("Hyrax::FileSetForm") rescue nil || Module.const_get("Hyrax::Forms::FileSetEditForm")
|
58
|
+
end
|
59
|
+
|
60
|
+
def secondary_terms form_name
|
61
|
+
form_name.terms - form_name.required_fields -
|
62
|
+
[:visibility_during_embargo, :embargo_release_date,
|
63
|
+
:visibility_after_embargo, :visibility_during_lease,
|
64
|
+
:lease_expiration_date, :visibility_after_lease, :visibility,
|
65
|
+
:thumbnail_id, :representative_id, :ordered_member_ids,
|
66
|
+
:collection_ids, :in_works_ids, :admin_set_id, :files, :source, :member_of_collection_ids]
|
67
|
+
end
|
68
|
+
|
53
69
|
def create_file_from_url(url, file_name, work, file_data)
|
54
70
|
::FileSet.new(import_url: url, label: file_name) do |fs|
|
55
71
|
fs.save
|
56
|
-
actor = Hyrax::Actors::FileSetActor.new(fs,
|
72
|
+
actor = Hyrax::Actors::FileSetActor.new(fs, current_user)
|
57
73
|
actor.create_metadata#(work, visibility: work.visibility)
|
58
74
|
actor.attach_file_to_work(work)
|
59
75
|
#byebug
|
@@ -61,7 +77,7 @@ module CdmMigrator
|
|
61
77
|
fs.save!
|
62
78
|
uri = URI.parse(url.gsub(' ','%20'))
|
63
79
|
if uri.scheme == 'file'
|
64
|
-
IngestLocalFileJob.perform_later(fs, uri.path.gsub('%20',' '),
|
80
|
+
IngestLocalFileJob.perform_later(fs, uri.path.gsub('%20',' '), current_user)
|
65
81
|
else
|
66
82
|
ImportUrlJob.perform_later(fs, log(actor.user))
|
67
83
|
end
|
@@ -93,8 +109,8 @@ module CdmMigrator
|
|
93
109
|
@works.each do |work_data|
|
94
110
|
work = Object.const_get(work_data.first.last).new#delete("object_type")).new
|
95
111
|
status_after, embargo_date, lease_date = nil, nil, nil
|
96
|
-
final_work_data = create_data work_data,
|
97
|
-
work.apply_depositor_metadata(
|
112
|
+
final_work_data = create_data work_data, work_form, work
|
113
|
+
work.apply_depositor_metadata(current_user)
|
98
114
|
work.attributes = final_work_data
|
99
115
|
work.save
|
100
116
|
create_files(work, index)
|
@@ -104,7 +120,7 @@ module CdmMigrator
|
|
104
120
|
|
105
121
|
def create_data data, type, object
|
106
122
|
final_data = {}
|
107
|
-
accepted_terms = Object.const_get(type).required_fields +
|
123
|
+
accepted_terms = Object.const_get(type).required_fields + secondary_terms(type)
|
108
124
|
data.each do |key, att|
|
109
125
|
if(att.nil? || att.empty? || key.to_s.include?("object_type") || !accepted_terms.include?(key.to_sym) )
|
110
126
|
next
|
@@ -136,7 +152,7 @@ module CdmMigrator
|
|
136
152
|
@files[index].each do |file_data|
|
137
153
|
url = file_data.delete('url')
|
138
154
|
title = file_data.delete('title')
|
139
|
-
final_file_data = create_data file_data,
|
155
|
+
final_file_data = create_data file_data, file_form, file
|
140
156
|
create_file_from_url(url, title, work, final_file_data)
|
141
157
|
end
|
142
158
|
end
|
@@ -153,4 +169,4 @@ module CdmMigrator
|
|
153
169
|
operation_type: "Attach Remote File")
|
154
170
|
end
|
155
171
|
end
|
156
|
-
end
|
172
|
+
end
|
data/app/jobs/csv_upload_job.rb
CHANGED
@@ -5,7 +5,6 @@ class CsvUploadJob < ActiveJob::Base
|
|
5
5
|
def perform(csv, mvs, current_user)
|
6
6
|
@csv = CSV.parse(File.read(csv), headers: true, encoding: 'utf-8').map(&:to_hash)
|
7
7
|
@mvs = mvs
|
8
|
-
@current_user = current_user
|
9
8
|
@works = []
|
10
9
|
@files = {}
|
11
10
|
@csv.each do |row|
|
@@ -24,11 +23,28 @@ class CsvUploadJob < ActiveJob::Base
|
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
26
|
+
|
27
|
+
def work_form
|
28
|
+
Module.const_get("Hyrax::#{params[:work]}Form") rescue nil || Module.const_get("Hyrax::Forms::WorkForm")
|
29
|
+
end
|
30
|
+
|
31
|
+
def file_form
|
32
|
+
Module.const_get("Hyrax::FileSetForm") rescue nil || Module.const_get("Hyrax::Forms::FileSetEditForm")
|
33
|
+
end
|
34
|
+
|
35
|
+
def secondary_terms form_name
|
36
|
+
form_name.terms - form_name.required_fields -
|
37
|
+
[:visibility_during_embargo, :embargo_release_date,
|
38
|
+
:visibility_after_embargo, :visibility_during_lease,
|
39
|
+
:lease_expiration_date, :visibility_after_lease, :visibility,
|
40
|
+
:thumbnail_id, :representative_id, :ordered_member_ids,
|
41
|
+
:collection_ids, :in_works_ids, :admin_set_id, :files, :source, :member_of_collection_ids]
|
42
|
+
end
|
27
43
|
|
28
44
|
def create_file_from_url(url, file_name, work, file_data)
|
29
45
|
::FileSet.new(import_url: url, label: file_name) do |fs|
|
30
46
|
fs.save
|
31
|
-
actor = Hyrax::Actors::FileSetActor.new(fs,
|
47
|
+
actor = Hyrax::Actors::FileSetActor.new(fs, current_user)
|
32
48
|
actor.create_metadata#(work, visibility: work.visibility)
|
33
49
|
actor.attach_file_to_work(work)
|
34
50
|
#byebug
|
@@ -36,7 +52,7 @@ class CsvUploadJob < ActiveJob::Base
|
|
36
52
|
fs.save!
|
37
53
|
uri = URI.parse(url.gsub(' ','%20'))
|
38
54
|
if uri.scheme == 'file'
|
39
|
-
IngestLocalFileJob.perform_later(fs, uri.path.gsub('%20',' '),
|
55
|
+
IngestLocalFileJob.perform_later(fs, uri.path.gsub('%20',' '), current_user)
|
40
56
|
else
|
41
57
|
ImportUrlJob.perform_later(fs, log(actor.user))
|
42
58
|
end
|
@@ -68,7 +84,7 @@ class CsvUploadJob < ActiveJob::Base
|
|
68
84
|
@works.each do |work_data|
|
69
85
|
work = Object.const_get(work_data.first.last).new#delete("object_type")).new
|
70
86
|
status_after, embargo_date, lease_date = nil, nil, nil
|
71
|
-
final_work_data = create_data work_data,
|
87
|
+
final_work_data = create_data work_data, work_form, work
|
72
88
|
work.apply_depositor_metadata(@current_user)
|
73
89
|
work.attributes = final_work_data
|
74
90
|
work.save
|
@@ -79,7 +95,7 @@ class CsvUploadJob < ActiveJob::Base
|
|
79
95
|
|
80
96
|
def create_data data, type, object
|
81
97
|
final_data = {}
|
82
|
-
accepted_terms = Object.const_get(type).required_fields +
|
98
|
+
accepted_terms = Object.const_get(type).required_fields + secondary_terms(type)
|
83
99
|
data.each do |key, att|
|
84
100
|
if(att.nil? || att.empty? || key.to_s.include?("object_type") || !accepted_terms.include?(key.to_sym) )
|
85
101
|
next
|
@@ -111,7 +127,7 @@ class CsvUploadJob < ActiveJob::Base
|
|
111
127
|
@files[index].each do |file_data|
|
112
128
|
url = file_data.delete('url')
|
113
129
|
title = file_data.delete('title')
|
114
|
-
final_file_data = create_data file_data,
|
130
|
+
final_file_data = create_data file_data, file_form, file
|
115
131
|
create_file_from_url(url, title, work, final_file_data)
|
116
132
|
end
|
117
133
|
end
|
@@ -120,4 +136,4 @@ class CsvUploadJob < ActiveJob::Base
|
|
120
136
|
Hyrax::Operation.create!(user: user,
|
121
137
|
operation_type: "Attach Remote File")
|
122
138
|
end
|
123
|
-
end
|
139
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%= form_tag cdm_mappings_path, method: "
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
<%= submit_tag 'choose mappings' %>
|
1
|
+
<%= form_tag cdm_mappings_path, method: "post", multipart: true do %>
|
2
|
+
<table>
|
3
|
+
<tr><td>Collection: </td><td><%= select_tag 'collection', options_for_select(@collections) %></td></tr>
|
4
|
+
<tr><td>Work: </td><td><%= select_tag 'work', options_for_select(@available_concerns) %></td></tr>
|
5
|
+
<tr><td>Use Local File Storage: </td><td><%= check_box_tag 'file_system', 'true', false %></td></tr>
|
6
|
+
<tr><td>Template to Apply: </td><td><%= file_field_tag 'template' %> (.yml file)</td></tr>
|
7
|
+
</table>
|
8
|
+
<%= submit_tag 'choose mappings' %>
|
9
9
|
<% end %>
|
@@ -9,6 +9,7 @@ table td{
|
|
9
9
|
border:1px solid black;
|
10
10
|
}
|
11
11
|
</style>
|
12
|
+
|
12
13
|
<%= form_tag cdm_generate_path.gsub("generate","generate.csv") do %>
|
13
14
|
<%= hidden_field_tag "collection", params[:collection] %>
|
14
15
|
<%= hidden_field_tag "file_system", params[:file_system] %>
|
@@ -21,13 +22,30 @@ border:1px solid black;
|
|
21
22
|
</td>
|
22
23
|
<td>
|
23
24
|
<h3>Choose one</h3>
|
24
|
-
<%= label_tag 'applies to boths compound objects and children:' %><%= select_tag "mappings[#{i}][hydra]", options_for_select(@terms), include_blank: true %><br>
|
25
|
-
<%= label_tag 'applies only to compound objects: ' %><%= select_tag "mappings[#{i}][hydrac]", options_for_select(@work_only), include_blank: true %>
|
25
|
+
<%= 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>
|
26
|
+
<%= 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 %>
|
26
27
|
</td>
|
27
28
|
</tr>
|
28
29
|
<% end %>
|
29
30
|
</table>
|
30
31
|
<%= select_tag "mappings_url", options_for_select(@dirs) if @cdm_dirs %>
|
31
32
|
<%= hidden_field_tag "work", params[:work] %>
|
32
|
-
<%= submit_tag 'generate csv'
|
33
|
+
<%= submit_tag 'generate csv'%>
|
33
34
|
<% end %>
|
35
|
+
|
36
|
+
<%= button_tag "Download Template", { "onclick" => "template()" } %>
|
37
|
+
|
38
|
+
<script type="text/javascript">
|
39
|
+
function template() {
|
40
|
+
document.getElementsByTagName("form")[0].action = "<%= cdm_template_path.gsub("template","template.yml") %>";
|
41
|
+
document.getElementsByName("commit")[0].click();
|
42
|
+
document.getElementsByTagName("form")[0].action = "<%= cdm_generate_path.gsub("generate","generate.csv") %>";
|
43
|
+
}
|
44
|
+
|
45
|
+
inputs = document.getElementsByTagName('option');
|
46
|
+
for (var i = 0; i < inputs.length; i++) {
|
47
|
+
if (inputs[i].hasAttribute('selected')) {
|
48
|
+
inputs[i].selected = true;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
</script>
|
data/config/routes.rb
CHANGED
@@ -4,6 +4,7 @@ CdmMigrator::Engine.routes.draw do
|
|
4
4
|
get '/csv/generate', to: 'csv#generate', as: 'csv_generate'
|
5
5
|
|
6
6
|
get 'cdm/collection', to: 'cdm#collection'
|
7
|
-
|
7
|
+
post 'cdm/mappings/', to: 'cdm#mappings', as: 'cdm_mappings'
|
8
8
|
post 'cdm/generate/', to: 'cdm#generate', as: 'cdm_generate'
|
9
|
+
post 'cdm/template', to: 'cdm#template', as: 'cdm_template'
|
9
10
|
end
|
data/lib/cdm_migrator/engine.rb
CHANGED
data/lib/cdm_migrator/version.rb
CHANGED
@@ -2,4 +2,20 @@ cdm_url: 'http://your-content-dm-host'
|
|
2
2
|
cdm_port: 8080
|
3
3
|
cdm_dirs:
|
4
4
|
dir1: '/dir1/path/goes/here'
|
5
|
-
dir2: '/dir2/path/goes/here'
|
5
|
+
dir2: '/dir2/path/goes/here'
|
6
|
+
api: 'front'
|
7
|
+
default_fields:
|
8
|
+
- title
|
9
|
+
- creator
|
10
|
+
- keyword
|
11
|
+
- license
|
12
|
+
- resource_type
|
13
|
+
- contributor
|
14
|
+
- description
|
15
|
+
- publisher
|
16
|
+
- date_created
|
17
|
+
- subject
|
18
|
+
- language
|
19
|
+
- identifier
|
20
|
+
- based_near
|
21
|
+
- related_url
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdm_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sephirothkod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hyrax
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.rc1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0.rc1
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: engine_cart
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
120
|
version: '0'
|
135
121
|
requirements: []
|
136
122
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.11
|
138
124
|
signing_key:
|
139
125
|
specification_version: 4
|
140
126
|
summary: ContentDM to Hyrax migrator.
|