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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 216eee2772c1e88ec1426ef8d0414e61958cfd3185149c999d19c02e38a9d32d
4
- data.tar.gz: f97512390c550f0714381c75a8d8c9365de356d0d02db87be16081608084ac89
3
+ metadata.gz: 9d18daee8127652273ede255b35ce9c8401354f5082c4f1806737b2486dc7178
4
+ data.tar.gz: a2b7599f05bc790822d80e5ec7dd83a64ef42ef5fd52cc4eae5db90792d0185a
5
5
  SHA512:
6
- metadata.gz: 26491648692773b00eeae89efeb47f1f3c9c33897705974c6497193b21cbfc4a4b184b7ba0e9976751b2dad9e4c7d72c2cfc2867458bbbc81c4803614a4bff12
7
- data.tar.gz: 59a869cb83864807167ccb21a4ce9f409afd73d60895d32ba91270da5fa7715e59d8e5310f576d6c582e40ec33961f2fe6fa2715622d5a71c5448234ad915830
6
+ metadata.gz: 72080a3809333bd1c3dacd7540c7bf108bf99b8fa0fa6b0450aae2180af8ff175ab273f9509f26043c01a14c0d45a478c4c242798c5f571a1befcdfe5a9784d8
7
+ data.tar.gz: 887b4651957305c709eaec3139735b83854d432dd8894777c0437ee4d243d09ff98a2244f9dd9486474ec89e56c8470d8b8ddad527f2507d83b7c0c903c544e2
@@ -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
- payload = _process_harvester_mods(client:, p_key:, json: payload, logger:)
49
- logger&.debug(message: 'Mods after process_harvester_mods', details: payload)
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 because we don't want to save it on the record
52
- payload.delete('dmphub_versions')
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
- payload['modified'] = now.iso8601
61
- payload['dmphub_modification_day'] = now.strftime('%Y-%m-%d')
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: payload, logger:)
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: payload, logger:)
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
- json = JSON.parse({ dmp: payload }.to_json)
75
- json = Versioner.append_versions(p_key:, dmp: json, client:, logger:)
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 = json['dmproadmap_related_identifiers'].select do |ri|
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
- json['dmproadmap_related_identifiers'] << {
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
- }.to_json
245
- elsif related['status'] != 'approved' && existing.any?
222
+ }
223
+ elsif related['status'] == 'rejected' && existing.any?
246
224
  # otherwise remove it
247
- json['dmproadmap_related_identifiers'] = json['dmproadmap_related_identifiers'].reject { |ri| ri == existing.first }
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
- client.put_item(json: original, logger:)
254
- json.delete('dmphub_modifications')
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.74'
4
+ VERSION = '0.1.76'
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.74
4
+ version: 0.1.76
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley