uc3-dmp-id 0.0.92 → 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 +10 -6
- 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
@@ -32,11 +32,13 @@ module Uc3DmpId
|
|
32
32
|
# - Splicing in the current changes onto the existing `VERSION#latest` item
|
33
33
|
# - Returning the spliced `VERSION#latest` back to this method
|
34
34
|
def new_version(provenance:, p_key:, client: nil, dmp:, latest_version: {}, logger: nil)
|
35
|
-
return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(dmp: dmp)
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
puts "Provenance: #{provenance}, PK: #{p_key}"
|
37
|
+
puts dmp
|
38
|
+
|
39
|
+
return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(p_key: p_key, dmp: latest_version)
|
40
|
+
|
41
|
+
client = Uc3DmpDynamo::Client.new if client.nil?
|
40
42
|
|
41
43
|
owner = latest_version['dmphub_provenance_id']
|
42
44
|
updater = provenance['PK']
|
@@ -82,8 +84,10 @@ module Uc3DmpId
|
|
82
84
|
private
|
83
85
|
|
84
86
|
# Determine whether the specified DMP metadata is versionable - returns boolean
|
85
|
-
def _versionable?(dmp:)
|
86
|
-
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
|
87
91
|
|
88
92
|
# It's versionable if it has a DMP ID
|
89
93
|
!dmp.fetch('dmp_id', {})['identifier'].nil?
|