uc3-dmp-id 0.1.75 → 0.1.77

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: 18cc7a2a74f91898c76cb8686c511023bc31dd2147d92bd172ae7a00a2dd72b3
4
- data.tar.gz: ab9b8e2009e384fc1b20a99ea92dc92ddabc1779c9c6d02ed369d171724766cb
3
+ metadata.gz: dcc7bf54d3beeb3610d64490a6037022fbef6569ae0ee67188eeafea34a67ae7
4
+ data.tar.gz: 722e4bd441ed71e9265d6bde56663cccc6b4ccbf49178ac24d1b46072aa97295
5
5
  SHA512:
6
- metadata.gz: d989d0ea6f7e7cb0486f9b7982a40f4085dc4056576c7f4bb0225b5d37f1fb9175fc57f3628a3d1e1cd2cf342305fb79791681798657c58f0be6bccc61bee5aa
7
- data.tar.gz: 71379ba74f63add7f9443b0a85b30cb64664e5602499cabd91f27512a5b0567bb88f83e9890efd42e8b6914267457aabfb177ee616eb3925939991c147e1fe4d
6
+ metadata.gz: 293ab0fd326ff54633662b53aae5a82a24b456593134196c0f15e167a3acaf57706ee2c432e4ba3bb1ef382f80540f3df9cc7074312606d58c6ec3d1a9c54da9
7
+ data.tar.gz: a0f9ee659c34501642287dfc4cbbd77b4e184d09272cac143df8d2fd60fab51a05ab5c24d50647c5650b9b8dcd55162b4c4394e65f54748e6ff0ca2e0f4a429a
@@ -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, version:, 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_') &&
145
- !%w[dmphub_modifications dmphub_versions].include?(key)
146
- end
147
- keys_to_retain.each { |key| mods[key] = version[key] }
148
-
149
- mods['PK'] = version['PK']
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
@@ -196,7 +174,7 @@ module Uc3DmpId
196
174
  # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
197
175
 
198
176
  # Fetch any Harvester modifications to the JSON
199
- def _process_harvester_mods(client:, p_key:, json:, logger: nil)
177
+ def _process_harvester_mods(client:, p_key:, json:, version:, logger: nil)
200
178
  logger&.debug(message: 'Incoming modifications', details: json)
201
179
  return json if json.fetch('dmphub_modifications', []).empty?
202
180
 
@@ -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.75'
4
+ VERSION = '0.1.77'
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.75
4
+ version: 0.1.77
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley