uc3-dmp-id 0.1.74 → 0.1.76
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 +19 -43
- 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: 9d18daee8127652273ede255b35ce9c8401354f5082c4f1806737b2486dc7178
|
4
|
+
data.tar.gz: a2b7599f05bc790822d80e5ec7dd83a64ef42ef5fd52cc4eae5db90792d0185a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72080a3809333bd1c3dacd7540c7bf108bf99b8fa0fa6b0450aae2180af8ff175ab273f9509f26043c01a14c0d45a478c4c242798c5f571a1befcdfe5a9784d8
|
7
|
+
data.tar.gz: 887b4651957305c709eaec3139735b83854d432dd8894777c0437ee4d243d09ff98a2244f9dd9486474ec89e56c8470d8b8ddad527f2507d83b7c0c903c544e2
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -45,35 +45,32 @@ module Uc3DmpId
|
|
45
45
|
raise UpdaterError, Helper::MSG_DMP_FORBIDDEN if owner != updater
|
46
46
|
|
47
47
|
# Handle any changes to the dmphub_modifications section
|
48
|
-
|
49
|
-
logger&.debug(message: '
|
48
|
+
version = _process_harvester_mods(client:, p_key:, json: payload, logger:)
|
49
|
+
logger&.debug(message: 'Version after process_harvester_mods', details: version)
|
50
50
|
|
51
|
-
# Remove the version info
|
52
|
-
|
53
|
-
|
54
|
-
# Splice the assertions
|
55
|
-
payload = _process_modifications(owner:, updater:, version:, mods: payload, logger:)
|
56
|
-
logger&.debug(message: 'Mods after process_modifications', details: payload)
|
51
|
+
# Remove the version info any any lingering modification blocks
|
52
|
+
version.delete('dmphub_versions')
|
53
|
+
version.delete('dmphub_modifications')
|
57
54
|
|
58
55
|
# Set the :modified timestamps
|
59
56
|
now = Time.now.utc
|
60
|
-
|
61
|
-
|
57
|
+
version['modified'] = now.iso8601
|
58
|
+
version['dmphub_modification_day'] = now.strftime('%Y-%m-%d')
|
62
59
|
|
63
60
|
# Save the changes
|
64
|
-
resp = client.put_item(json:
|
61
|
+
resp = client.put_item(json: version, logger:)
|
65
62
|
raise UpdaterError, Helper::MSG_DMP_UNABLE_TO_VERSION if resp.nil?
|
66
63
|
|
67
64
|
# Send the updates to EZID
|
68
|
-
_post_process(provenance:, json:
|
65
|
+
_post_process(provenance:, json: version, logger:)
|
69
66
|
|
70
67
|
# Return the new version record
|
71
68
|
logger.info(message: "Updated DMP ID: #{p_key}") if logger.respond_to?(:debug)
|
72
69
|
|
73
70
|
# Append the :dmphub_versions Array
|
74
|
-
|
75
|
-
|
76
|
-
Helper.cleanse_dmp_json(json:)
|
71
|
+
out = JSON.parse({ dmp: version }.to_json)
|
72
|
+
out = Versioner.append_versions(p_key:, dmp: out, client:, logger:)
|
73
|
+
Helper.cleanse_dmp_json(json: out)
|
77
74
|
end
|
78
75
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
79
76
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -134,25 +131,6 @@ module Uc3DmpId
|
|
134
131
|
end
|
135
132
|
# rubocop:enable Metrics/AbcSize
|
136
133
|
|
137
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
138
|
-
def _process_modifications(owner:, updater:, version:, mods:, logger: nil)
|
139
|
-
return version unless mods.is_a?(Hash) && !updater.nil?
|
140
|
-
return mods unless version.is_a?(Hash) && !owner.nil?
|
141
|
-
|
142
|
-
logger.debug(message: 'Modifications before merge.', details: mods) if logger.respond_to?(:debug)
|
143
|
-
keys_to_retain = version.keys.select do |key|
|
144
|
-
(key.start_with?('dmphub_') && !%w[dmphub_modifications dmphub_versions].include?(key)) ||
|
145
|
-
key.start_with?('PK') || key.start_with?('dmproadmap_related_identifiers')
|
146
|
-
end
|
147
|
-
keys_to_retain.each do |key|
|
148
|
-
mods[key] = version[key]
|
149
|
-
end
|
150
|
-
mods['SK'] = Helper::DMP_LATEST_VERSION
|
151
|
-
logger.debug(message: 'Modifications after merge.', details: mods) if logger.respond_to?(:debug)
|
152
|
-
mods
|
153
|
-
end
|
154
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
155
|
-
|
156
134
|
# Once the DMP has been updated, we need to update it's DOI metadata
|
157
135
|
# -------------------------------------------------------------------------
|
158
136
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
@@ -229,31 +207,29 @@ module Uc3DmpId
|
|
229
207
|
logger&.debug(message: "Updating status for #{key} from #{original['related_works'][key]['status']} to #{related['status']}")
|
230
208
|
original['related_works'][key]['status'] = related['status']
|
231
209
|
|
232
|
-
existing =
|
210
|
+
existing = version['dmproadmap_related_identifiers'].select do |ri|
|
233
211
|
ri['identifier'] == key
|
234
212
|
end
|
235
213
|
|
236
214
|
# Add it if it was approved and doesn't exist in dmproadmap_related_identifiers
|
237
215
|
if related['status'] == 'approved' && existing.empty?
|
238
|
-
|
216
|
+
version['dmproadmap_related_identifiers'] << {
|
239
217
|
identifier: key,
|
240
218
|
work_type: related['work_type'],
|
241
219
|
type: related['type'],
|
242
220
|
descriptor: related['descriptor'],
|
243
221
|
citation: related['citation']
|
244
|
-
}
|
245
|
-
elsif related['status']
|
222
|
+
}
|
223
|
+
elsif related['status'] == 'rejected' && existing.any?
|
246
224
|
# otherwise remove it
|
247
|
-
|
225
|
+
version['dmproadmap_related_identifiers'] = version['dmproadmap_related_identifiers'].reject { |ri| ri == existing.first }
|
248
226
|
end
|
249
227
|
end
|
250
228
|
end
|
251
229
|
|
252
230
|
logger&.debug(message: 'Updating HARVESTER_MODS with:', details: original)
|
253
|
-
|
254
|
-
|
255
|
-
logger&.debug(message: 'After deleting dmphub_modifications:', details: json)
|
256
|
-
json
|
231
|
+
logger&.debug(message: 'Returning updated VERSION:', details: version)
|
232
|
+
version
|
257
233
|
end
|
258
234
|
end
|
259
235
|
end
|
data/lib/uc3-dmp-id/version.rb
CHANGED