uc3-dmp-id 0.0.75 → 0.0.77
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 +10 -7
- data/lib/uc3-dmp-id/updater.rb +10 -0
- data/lib/uc3-dmp-id/version.rb +1 -1
- data/lib/uc3-dmp-id/versioner.rb +7 -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: bae071224d4e143bf9f192f5b32bd755c752c0634c3314ec71480a3a48d1ad93
|
4
|
+
data.tar.gz: ff1e3c94a9e09dbd400833a5a90d1bb080dd6f2f47ad55c198982466daad578f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f477d5ae13ae8c352a720faa71a91532884db19859e9399962c1481966d98610a407c2b5abf16e33d09a19061f2643dee1b91315df88983654671a64f0279461
|
7
|
+
data.tar.gz: 0f4c206e3fa4b5ac476b6e39f89a24926b75637115819d83c55aa5eddbc2b37de54e7dfe0355c70a8f28441c09fa50d299c9b935cc77aa3026056fcf243e2e24
|
data/lib/uc3-dmp-id/finder.rb
CHANGED
@@ -19,10 +19,10 @@ module Uc3DmpId
|
|
19
19
|
|
20
20
|
class << self
|
21
21
|
# TODO: Replace this with ElasticSearch
|
22
|
-
def search_dmps(args:, debug:
|
23
|
-
return _by_owner(owner_org: args['owner_orcid']) unless args['owner_orcid'].nil?
|
24
|
-
return _by_owner_org(owner_org: args['owner_org_ror']) unless args['owner_org_ror'].nil?
|
25
|
-
return _by_mod_day(day: args['modification_day']) unless args['modification_day'].nil?
|
22
|
+
def search_dmps(args:, debug: false)
|
23
|
+
return _by_owner(owner_org: args['owner_orcid'], debug: debug) unless args['owner_orcid'].nil?
|
24
|
+
return _by_owner_org(owner_org: args['owner_org_ror'], debug: debug) unless args['owner_org_ror'].nil?
|
25
|
+
return _by_mod_day(day: args['modification_day'], debug: debug) unless args['modification_day'].nil?
|
26
26
|
|
27
27
|
[]
|
28
28
|
end
|
@@ -115,7 +115,7 @@ module Uc3DmpId
|
|
115
115
|
private
|
116
116
|
|
117
117
|
# Fetch the DMP IDs for the specified owner's ORCID (the owner is the :dmphub_owner_id on the DMP ID record)
|
118
|
-
def _by_owner(owner_id:)
|
118
|
+
def _by_owner(owner_id:, debug: false)
|
119
119
|
regex = %r{^([0-9A-Z]{4}-){3}[0-9A-Z]{4}$}
|
120
120
|
raise FinderError, MSG_INVALID_OWNER_ID if owner_id.nil? || (owner_id.to_s.downcase =~ regex).nil?
|
121
121
|
|
@@ -133,12 +133,13 @@ module Uc3DmpId
|
|
133
133
|
filter_expression: 'SK = :version',
|
134
134
|
expression_attribute_values: { ':version': Helper::DMP_LATEST_VERSION }
|
135
135
|
}
|
136
|
+
puts "Querying _by_owner with #{args}" if debug
|
136
137
|
client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
|
137
138
|
_process_search_response(response: client.query(args: args))
|
138
139
|
end
|
139
140
|
|
140
141
|
# Fetch the DMP IDs for the specified organization/institution (the org is the :dmphub_owner_org on the DMP ID record)
|
141
|
-
def _by_owner_org(owner_org:)
|
142
|
+
def _by_owner_org(owner_org:, debug: false)
|
142
143
|
regex = %r{^[a-zA-Z0-9]+$}
|
143
144
|
raise FinderError, MSG_INVALID_OWNER_ID if owner_org.nil? ||(owner_org.to_s.downcase =~ regex).nil?
|
144
145
|
|
@@ -156,12 +157,13 @@ module Uc3DmpId
|
|
156
157
|
filter_expression: 'SK = :version',
|
157
158
|
expression_attribute_values: { ':version': Helper::DMP_LATEST_VERSION }
|
158
159
|
}
|
160
|
+
puts "Querying _by_owner_org with #{args}" if debug
|
159
161
|
client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
|
160
162
|
_process_search_response(response: client.query(args: args))
|
161
163
|
end
|
162
164
|
|
163
165
|
# Fetch the DMP IDs modified on the specified date (the date is the :dmphub_modification_day on the DMP ID record)
|
164
|
-
def _by_mod_day(day:)
|
166
|
+
def _by_mod_day(day:, debug: false)
|
165
167
|
regex = %r{^[0-9]{4}(-[0-9]{2}){2}}
|
166
168
|
raise FinderError, MSG_INVALID_OWNER_ID if day.nil? || (day.to_s =~ regex).nil?
|
167
169
|
|
@@ -176,6 +178,7 @@ module Uc3DmpId
|
|
176
178
|
filter_expression: 'SK = :version',
|
177
179
|
expression_attribute_values: { ':version': Helper::DMP_LATEST_VERSION }
|
178
180
|
}
|
181
|
+
puts "Querying _by_mod_day with #{args}" if debug
|
179
182
|
client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
|
180
183
|
_process_search_response(response: client.query(args: args))
|
181
184
|
end
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -14,11 +14,17 @@ module Uc3DmpId
|
|
14
14
|
|
15
15
|
dmp = Helper.parse_json(json: json)
|
16
16
|
errs = _updateable?(provenance: provenance, p_key: p_key, dmp: dmp)
|
17
|
+
|
18
|
+
puts "Updateable? #{errs}"
|
19
|
+
|
17
20
|
raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
|
18
21
|
|
19
22
|
# Add the DMPHub specific attributes
|
20
23
|
annotated = Helper.annotate_dmp(provenance: provenance, json: dmp['dmp'], p_key: p_key)
|
21
24
|
|
25
|
+
puts 'Annotated:'
|
26
|
+
puts annotated
|
27
|
+
|
22
28
|
# fetch the existing latest version of the DMP ID
|
23
29
|
client = Uc3DmpDynamo::Client.new(debug: debug)
|
24
30
|
existing = Finder.by_pk(p_key: p_key, client: client, debug: debug)
|
@@ -27,6 +33,10 @@ module Uc3DmpId
|
|
27
33
|
|
28
34
|
# Generate a new version of the DMP. This involves versioning the current latest version
|
29
35
|
new_version = versioner.new_version(p_key: p_key, dmp: json)
|
36
|
+
|
37
|
+
puts 'DMP after splicing all changes:'
|
38
|
+
puts new_version
|
39
|
+
|
30
40
|
raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if new_version.nil?
|
31
41
|
|
32
42
|
# Save the changes as the new latest version
|
data/lib/uc3-dmp-id/version.rb
CHANGED
data/lib/uc3-dmp-id/versioner.rb
CHANGED
@@ -46,7 +46,7 @@ module Uc3DmpId
|
|
46
46
|
|
47
47
|
args = { owner: owner, updater: updater, base: prior, mods: dmp, debug: debug }
|
48
48
|
puts 'DMP ID update prior to splicing changes' if debug
|
49
|
-
puts dmp
|
49
|
+
puts dmp if debug
|
50
50
|
|
51
51
|
args = { owner: owner, updater: updater, base: prior, mods: dmp, debug: debug }
|
52
52
|
# If the system of provenance is making the change then just use the
|
@@ -96,9 +96,15 @@ module Uc3DmpId
|
|
96
96
|
# Only create a version if the Updater is not the Owner OR the changes have happened on a different day
|
97
97
|
mod_time = Time.parse(latest_version.fetch('dmphub_updated_at', Time.now.iso8601))
|
98
98
|
now = Time.now
|
99
|
+
|
100
|
+
puts "_generate_version -- mod_time: #{mod_time} --> !(now - mod_time).is_a?(Float)"
|
101
|
+
|
99
102
|
return latest_version if mod_time.nil? || !(now - mod_time).is_a?(Float)
|
100
103
|
|
101
104
|
same_hour = (now - mod_time).round <= 3600
|
105
|
+
|
106
|
+
puts "_generate_version -- owner is updater? #{owner == updater}, same hour? #{same_hour}"
|
107
|
+
|
102
108
|
return latest_version if owner != updater || (owner == updater && same_hour)
|
103
109
|
|
104
110
|
latest_version['SK'] = "#{Helper::SK_DMP_PREFIX}#{latest_version['dmphub_updated_at'] || Time.now.iso8601}"
|