uc3-dmp-id 0.0.12 → 0.0.14
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 +21 -6
- data/lib/uc3-dmp-id/version.rb +1 -1
- 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: db1f76572c527c11eaf8e14afa51c095eab796c53c631d6fe1b78bca2c5f3395
|
4
|
+
data.tar.gz: 671c4b0a629837069b23286876b2cd871caab2f9df1bc011b91e68f68bf45bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c00b9f95b7b5fefac06ba75696e6b5fc6b1ddb244093888b08899b79d2df98996a70c7c3026bcebcc3bf91030fced1172587dc1494419dad101cd30e1a87bf
|
7
|
+
data.tar.gz: 4664882d1dbf1ef2ba593b8ca4858829b4c05e767bb94e107a7db6b24370ca6739983b53b66eef56909bb7f713fdaeba05f8d71217ae181ad87ef43824d6d64d
|
data/lib/uc3-dmp-id/finder.rb
CHANGED
@@ -60,21 +60,26 @@ module Uc3DmpId
|
|
60
60
|
def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, debug: false)
|
61
61
|
raise Uc3DmpIdFinderError, MSG_MISSING_PK if p_key.nil?
|
62
62
|
|
63
|
-
s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.strip.empty?
|
63
|
+
s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.to_s.strip.empty?
|
64
|
+
|
65
|
+
puts "PK: #{p_key}, SK: #{s_key}"
|
64
66
|
|
65
67
|
client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
|
66
68
|
resp = client.get_item(
|
67
69
|
key: {
|
68
70
|
PK: Helper.append_pk_prefix(p_key: p_key),
|
69
|
-
SK: s_key
|
71
|
+
SK: s_key
|
70
72
|
}
|
71
73
|
)
|
72
74
|
return resp unless resp.is_a?(Hash)
|
73
75
|
|
76
|
+
puts "FETCHED:"
|
77
|
+
puts resp
|
78
|
+
|
74
79
|
dmp = resp['dmp'].nil? ? JSON.parse({ dmp: resp }.to_json) : resp
|
75
|
-
return nil if
|
80
|
+
return nil if dmp['dmp']['PK'].nil?
|
76
81
|
|
77
|
-
_append_versions(p_key:
|
82
|
+
_append_versions(p_key: dmp['dmp']['PK'], dmp: dmp, client: client, debug: debug)
|
78
83
|
end
|
79
84
|
|
80
85
|
# Attempt to find the DMP item by the provenance system's identifier
|
@@ -98,7 +103,7 @@ module Uc3DmpId
|
|
98
103
|
return resp unless resp.is_a?(Hash)
|
99
104
|
|
100
105
|
dmp = resp['dmp'].nil? ? JSON.parse({ dmp: resp }.to_json) : resp
|
101
|
-
return nil if
|
106
|
+
return nil if dmp['dmp']['PK'].nil?
|
102
107
|
|
103
108
|
# If we got a hit, fetch the DMP and return it.
|
104
109
|
by_pk(p_key: dmp['dmp']['PK'], s_key: dmp['dmp']['SK'])
|
@@ -112,10 +117,16 @@ module Uc3DmpId
|
|
112
117
|
def _append_versions(p_key:, dmp:, client: nil, debug: false)
|
113
118
|
return dmp if p_key.nil? || !dmp.is_a?(Hash) || dmp['dmp'].nil?
|
114
119
|
|
120
|
+
puts "FETCHING VERSIONS"
|
121
|
+
|
115
122
|
results = versions(p_key: p_key, client: client, debug: debug)
|
116
123
|
return dmp unless results.length > 1
|
117
124
|
|
118
|
-
versions = results.map do |
|
125
|
+
versions = results.map do |ver|
|
126
|
+
|
127
|
+
puts version
|
128
|
+
|
129
|
+
version = ver['dmp'].nil? ? JSON.parse({ dmp: ver }.to_json) : ver
|
119
130
|
next if version.fetch('dmp', {})['modified'].nil?
|
120
131
|
|
121
132
|
timestamp = version['dmp']['modified']
|
@@ -125,6 +136,10 @@ module Uc3DmpId
|
|
125
136
|
}
|
126
137
|
end
|
127
138
|
dmp['dmp']['dmphub_versions'] = JSON.parse(versions.to_json)
|
139
|
+
|
140
|
+
puts "AFTER APPENDING VERSIONS:"
|
141
|
+
puts dmp
|
142
|
+
|
128
143
|
dmp
|
129
144
|
end
|
130
145
|
# rubocop:enable Metrics/AbcSize
|
data/lib/uc3-dmp-id/version.rb
CHANGED