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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55e15684bfc0ccb76cb498ccddfae9b83c8ce935240efbb5ad1112ddbf791ab8
4
- data.tar.gz: 2a729a50e838d4e25a4921d5a33f6b12b3e786e2da4c91b12016340b6d5a158b
3
+ metadata.gz: 6e1f1181484200c982f852613b05b15f2e7a7e5ada500395d0c3d2dadc784f9e
4
+ data.tar.gz: c8edfcf737056d7e81f29545ccaefc6206da8e20a76ae42754206204a82145be
5
5
  SHA512:
6
- metadata.gz: 70315b0ebd96129ec4c7ba051e39d5e385952079f20a565e000bd7b4812be60687a2cde3c414c66db71bda2ccb35a67e06dfcf90aa21b65dee22cb26786ddbfb
7
- data.tar.gz: '0481364645a94de5cb4178bd4657b7d7e1622016cbc7bb0ff9cd3e2082efe2424f5bc98cf47d4b36f2e59515399e7dbd237f4e62ba49b025e788ae0c705bb135'
6
+ metadata.gz: eed9ebc90a13702268f189f24ae23909227adb2531a53f709599483d1075372b1ce0442d6e8b158e280d493e8a7dd6ab053fe2fd21f7b5f7ac9dd30608a4c914
7
+ data.tar.gz: fe1042e750a090a3e5d9f5447e17a7a2a378294a4dccd866c09d5fe76f21ce75db9cd6c72882dab7261758c2be687070b23f87044b14aa5219b5c42e20ad0718
@@ -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
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.92'
4
+ VERSION = '0.0.94'
5
5
  end
@@ -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
- client = Uc3DmpDynamo::Client.new(logger: logger) if client.nil?
38
- latest_version = Finder.by_p_key(client: client, p_key: p_key) unless latest_version.is_a?(Hash) &&
39
- !latest_version['PK'].nil?
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) && dmp['PK'].nil? && dmp['SK'].nil?
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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.92
4
+ version: 0.0.94
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley