uc3-dmp-id 0.1.72 → 0.1.74

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b90c20a70e3d549ed563b01ac4548f727ff36333e017841fbcc33dd1687e1f9e
4
- data.tar.gz: a86589814101e440390ec0c637b2a79ba8f6ee1e454cc2eeb8b51801bdbe4e5d
3
+ metadata.gz: 216eee2772c1e88ec1426ef8d0414e61958cfd3185149c999d19c02e38a9d32d
4
+ data.tar.gz: f97512390c550f0714381c75a8d8c9365de356d0d02db87be16081608084ac89
5
5
  SHA512:
6
- metadata.gz: 422bd12145eca2376172a80f8c6c66376ce4c792760d5ba4c99fabab266a7f9463831a89c0743edc76c84576c6cc0330db7c8721c765711b80f05339f4a202ba
7
- data.tar.gz: 6f98e2324a6cd7023960dbe641da9d263baed02503645f1e32933feef751117a4de84c13c20056b9fac0d24d79c12e24ea6f1fbfa507db66b22312c3583f7ed8
6
+ metadata.gz: 26491648692773b00eeae89efeb47f1f3c9c33897705974c6497193b21cbfc4a4b184b7ba0e9976751b2dad9e4c7d72c2cfc2867458bbbc81c4803614a4bff12
7
+ data.tar.gz: 59a869cb83864807167ccb21a4ce9f409afd73d60895d32ba91270da5fa7715e59d8e5310f576d6c582e40ec33961f2fe6fa2715622d5a71c5448234ad915830
@@ -211,10 +211,13 @@ module Uc3DmpId
211
211
  # The `dmphub_modifications` array will ONLY ever have things the harvester mods know about
212
212
  # so just find them and update the status accordingly
213
213
  original = resp.dup
214
+ json['dmproadmap_related_identifiers'] = [] if json['dmproadmap_related_identifiers'].nil?
215
+
214
216
  json['dmphub_modifications'].each do |entry|
215
217
  next if entry.fetch('dmproadmap_related_identifiers', []).empty?
216
218
 
217
219
  entry['dmproadmap_related_identifiers'].each do |related|
220
+ # Detrmine if the HARVESTER_MODS record even knows about the mod
218
221
  related_id = related.respond_to?(:identifier) ? related.identifier : related['identifier']
219
222
  related_domain = related.respond_to?(:domain) ? related.domain : related['domain']
220
223
  key = "#{related_domain.end_with?('/') ? related_domain : "#{related_domain}/"}#{related_id}"
@@ -222,8 +225,27 @@ module Uc3DmpId
222
225
  logger&.debug(message: "No matching HARVEST_MOD found for #{key}") unless key_found
223
226
  next unless key_found
224
227
 
228
+ # Update the status in the HARVESTER_MODS record
225
229
  logger&.debug(message: "Updating status for #{key} from #{original['related_works'][key]['status']} to #{related['status']}")
226
230
  original['related_works'][key]['status'] = related['status']
231
+
232
+ existing = json['dmproadmap_related_identifiers'].select do |ri|
233
+ ri['identifier'] == key
234
+ end
235
+
236
+ # Add it if it was approved and doesn't exist in dmproadmap_related_identifiers
237
+ if related['status'] == 'approved' && existing.empty?
238
+ json['dmproadmap_related_identifiers'] << {
239
+ identifier: key,
240
+ work_type: related['work_type'],
241
+ type: related['type'],
242
+ descriptor: related['descriptor'],
243
+ citation: related['citation']
244
+ }.to_json
245
+ elsif related['status'] != 'approved' && existing.any?
246
+ # otherwise remove it
247
+ json['dmproadmap_related_identifiers'] = json['dmproadmap_related_identifiers'].reject { |ri| ri == existing.first }
248
+ end
227
249
  end
228
250
  end
229
251
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.72'
4
+ VERSION = '0.1.74'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.72
4
+ version: 0.1.74
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley