dina 0.2.0.0 → 0.4.0.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
  SHA256:
3
- metadata.gz: ac8691de71d4edf3e8c55134a2eab3907db3330ab74e40d12779c960178d5d23
4
- data.tar.gz: b3f6cb667ce6d648ff804ebec0d172b98801b877d38145d5e819e98f7e489f7d
3
+ metadata.gz: 4cae0ee74ed1a0967bb360af211c2ab37676dfdb39b54a377ec39b539e0f4301
4
+ data.tar.gz: 45ee9d1cda7f37da9fb5384690751dac5e5cc0fe30153cddf8306e11a20f7151
5
5
  SHA512:
6
- metadata.gz: e9ba7de4e15555f92494770785e1ac42f97cea709a0542dfedce95fe19227536c36ef6bf5ee8cf009728c75ea4268a685f7bab88948ca277477c179ecfeb639b
7
- data.tar.gz: 75d2b0e52d5399cca2ab1b9785338d5a3f51b58aa1d82452eb103e6bbecce9b4642aab3e1c309a9a1625587edecfd4a380715ed454a72bb53497e8d0737393ae
6
+ metadata.gz: 60a62ece7262ab086b88002497bd55f1ea04059b94468134b7c93d35a3349deff0c3ed58c45f634dd07a3149e4895da1525c215aef1895258beb62cf5af0aba5
7
+ data.tar.gz: dba63bace34688530c56cb56af702af39fe36bcb7ba86bf664b1192a7186ca51207ef9cef2deed311993671127772deb4f149f99fd90619ad56408dc379882a7
@@ -81,11 +81,11 @@ module Dina
81
81
  end
82
82
 
83
83
  def access_token
84
- read_token[:access_token] rescue nil
84
+ read_token[:access_token]
85
85
  end
86
86
 
87
87
  def refresh_token
88
- read_token[:refresh_token] rescue nil
88
+ read_token[:refresh_token]
89
89
  end
90
90
 
91
91
  def auth_expiry
@@ -1,4 +1,3 @@
1
-
2
1
  module Dina
3
2
  class ArrayCaster
4
3
  def self.cast(value, default)
@@ -2,4 +2,5 @@ module Dina
2
2
  class DinaException < StandardError; end
3
3
  class TokenStoreFileNotFound < DinaException; end
4
4
  class ObjectInvalid < DinaException; end
5
+ class PropertyValueInvalid < ObjectInvalid; end
5
6
  end
@@ -11,7 +11,7 @@ module Dina
11
11
  property :createdBy, type: :string
12
12
  property :createdOn, type: :time
13
13
 
14
- has_many :attachment, class_name: "ObjectStore"
14
+ has_many :attachment, class_name: "Attachment"
15
15
 
16
16
  validates_presence_of :group, message: "group is required"
17
17
  validates_presence_of :name, message: "name is required"
@@ -4,8 +4,10 @@ module Dina
4
4
  class Attachment < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
6
 
7
- belongs_to :material_sample, shallow_path: true
8
- belongs_to :project, shallow_path: true
7
+ belongs_to :material_sample, shallow_path: true, class_name: "MaterialSample"
8
+ belongs_to :collecting_event, shallow_path: true, class_name: "CollectingEvent"
9
+ belongs_to :project, shallow_path: true, class_name: "Project"
10
+ belongs_to :transaction, shallow_path: true, class_name: "Transaction"
9
11
 
10
12
  def self.endpoint_path
11
13
  "collection-api/"
@@ -15,7 +15,7 @@ module Dina
15
15
  property :createdBy, type: :string
16
16
  property :createdOn, type: :time
17
17
 
18
- has_one :institution, class_name: "Institution"
18
+ belongs_to :institution, shallow_path: true, class_name: "Institution"
19
19
  has_one :parent_collection, class_name: "Collection"
20
20
 
21
21
  validates_presence_of :group, message: "group is required"
@@ -3,16 +3,19 @@ require_rel 'base_model'
3
3
  module Dina
4
4
  class Derivative < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
+ property :group, type: :string
6
7
  property :bucket, type: :string
7
8
  property :fileIdentifier, type: :string
8
9
  property :fileExtension, type: :string
9
10
  property :dcType, type: :string
10
- property :cdFormat, type: :string
11
+ property :dcFormat, type: :string
11
12
  property :acHashFunction, type: :string, default: "SHA-1"
12
13
  property :acHashValue, type: :string
13
14
  property :derivativeType, type: :string
14
15
 
15
- belongs_to :object_store, shallow_path: true
16
+ belongs_to :ac_derived_from, shallow_path: true, class_name: "ObjectStore"
17
+
18
+ validates_presence_of :group, message: "group is required"
16
19
 
17
20
  def self.endpoint_path
18
21
  "objectstore-api/"
@@ -22,5 +25,14 @@ module Dina
22
25
  "derivative"
23
26
  end
24
27
 
28
+ private
29
+
30
+ def on_before_save
31
+ if self.bucket.nil?
32
+ self.bucket = self.group
33
+ end
34
+ super
35
+ end
36
+
25
37
  end
26
38
  end
@@ -1,40 +1,62 @@
1
- require_rel 'base_model'
2
-
3
1
  module Dina
4
- class File < BaseModel
5
- property :id, type: :string, default: SecureRandom.uuid
2
+ class File
3
+ attr_accessor :file_path, :group, :is_derivative, :id
4
+
5
+ def self.find(group:, id:)
6
+ obj = self.new
7
+ obj.group = group
8
+ RestClient::Request.execute(
9
+ method: :get,
10
+ headers: { authorization: Dina::Authentication.header },
11
+ url: obj.url + "/#{id}"
12
+ )
13
+ end
6
14
 
7
- def self.endpoint_path
15
+ def initialize
16
+ end
17
+
18
+ def endpoint_path
8
19
  "objectstore-api/"
9
20
  end
10
21
 
11
- def self.table_name
12
- "file"
22
+ def table_name
23
+ "file/#{@group}"
13
24
  end
14
25
 
15
- #TODO: a "bucket" as part of the path (=table_name) to permit POST with necessary permissions
16
- #TODO: body not JSON but an asset
26
+ def url
27
+ Dina::Authentication.endpoint_url + endpoint_path + table_name
28
+ end
17
29
 
18
- =begin
30
+ def file
31
+ ::File.new(file_path)
32
+ end
19
33
 
20
- def initialize(bucket:, file:)
21
- if !file.is_a?(::File) || !::File.exist?(file)
22
- raise Exception.new "file is not of class File or does not exist"
23
- end
24
- super
25
- set_headers
34
+ def save
35
+ validate_params
36
+ response = RestClient::Request.execute(
37
+ method: :post,
38
+ headers: { authorization: Dina::Authentication.header },
39
+ url: (!is_derivative) ? url : url + "/derivative",
40
+ payload: {
41
+ multipart: true,
42
+ file: file
43
+ }
44
+ )
45
+ json = JSON.parse(response, symbolize_names: true)
46
+ self.id = json[:uuid]
47
+ json
26
48
  end
27
49
 
28
50
  private
29
51
 
30
- def set_headers
31
- headers = {
32
- content_type: "application/octet-stream",
33
- content_disposition: "form-data; name=file; filename=#{::File.basename(file.path)}"
34
- }
35
- self.custom_headers.merge(headers)
52
+ def validate_params
53
+ if group.nil?
54
+ raise ObjectInvalid, "#{self.class} is invalid. group is required."
55
+ end
56
+ if file_path.nil? || !::File.exist?(file_path)
57
+ raise ObjectInvalid, "#{self.class} is invalid. file not found in file_path."
58
+ end
36
59
  end
37
- =end
38
60
 
39
61
  end
40
62
  end
@@ -16,52 +16,5 @@ module Dina
16
16
  "identifier"
17
17
  end
18
18
 
19
- =begin
20
- TODO: fix because identifier has independent model now
21
-
22
- def self.find_by_orcid(orcid)
23
- if orcid.include? "http"
24
- orcid = orcid.orcid_from_url
25
- end
26
- if orcid.is_orcid?
27
- orcid = "https://orcid.org/#{orcid}"
28
- where("identifiers.uri": orcid).all.first
29
- else
30
- nil
31
- end
32
- end
33
-
34
- def self.find_by_wikidata(wikidata)
35
- if wikidata.include? "http"
36
- wikidata = wikidata.wiki_from_url
37
- end
38
- if wikidata.is_wiki_id?
39
- wikidata = "http://www.wikidata.org/entity/#{wikidata}"
40
- where("identifiers.uri": wikidata).all.first
41
- else
42
- nil
43
- end
44
- where("identifiers.uri": wikidata).all.first
45
- end
46
-
47
- def orcid
48
- identifiers.select{|o| o[:type] == "ORCID"}.first[:uri]
49
- end
50
-
51
- def orcid=(uri)
52
- identifiers.delete_if{|o| o[:type] == "ORCID"}
53
- identifiers << { type: "ORCID", uri: uri }
54
- end
55
-
56
- def wikidata
57
- identifiers.select{|o| o[:type] == "WIKIDATA"}.first[:uri]
58
- end
59
-
60
- def wikidata=(id)
61
- identifiers.delete_if{|o| o[:type] == "WIKIDATA"}
62
- identifiers << { type: "WIKIDATA", uri: uri }
63
- end
64
- =end
65
-
66
19
  end
67
20
  end
@@ -6,14 +6,18 @@ module Dina
6
6
  property :group, type: :string
7
7
  property :name, type: :string
8
8
  property :key, type: :string
9
- property :managedAttributeType, type: :string #values = STRING or INTEGER
10
- property :managedAttributeComponent, type: :string #values = COLLECTING_EVENT, MATERIAL_SAMPLE, or DETERMINATION
9
+ property :managedAttributeType, type: :string
10
+ property :managedAttributeComponent, type: :string
11
11
  property :acceptedValues, type: :array
12
12
  property :multilingualDescription, type: :multilingual_description
13
13
  property :createdBy, type: :string
14
14
  property :createdOn, type: :time
15
15
 
16
16
  validates_presence_of :group, message: "group is required"
17
+ validates_presence_of :name, message: "name is required"
18
+ validates_presence_of :managedAttributeType, message: "managedAttributeType is required"
19
+
20
+ attr_accessor :accepted_components, :accepted_types
17
21
 
18
22
  def self.endpoint_path
19
23
  "collection-api/"
@@ -23,6 +27,25 @@ module Dina
23
27
  "managed-attribute"
24
28
  end
25
29
 
30
+ def self.accepted_components
31
+ [
32
+ "COLLECTING_EVENT",
33
+ "MATERIAL_SAMPLE",
34
+ "DETERMINATION",
35
+ "ASSEMBLAGE"
36
+ ]
37
+ end
38
+
39
+ def self.accepted_types
40
+ [
41
+ "INTEGER",
42
+ "STRING",
43
+ "PICKLIST",
44
+ "DATE",
45
+ "BOOL"
46
+ ]
47
+ end
48
+
26
49
  def english_description=(desc)
27
50
  description[:en] = desc
28
51
  end
@@ -39,5 +62,17 @@ module Dina
39
62
  description[:fr]
40
63
  end
41
64
 
65
+ private
66
+
67
+ def on_before_save
68
+ if !self.managedAttributeComponent.nil? && !self.class.accepted_components.include?(self.managedAttributeComponent)
69
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for managedAttributeComponent is one of #{self.class.accepted_components.join(", ")}"
70
+ end
71
+ if !self.managedAttributeType.nil? && !self.class.accepted_types.include?(self.managedAttributeType)
72
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for managedAttributeType is one of #{self.class.accepted_types.join(", ")}"
73
+ end
74
+ super
75
+ end
76
+
42
77
  end
43
78
  end
@@ -12,7 +12,6 @@ module Dina
12
12
  property :group, type: :string
13
13
  property :managedAttributes, type: :object
14
14
  property :dwcOtherCatalogNumbers, type: :array
15
- property :preparationMethod, type: :string
16
15
  property :preservationType, type: :string
17
16
  property :preparationFixative, type: :string
18
17
  property :preparationMaterials, type: :string
@@ -24,6 +23,9 @@ module Dina
24
23
  property :stateChangedOn, type: :time
25
24
  property :stateChangeRemarks, type: :string
26
25
  property :materialSampleRemarks, type: :string
26
+ property :restrictionFieldsExtension, type: :array
27
+ property :restrictionRemarks, type: :string
28
+ property :isRestricted, type: :boolean
27
29
  property :materialSampleChildren, type: :array
28
30
  property :associations, type: :array, default: []
29
31
  property :tags, type: :array, default: []
@@ -34,22 +36,25 @@ module Dina
34
36
  property :hierarchy, type: :object
35
37
  property :allowDuplicateName, type: :boolean
36
38
 
37
- has_one :collection
38
- has_one :parent_material_sample, class_name: "MaterialSample"
39
+ has_one :collection, class_name: "Collection"
39
40
  has_one :collecting_event, class_name: "CollectingEvent"
40
- has_one :preparation_type
41
- has_one :prepared_by, class_name: "Person"
42
- has_one :storage_unit
43
- has_one :acquisition_event
44
-
45
- has_many :assemblages, class_name: "Assemblage"
41
+ has_one :preparation_type, class_name: "PreparationType"
42
+ has_one :preparation_method, class_name: "PreparationMethod"
43
+ has_one :parent_material_sample, class_name: "MaterialSample"
44
+ has_one :preparation_protocol, class_name: "Protocol"
45
+ has_one :acquisition_event, class_name: "AcquisitionEvent"
46
+ has_one :storage_unit, class_name: "StorageUnit"
47
+ has_many :prepared_by, class_name: "Person"
48
+ has_many :attachment, class_name: "Attachment"
46
49
  has_many :projects, class_name: "Project"
47
- has_many :attachment, class_name: "Attachment" #TODO: error requesting Dina::MaterialSample::Metadatum
48
- has_many :preparation_attachment, class_name: "Attachment" #TODO: error requesting Dina::MaterialSample::Metadatum
50
+ has_many :assemblages, class_name: "Assemblage"
49
51
  has_many :organism, class_name: "Organism"
50
52
 
51
53
  validates_presence_of :group, message: "group is required"
52
54
  validates_presence_of :materialSampleName, message: "materialSampleName is required"
55
+ validates_presence_of :materialSampleType, message: "materialSampleType is required"
56
+
57
+ attr_accessor :accepted_types
53
58
 
54
59
  def self.endpoint_path
55
60
  "collection-api/"
@@ -59,5 +64,23 @@ module Dina
59
64
  "material-sample"
60
65
  end
61
66
 
67
+ def self.accepted_types
68
+ [
69
+ "WHOLE_ORGANISM",
70
+ "ORGANISM_PART",
71
+ "MIXED_ORGANISMS",
72
+ "MOLECULAR_SAMPLE"
73
+ ]
74
+ end
75
+
76
+ private
77
+
78
+ def on_before_save
79
+ if !self.materialSampleType.nil? && !self.class.accepted_types.include?(self.materialSampleType)
80
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for materialSampleType is one of #{self.class.accepted_types.join(", ")}"
81
+ end
82
+ super
83
+ end
84
+
62
85
  end
63
86
  end
@@ -3,34 +3,31 @@ require_rel 'base_model'
3
3
  module Dina
4
4
  class ObjectStore < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
+ property :createdBy, type: :string
7
+ property :createdOn, type: :time
6
8
  property :group, type: :string
7
- property :dcType, type: :string
8
- property :originalFilename, type: :string
9
- property :bucket, type: :string
10
- property :dateTimeDigitized, type: :string
11
- property :fileIdentifier, type: :string
12
- property :fileExtension, type: :string
13
9
  property :dcFormat, type: :string
14
10
  property :dcType, type: :string
15
- property :acDigitizationDate, type: :time
11
+ property :acSubtype, type: :string
12
+ property :fileIdentifier, type: :string
13
+ property :bucket, type: :string
16
14
  property :acCaption, type: :string
15
+ property :acDigitizationDate, type: :time
17
16
  property :xmpMetadataDate, type: :time
18
- property :xmpRightsWebStatement, type: :string, default: "https://open.canada.ca/en/open-government-licence-canada"
19
- property :dcRights, type: :string, default: "© Her Majesty The Queen in Right of Canada, as represented by the Minister of Agriculture and Agri-Food | © Sa Majesté la Reine du chef du Canada, représentée par le ministre de l’Agriculture et de l’Agroalimentaire"
20
- property :xmpRightsOwner, type: :string, default: "Government of Canada"
21
- property :xmpRightsUsageTerms, type: :string, default: "Government of Canada Usage Term"
22
- property :orientation, type: :integer
23
17
  property :originalFilename, type: :string
18
+ property :fileExtension, type: :string
24
19
  property :acHashFunction, type: :string, default: "SHA-1"
25
20
  property :acHashValue, type: :string
26
- property :acSubtype, type: :string
21
+ property :xmpRightsUsageTerms, type: :string, default: "Government of Canada Usage Term"
22
+ property :xmpRightsWebStatement, type: :string, default: "https://open.canada.ca/en/open-government-licence-canada"
23
+ property :dcRights, type: :string, default: "© Her Majesty The Queen in Right of Canada, as represented by the Minister of Agriculture and Agri-Food | © Sa Majesté la Reine du chef du Canada, représentée par le ministre de l’Agriculture et de l’Agroalimentaire"
24
+ property :xmpRightsOwner, type: :string, default: "Government of Canada"
27
25
  property :publiclyReleasable, type: :boolean, default: true
