uc3-dmp-id 0.0.93 → 0.0.94
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/finder.rb +2 -2
- data/lib/uc3-dmp-id/updater.rb +1 -1
- data/lib/uc3-dmp-id/version.rb +1 -1
- data/lib/uc3-dmp-id/versioner.rb +5 -5
- 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: 6e1f1181484200c982f852613b05b15f2e7a7e5ada500395d0c3d2dadc784f9e
|
4
|
+
data.tar.gz: c8edfcf737056d7e81f29545ccaefc6206da8e20a76ae42754206204a82145be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eed9ebc90a13702268f189f24ae23909227adb2531a53f709599483d1075372b1ce0442d6e8b158e280d493e8a7dd6ab053fe2fd21f7b5f7ac9dd30608a4c914
|
7
|
+
data.tar.gz: fe1042e750a090a3e5d9f5447e17a7a2a378294a4dccd866c09d5fe76f21ce75db9cd6c72882dab7261758c2be687070b23f87044b14aa5219b5c42e20ad0718
|
data/lib/uc3-dmp-id/finder.rb
CHANGED
@@ -49,7 +49,7 @@ module Uc3DmpId
|
|
49
49
|
|
50
50
|
# Find the DMP by its PK and SK
|
51
51
|
# -------------------------------------------------------------------------
|
52
|
-
def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, logger: nil)
|
52
|
+
def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, cleanse: true, logger: nil)
|
53
53
|
raise FinderError, MSG_MISSING_PK if p_key.nil?
|
54
54
|
|
55
55
|
s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.to_s.strip.empty?
|
@@ -67,7 +67,7 @@ module Uc3DmpId
|
|
67
67
|
return nil if dmp['dmp']['PK'].nil?
|
68
68
|
|
69
69
|
dmp = Versioner.append_versions(p_key: dmp['dmp']['PK'], dmp: dmp, client: client, logger: logger)
|
70
|
-
Helper.cleanse_dmp_json(json: dmp)
|
70
|
+
cleanse ? Helper.cleanse_dmp_json(json: dmp) : dmp
|
71
71
|
end
|
72
72
|
|
73
73
|
# Fetch just the PK to see if a record exists
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -21,7 +21,7 @@ module Uc3DmpId
|
|
21
21
|
|
22
22
|
# fetch the existing latest version of the DMP ID
|
23
23
|
client = Uc3DmpDynamo::Client.new(logger: logger)
|
24
|
-
existing = Finder.by_pk(p_key: p_key, client: client, logger: logger)
|
24
|
+
existing = Finder.by_pk(p_key: p_key, client: client, logger: logger, cleanse: false)
|
25
25
|
logger.debug(message: "Existing latest record", details: existing) if logger.respond_to?(:debug)
|
26
26
|
|
27
27
|
errs = _updateable?(provenance: provenance, p_key: p_key, json: annotated)
|
data/lib/uc3-dmp-id/version.rb
CHANGED
data/lib/uc3-dmp-id/versioner.rb
CHANGED
@@ -36,11 +36,9 @@ module Uc3DmpId
|
|
36
36
|
puts "Provenance: #{provenance}, PK: #{p_key}"
|
37
37
|
puts dmp
|
38
38
|
|
39
|
-
return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(dmp:
|
39
|
+
return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(p_key: p_key, dmp: latest_version)
|
40
40
|
|
41
41
|
client = Uc3DmpDynamo::Client.new if client.nil?
|
42
|
-
latest_version = Finder.by_p_key(client: client, p_key: p_key) unless latest_version.is_a?(Hash) &&
|
43
|
-
!latest_version['PK'].nil?
|
44
42
|
|
45
43
|
owner = latest_version['dmphub_provenance_id']
|
46
44
|
updater = provenance['PK']
|
@@ -86,8 +84,10 @@ puts dmp
|
|
86
84
|
private
|
87
85
|
|
88
86
|
# Determine whether the specified DMP metadata is versionable - returns boolean
|
89
|
-
def _versionable?(dmp:)
|
90
|
-
return false unless dmp.is_a?(Hash) &&
|
87
|
+
def _versionable?(p_key:, dmp:)
|
88
|
+
return false unless dmp.is_a?(Hash) &&
|
89
|
+
dmp['PK']&.to_s&.downcase == p_key&.to_s&.downcase &&
|
90
|
+
dmp['SK'] == Helper::DMP_LATEST_VERSION
|
91
91
|
|
92
92
|
# It's versionable if it has a DMP ID
|
93
93
|
!dmp.fetch('dmp_id', {})['identifier'].nil?
|