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 +4 -4
- data/lib/dina/authentication/authentication.rb +18 -0
- data/lib/dina/components/agent_role.rb +18 -0
- data/lib/dina/components/determination.rb +3 -3
- data/lib/dina/components/shipment.rb +24 -0
- data/lib/dina/exceptions.rb +1 -0
- data/lib/dina/models/acquisition_event.rb +1 -1
- data/lib/dina/models/assemblage.rb +2 -1
- data/lib/dina/models/base_model.rb +7 -0
- data/lib/dina/models/collecting_event.rb +2 -1
- data/lib/dina/models/collecting_method.rb +1 -1
- data/lib/dina/models/collection.rb +1 -1
- data/lib/dina/models/collection_sequence_generator.rb +17 -0
- data/lib/dina/models/managed_attribute.rb +1 -1
- data/lib/dina/models/material_sample.rb +2 -1
- data/lib/dina/models/object_store.rb +1 -1
- data/lib/dina/models/organism.rb +1 -1
- data/lib/dina/models/person.rb +7 -2
- data/lib/dina/models/preparation_type.rb +1 -1
- data/lib/dina/models/project.rb +1 -1
- data/lib/dina/models/protocol.rb +1 -1
- data/lib/dina/models/storage_unit.rb +1 -1
- data/lib/dina/models/storage_unit_type.rb +1 -1
- data/lib/dina/models/transaction.rb +39 -0
- data/lib/dina/models/user.rb +1 -1
- data/lib/dina/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac8691de71d4edf3e8c55134a2eab3907db3330ab74e40d12779c960178d5d23
|
4
|
+
data.tar.gz: b3f6cb667ce6d648ff804ebec0d172b98801b877d38145d5e819e98f7e489f7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/dina/exceptions.rb
CHANGED
@@ -13,7 +13,8 @@ module Dina
|
|
13
13
|
|
14
14
|
has_many :attachment, class_name: "ObjectStore"
|
15
15
|
|
16
|
-
validates_presence_of :group, :
|
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
|
@@ -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
|
@@ -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, :
|
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/"
|
data/lib/dina/models/organism.rb
CHANGED
data/lib/dina/models/person.rb
CHANGED
@@ -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
|
40
|
+
def on_before_save
|
36
41
|
if self.displayName.nil? || self.displayName == ""
|
37
42
|
self.displayName = [familyNames, givenNames].compact.join(", ")
|
38
43
|
end
|
data/lib/dina/models/project.rb
CHANGED
data/lib/dina/models/protocol.rb
CHANGED
@@ -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
|
data/lib/dina/models/user.rb
CHANGED
data/lib/dina/version.rb
CHANGED
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.
|
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-
|
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: {}
|