28
26
  property :notPubliclyReleasableReason, type: :string
27
+ property :managedAttributes, type: :object
29
28
  property :acTags, type: :string
29
+ property :orientation, type: :integer
30
30
  property :resourceExternalURL, type: :string
31
- property :managedAttributes, type: :object
32
- property :createdBy, type: :string
33
- property :createdOn, type: :time
34
31
 
35
32
  has_one :ac_metadata_creator, class_name: "Person"
36
33
  has_one :dc_creator, class_name: "Person"
@@ -38,6 +35,8 @@ module Dina
38
35
 
39
36
  validates_presence_of :group, message: "group is required"
40
37
 
38
+ attr_accessor :accepted_types
39
+
41
40
  def self.endpoint_path
42
41
  "objectstore-api/"
43
42
  end
@@ -46,5 +45,25 @@ module Dina
46
45
  "metadata"
47
46
  end
48
47
 
48
+ def self.accepted_types
49
+ [
50
+ "IMAGE",
51
+ "MOVING_IMAGE",
52
+ "SOUND",
53
+ "TEXT",
54
+ "DATASET",
55
+ "UNDETERMINED"
56
+ ]
57
+ end
58
+
59
+ private
60
+
61
+ def on_before_save
62
+ if !self.dcType.nil? && !self.class.accepted_types.include?(self.dcType)
63
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for dcType is one of #{self.class.accepted_types.join(", ")}"
64
+ end
65
+ super
66
+ end
67
+
49
68
  end
50
69
  end
@@ -19,20 +19,13 @@ module Dina
19
19
  "managed-attribute"
20
20
  end
21
21
 
22
- def english_description=(desc)
23
- description[:en] = desc
24
- end
25
-
26
- def english_description
27
- description[:en]
28
- end
29
-
30
- def french_description=(desc)
31
- description[:fr] = desc
32
- end
22
+ private
33
23
 
34
- def french_description
35
- description[:fr]
24
+ def on_before_save
25
+ if !self.managedAttributeType.nil? && !ManagedAttribute.accepted_types.include?(self.managedAttributeType)
26
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for managedAttributeType is one of #{ManagedAttribute.accepted_types.join(", ")}"
27
+ end
28
+ super
36
29
  end
37
30
 
38
31
  end
@@ -3,6 +3,10 @@ require_rel 'base_model'
3
3
  module Dina
4
4
  class ObjectSubtype < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
+ property :createdBy, type: :string
7
+ property :createdOn, type: :time
8
+ property :dcType, type: :string
9
+ property :acSubtype, type: :string
6
10
 
7
11
  def self.endpoint_path
8
12
  "objectstore-api/"
@@ -11,5 +15,15 @@ module Dina
11
15
  def self.table_name
12
16
  "object-subtype"
13
17
  end
18
+
19
+ private
20
+
21
+ def on_before_save
22
+ if !self.dcType.nil? && !ObjectStore.accepted_types.include?(self.dcType)
23
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for dcType is one of #{ObjectStore.accepted_types.join(", ")}"
24
+ end
25
+ super
26
+ end
27
+
14
28
  end
15
29
  end
@@ -3,7 +3,6 @@ require_rel 'base_model'
3
3
  module Dina
4
4
  class Organization < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
- #NOTE: should be type: :multilingual_description but API not adjusted
7
6
  property :names, type: :array, default: [{languageCode: "EN", name: nil}, {languageCode: "FR", name: nil}]
8
7
  property :aliases, type: :array, default: []
9
8
  property :createdBy, type: :string
@@ -13,8 +13,8 @@ module Dina
13
13
  property :createdBy, type: :string
14
14
  property :createdOn, type: :time
15
15
 
16
- has_many :organizations
17
- has_many :identifiers
16
+ has_many :organizations, class_name: "Organization"
17
+ has_many :identifiers, class_name: "Identifier"
18
18
 
19
19
  validates_presence_of :familyNames, message: "familyNames is required"
20
20
  validates_presence_of :displayName
@@ -30,9 +30,9 @@ module Dina
30
30
  # Finds a Person object using an email address
31
31
  #
32
32
  # @param email [String] an email address
33
- # @return Person [Object] a Person object
33
+ # @return array [Array] an array of Person objects
34
34
  def self.find_by_email(email)
35
- where("email": email).all.first
35
+ where("email": email).all
36
36
  end
37
37
 
38
38
  private
@@ -0,0 +1,23 @@
1
+ require_rel 'base_model'
2
+
3
+ module Dina
4
+ class PreparationMethod < BaseModel
5
+ property :id, type: :string, default: SecureRandom.uuid
6
+ property :group, type: :string
7
+ property :name, type: :string
8
+ property :multilingualDescription, type: :multilingual_description
9
+ property :createdBy, type: :string
10
+ property :createdOn, type: :time
11
+
12
+ validates_presence_of :group, message: "group is required"
13
+
14
+ def self.endpoint_path
15
+ "collection-api/"
16
+ end
17
+
18
+ def self.table_name
19
+ "preparation-method"
20
+ end
21
+
22
+ end
23
+ end
@@ -12,7 +12,7 @@ module Dina
12
12
  property :createdBy, type: :string
13
13
  property :createdOn, type: :time
14
14
 
15
- has_many :attachment, class_name: "ObjectStore"
15
+ has_many :attachment, class_name: "Attachment"
16
16
 
17
17
  validates_presence_of :group, message: "group is required"
18
18
 
@@ -9,7 +9,7 @@ module Dina
9
9
  property :createdBy, type: :string
10
10
  property :createdOn, type: :time
11
11
 
12
- has_many :attachment, class_name: "ObjectStore"
12
+ has_many :attachment, class_name: "Attachment"
13
13
 
14
14
  validates_presence_of :group, message: "group is required"
15
15
 
@@ -6,6 +6,7 @@ module Dina
6
6
  property :group, type: :string
7
7
  property :name, type: :string
8
8
  property :isInseperable, type: :boolean
9
+ property :gridLayoutDefinition, type: :object
9
10
  property :createdBy, type: :string
10
11
  property :createdOn, type: :time
11
12
 
@@ -22,11 +22,13 @@ module Dina
22
22
  property :createdOn, type: :time
23
23
 
24
24
  has_many :material_samples, class_name: "MaterialSample"
25
- has_many :attachment
25
+ has_many :attachment, class_name: "Attachment"
26
26
  has_many :involved_agents, class_name: "Person"
27
27
 
28
28
  validates_presence_of :group, message: "group is required"
29
29
 
30
+ attr_accessor :accepted_directions
31
+
30
32
  def self.endpoint_path
31
33
  "loan-transaction/"
32
34
  end
@@ -35,5 +37,21 @@ module Dina
35
37
  "transaction"
36
38
  end
37
39
 
40
+ def self.accepted_directions
41
+ [
42
+ "IN",
43
+ "OUT"
44
+ ]
45
+ end
46
+
47
+ private
48
+
49
+ def on_before_save
50
+ if !self.materialDirection.nil? && !self.class.accepted_directions.include?(self.materialDirection)
51
+ raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for materialDirection is one of #{self.class.accepted_directions.join(", ")}"
52
+ end
53
+ super
54
+ end
55
+
38
56
  end
39
57
  end
data/lib/dina/version.rb CHANGED
@@ -2,7 +2,7 @@ module Dina
2
2
  class Version
3
3
 
4
4
  MAJOR = 0
5
- MINOR = 2
5
+ MINOR = 4
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.2.0.0
4
+ version: 0.4.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-28 00:00:00.000000000 Z
11
+ date: 2022-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client
@@ -145,7 +145,6 @@ files:
145
145
  - lib/dina/models/assemblage.rb
146
146
  - lib/dina/models/attachment.rb
147
147
  - lib/dina/models/base_model.rb
148
- - lib/dina/models/bucket.rb
149
148
  - lib/dina/models/collecting_event.rb
150
149
  - lib/dina/models/collecting_method.rb
151
150
  - lib/dina/models/collection.rb
@@ -162,6 +161,7 @@ files:
162
161
  - lib/dina/models/organism.rb
163
162
  - lib/dina/models/organization.rb
164
163
  - lib/dina/models/person.rb
164
+ - lib/dina/models/preparation_method.rb
165
165
  - lib/dina/models/preparation_type.rb
166
166
  - lib/dina/models/project.rb
167
167
  - lib/dina/models/protocol.rb
@@ -1,8 +0,0 @@
1
- require_rel 'base_model'
2
- require_rel 'file'
3
-
4
- module Dina
5
- class Bucket < File
6
- property :id, type: :string, default: SecureRandom.uuid
7
- end
8
- end