uc3-dmp-id 0.0.60 → 0.0.61

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: fc2cccff208ffef601a91dc92d6cd2e3ed5b517fd47e09254ff7fea2572ea928
4
- data.tar.gz: 32ed9cdab64dcc03154eacb748ad3fe9bde7ee61d4080874092381c3ffc59c09
3
+ metadata.gz: f57c20b88aa66fde624307bb92a176682f83058929d36c54f5bc8f3930a98b2d
4
+ data.tar.gz: 2dc28c07fc2fc766904b3360b043cd6c3b3af7a772765f5681e9dd29040d0a39
5
5
  SHA512:
6
- metadata.gz: c65520e657194a50a53c6fa88d5e5e43ae471c8d7ac5a56b5da1d3b16bbf0932b90eb42f01674141afbd3577ac071e02c77e8accb7d0e3c3eb150e8344a8bca7
7
- data.tar.gz: 5ab9a028be14f33f10031ef3530d78e2f9d09fb496c9a8225f664fa307de50b8a3fb2fbb1615bc4e0226a3197273a440b3aa00bdf955e25b92dc117716cc905f
6
+ metadata.gz: 9896f63e4d891d16bd97d5293516bf3dc4694ae9dcb8490431433d1061e03dca23c5f99a5d0b6959e7316e6eec19cd5c16aaa7ec93d3fd156b6d877097aec8c9
7
+ data.tar.gz: fe9a16d6cf9cfad66eb1547137fa5a43583b59c3198476809249a311a01ee91a3086802108a9196dfeb0a95f48620e992505f03d4fe178b434059cf7722b2809
@@ -136,10 +136,16 @@ module Uc3DmpId
136
136
  # Add DMPHub specific fields to the DMP ID JSON
137
137
  def annotate_dmp_json(provenance:, owner_org:, p_key:, json:)
138
138
  json = parse_json(json: json)
139
+
140
+ puts "annotate - prov: #{provenance['PK']}, owner_org: #{owner_org}, p_key: #{p_key}, Hash? #{json.is_a?(Hash)} ::: #{provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)}"
141
+
139
142
  return json if provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)
140
143
 
141
144
  # Fail the json as is if the :PK does not match the :dmp_id if the json has a :PK
142
145
  id = dmp_id_to_pk(json: json.fetch('dmp_id', {}))
146
+
147
+ puts "annotate - id: #{id}, PK exist? #{json['PK']} ::: #{id != p_key && !json['PK'].nil?}"
148
+
143
149
  return json if id != p_key && !json['PK'].nil?
144
150
 
145
151
  annotated = deep_copy_dmp(obj: json)
@@ -46,23 +46,29 @@ module Uc3DmpId
46
46
  # fetch the existing latest version of the DMP ID
47
47
  client = Uc3DmpDynamo::Client.new(debug: debug)
48
48
  dmp = Finder.by_pk(p_key: p_key, client: client, debug: debug)
49
- # Don't continue if nothing has changed!
50
- raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil?
49
+ owner_org = dmp['dmp'].fetch('contact', {}).fetch('dmproadmap_affiliation', {}) unless dmp.nil?
50
+ owner_org = owner_org.fetch('affiliation_id', {})['identifier'] unless owner_org.nil?
51
+
52
+ puts "OWNER ORG: #{owner_org}"
53
+
54
+ # Don't continue if DMP ID could not be found or the contact has no identifier (should be impossible)
55
+ raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil? || owner_org.nil?
51
56
 
52
57
  errs = _updateable?(provenance: provenance, p_key: p_key, json: dmp['dmp'])
53
58
  raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
54
59
 
55
- # Add the DMPHub specific attributes
56
- dmp['dmp']['dmproadmap_related_identifiers'] = [] if dmp['dmp']['dmproadmap_related_identifiers'].nil?
57
- dmp['dmp']['dmproadmap_related_identifiers'] << {
60
+ # Add the DMPHub specific attributes and then add the download URl for the PDF
61
+ annotated = Helper.annotate_dmp_json(provenance: provenance, owner_org: owner_org, p_key: p_key, json: dmp['dmp'])
62
+ annotated['dmproadmap_related_identifiers'] = [] if annotated['dmproadmap_related_identifiers'].nil?
63
+ annotated['dmproadmap_related_identifiers'] << {
58
64
  descriptor: 'is_metadata_for', work_type: 'output_management_plan', type: 'url', identifier: url
59
65
  }
60
66
 
61
67
  puts "Attached:"
62
- puts dmp
68
+ puts annotated
63
69
 
64
- # Save the changes as the new latest version
65
- resp = client.put_item(json: dmp['dmp'], debug: debug)
70
+ # Save the changes without creating a new version!
71
+ resp = client.put_item(json: annotated, debug: debug)
66
72
  raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
67
73
 
68
74
  true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.60'
4
+ VERSION = '0.0.61'
5
5
  end
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.60
4
+ version: 0.0.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley