cdm_migrator 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 330afa0ea8f2de397dc822fafef651778e039b0b422ec8ab93e61bd4ed6e9ced
4
- data.tar.gz: 6860866888bf49430fbbb4eace6e38bb7b2da09f6b8633608e7508cac374dc4c
3
+ metadata.gz: 8bc6e448326179791de466ba5dc1d35a26fd48fa2a85a8fbabeb7d8dad60339e
4
+ data.tar.gz: f3cf46dec46cd8166bc0555eef28e2868db6fbbf77963083f93fca1958b00e19
5
5
  SHA512:
6
- metadata.gz: f263a7da82234a60ac6ac4f73529b226762b483dee9ce093712f8dd3c34dc97b3b1b96b5b62cbc98d0de5f2dc1157367b5c1352a5cb79bd7703f45a707ceb034
7
- data.tar.gz: f4f095574c88c63970d2de9032ad96ad134ff34952b78068a2ddceee404d9998134ccfac15ee29ca75d2ac9c7b8f4a3a4db33030b6218d8b100afa64ea357cd3
6
+ metadata.gz: 9d8b8bc4d318269375c82429cbcd4bb2e3d07b1761ef54854b262746c09e46430ee3d9da02122567f5244599bb3f312b7248b1b0a610b12abc2a049b0b7470dc
7
+ data.tar.gz: 4dfc8a920f09e1e3c84b5eb09116adadcbf44556c3abe4b4daa1dbce7e87e767ea380de9fbdc5368c548032bf4b6f074a5ab0268fd6600dff75a9530445a7210
@@ -117,6 +117,7 @@ module CdmMigrator
117
117
  solr = RSolr.connect url: Account.find_by(tenant: Apartment::Tenant.current).solr_endpoint.url
118
118
  response = solr.get 'select', params: {
119
119
  q: "member_of_collection_ids_ssim:#{params[:collection_id]}",
120
+ rows: 3400,
120
121
  fl: "id"
121
122
  }
122
123
  unless response['response']['docs'].empty? || response['response']['docs'][0].empty?
@@ -269,13 +270,49 @@ module CdmMigrator
269
270
  def check_edtf(row_number, row)
270
271
  edtf_fields = @edtf_fields
271
272
  edtf_errors = edtf_fields.each_with_object({}) do |field, hash|
272
- if Date.edtf(row[field]) == nil and row[field] != "unknown"
273
- hash[field.to_s] = "Blank or not a valid EDTF date."
273
+ temp_date = row[field]
274
+ # modify date so that the interval encompasses the years on the last interval date
275
+ temp_date = temp_date.gsub('/..','').gsub('%','?~').gsub(/\/$/,'')
276
+ date = temp_date.include?("/") ? temp_date.gsub(/([0-9]+X+\/)([0-9]+)(X+)/){"#{$1}"+"#{$2.to_i+1}"+"#{$3}"}.gsub("X","u") : temp_date
277
+ date = date.gsub("XX-","uu-").gsub("X-", "u-").gsub('XX?','uu').gsub('X?', 'u').gsub('u?','u').gsub('?','')
278
+ # edtf has trouble with year-month (e.g. "19uu-12") or year-season strings (e.g. "190u-23")
279
+ # that contain unspecified years, or intervals containing the above ("19uu-22/19uu-23", etc.).
280
+ # So we check for/create exceptions.
281
+ # Check for season interval
282
+ if Date.edtf(date) == nil and date != "unknown" # Accept season intervals
283
+ unless is_season?(date.split("/").first) and is_season?(date.split("/").second)
284
+ # If an interval then, check each date individually
285
+ if date.include?("/")
286
+ dates = date.split("/")
287
+ else
288
+ dates = [date]
289
+ end
290
+ #byebug
291
+ dates.each do |d|
292
+ # Dates with 'u' in the last digit of the year return invalid when in format YYYY-MM
293
+ # So we flub day specifity before checking again if the date is valid
294
+ unless Date.edtf(d + '-01') # Date.edtf('193u-03-01') returns valid
295
+ if match = d[/\d{3}u/] or match = d[/\d{2}u{2}-[2][1-4]/] # edtf can't parse single u in year (e.g. 192u) or uu in YYYY-SS (e.g. 19uu-21), so we replace it
296
+ d.gsub!(match, match.gsub("u","0"))
297
+ unless Date.edtf(d)
298
+ hash[field.to_s] = "Blank or not a valid EDTF date."
299
+ end
300
+ else
301
+ hash[field.to_s] = "Blank or not a valid EDTF date."
302
+ end
303
+ end
304
+ end
305
+ end
274
306
  end
307
+
275
308
  end
276
309
  @error_list[row_number] = edtf_errors
277
310
  end
278
311
 
