dina 0.1.0.0 → 0.3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dina/authentication/authentication.rb +18 -0
  3. data/lib/dina/casters/array_caster.rb +0 -1
  4. data/lib/dina/components/agent_role.rb +18 -0
  5. data/lib/dina/components/determination.rb +3 -3
  6. data/lib/dina/components/shipment.rb +24 -0
  7. data/lib/dina/exceptions.rb +1 -0
  8. data/lib/dina/models/acquisition_event.rb +1 -1
  9. data/lib/dina/models/assemblage.rb +3 -2
  10. data/lib/dina/models/attachment.rb +4 -2
  11. data/lib/dina/models/base_model.rb +7 -0
  12. data/lib/dina/models/collecting_event.rb +2 -1
  13. data/lib/dina/models/collecting_method.rb +1 -1
  14. data/lib/dina/models/collection.rb +2 -2
  15. data/lib/dina/models/collection_sequence_generator.rb +17 -0
  16. data/lib/dina/models/file.rb +30 -26
  17. data/lib/dina/models/identifier.rb +0 -47
  18. data/lib/dina/models/managed_attribute.rb +1 -1
  19. data/lib/dina/models/material_sample.rb +15 -12
  20. data/lib/dina/models/object_store.rb +23 -17
  21. data/lib/dina/models/object_store_managed_attribute.rb +0 -16
  22. data/lib/dina/models/object_subtype.rb +4 -0
  23. data/lib/dina/models/organism.rb +1 -1
  24. data/lib/dina/models/organization.rb +0 -1
  25. data/lib/dina/models/person.rb +9 -4
  26. data/lib/dina/models/preparation_method.rb +23 -0
  27. data/lib/dina/models/preparation_type.rb +1 -1
  28. data/lib/dina/models/project.rb +2 -2
  29. data/lib/dina/models/protocol.rb +2 -2
  30. data/lib/dina/models/storage_unit.rb +1 -1
  31. data/lib/dina/models/storage_unit_type.rb +1 -1
  32. data/lib/dina/models/transaction.rb +39 -0
  33. data/lib/dina/models/user.rb +1 -1
  34. data/lib/dina/version.rb +1 -1
  35. metadata +8 -4
  36. data/lib/dina/models/bucket.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb9d082cc5779c2164cc62c37dc96ccb9518172dd7d4906e5e7de7ca9270af35
4
- data.tar.gz: 0fe67de260e7fab5f9167175dfc85bd8fe64f000887941648d7b003bbab16ab5
3
+ metadata.gz: 9245c7481399aefbf8a290931823fafbc4970c2008ae4e299833c274825353c3
4
+ data.tar.gz: 448dcde684c17dd881ee2128f184871d05f690429199b92dd858c5c0735c22b8
5
5
  SHA512:
6
- metadata.gz: b1bc2b324d1c9d970aaba2703f347734dff1624f55104c924779e1ddf5a8f3cc0244403cd18c4de355e13dd7949251db844fc992414fb9652329b6d0e09afcae
7
- data.tar.gz: c3e36505634d44f74c9068988a90ccdd41bf4a9d8462491131665ffb53af15bfd1fc9d64d2527bf43dd2e352457de4a7f8bf228e29f72cb6069a5717e7e6cf0d
6
+ metadata.gz: b8d3ea143e058dab38c1073d6d614539620ceb5b14f3dc394a3b4535e069449b2921fe2365208bb9f8b5f7b2b46afb830edbe5bd0471dbd6c518c3d6cc3b8e2d
7
+ data.tar.gz: 9c18d70386ba41207d9d341e3a700e413ba63ddd34d5f81fcacd1f21453d05c84de2738d28b131767a07c649af800da404dcc62475e83055c92bbd44009b29ef
@@ -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
@@ -1,4 +1,3 @@
1
-
2
1
  module Dina
3
2
  class ArrayCaster
4
3
  def self.cast(value, default)
@@ -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/"
@@ -11,9 +11,10 @@ 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
- 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/"
@@ -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/"
@@ -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/"
@@ -15,10 +15,10 @@ 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
- 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
@@ -1,40 +1,44 @@
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
6
4
 
7
- def self.endpoint_path
8
- "objectstore-api/"
5
+ def initialize
9
6
  end
10
7
 
11
- def self.table_name
12
- "file"
8
+ def endpoint_path
9
+ "objectstore-api/"
13
10
  end
14
11
 
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
17
-
18
- =begin
12
+ def table_name
13
+ "file/#{@group}"
14
+ end
19
15
 
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
16
+ def url
17
+ Dina::Authentication.endpoint_url + endpoint_path + table_name
26
18
  end
27
19
 
28
- private
20
+ def file
21
+ ::File.new(file_path)
22
+ end
29
23
 
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)
24
+ def save
25
+ if group.nil?
26
+ raise ObjectInvalid, "#{self.class} is invalid. group is required."
27
+ end
28
+ if file_path.nil? || !::File.exist?(file_path)
29
+ raise ObjectInvalid, "#{self.class} is invalid. file not found in file_path."
30
+ end
31
+ response = RestClient::Request.execute(
32
+ method: :post,
33
+ headers: { authorization: Dina::Authentication.header },
34
+ url: url,
35
+ payload: {
36
+ multipart: true,
37
+ file: file
38
+ }
39
+ )
40
+ JSON.parse(response, symbolize_names: true)
36
41
  end
37
- =end
38
42
 
39
43
  end
40
44
  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
@@ -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/"
@@ -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,21 +36,22 @@ 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
- validates_presence_of :group, :materialSampleName
53
+ validates_presence_of :group, message: "group is required"
54
+ validates_presence_of :materialSampleName, message: "materialSampleName is required"
52
55
 
53
56
  def self.endpoint_path
54
57
  "collection-api/"
@@ -3,40 +3,37 @@ 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"
37
34
  has_many :derivatives, class_name: "Derivative"
38
35
 
39
- validates_presence_of :group
36
+ validates_presence_of :group, message: "group is required"
40
37
 
41
38
  def self.endpoint_path
42
39
  "objectstore-api/"
@@ -46,5 +43,14 @@ module Dina
46
43
  "metadata"
47
44
  end
48
45
 
46
+ private
47
+
48
+ def on_before_save
49
+ if self.bucket.nil?
50
+ self.bucket = self.group
51
+ end
52
+ super
53
+ end
54
+
49
55
  end
50
56
  end
@@ -19,21 +19,5 @@ 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
33
-
34
- def french_description
35
- description[:fr]
36
- end
37
-
38
22
  end
39
23
  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/"
@@ -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/"
@@ -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,10 +13,11 @@ 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
- 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
@@ -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
@@ -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/"
@@ -12,9 +12,9 @@ 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
- 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/"
@@ -9,9 +9,9 @@ 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
- 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, class_name: "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 = 3
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.3.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-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client
@@ -136,17 +136,19 @@ 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
144
146
  - lib/dina/models/attachment.rb
145
147
  - lib/dina/models/base_model.rb
146
- - lib/dina/models/bucket.rb
147
148
  - lib/dina/models/collecting_event.rb
148
149
  - lib/dina/models/collecting_method.rb
149
150
  - lib/dina/models/collection.rb
151
+ - lib/dina/models/collection_sequence_generator.rb
150
152
  - lib/dina/models/derivative.rb
151
153
  - lib/dina/models/file.rb
152
154
  - lib/dina/models/identifier.rb
@@ -159,11 +161,13 @@ files:
159
161
  - lib/dina/models/organism.rb
160
162
  - lib/dina/models/organization.rb
161
163
  - lib/dina/models/person.rb
164
+ - lib/dina/models/preparation_method.rb
162
165
  - lib/dina/models/preparation_type.rb
163
166
  - lib/dina/models/project.rb
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: {}
@@ -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