dina 0.5.2.0 → 0.5.4.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/components/agent_role.rb +14 -3
- data/lib/dina/components/determination.rb +42 -2
- data/lib/dina/components/georeference_assertion.rb +12 -2
- data/lib/dina/components/shipment.rb +9 -1
- data/lib/dina/models/agent/identifier.rb +3 -0
- data/lib/dina/models/material_sample/collecting_event.rb +1 -1
- data/lib/dina/models/material_sample/collection.rb +8 -0
- data/lib/dina/models/material_sample/material_sample.rb +1 -1
- data/lib/dina/models/object_store/file.rb +1 -1
- data/lib/dina/models/object_store/object_store.rb +5 -1
- data/lib/dina/models/transaction/transaction.rb +3 -2
- data/lib/dina/search/base_search.rb +1 -1
- data/lib/dina/utils/identifier.rb +14 -6
- data/lib/dina/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd91960b1bdd12e80298ec10a00fbb667f4eb54d1395c6ffa8f9a623c74baee
|
4
|
+
data.tar.gz: e323a54e622ea8b29f0ac6d0f61b36194df1f59308ebb15f7df65d2c29668612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08981c9cab7306ceaafd89e5fa86f91f6abe96dbfcef74604bab6636da5b5b42084f55228d08f1001b8573e424046094965f6f9ad5cc7ffbfcf6470af62f4a0b'
|
7
|
+
data.tar.gz: d846e3986c30490f49745b35356796ab058ed2ab608c4554ccf3af2b1253aaa84e2b2d424ba1b42f0083f82d7aae90994380f2698f51808d7d66314fe499c66d
|
@@ -1,17 +1,28 @@
|
|
1
1
|
module Dina
|
2
2
|
class AgentRole
|
3
|
-
attr_accessor :agent #
|
4
|
-
attr_accessor :roles #
|
3
|
+
attr_accessor :agent #An array of known UUIDs for a Person
|
4
|
+
attr_accessor :roles #An array of roles: Owner, Borrower, Prepared By
|
5
5
|
attr_accessor :date
|
6
6
|
attr_accessor :remarks
|
7
7
|
|
8
8
|
def initialize
|
9
|
+
@agent = []
|
10
|
+
@roles = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_agent(id)
|
14
|
+
raise PropertyValueInvalid, "Agent must be a UUID." if !id.is_uuid?
|
15
|
+
@agent << id
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_role(role)
|
19
|
+
@roles << role
|
9
20
|
end
|
10
21
|
|
11
22
|
def to_hash
|
12
23
|
hash = {}
|
13
24
|
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
14
|
-
hash
|
25
|
+
hash.deep_symbolize_keys
|
15
26
|
end
|
16
27
|
|
17
28
|
end
|
@@ -9,7 +9,7 @@ module Dina
|
|
9
9
|
attr_accessor :determinationRemarks
|
10
10
|
attr_accessor :typeStatus
|
11
11
|
attr_accessor :typeStatusEvidence
|
12
|
-
attr_accessor :determiner #
|
12
|
+
attr_accessor :determiner #An array of known UUIDs for Person
|
13
13
|
attr_accessor :determinedOn
|
14
14
|
attr_accessor :qualifier
|
15
15
|
attr_accessor :scientificNameSource
|
@@ -18,13 +18,53 @@ module Dina
|
|
18
18
|
attr_accessor :isFiledAs #boolean
|
19
19
|
attr_accessor :managedAttributes #array
|
20
20
|
|
21
|
+
attr_accessor :classification
|
22
|
+
attr_accessor :ranks
|
23
|
+
|
21
24
|
def initialize
|
25
|
+
@scientificNameDetails = {}
|
26
|
+
@determiner = []
|
27
|
+
end
|
28
|
+
|
29
|
+
# Add a materialized classification string to scientificNameDetails
|
30
|
+
# Path should use pipes, "|" as separators
|
31
|
+
#
|
32
|
+
# @param path [String] the classification
|
33
|
+
def classification=(path)
|
34
|
+
if !path.instance_of?(String)
|
35
|
+
raise PropertyValueInvalid, "Classification must be a string with individual items separated by pipes."
|
36
|
+
end
|
37
|
+
@classification = path
|
38
|
+
scientificNameDetails.merge!({ classificationPath: path })
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add a materialized ranks string to scientificNameDetails
|
42
|
+
# Ranks should use pipes, "|" as separators
|
43
|
+
#
|
44
|
+
# @param ranks [String] the ranks
|
45
|
+
def ranks=(ranks)
|
46
|
+
if !ranks.instance_of?(String)
|
47
|
+
raise PropertyValueInvalid, "Ranks must be a string with individual items separated by pipes."
|
48
|
+
end
|
49
|
+
@ranks = ranks
|
50
|
+
scientificNameDetails.merge!({ classificationRanks: ranks })
|
51
|
+
end
|
52
|
+
|
53
|
+
# Add a determiner as UUID to the array of determiner
|
54
|
+
#
|
55
|
+
# @param id [String] a UUID for a determiner
|
56
|
+
def add_determiner(id)
|
57
|
+
raise PropertyValueInvalid, "Determiner must be a UUID." if !id.is_uuid?
|
58
|
+
@determiner << id
|
22
59
|
end
|
23
60
|
|
61
|
+
# Produce a hash with symbolized keys
|
24
62
|
def to_hash
|
25
63
|
hash = {}
|
64
|
+
remove_instance_variable(:@classification) if @classification
|
65
|
+
remove_instance_variable(:@ranks) if @ranks
|
26
66
|
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
27
|
-
hash
|
67
|
+
hash.deep_symbolize_keys
|
28
68
|
end
|
29
69
|
|
30
70
|
end
|
@@ -9,17 +9,27 @@ module Dina
|
|
9
9
|
attr_accessor :dwcGeoreferenceProtocol
|
10
10
|
attr_accessor :dwcGeoreferenceSources
|
11
11
|
attr_accessor :dwcGeoreferenceRemarks
|
12
|
-
attr_accessor :dwcGeodeticDatum
|
12
|
+
attr_accessor :dwcGeodeticDatum
|
13
13
|
attr_accessor :isPrimary
|
14
14
|
attr_accessor :dwcGeoreferenceVerificationStatus
|
15
|
+
attr_accessor :createdOn
|
15
16
|
|
16
17
|
def initialize
|
18
|
+
@georeferencedBy = []
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add a georeferencedBy as UUID to the array
|
22
|
+
#
|
23
|
+
# @param id [String] a UUID for a georeferencedBy
|
24
|
+
def add_georeferencedBy(id)
|
25
|
+
raise PropertyValueInvalid, "georeferencedBy must be a UUID." if !id.is_uuid?
|
26
|
+
@georeferencedBy << id
|
17
27
|
end
|
18
28
|
|
19
29
|
def to_hash
|
20
30
|
hash = {}
|
21
31
|
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
22
|
-
hash
|
32
|
+
hash.deep_symbolize_keys
|
23
33
|
end
|
24
34
|
|
25
35
|
end
|
@@ -12,12 +12,20 @@ module Dina
|
|
12
12
|
attr_accessor :address # with properties receiverName, companyName, addressLine1, addressLine2, city, provinceState, zipCode, country
|
13
13
|
|
14
14
|
def initialize
|
15
|
+
@address = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_address(address)
|
19
|
+
if !address.instance_of?(Hash)
|
20
|
+
raise PropertyValueInvalid, "Address must be a Hash."
|
21
|
+
end
|
22
|
+
@address.merge!(address)
|
15
23
|
end
|
16
24
|
|
17
25
|
def to_hash
|
18
26
|
hash = {}
|
19
27
|
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
20
|
-
hash
|
28
|
+
hash.deep_symbolize_keys
|
21
29
|
end
|
22
30
|
|
23
31
|
end
|
@@ -10,6 +10,9 @@ module Dina
|
|
10
10
|
|
11
11
|
belongs_to :person, shallow_path: true, class_name: "Person"
|
12
12
|
|
13
|
+
validates_presence_of :namespace, message: "namespace is required"
|
14
|
+
validates_presence_of :value, message: "value is required"
|
15
|
+
|
13
16
|
def self.endpoint_path
|
14
17
|
"agent-api/"
|
15
18
|
end
|
@@ -30,7 +30,7 @@ module Dina
|
|
30
30
|
property :dwcMaximumDepthInMeters, type: :float
|
31
31
|
property :substrate, type: :string
|
32
32
|
property :remarks, type: :string
|
33
|
-
property :publiclyReleasable, type: :boolean
|
33
|
+
property :publiclyReleasable, type: :boolean, default: true
|
34
34
|
property :notPubliclyReleasableReason, type: :string, default: nil
|
35
35
|
property :tags, type: :array, default: []
|
36
36
|
property :geographicPlaceNameSource, type: :string
|
@@ -28,10 +28,18 @@ module Dina
|
|
28
28
|
"collection"
|
29
29
|
end
|
30
30
|
|
31
|
+
# Finds a Collection object by name
|
32
|
+
#
|
33
|
+
# @param email [String] a name
|
34
|
+
# @return object [Object] a Collection object
|
31
35
|
def self.find_by_name(name)
|
32
36
|
where(name: name).all.first
|
33
37
|
end
|
34
38
|
|
39
|
+
# Finds a Collection object by code
|
40
|
+
#
|
41
|
+
# @param code [String] a code
|
42
|
+
# @return object [Object] a Collection object
|
35
43
|
def self.find_by_code(code)
|
36
44
|
where(code: code).all.first
|
37
45
|
end
|
@@ -29,7 +29,7 @@ module Dina
|
|
29
29
|
property :materialSampleChildren, type: :array
|
30
30
|
property :associations, type: :array, default: []
|
31
31
|
property :tags, type: :array, default: []
|
32
|
-
property :publiclyReleasable, type: :boolean
|
32
|
+
property :publiclyReleasable, type: :boolean, default: true
|
33
33
|
property :notPubliclyReleasableReason, type: :string
|
34
34
|
property :hostOrganism, type: :object, default: { name: nil, remarks: nil }
|
35
35
|
property :scheduledActions, type: :object
|
@@ -6,7 +6,7 @@ module Dina
|
|
6
6
|
property :createdBy, type: :string
|
7
7
|
property :createdOn, type: :time
|
8
8
|
property :group, type: :string
|
9
|
-
property :dcFormat, type: :string
|
9
|
+
property :dcFormat, type: :string, default: "image/jpeg"
|
10
10
|
property :dcType, type: :string
|
11
11
|
property :acSubtype, type: :string
|
12
12
|
property :fileIdentifier, type: :string
|
@@ -34,6 +34,10 @@ module Dina
|
|
34
34
|
has_many :derivatives, class_name: "Derivative"
|
35
35
|
|
36
36
|
validates_presence_of :group, message: "group is required"
|
37
|
+
validates_presence_of :dcFormat, message: "dcFormat is required"
|
38
|
+
validates_presence_of :dcType, message: "dcType is required"
|
39
|
+
validates_presence_of :xmpRightsUsageTerms, message: "xmpRightsUsageTerms is required"
|
40
|
+
validates_presence_of :dcRights, message: "dcRights is required"
|
37
41
|
|
38
42
|
attr_accessor :accepted_types
|
39
43
|
|
@@ -16,8 +16,8 @@ module Dina
|
|
16
16
|
property :dueDate, type: :time
|
17
17
|
property :remarks, type: :string
|
18
18
|
property :managedAttributes, type: :object
|
19
|
-
property :agentRoles, type: :array
|
20
|
-
property :shipment, type: :object
|
19
|
+
property :agentRoles, type: :array # Each of type Dina::AgentRole
|
20
|
+
property :shipment, type: :object # Of type Dina::Shipment
|
21
21
|
property :createdBy, type: :string
|
22
22
|
property :createdOn, type: :time
|
23
23
|
|
@@ -26,6 +26,7 @@ module Dina
|
|
26
26
|
has_many :involved_agents, class_name: "Person"
|
27
27
|
|
28
28
|
validates_presence_of :group, message: "group is required"
|
29
|
+
validates_presence_of :materialDirection, message: "materialDirection is required"
|
29
30
|
|
30
31
|
attr_accessor :accepted_directions
|
31
32
|
|
@@ -30,7 +30,7 @@ module Dina
|
|
30
30
|
begin
|
31
31
|
response = RestClient::Request.execute(
|
32
32
|
method: method,
|
33
|
-
url: endpoint + endpoint_path + "?" + params.to_query,
|
33
|
+
url: endpoint + "/" + endpoint_path + "?" + params.to_query,
|
34
34
|
payload: payload.to_json,
|
35
35
|
headers: {
|
36
36
|
accept: 'application/json',
|
@@ -1,30 +1,34 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
class String
|
3
3
|
def is_orcid?
|
4
|
-
::Dina::
|
4
|
+
::Dina::PersistentIdentifier.is_orcid_regex.match?(self) &&
|
5
5
|
::Dina::Identifier.orcid_valid_checksum(self)
|
6
6
|
end
|
7
7
|
|
8
8
|
def is_wiki_id?
|
9
|
-
::Dina::
|
9
|
+
::Dina::PersistentIdentifier.is_wiki_regex.match?(self)
|
10
10
|
end
|
11
11
|
|
12
12
|
def is_doi?
|
13
|
-
::Dina::
|
13
|
+
::Dina::PersistentIdentifier.is_doi_regex.match?(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_uuid?
|
17
|
+
::Dina::PersistentIdentifier.is_uuid_regex.match?(self)
|
14
18
|
end
|
15
19
|
|
16
20
|
def orcid_from_url
|
17
|
-
::Dina::
|
21
|
+
::Dina::PersistentIdentifier.extract_orcid_regex.match(self)[0] rescue nil
|
18
22
|
end
|
19
23
|
|
20
24
|
def wiki_from_url
|
21
|
-
::Dina::
|
25
|
+
::Dina::PersistentIdentifier.extract_wiki_regex.match(self)[0] rescue nil
|
22
26
|
end
|
23
27
|
|
24
28
|
end
|
25
29
|
|
26
30
|
module Dina
|
27
|
-
class
|
31
|
+
class PersistentIdentifier
|
28
32
|
|
29
33
|
class << self
|
30
34
|
def is_orcid_regex
|
@@ -39,6 +43,10 @@ module Dina
|
|
39
43
|
/^10.\d{4,9}\/[-._;()\/:<>A-Z0-9]+$/i
|
40
44
|
end
|
41
45
|
|
46
|
+
def is_uuid_regex
|
47
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
48
|
+
end
|
49
|
+
|
42
50
|
def orcid_valid_checksum(orcid_string)
|
43
51
|
parts = orcid_string.scan(/[0-9X]/)
|
44
52
|
mod = parts[0..14].map(&:to_i)
|
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.5.
|
4
|
+
version: 0.5.4.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-12-
|
11
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|