312
+ def is_season?(date)
313
+ Date.edtf(date).class == EDTF::Season
314
+ end
315
+
279
316
  # <Example: should be http://rightsstatements.org/vocab/etc. NOT https://rightsstatements.org/page/etc.
280
317
  def check_uris(row_number, row)
281
318
  uri_fields = @uri_fields
@@ -294,7 +331,7 @@ module CdmMigrator
294
331
  value = row[field]
295
332
  if value.present?
296
333
  URI.extract(value).each { |uri| value.gsub!(uri, '') }
297
- unless value.split("").all?(character) # Check if remaining characters are the correct separator
334
+ unless value.split("").all? { |sep| sep == character } # Check if remaining characters are the correct separator
298
335
  hash[field.to_s] = "May contain the wrong multi-value separator (i.e. not #{character})."
299
336
  end
300
337
  end
@@ -30,7 +30,7 @@ border:1px solid black;
30
30
  </tr>
31
31
  <% end %>
32
32
  </table>
33
- <%= select_tag "mappings_url", options_for_select(@dirs) if @cdm_dirs %>
33
+ <%= select_tag "mappings_url", options_for_select(@dirs.sort { |x,y| x[0].downcase <=> y[0].downcase }) if @cdm_dirs %>
34
34
  <%= hidden_field_tag "work", params[:work] %>
35
35
  <%= submit_tag 'generate csv'%>
36
36
  <% end %>
@@ -0,0 +1,21 @@
1
+ <% if @error_list && @error_list.any? %>
2
+ <%#= @error_list.inspect %>
3
+ <table class="table table-striped">
4
+ <thead>
5
+ <tr>
6
+ <th scope="col" style="min-width: 100px;">Line No.</th>
7
+ <th scope="col" style="margin-right: 0.5em;">Column(s)</th>
8
+ <th scope="col">Issue</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @error_list.keys.each do |line_number| %>
13
+ <tr>
14
+ <td><%= line_number %></td>
15
+ <td><%= @error_list[line_number].keys.join("<br />").html_safe %></td>
16
+ <td><%= @error_list[line_number].values.join("<br />").html_safe %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module CdmMigrator
2
- VERSION = '3.2.0'
2
+ VERSION = '3.2.1'
3
3
  end
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: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sephirothkod
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -100,9 +100,8 @@ files:
100
100
  - app/views/cdm_migrator/cdm/mappings.html.erb
101
101
  - app/views/cdm_migrator/csv/_batches_list.html.erb
102
102
  - app/views/cdm_migrator/csv/_default_group.html.erb
103
+ - app/views/cdm_migrator/csv/_error_list.html.erb
103
104
  - app/views/cdm_migrator/csv/_list_batches.html.erb
104
- - app/views/cdm_migrator/csv/_path_list.html.erb
105
- - app/views/cdm_migrator/csv/_results_pagination.html.erb
106
105
  - app/views/cdm_migrator/csv/_tabs.html.erb
107
106
  - app/views/cdm_migrator/csv/csv_checker.html.erb
108
107
  - app/views/cdm_migrator/csv/edit.html.erb
@@ -125,7 +124,7 @@ homepage: https://github.com/UVicLibrary/cdm_migrator
125
124
  licenses:
126
125
  - MIT
127
126
  metadata: {}
128
- post_install_message:
127
+ post_install_message:
129
128
  rdoc_options: []
130
129
  require_paths:
131
130
  - lib
@@ -140,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
139
  - !ruby/object:Gem::Version
141
140
  version: '0'
142
141
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.7.7
145
- signing_key:
142
+ rubygems_version: 3.1.2
143
+ signing_key:
146
144
  specification_version: 4
147
145
  summary: ContentDM to Hyrax migrator.
148
146
  test_files: []
@@ -1,19 +0,0 @@
1
- <% if @path_list && @path_list.any? %>
2
- <table class="table table-striped">
3
- <thead>
4
- <tr>
5
- <th scope="col" style="min-width: 100px;">Line No.</th>
6
- <th scope="col">File Path (url)</th>
7
- </tr>
8
- </thead>
9
- <tbody>
10
- <% @path_list.each do |line, path| %>
11
- <tr>
12
- <td><%= line %></td>
13
- <td><%= path %></td>
14
- </tr>
15
- <% end %>
16
- </tbody>
17
- </table>
18
- <% end %>
19
-
@@ -1,9 +0,0 @@
1
- <% if @response.total_pages > 1 %>
2
- <div class="row record-padding">
3
- <div class="col-md-9">
4
- <div class="pagination">
5
- <%= paginate @response, outer_window: 2, theme: 'blacklight', route_set: hyrax %>
6
- </div>
7
- </div>
8
- </div>
9
- <% end %>