dina 0.1.0.0 → 0.2.0.0

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: fb9d082cc5779c2164cc62c37dc96ccb9518172dd7d4906e5e7de7ca9270af35
4
- data.tar.gz: 0fe67de260e7fab5f9167175dfc85bd8fe64f000887941648d7b003bbab16ab5
3
+ metadata.gz: ac8691de71d4edf3e8c55134a2eab3907db3330ab74e40d12779c960178d5d23
4
+ data.tar.gz: b3f6cb667ce6d648ff804ebec0d172b98801b877d38145d5e819e98f7e489f7d
5
5
  SHA512:
6
- metadata.gz: b1bc2b324d1c9d970aaba2703f347734dff1624f55104c924779e1ddf5a8f3cc0244403cd18c4de355e13dd7949251db844fc992414fb9652329b6d0e09afcae
7
- data.tar.gz: c3e36505634d44f74c9068988a90ccdd41bf4a9d8462491131665ffb53af15bfd1fc9d64d2527bf43dd2e352457de4a7f8bf228e29f72cb6069a5717e7e6cf0d
6
+ metadata.gz: e9ba7de4e15555f92494770785e1ac42f97cea709a0542dfedce95fe19227536c36ef6bf5ee8cf009728c75ea4268a685f7bab88948ca277477c179ecfeb639b
7
+ data.tar.gz: 75d2b0e52d5399cca2ab1b9785338d5a3f51b58aa1d82452eb103e6bbecce9b4642aab3e1c309a9a1625587edecfd4a380715ed454a72bb53497e8d0737393ae
@@ -3,6 +3,20 @@
3
3
  module Dina
4
4
  module Authentication
5
5
 
6
+ # Sets Authentication configuration
7
+ # Options hash as follows:
8
+ # {
9
+ # token_store_file: "file to store the token",
10
+ # user: "username provided by DINA admin in Keycloak",
11
+ # password: "password provided by DINA admin in Keycloak",
12
+ # server_name: "used locally to reference the token",
13
+ # client_id: "provided by DINA admin in Keycloak",
14
+ # endpoint_url: "DINA API URL",
15
+ # authorization_url: "Keycloak authorization URL".
16
+ # realm: "provided by DINA admin in Keycloak"
17
+ # }
18
+ #
19
+ # @param options [Hash] the configuration options
6
20
  def self.config(options = {})
7
21
  @token_store_file = options[:token_store_file]
8
22
  @user = options[:user]
@@ -16,6 +30,10 @@ module Dina
16
30
  Keycloak.realm = @realm
17
31
  end
18
32
 
33
+ # Gets, sets, and renews a Bearer access token as required
34
+ # and produces a Header string
35
+ #
36
+ # @return [String] the Bearer token
19
37
  def self.header
20
38
  if access_token.nil? || refresh_token.nil?
21
39
  set_token
@@ -0,0 +1,18 @@
1
+ module Dina
2
+ class AgentRole
3
+ attr_accessor :agent #A known UUID for a Person
4
+ attr_accessor :roles #an array of roles: Owner, Borrower, Prepared By
5
+ attr_accessor :date
6
+ attr_accessor :remarks
7
+
8
+ def initialize
9
+ end
10
+
11
+ def to_hash
12
+ hash = {}
13
+ instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
14
+ hash
15
+ end
16
+
17
+ end
18
+ end
@@ -14,9 +14,9 @@ module Dina
14
14
  attr_accessor :qualifier
15
15
  attr_accessor :scientificNameSource
16
16
  attr_accessor :scientificNameDetails #in the form { classificationPath: "", classificationRanks: "" }
17
- attr_accessor :isPrimary
18
- attr_accessor :isFiledAs
19
- attr_accessor :managedAttributes
17
+ attr_accessor :isPrimary #boolean
18
+ attr_accessor :isFiledAs #boolean
19
+ attr_accessor :managedAttributes #array
20
20
 
21
21
  def initialize
22
22
  end
@@ -0,0 +1,24 @@
1
+ module Dina
2
+ class Shipment
3
+ attr_accessor :contentRemarks
4
+ attr_accessor :value
5
+ attr_accessor :currency
6
+ attr_accessor :itemCount
7
+ attr_accessor :shippedOn
8
+ attr_accessor :status
9
+ attr_accessor :packingMethod
10
+ attr_accessor :trackingNumber
11
+ attr_accessor :shipmentRemarks
12
+ attr_accessor :address # with properties receiverName, companyName, addressLine1, addressLine2, city, provinceState, zipCode, country
13
+
14
+ def initialize
15
+ end
16
+
17
+ def to_hash
18
+ hash = {}
19
+ instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
20
+ hash
21
+ end
22
+
23
+ end
24
+ end
@@ -1,4 +1,5 @@
1
1
  module Dina
2
2
  class DinaException < StandardError; end
3
3
  class TokenStoreFileNotFound < DinaException; end
4
+ class ObjectInvalid < DinaException; end
4
5
  end
@@ -11,7 +11,7 @@ module Dina
11
11
  property :createdBy, type: :string
12
12
  property :createdOn, type: :time
13
13
 
14
- validates_presence_of :group
14
+ validates_presence_of :group, message: "group is required"
15
15
 
16
16
  def self.endpoint_path
17
17
  "collection-api/"
@@ -13,7 +13,8 @@ module Dina
13
13
 
14
14
  has_many :attachment, class_name: "ObjectStore"
15
15
 
16
- validates_presence_of :group, :name
16
+ validates_presence_of :group, message: "group is required"
17
+ validates_presence_of :name, message: "name is required"
17
18
 
18
19
  def self.endpoint_path
19
20
  "collection-api/"
@@ -6,6 +6,7 @@ module Dina
6
6
  self.paginator = JsonApiClient::Paginating::NestedParamPaginator
7
7
 
8
8
  before_create :on_before_create
9
+ before_save :on_before_save
9
10
 
10
11
  def self.endpoint_path
11
12
  end
@@ -41,5 +42,11 @@ module Dina
41
42
  self.attributes = self.attributes.deep_symbolize_keys
42
43
  end
43
44
 
45
+ def on_before_save
46
+ if !self.valid?
47
+ raise ObjectInvalid, "#{self.class} is invalid. #{self.errors.map(&:message).join("; ")}"
48
+ end
49
+ end
50
+
44
51
  end
45
52
  end
@@ -45,7 +45,7 @@ module Dina
45
45
  has_many :collectors, class_name: "Person"
46
46
  has_many :attachment, class_name: "Attachment"
47
47
 
48
- validates_presence_of :group
48
+ validates_presence_of :group, message: "group is required"
49
49
 
50
50
  before_save :on_before_save
51
51
 
@@ -70,6 +70,7 @@ module Dina
70
70
  if !self.geoReferenceAssertions.empty? && self.geoReferenceAssertions[0][:dwcDecimalLatitude].nil?
71
71
  self.geoReferenceAssertions = nil
72
72
  end
73
+ super
73
74
  end
74
75
 
75
76
  end
@@ -9,7 +9,7 @@ module Dina
9
9
  property :createdBy, type: :string
10
10
  property :createdOn, type: :time
11
11
 
12
- validates_presence_of :group
12
+ validates_presence_of :group, message: "group is required"
13
13
 
14
14
  def self.endpoint_path
15
15
  "collection-api/"
@@ -18,7 +18,7 @@ module Dina
18
18
  has_one :institution, class_name: "Institution"
19
19
  has_one :parent_collection, class_name: "Collection"
20
20
 
21
- validates_presence_of :group
21
+ validates_presence_of :group, message: "group is required"
22
22
 
23
23
  def self.endpoint_path
24
24
  "collection-api/"
@@ -0,0 +1,17 @@
1
+ require_rel 'base_model'
2
+
3
+ module Dina
4
+ class CollectionSequenceGenerator < BaseModel
5
+ property :id, type: :string, default: SecureRandom.uuid
6
+ property :amount, type: :string
7
+
8
+ def self.endpoint_path
9
+ "collection-api/"
10
+ end
11
+
12
+ def self.table_name
13
+ "collection-sequence-generator"
14
+ end
15
+
16
+ end
17
+ end
@@ -13,7 +13,7 @@ module Dina
13
13
  property :createdBy, type: :string
14
14
  property :createdOn, type: :time
15
15
 
16
- validates_presence_of :group
16
+ validates_presence_of :group, message: "group is required"
17
17
 
18
18
  def self.endpoint_path
19
19
  "collection-api/"
@@ -48,7 +48,8 @@ module Dina
48
48
  has_many :preparation_attachment, class_name: "Attachment" #TODO: error requesting Dina::MaterialSample::Metadatum
49
49
  has_many :organism, class_name: "Organism"
50
50
 
51
- validates_presence_of :group, :materialSampleName
51
+ validates_presence_of :group, message: "group is required"
52
+ validates_presence_of :materialSampleName, message: "materialSampleName is required"
52
53
 
53
54
  def self.endpoint_path
54
55
  "collection-api/"
@@ -36,7 +36,7 @@ module Dina
36
36
  has_one :dc_creator, class_name: "Person"
37
37
  has_many :derivatives, class_name: "Derivative"
38
38
 
39
- validates_presence_of :group
39
+ validates_presence_of :group, message: "group is required"
40
40
 
41
41
  def self.endpoint_path
42
42
  "objectstore-api/"
@@ -12,7 +12,7 @@ module Dina
12
12
  property :createdBy, type: :string
13
13
  property :createdOn, type: :time
14
14
 
15
- validates_presence_of :group
15
+ validates_presence_of :group, message: "group is required"
16
16
 
17
17
  def self.endpoint_path
18
18
  "collection-api/"
@@ -16,7 +16,8 @@ module Dina
16
16
  has_many :organizations
17
17
  has_many :identifiers
18
18
 
19
- validates_presence_of :familyNames
19
+ validates_presence_of :familyNames, message: "familyNames is required"
20
+ validates_presence_of :displayName
20
21
 
21
22
  def self.endpoint_path
22
23
  "agent-api/"
@@ -26,13 +27,17 @@ module Dina
26
27
  "person"
27
28
  end
28
29
 
30
+ # Finds a Person object using an email address
31
+ #
32
+ # @param email [String] an email address
33
+ # @return Person [Object] a Person object
29
34
  def self.find_by_email(email)
30
35
  where("email": email).all.first
31
36
  end
32
37
 
33
38
  private
34
39
 
35
- def set_defaults
40
+ def on_before_save
36
41
  if self.displayName.nil? || self.displayName == ""
37
42
  self.displayName = [familyNames, givenNames].compact.join(", ")
38
43
  end
@@ -9,7 +9,7 @@ module Dina
9
9
  property :createdBy, type: :string
10
10
  property :createdOn, type: :time
11
11
 
12
- validates_presence_of :group
12
+ validates_presence_of :group, message: "group is required"
13
13
 
14
14
  def self.endpoint_path
15
15
  "collection-api/"
@@ -14,7 +14,7 @@ module Dina
14
14
 
15
15
  has_many :attachment, class_name: "ObjectStore"
16
16
 
17
- validates_presence_of :group
17
+ validates_presence_of :group, message: "group is required"
18
18
 
19
19
  def self.endpoint_path
20
20
  "collection-api/"
@@ -11,7 +11,7 @@ module Dina
11
11
 
12
12
  has_many :attachment, class_name: "ObjectStore"
13
13
 
14
- validates_presence_of :group
14
+ validates_presence_of :group, message: "group is required"
15
15
 
16
16
  def self.endpoint_path
17
17
  "collection-api/"
@@ -13,7 +13,7 @@ module Dina
13
13
  has_one :storage_unit_type
14
14
  has_one :parent_storage_unit, class_name: "StorageUnit"
15
15
 
16
- validates_presence_of :group
16
+ validates_presence_of :group, message: "group is required"
17
17
 
18
18
  def self.endpoint_path
19
19
  "collection-api/"
@@ -9,7 +9,7 @@ module Dina
9
9
  property :createdBy, type: :string
10
10
  property :createdOn, type: :time
11
11
 
12
- validates_presence_of :group
12
+ validates_presence_of :group, message: "group is required"
13
13
 
14
14
  def self.endpoint_path
15
15
  "collection-api/"
@@ -0,0 +1,39 @@
1
+ require_rel 'base_model'
2
+
3
+ module Dina
4
+ class Transaction < BaseModel
5
+ property :id, type: :string, default: SecureRandom.uuid
6
+ property :transactionNumber, type: :string
7
+ property :materialDirection, type: :string
8
+ property :materialToBeReturned, type: :boolean
9
+ property :group, type: :string
10
+ property :transactionType, type: :string
11
+ property :otherIdentifiers, type: :array, default: []
12
+ property :status, type: :string
13
+ property :purpose, type: :string
14
+ property :openedDate, type: :time
15
+ property :closedDate, type: :time
16
+ property :dueDate, type: :time
17
+ property :remarks, type: :string
18
+ property :managedAttributes, type: :object
19
+ property :agentRoles, type: :array
20
+ property :shipment, type: :object
21
+ property :createdBy, type: :string
22
+ property :createdOn, type: :time
23
+
24
+ has_many :material_samples, class_name: "MaterialSample"
25
+ has_many :attachment
26
+ has_many :involved_agents, class_name: "Person"
27
+
28
+ validates_presence_of :group, message: "group is required"
29
+
30
+ def self.endpoint_path
31
+ "loan-transaction/"
32
+ end
33
+
34
+ def self.table_name
35
+ "transaction"
36
+ end
37
+
38
+ end
39
+ end
@@ -12,7 +12,7 @@ module Dina
12
12
  property :createdBy, type: :string
13
13
  property :createdOn, type: :time
14
14
 
15
- validates_presence_of :username
15
+ validates_presence_of :username, message: "username is required"
16
16
 
17
17
  def self.endpoint_path
18
18
  "user-api/"
data/lib/dina/version.rb CHANGED
@@ -2,7 +2,7 @@ module Dina
2
2
  class Version
3
3
 
4
4
  MAJOR = 0
5
- MINOR = 1
5
+ MINOR = 2
6
6
  PATCH = 0
7
7
  BUILD = 0
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.0
4
+ version: 0.2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client
@@ -136,8 +136,10 @@ files:
136
136
  - lib/dina/casters/multilingual_title.rb
137
137
  - lib/dina/casters/multilingual_title_caster.rb
138
138
  - lib/dina/casters/object_caster.rb
139
+ - lib/dina/components/agent_role.rb
139
140
  - lib/dina/components/determination.rb
140
141
  - lib/dina/components/georeference_assertion.rb
142
+ - lib/dina/components/shipment.rb
141
143
  - lib/dina/exceptions.rb
142
144
  - lib/dina/models/acquisition_event.rb
143
145
  - lib/dina/models/assemblage.rb
@@ -147,6 +149,7 @@ files:
147
149
  - lib/dina/models/collecting_event.rb
148
150
  - lib/dina/models/collecting_method.rb
149
151
  - lib/dina/models/collection.rb
152
+ - lib/dina/models/collection_sequence_generator.rb
150
153
  - lib/dina/models/derivative.rb
151
154
  - lib/dina/models/file.rb
152
155
  - lib/dina/models/identifier.rb
@@ -164,6 +167,7 @@ files:
164
167
  - lib/dina/models/protocol.rb
165
168
  - lib/dina/models/storage_unit.rb
166
169
  - lib/dina/models/storage_unit_type.rb
170
+ - lib/dina/models/transaction.rb
167
171
  - lib/dina/models/user.rb
168
172
  - lib/dina/search/base_search.rb
169
173
  - lib/dina/search/search.rb
@@ -173,7 +177,7 @@ files:
173
177
  - lib/dina/utils/identifier.rb
174
178
  - lib/dina/utils/identifier_type.rb
175
179
  - lib/dina/version.rb
176
- homepage: ''
180
+ homepage: https://github.com/dshorthouse/dina
177
181
  licenses:
178
182
  - MIT
179
183
  metadata: {}