uc3-dmp-id 0.0.51 → 0.0.53
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/creator.rb +0 -6
- data/lib/uc3-dmp-id/updater.rb +29 -5
- data/lib/uc3-dmp-id/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c6aefe84a14cc3fed061803e17239d43059129ba99834def60393b53128b7c2
|
4
|
+
data.tar.gz: fb432fe944e5c9db435ce031e602f19ae503de8ba5efb6a8efaf17baedfd521a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d37cb0887e748983735c5100130185d130807fa72ffbcc22ce5c0937439b03fcdbdd5b6fa4f369581a56a8eb79c9a7ca7891e1f17b16ee7b727626643f1ac2f
|
7
|
+
data.tar.gz: c67d9e3a5601534f103895a3f507e3b9ae3e2bddb880f92de1a3a01a7fe6de595b144bac818040e7388847cd2edfff817f3602772027d9cf69c70c4e1e5c4c8d
|
data/lib/uc3-dmp-id/creator.rb
CHANGED
@@ -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' &&
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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, json: 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
|
data/lib/uc3-dmp-id/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|