uc3-dmp-id 0.0.51 → 0.0.52

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: bfeca7fa5375efa50a0ebcf8226695a7a172d9664a7a97444d8654b01e67a088
4
- data.tar.gz: 2a31f49349406d4622653ed033029d22ae9deeb375b4323f1248860250ce0378
3
+ metadata.gz: 3259fcdd4e0878c48793799628f8b99386301581352b694469b311cf72d1e553
4
+ data.tar.gz: d43a114272138af758e54fbb113398fef23d4fe6b2fff8a28b89fc7cd973a367
5
5
  SHA512:
6
- metadata.gz: 9b3a0d5540564443aebe581e57f9d026db7caa7dd89cc9dd9128e5ad75278703b29ea8a1442d42d8a849ee84fcdd793d709f16ec241c4b109390387e544f6317
7
- data.tar.gz: 5143d9fca0e5f8352c48b1bacecdab81f5a7d05acf29bda69b54fe28cddda4a8f3c843f27d559f1f4b84aab326655b1689d6b0b69516be6d8c2ed54cc34c7c9b
6
+ metadata.gz: f539afeb4ddc714a737649b68bfa55e7b2c5b7c49afcb64c7d42a7c1281d59b68523ba7f1188da94026c4cd4b69a75df63f1ef86dc4e7c11523cf48e5e77e9ae
7
+ data.tar.gz: ec959594a81a6b63ccb2f08676c5cd7bfda4de7baefad0acc80020a2f13d4a5198d3f72b8244d608aaa65d88eed52246c369c1337f21fe3e6a4a0bc4a587f065
@@ -57,12 +57,6 @@ module Uc3DmpId
57
57
  existing = json.fetch('dmp', {}).fetch('dmp_id', {})
58
58
  id = existing['identifier'].gsub(%r{https?://}, Helper::PK_DMP_PREFIX) if existing.is_a?(Hash) &&
59
59
  !existing['identifier'].nil?
60
-
61
- puts "_preregister_dmp_id:"
62
- puts provenance
63
- puts json
64
- puts id
65
-
66
60
  return id if !id.nil? &&
67
61
  existing.fetch('type', 'other').to_s.downcase == 'doi' &&
68
62
  provenance.fetch('seedingWithLiveDmpIds', false).to_s.downcase == 'true' &&
@@ -10,11 +10,11 @@ module Uc3DmpId
10
10
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
11
11
  # -------------------------------------------------------------------------
12
12
  def update(provenance:, p_key:, json: {})
13
- raise DeleterError, MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
13
+ raise UpdaterError, MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
14
14
 
15
15
  dmp = Helper.parse_json(json: json)
16
16
  errs = _updateable?(provenance: provenance, p_key: p_key, dmp: dmp)
17
- raise DeleterError, errs if errs.is_a?(Array) && errs.any?
17
+ raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
18
18
 
19
19
  # Add the DMPHub specific attributes
20
20
  annotated = Helper.annotate_dmp(provenance: provenance, json: dmp['dmp'], p_key: p_key)
@@ -23,15 +23,15 @@ module Uc3DmpId
23
23
  client = Uc3DmpDynamo::Client.new(debug: debug)
24
24
  existing = Finder.by_pk(p_key: p_key, client: client, debug: debug)
25
25
  # Don't continue if nothing has changed!
26
- raise DeleterError, MSG_NO_CHANGE if Helper.eql?(dmp_a: existing, dmp_b: annotated)
26
+ raise UpdaterError, MSG_NO_CHANGE if Helper.eql?(dmp_a: existing, dmp_b: annotated)
27
27
 
28
28
  # Generate a new version of the DMP. This involves versioning the current latest version
29
29
  new_version = versioner.new_version(p_key: p_key, dmp: json)
30
- raise DeleterError, MSG_DMP_UNABLE_TO_VERSION if new_version.nil?
30
+ raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if new_version.nil?
31
31
 
32
32
  # Save the changes as the new latest version
33
33
  resp = client.put_item(json: new_version, debug: debug)
34
- raise DeleterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
34
+ raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
35
35
 
36
36
  # Send the updates to EZID, notify the provenance and download the PDF if applicable
37
37
  _post_process(json: dmp, debug: debug)
@@ -40,6 +40,30 @@ module Uc3DmpId
40
40
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
41
41
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
42
42
 
43
+ def attach_narrative(provenance:, p_key:, url:, debug: false)
44
+ raise UpdaterError, MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
45
+
46
+ # fetch the existing latest version of the DMP ID
47
+ client = Uc3DmpDynamo::Client.new(debug: debug)
48
+ dmp = Finder.by_pk(p_key: p_key, client: client, debug: debug)
49
+ # Don't continue if nothing has changed!
50
+ raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil?
51
+
52
+ errs = _updateable?(provenance: provenance, p_key: p_key, dmp: dmp)
53
+ raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
54
+
55
+ # Add the DMPHub specific attributes
56
+ annotated = Helper.annotate_dmp(provenance: provenance, json: dmp['dmp'], p_key: p_key)
57
+ annotated['dmproadmap_related_identifiers'] = [] if annotated['dmproadmap_related_identifiers'].nil?
58
+ annotated << { descriptor: 'is_metadata_for', work_type: 'output_management_plan', type: 'url', identifier: url }
59
+
60
+ # Save the changes as the new latest version
61
+ resp = client.put_item(json: annotated, debug: debug)
62
+ raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
63
+
64
+ true
65
+ end
66
+
43
67
  private
44
68
 
45
69
  # Check if the DMP ID is updateable by the provenance
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.51'
4
+ VERSION = '0.0.52'
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.0.51
4
+ version: 0.0.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley