uc3-dmp-id 0.0.119 → 0.0.120

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4a11cc424db9e42423e19c76630d0a765a3b97f9c767eb7e40ef51a8b223c68
4
- data.tar.gz: ace4fae3b2c6c8c8aa259de6bc887f4302c606450d9e70d041d6b14761db05a9
3
+ metadata.gz: 8ae962d11255c69b46fcf602f63e2bd4af87dc3ac8890328c195be2aef6ed790
4
+ data.tar.gz: 603c459afac9269cc1b8febc875ded85d5d7cc720137bc2a4e74af80311e5bf7
5
5
  SHA512:
6
- metadata.gz: 5302de9eda8ba796bd5ccc958542c2915c9cda5af8d65f600b3e0583c5151dbb618ec657e71b111406206e803df03435097a24e4dadf7a66fff7a35edce63096
7
- data.tar.gz: e664b942efd9104a386d9f52a584cda0dbd3d37f98a608c9144c40952760c4594e10a68514262fcaa1c465fcb30e3fc88e8306408048f501ac73d40825bc7cd4
6
+ metadata.gz: 31896127df6ff802a4fad901596d746264d95273d0e6d37a2b66f668775101f97fc17a2e242752735c67fa398e0a9b6702311de39bd3d42505f85190761c84d8
7
+ data.tar.gz: 4cc9c80985441ce41c37115b666ee55bcb2b6683e88c38ef963a24814f73cfb70ea34c91701d8ad4a9455cee3648070c11e87f4e80274a71642c860265026eba
@@ -38,7 +38,7 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
38
38
 
39
39
  # Return the modified_version if the timestamps are the same (meaning no new assertions were made while the
40
40
  # user was working on the DMP ID) OR neither version has assertions
41
- return modified_version if latest_version['dmphub_updated_at'] == modified_version['dmphub_updated_at'] ||
41
+ return modified_version if latest_version['modified'] == modified_version['modified'] ||
42
42
  (latest_version.fetch('dmphub_assertions', []).empty? &&
43
43
  modified_version.fetch('dmphub_assertions', []).empty?)
44
44
 
@@ -48,9 +48,9 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
48
48
  logger.debug(message: "Existing assertions", details: existing_assertions) if logger.respond_to?(:debug)
49
49
  logger.debug(message: "Incoming modifications", details: incoming_assertions) if logger.respond_to?(:debug)
50
50
 
51
- # Keep any assetions that were made after the dmphub_updated_at on the incoming changes
51
+ # Keep any assetions that were made after the modified on the incoming changes
52
52
  modified_version['dmphub_assertions'] = existing_assertions.select do |entry|
53
- !entry['timestamp'].nil? && Time.parse(entry['timestamp']) > Time.parse(modified_version['dmphub_updated_at'])
53
+ !entry['timestamp'].nil? && Time.parse(entry['timestamp']) > Time.parse(modified_version['modified'])
54
54
  end
55
55
  return modified_version unless incoming_assertions.any?
56
56
 
@@ -132,7 +132,7 @@ module Uc3DmpId
132
132
  b = deep_copy_dmp(obj: dmp_b)
133
133
 
134
134
  # ignore some of the attributes before comparing
135
- %w[SK dmphub_modification_day dmphub_updated_at dmphub_created_at dmphub_assertions].each do |key|
135
+ %w[SK dmphub_modification_day modified created dmphub_assertions].each do |key|
136
136
  a['dmp'].delete(key) unless a['dmp'][key].nil?
137
137
  b['dmp'].delete(key) unless b['dmp'][key].nil?
138
138
  end
@@ -167,6 +167,7 @@ module Uc3DmpId
167
167
  # Add DMPHub specific fields to the DMP ID JSON
168
168
  def annotate_dmp_json(provenance:, p_key:, json:)
169
169
  json = parse_json(json: json)
170
+ bool_vals = [1, '1', true, 'true', 'yes']
170
171
  return json if provenance.nil? || p_key.nil? || !json.is_a?(Hash)
171
172
 
172
173
  # Fail the json as is if the :PK does not match the :dmp_id if the json has a :PK
@@ -183,13 +184,13 @@ module Uc3DmpId
183
184
  owner_id = extract_owner_id(json: json)
184
185
  owner_org = extract_owner_org(json: json)
185
186
 
187
+ # Set the :dmproadmap_featured flag appropriately
188
+ annotated['dmproadmap_featured'] = bool_vals.include?(annotated['dmproadmap_featured']&.downcase) ? 1 : 0
189
+
186
190
  # Update the modification timestamps
187
191
  annotated['dmphub_modification_day'] = Time.now.strftime('%Y-%m-%d')
188
192
  annotated['dmphub_owner_id'] = owner_id unless owner_id.nil?
189
193
  annotated['dmphub_owner_org'] = owner_org unless owner_org.nil?
190
- annotated['dmphub_updated_at'] = Time.now.iso8601 if annotated['dmphub_updated_at'].nil?
191
- # Only add the Creation date if it is blank
192
- annotated['dmphub_created_at'] = Time.now.iso8601 if json['dmphub_created_at'].nil?
193
194
  return annotated unless json['dmphub_provenance_id'].nil?
194
195
 
195
196
  annotated['dmphub_provenance_id'] = provenance.fetch('PK', '')
@@ -218,7 +219,7 @@ module Uc3DmpId
218
219
  return json.map { |obj| cleanse_dmp_json(json: obj) }.compact if json.is_a?(Array)
219
220
 
220
221
  cleansed = {}
221
- allowable = %w[dmphub_created_at dmphub_updated_at dmphub_versions]
222
+ allowable = %w[dmphub_versions]
222
223
  json.each_key do |key|
223
224
  next if (key.to_s.start_with?('dmphub') && !allowable.include?(key)) || %w[PK SK].include?(key.to_s)
224
225
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.119'
4
+ VERSION = '0.0.120'
5
5
  end
@@ -19,19 +19,19 @@ module Uc3DmpId
19
19
  key_conditions: {
20
20
  PK: { attribute_value_list: [Helper.append_pk_prefix(p_key: p_key)], comparison_operator: 'EQ' }
21
21
  },
22
- projection_expression: 'dmphub_updated_at',
22
+ projection_expression: 'modified',
23
23
  scan_index_forward: false
24
24
  }
25
25
  client = client.nil? ? Uc3DmpDynamo::Client.new : client
26
26
  client.query(args: args, logger: logger)
27
27
  end
28
28
 
29
- # Generate a snapshot of the current latest version of the DMP ID using the existing :dmphub_updated_at as
29
+ # Generate a snapshot of the current latest version of the DMP ID using the existing :modified as
30
30
  # the new SK.
31
31
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
32
32
  def generate_version(client:, latest_version:, owner:, updater:, logger: nil)
33
33
  # Only create a version if the Updater is not the Owner OR the changes have happened on a different day
34
- mod_time = Time.parse(latest_version.fetch('dmphub_updated_at', Time.now.iso8601))
34
+ mod_time = Time.parse(latest_version.fetch('modified', Time.now.iso8601))
35
35
  now = Time.now
36
36
  if mod_time.nil? || !(now - mod_time).is_a?(Float)
37
37
  logger.error(message: "#{SOURCE} unable to determine mod time: #{mod_time}") if logger.respond_to?(:debug)
@@ -47,10 +47,10 @@ module Uc3DmpId
47
47
  return latest_version
48
48
  end
49
49
 
50
- # Make a copy of the latest_version and then update it's SK to the :dmphub_updated_at to mark it in a point of time
50
+ # Make a copy of the latest_version and then update it's SK to the :modified to mark it in a point of time
51
51
  # We essentially make a snapshot of the record before making changes
52
52
  prior = Helper.deep_copy_dmp(obj: latest_version)
53
- prior['SK'] = "#{Helper::SK_DMP_PREFIX}#{latest_version['dmphub_updated_at'] || Time.now.iso8601}"
53
+ prior['SK'] = "#{Helper::SK_DMP_PREFIX}#{latest_version['modified'] || Time.now.iso8601}"
54
54
  # Create the prior version record ()
55
55
  client = client.nil? ? Uc3DmpDynamo::Client.new : client
56
56
  resp = client.put_item(json: prior, logger: logger)
@@ -58,9 +58,6 @@ module Uc3DmpId
58
58
 
59
59
  msg = "#{SOURCE} created version PK: #{prior['PK']} SK: #{prior['SK']}"
60
60
  logger.info(message: msg, details: prior) if logger.respond_to?(:debug)
61
-
62
- # Set the modification dates to now and then return the latest version
63
- latest_version['dmphub_updated_at'] = Time.now.iso8601
64
61
  latest_version
65
62
  end
66
63
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -75,10 +72,10 @@ module Uc3DmpId
75
72
  return json unless results.length > 1
76
73
 
77
74
  versions = results.map do |ver|
78
- next if ver['dmphub_updated_at'].nil?
75
+ next if ver['modified'].nil?
79
76
  {
80
- timestamp: ver['dmphub_updated_at'],
81
- url: "#{Helper.landing_page_url}#{Helper.remove_pk_prefix(p_key: p_key)}?version=#{ver['dmphub_updated_at']}"
77
+ timestamp: ver['modified'],
78
+ url: "#{Helper.landing_page_url}#{Helper.remove_pk_prefix(p_key: p_key)}?version=#{ver['modified']}"
82
79
  }
83
80
  end
84
81
  json['dmp']['dmphub_versions'] = JSON.parse(versions.to_json)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.119
4
+ version: 0.0.120
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-02 00:00:00.000000000 Z
11
+ date: 2023-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json