dmao-generic-ingesters 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9638acab4b7d6a95530831b63d34343c12c4be18
4
- data.tar.gz: cc6cdc638125bb133ea3f0df7f8576acdf6f6b87
3
+ metadata.gz: fc3660d2139876fe0f7df82aef788401e924f8ae
4
+ data.tar.gz: 0dab9d29f5c79e9e25590800375f4ef990a66482
5
5
  SHA512:
6
- metadata.gz: 5d94d17e706c4e19f20247b0d89c4a7406ae08fb31cdc45af2eb692db922e0bff151155449199be49620a1d371ae02b312c9cdf56817adf9eba3c1a6841a4ef5
7
- data.tar.gz: 96941dcc369fa5830d532ddb3f4881e4e8fbc476734bc6e97e32fcbba474ceacd99d03a13fa72df82600ec734145b5fd5ecd435a869231872d21625ccb390e5f
6
+ metadata.gz: 8c9e229af03e4b115b1527ac75442873d5f6cf0810bbc0305d88be65009e01b5b328106730fbd517cb1cf82f9206bd8837f2dc888be18ea2ca9772ba0062c8f7
7
+ data.tar.gz: 36372adc4030072c1e39b44c073f31508ab93d9168f6b28c59e664af261079435c3a06c0567d5d55f3b7bbecc0bd8510adef2720a255af4d002cc84202178843
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "dmao_api", "~> 0.5.0"
33
+ spec.add_dependency "dmao_api", "~> 0.6.0"
34
34
 
35
35
  spec.add_development_dependency "bundler", "~> 1.13"
36
36
  spec.add_development_dependency "rake", "~> 10.0"
@@ -0,0 +1,17 @@
1
+ require 'dmao/ingesters/errors/ingest_entity_error'
2
+
3
+ module DMAO
4
+ module Ingesters
5
+ module Errors
6
+
7
+ class IngestProjectParticipantError < IngestEntityError
8
+
9
+ def initialize(msg="Error ingesting project participant.")
10
+ super(msg)
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -54,7 +54,7 @@ module DMAO
54
54
 
55
55
  def ingest_entity attributes = {}
56
56
 
57
- raise DMAO::Ingesters::Errors::EmptyAttributes.new("Cannot ingest #{self.class.entity_name} without attributes.") if attributes.nil? || attributes.empty?
57
+ validate_attributes_present attributes
58
58
 
59
59
  begin
60
60
 
@@ -93,6 +93,10 @@ module DMAO
93
93
 
94
94
  private
95
95
 
96
+ def validate_attributes_present attributes
97
+ raise DMAO::Ingesters::Errors::EmptyAttributes.new("Cannot ingest #{self.class.entity_name} without attributes.") if attributes.nil? || attributes.empty?
98
+ end
99
+
96
100
  def perform_entity_action action, arguments
97
101
 
98
102
  errors_to_handle = self.class::ERROR_HANDLING.nil? ? generic_errors : self.class::ERROR_HANDLING
@@ -0,0 +1,54 @@
1
+ require 'dmao/ingesters/generic/ingester'
2
+ require 'dmao/ingesters/errors/ingest_project_participant_error'
3
+
4
+ module DMAO
5
+ module Ingesters
6
+ module Generic
7
+
8
+ class ProjectParticipantsIngester < Ingester
9
+
10
+ ENTITY = DMAO::API::ProjectParticipant
11
+ ENTITY_ERROR = DMAO::Ingesters::Errors::IngestProjectParticipantError
12
+ ENTITY_ERROR_MESSAGE = "Invalid project participant details"
13
+ ERROR_HANDLING = {
14
+ "DMAO::API::Errors::ProjectParticipantNotFound" => "Project participant not found, cannot update project participant that does not exist",
15
+ "DMAO::API::Errors::InvalidProjectID" => "Project not found, cannot add participant to non existent project",
16
+ "DMAO::API::Errors::InvalidPersonID" => "Participant not found cannot a non existent person to a project",
17
+ "DMAO::API::Errors::InstitutionNotFound" => "Institution not found, cannot ingest project participant to non-existent institution",
18
+
19
+ }
20
+
21
+ def ingest_entity attributes={}
22
+
23
+ validate_attributes_present attributes
24
+
25
+ begin
26
+
27
+ participant_system_uuid = attributes[:participant_system_uuid]
28
+ project_system_uuid = attributes[:project_system_uuid]
29
+
30
+ participant = DMAO::API::Person.find_by_system_uuid(participant_system_uuid)
31
+ project = DMAO::API::Project.find_by_system_uuid(project_system_uuid)
32
+
33
+ project_participant = DMAO::API::ProjectParticipant.find_project_participant project.id, participant.id
34
+
35
+ update_entity project_participant.id, {person_id: participant.id, project_id: project.id}.merge(attributes)
36
+
37
+ rescue DMAO::API::Errors::PersonNotFound
38
+ raise self.class::ENTITY_ERROR.new("Participant not found, cannot add a non existent person to a project")
39
+ rescue DMAO::API::Errors::ProjectNotFound
40
+ raise self.class::ENTITY_ERROR.new("Project not found, cannot add participant to non existent project")
41
+ rescue DMAO::API::Errors::ProjectParticipantNotFound
42
+ add_entity({person_id: participant.id, project_id: project.id}.merge(attributes))
43
+ rescue DMAO::API::Errors::InvalidResponseLength => e
44
+ raise self.class::ENTITY_ERROR.new(e.message)
45
+ end
46
+
47
+ end
48
+
49
+
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -1,7 +1,7 @@
1
1
  module DMAO
2
2
  module Ingesters
3
3
  module Generic
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmao-generic-ingesters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Robinson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dmao_api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.0
19
+ version: 0.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.0
26
+ version: 0.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -130,12 +130,14 @@ files:
130
130
  - lib/dmao/ingesters/errors/ingest_organisation_unit_error.rb
131
131
  - lib/dmao/ingesters/errors/ingest_person_error.rb
132
132
  - lib/dmao/ingesters/errors/ingest_project_error.rb
133
+ - lib/dmao/ingesters/errors/ingest_project_participant_error.rb
133
134
  - lib/dmao/ingesters/errors/link_organisation_unit_error.rb
134
135
  - lib/dmao/ingesters/generic.rb
135
136
  - lib/dmao/ingesters/generic/funders_ingester.rb
136
137
  - lib/dmao/ingesters/generic/ingester.rb
137
138
  - lib/dmao/ingesters/generic/organisation_ingester.rb
138
139
  - lib/dmao/ingesters/generic/people_ingester.rb
140
+ - lib/dmao/ingesters/generic/project_participants_ingester.rb
139
141
  - lib/dmao/ingesters/generic/projects_ingester.rb
140
142
  - lib/dmao/ingesters/generic/version.rb
141
143
  homepage: https://github.com/lulibrary/DMAO-Generic-Ingesters