uc3-dmp-id 0.1.49 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-id/finder.rb +89 -62
- data/lib/uc3-dmp-id/updater.rb +2 -4
- 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: 1da21791c323e09fa4bbf7fc3da0ef27eff01b41e515386283adece51ad1b3b2
|
4
|
+
data.tar.gz: 712798fe2dcee1ee6169802b5ac91eff5ca852878ea4e27f4165a8bd718fa9af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b8b75779891e9fc20c060f61bc02ada59f43d576cb0f17625e1d10a178a5bc30c3cab5b4f368fcfe0db09dcf5c461079e441bf693ae20f106a3c9567b3214d
|
7
|
+
data.tar.gz: f925705ac81607778c2a6757567e870791289f625ac954b8cc5f5d82c001df4b55854a1ed20a0e97fb2d14cb4fd92bf748129181a7ed633da43f15dcdc7f6d70
|
data/lib/uc3-dmp-id/finder.rb
CHANGED
@@ -17,22 +17,19 @@ module Uc3DmpId
|
|
17
17
|
MSG_MISSING_PROV_ID = 'No Provenance identifier was provided. \
|
18
18
|
Expected: `{ "dmp_id": { "identifier": "value", "type": "value" }`'
|
19
19
|
|
20
|
+
ORCID_DOMAIN = 'orcid.org'
|
21
|
+
ROR_DOMAIN = 'ror.org'
|
22
|
+
|
20
23
|
class << self
|
21
24
|
# TODO: Replace this with ElasticSearch
|
22
25
|
def search_dmps(args:, logger: nil)
|
23
|
-
client = Uc3DmpDynamo::Client.new
|
24
|
-
return _by_owner(
|
26
|
+
client = Uc3DmpDynamo::Client.new(table: ENV['DYNAMO_INDEX_TABLE'])
|
27
|
+
return _by_owner(owner: args['owner'], client:, logger:) unless args['owner'].nil?
|
28
|
+
return _by_org(org: args['org'], client:, logger:) unless args['org'].nil?
|
29
|
+
return _by_funder(funder: args['funder'], client:, logger:) unless args['funder'].nil?
|
30
|
+
return _by_featured(client:, logger:) if args.fetch('featured', 'false').to_s.downcase == 'true'
|
25
31
|
|
26
|
-
|
27
|
-
return _by_owner_org(owner_org: args['owner_org_ror'], client:,
|
28
|
-
logger:)
|
29
|
-
end
|
30
|
-
unless args['modification_day'].nil?
|
31
|
-
return _by_mod_day(day: args['modification_day'], client:,
|
32
|
-
logger:)
|
33
|
-
end
|
34
|
-
|
35
|
-
[]
|
32
|
+
return _publicly_visible(client:, logger:)
|
36
33
|
end
|
37
34
|
|
38
35
|
# Find a DMP based on the contents of the incoming JSON
|
@@ -134,72 +131,102 @@ module Uc3DmpId
|
|
134
131
|
|
135
132
|
private
|
136
133
|
|
137
|
-
# Fetch the DMP IDs for the specified
|
138
|
-
def _by_owner(
|
139
|
-
|
140
|
-
|
134
|
+
# Fetch the DMP IDs for the specified person's ORCID (or email)
|
135
|
+
def _by_owner(owner:, client: nil, logger: nil)
|
136
|
+
orcid_regex = /^([0-9A-Z]{4}-){3}[0-9A-Z]{4}$/
|
137
|
+
email_regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
138
|
+
email = owner.trim() unless owner.to_s =~ email_regex).nil?
|
139
|
+
|
140
|
+
if email.nil?
|
141
|
+
args = {
|
142
|
+
filter_expression: 'contains(:people_ids, people)',
|
143
|
+
expression_attribute_values: {
|
144
|
+
':sk': 'METADATA',
|
145
|
+
':people_ids': [
|
146
|
+
"http://#{ORCID_DOMAIN}/#{owner}",
|
147
|
+
"https://#{ORCID_DOMAIN}/#{owner}"
|
148
|
+
]
|
149
|
+
}
|
150
|
+
}
|
151
|
+
else
|
152
|
+
args = {
|
153
|
+
filter_expression: 'contains(:people, people)',
|
154
|
+
expression_attribute_values: { ':sk': 'METADATA', ':people': [email] }
|
155
|
+
}
|
156
|
+
end
|
157
|
+
logger&.debug(message: 'Fetch relevant DMPs _by_owner - scan args', details: args)
|
158
|
+
resp = client.scan(args)
|
159
|
+
|
160
|
+
client = Uc3DmpDynamo::Client.new if client.nil?
|
161
|
+
_process_search_response(response: client.query(args:, logger:))
|
162
|
+
end
|
163
|
+
|
164
|
+
# Fetch the DMP IDs for the specified organization/institution
|
165
|
+
def _by_org(org:, client: nil, logger: nil)
|
166
|
+
regex = /^[a-zA-Z0-9]+$/
|
167
|
+
ror = org.trim() unless (org.to_s =~ regex).nil?
|
141
168
|
|
142
169
|
args = {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
}
|
152
|
-
},
|
153
|
-
filter_expression: 'SK = :version',
|
154
|
-
expression_attribute_values: { ':version': Helper::DMP_LATEST_VERSION }
|
170
|
+
filter_expression: 'contains(:affiliation_ids, affiliation_ids)',
|
171
|
+
expression_attribute_values: {
|
172
|
+
':sk': 'METADATA',
|
173
|
+
':affiliation_ids': [
|
174
|
+
"http://#{ROR_DOMAIN}/#{ror}",
|
175
|
+
"https://#{ROR_DOMAIN}/#{ror}"
|
176
|
+
]
|
177
|
+
}
|
155
178
|
}
|
156
|
-
logger
|
179
|
+
logger&.debug(message: 'Fetch relevant DMPs _by_org - scan args', details: args)
|
180
|
+
resp = client.scan(args)
|
181
|
+
|
157
182
|
client = Uc3DmpDynamo::Client.new if client.nil?
|
158
183
|
_process_search_response(response: client.query(args:, logger:))
|
159
184
|
end
|
160
185
|
|
161
|
-
# Fetch the DMP IDs for the specified
|
162
|
-
|
163
|
-
def _by_owner_org(owner_org:, client: nil, logger: nil)
|
186
|
+
# Fetch the DMP IDs for the specified funder
|
187
|
+
def _by_funder(funder:, client: nil, logger: nil)
|
164
188
|
regex = /^[a-zA-Z0-9]+$/
|
165
|
-
|
189
|
+
ror = funder.trim() unless (funder.to_s =~ regex).nil?
|
166
190
|
|
167
191
|
args = {
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
}
|
177
|
-
},
|
178
|
-
filter_expression: 'SK = :version',
|
179
|
-
expression_attribute_values: { ':version': Helper::DMP_LATEST_VERSION }
|
192
|
+
filter_expression: 'contains(:funder_ids, funder_ids)',
|
193
|
+
expression_attribute_values: {
|
194
|
+
':sk': 'METADATA',
|
195
|
+
':funder_ids': [
|
196
|
+
"http://#{ROR_DOMAIN}/#{ror}",
|
197
|
+
"https://#{ROR_DOMAIN}/#{ror}"
|
198
|
+
]
|
199
|
+
}
|
180
200
|
}
|
181
|
-
logger
|
201
|
+
logger&.debug(message: 'Fetch relevant DMPs _by_funder - scan args', details: args)
|
202
|
+
resp = client.scan(args)
|
203
|
+
|
182
204
|
client = Uc3DmpDynamo::Client.new if client.nil?
|
183
205
|
_process_search_response(response: client.query(args:, logger:))
|
184
206
|
end
|
185
207
|
|
186
|
-
# Fetch the DMP IDs
|
187
|
-
def
|
188
|
-
|
189
|
-
|
208
|
+
# Fetch the DMP IDs that are marked as featured
|
209
|
+
def _by_featured(client: nil, logger: nil)
|
210
|
+
args = {
|
211
|
+
filter_expression: ':featured = featured',
|
212
|
+
expression_attribute_values: { ':sk': 'METADATA', ':featured': 1 }
|
213
|
+
}
|
214
|
+
logger&.debug(message: 'Fetch relevant DMPs _by_featured - scan args', details: args)
|
215
|
+
resp = client.scan(args)
|
216
|
+
|
217
|
+
client = Uc3DmpDynamo::Client.new if client.nil?
|
218
|
+
_process_search_response(response: client.query(args:, logger:))
|
219
|
+
end
|
190
220
|
|
221
|
+
# Return all of the publicly visible DMPs
|
222
|
+
def _publicly_visible(client: nil, logger: nil)
|
191
223
|
args = {
|
192
|
-
|
193
|
-
|
194
|
-
dmphub_modification_day: {
|
195
|
-
attribute_value_list: [day.to_s],
|
196
|
-
comparison_operator: 'IN'
|
197
|
-
}
|
198
|
-
},
|
199
|
-
filter_expression: 'SK = :version',
|
200
|
-
expression_attribute_values: { ':version': Helper::DMP_LATEST_VERSION }
|
224
|
+
filter_expression: ':visibility = visibility',
|
225
|
+
expression_attribute_values: { ':sk': 'METADATA', ':visibility': 'public' }
|
201
226
|
}
|
202
|
-
logger
|
227
|
+
logger&.debug(message: 'Fetch relevant DMPs _publicly_visible - scan args', details: args)
|
228
|
+
resp = client.scan(args)
|
229
|
+
|
203
230
|
client = Uc3DmpDynamo::Client.new if client.nil?
|
204
231
|
_process_search_response(response: client.query(args:, logger:))
|
205
232
|
end
|
@@ -212,8 +239,8 @@ module Uc3DmpId
|
|
212
239
|
next if item.nil?
|
213
240
|
|
214
241
|
dmp = item['dmp'].nil? ? JSON.parse({ dmp: item }.to_json) : item
|
215
|
-
dmp = _remove_narrative_if_private(json: dmp)
|
216
|
-
Helper.cleanse_dmp_json(json: dmp)
|
242
|
+
# dmp = _remove_narrative_if_private(json: dmp)
|
243
|
+
# Helper.cleanse_dmp_json(json: dmp)
|
217
244
|
end
|
218
245
|
results.compact.uniq
|
219
246
|
end
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -208,11 +208,9 @@ module Uc3DmpId
|
|
208
208
|
next if entry.fetch('dmproadmap_related_identifiers', []).empty?
|
209
209
|
|
210
210
|
entry['dmproadmap_related_identifiers'].each do |related|
|
211
|
-
|
212
|
-
related_id = mods['related_works'][related['identifier']] if related_id.nil?
|
213
|
-
next if related_id.nil?
|
211
|
+
next if mods['related_works'][related.identifier].nil?
|
214
212
|
|
215
|
-
mods['related_works'][
|
213
|
+
mods['related_works'][related.identifier]['status'] = related['status']
|
216
214
|
end
|
217
215
|
end
|
218
216
|
|
data/lib/uc3-dmp-id/version.rb
CHANGED