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 +4 -4
- data/lib/uc3-dmp-id/updater.rb +22 -0
- data/lib/uc3-dmp-id/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216eee2772c1e88ec1426ef8d0414e61958cfd3185149c999d19c02e38a9d32d
|
4
|
+
data.tar.gz: f97512390c550f0714381c75a8d8c9365de356d0d02db87be16081608084ac89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26491648692773b00eeae89efeb47f1f3c9c33897705974c6497193b21cbfc4a4b184b7ba0e9976751b2dad9e4c7d72c2cfc2867458bbbc81c4803614a4bff12
|
7
|
+
data.tar.gz: 59a869cb83864807167ccb21a4ce9f409afd73d60895d32ba91270da5fa7715e59d8e5310f576d6c582e40ec33961f2fe6fa2715622d5a71c5448234ad915830
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -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
|
|
data/lib/uc3-dmp-id/version.rb
CHANGED