dina 2.3.0.0 → 3.0.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: 9ea5252ef054c209ba20f6838bb83a9ca4bd0316e4e6a6cf3f80b6376ebb584e
4
- data.tar.gz: 1ee32a455976e479d30cc56fbdf87f570769cff606556ed18ade6d6bc896e277
3
+ metadata.gz: 3174b82c140553bb33e4c0e2e51045aeb2348cf45641b5e16e9985f10e7bbe78
4
+ data.tar.gz: 665cfdca10f68aeb174b6b9e2d9a8b8d82eee62f46c2b566d1536325ec39dd1d
5
5
  SHA512:
6
- metadata.gz: 98623d3b0ef78e402bca5a56848ca5b4174e441e164ab68ba2148c76b2b09d8e1358b705f87d7bc9b9a7a6c1c97bc9353aef9f70027dc80fa9269e0b7fa68837
7
- data.tar.gz: f21cd32cbcaad5ffca5ec8ae82cb63be9f6deba75eceddf2be5081b4c7132b0d7e5cb85ed74f4cc218121f86bc4d5137f9c98a1cdd30042831ec2d5da29faa1b
6
+ metadata.gz: 9c766bb416f305c286121edcdcef8bc36eaa2e0b25c8070a9aa48f59cca9ee95f671ab731ef566718c4980714cb813672b20c20f56db3229d082809acad5f32b
7
+ data.tar.gz: e109627e4b8b7e95e660db7fd469d89c29a9ec428973921144c2bccb2bae1ca3358a0ca586c3af082192261b388f249799e262f52bdf6f00b1008756d2fe4ec6
@@ -8,7 +8,7 @@ module Dina
8
8
  property :createdBy, type: :string
9
9
  property :createdOn, type: :time
10
10
 
11
- belongs_to :person, shallow_path: true, class_name: "Person"
11
+ belongs_to :person, class_name: "Person", shallow_path: true
12
12
 
13
13
  validates_presence_of :namespace, message: "namespace is required"
14
14
  validates_presence_of :value, message: "value is required"
@@ -8,8 +8,8 @@ module Dina
8
8
  property :createdBy, type: :string
9
9
  property :createdOn, type: :time
10
10
 
11
- validates :english_name, presence: true, on: :create
12
- validates :french_name, presence: true, on: :create
11
+ validates :englishName, presence: true, on: :create
12
+ validates :frenchName, presence: true, on: :create
13
13
 
14
14
  def self.endpoint_path
15
15
  "agent-api/"
@@ -19,21 +19,21 @@ module Dina
19
19
  "organization"
20
20
  end
21
21
 
22
- def english_name=(name)
22
+ def englishName=(name)
23
23
  names.delete_if{|o| o[:languageCode] == "EN"}
24
24
  names << { languageCode: "EN", name: name }
25
25
  end
26
26
 
27
- def english_name
27
+ def englishName
28
28
  names.select{|o| o[:languageCode] == "EN"}.first[:name]
29
29
  end
30
30
 
31
- def french_name=(name)
31
+ def frenchName=(name)
32
32
  names.delete_if{|o| o[:languageCode] == "FR"}
33
33
  names << { languageCode: "FR", name: name }
34
34
  end
35
35
 
36
- def french_name
36
+ def frenchName
37
37
  names.select{|o| o[:languageCode] == "FR"}.first[:name]
38
38
  end
39
39
 
@@ -4,10 +4,10 @@ module Dina
4
4
  class Attachment < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid_v7
6
6
 
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"
7
+ belongs_to :materialSample, class_name: "MaterialSample", shallow_path: true
8
+ belongs_to :collectingEvent, class_name: "CollectingEvent", shallow_path: true
9
+ belongs_to :project, class_name: "Project", shallow_path: true
10
+ belongs_to :transaction, class_name: "Transaction", shallow_path: true
11
11
 
12
12
  def self.endpoint_path
13
13
  "collection-api/"
@@ -4,9 +4,15 @@ module Dina
4
4
 
5
5
  self.raise_on_blank_find_param = true
6
6
  self.add_defaults_to_changes = true
7
- self.json_key_format = :camelized_key
8
7
  self.paginator = JsonApiClient::Paginating::NestedParamPaginator
9
8
 
9
+ resolve_custom_type "collection-method", "Dina::CollectionMethod"
10
+ resolve_custom_type "collecting-event", "Dina::CollectingEvent"
11
+ resolve_custom_type "preparation-type", "Dina::PreparationType"
12
+ resolve_custom_type "preparation-method", "Dina::PreparationMethod"
13
+ resolve_custom_type "material-sample", "Dina::MaterialSample"
14
+ resolve_custom_type "storage-unit", "Dina::StorageUnit"
15
+
10
16
  before_create :on_before_create
11
17
  before_save :on_before_save
12
18
 
@@ -43,11 +43,11 @@ module Dina
43
43
  property :createdBy, type: :string
44
44
  property :createdOn, type: :time
45
45
 
46
+ has_one :protocol, class_name: "Protocol"
47
+ has_one :collectionMethod, class_name: "CollectionMethod"
46
48
  has_many :collectors, class_name: "Person"
47
49
  has_many :attachment, class_name: "Attachment"
48
50
 
49
- has_one :collection_method, class_name: "CollectionMethod"
50
-
51
51
  validates_presence_of :group, message: "group is required"
52
52
 
53
53
  before_save :on_before_save
@@ -15,8 +15,8 @@ module Dina
15
15
  property :createdBy, type: :string
16
16
  property :createdOn, type: :time
17
17
 
18
- belongs_to :institution, shallow_path: true, class_name: "Institution"
19
- has_one :parent_collection, class_name: "Collection"
18
+ belongs_to :institution, class_name: "Institution", shallow_path: true
19
+ has_one :parentCollection, class_name: "Collection"
20
20
 
21
21
  validates_presence_of :group, message: "group is required"
22
22
 
@@ -9,8 +9,6 @@ module Dina
9
9
  property :createdBy, type: :string
10
10
  property :createdOn, type: :time
11
11
 
12
- belongs_to :collecting_event, class: "CollectingEvent", shallow_path: true
13
-
14
12
  validates_presence_of :group, message: "group is required"
15
13
 
16
14
  def self.endpoint_path
@@ -41,13 +41,13 @@ module Dina
41
41
  property :allowDuplicateName, type: :boolean
42
42
 
43
43
  has_one :collection, class_name: "Collection"
44
- has_one :collecting_event, class_name: "CollectingEvent"
45
- has_one :preparation_type, class_name: "PreparationType"
46
- has_one :preparation_method, class_name: "PreparationMethod"
47
- has_one :parent_material_sample, class_name: "MaterialSample"
48
- has_one :preparation_protocol, class_name: "Protocol"
49
- has_one :storage_unit, class_name: "StorageUnit"
50
- has_many :prepared_by, class_name: "Person"
44
+ has_one :collectingEvent, class_name: "CollectingEvent"
45
+ has_one :preparationType, class_name: "PreparationType"
46
+ has_one :preparationMethod, class_name: "PreparationMethod"
47
+ has_one :parentMaterialSample, class_name: "MaterialSample"
48
+ has_one :preparationProtocol, class_name: "Protocol"
49
+ has_one :storageUnit, class_name: "StorageUnit"
50
+ has_many :preparedBy, class_name: "Person"
51
51
  has_many :attachment, class_name: "Attachment"
52
52
  has_many :projects, class_name: "Project"
53
53
  has_many :assemblages, class_name: "Assemblage"
@@ -13,7 +13,7 @@ module Dina
13
13
  property :derivativeType, type: :string
14
14
  property :publiclyReleasable, type: :boolean, default: true
15
15
 
16
- has_one :ac_derived_from, class_name: "ObjectStore"
16
+ has_one :acDerivedFrom, class_name: "ObjectStore"
17
17
 
18
18
  validates_presence_of :bucket, message: "bucket is required"
19
19
  validates_presence_of :dcFormat, message: "dcFormat is required"
@@ -33,7 +33,7 @@ module Dina
33
33
 
34
34
  def on_before_save
35
35
  if self.as_json_api["relationships"].nil? || !self.as_json_api["relationships"].has_key?("acDerivedFrom")
36
- raise ObjectInvalid, "#{self.class} is invalid. ac_derived_from relationship is required"
36
+ raise ObjectInvalid, "#{self.class} is invalid. acDerivedFrom relationship is required"
37
37
  end
38
38
  super
39
39
  end
@@ -4,14 +4,14 @@ require_rel 'file_connection'
4
4
  module Dina
5
5
 
6
6
  class File < BaseModel
7
+ self.connection_class = FileConnection
8
+
7
9
  property :id, type: :string, default: SecureRandom.uuid_v7
8
10
  property :group, type: :string
9
11
  property :filePath, type: :string
10
12
  property :fileName, type: :string
11
13
  property :dcFormat, type: :string
12
- property :is_derivative, type: :boolean
13
-
14
- self.connection_class = FileConnection
14
+ property :isDerivative, type: :boolean
15
15
 
16
16
  validates_presence_of :group, message: "group is required"
17
17
  validates_presence_of :filePath, message: "filePath is required"
@@ -10,6 +10,7 @@ module Dina
10
10
 
11
11
  @faraday = Faraday.new(site, connection_options) do |builder|
12
12
  builder.request :multipart
13
+ builder.response :json
13
14
  builder.adapter(*adapter_options)
14
15
  end
15
16
  yield(self) if block_given?
@@ -17,7 +18,7 @@ module Dina
17
18
 
18
19
  def run(request_method, path, params: nil, headers: {}, body: nil)
19
20
  path = path + "/#{body[:data]["attributes"]["group"].downcase}"
20
- if body[:data]["attributes"].key?("is_derivative")
21
+ if body[:data]["attributes"].key?("isDerivative")
21
22
  path = path + "/derivative"
22
23
  end
23
24
  file_path = body[:data]["attributes"]["filePath"]
@@ -33,7 +34,7 @@ module Dina
33
34
  response = @faraday.run_request(request_method, path, body, headers) do |request|
34
35
  request.params.update(params) if params
35
36
  end
36
- attributes = JSON.parse(response.body.dup)
37
+ attributes = response.body.dup
37
38
  response.body["meta"] = {}
38
39
  response.body["errors"] = []
39
40
  response.body["data"] = {
@@ -29,8 +29,8 @@ module Dina
29
29
  property :orientation, type: :integer
30
30
  property :resourceExternalURL, type: :string
31
31
 
32
- has_one :ac_metadata_creator, class_name: "Person"
33
- has_one :dc_creator, class_name: "Person"
32
+ has_one :acMetadataCreator, class_name: "Person"
33
+ has_one :dcCreator, class_name: "Person"
34
34
  has_many :derivatives, class_name: "Derivative"
35
35
 
36
36
  validates_presence_of :group, message: "group is required"
@@ -30,7 +30,7 @@ module Dina
30
30
  property :createdBy, type: :string
31
31
  property :createdOn, type: :time
32
32
 
33
- has_one :region
33
+ has_one :region, class_name: "Region"
34
34
 
35
35
  validates_presence_of :group, message: "group is required"
36
36
  validates_presence_of :name, message: "name is required"
@@ -11,7 +11,7 @@ module Dina
11
11
  property :createdBy, type: :string
12
12
  property :createdOn, type: :time
13
13
 
14
- has_one :storage_unit_type
14
+ has_one :storage_unit_type, class_name: "StorageUnitType"
15
15
  has_one :parent_storage_unit, class_name: "StorageUnit"
16
16
 
17
17
  validates_presence_of :group, message: "group is required"
@@ -3,7 +3,6 @@ require_rel 'search_connection'
3
3
 
4
4
  module Dina
5
5
  class Search < BaseModel
6
-
7
6
  self.connection_class = SearchConnection
8
7
 
9
8
  custom_endpoint :execute, on: :collection, request_method: :post
@@ -5,7 +5,6 @@ require_rel 'search_connection'
5
5
 
6
6
  module Dina
7
7
  class SearchAutoComplete < BaseModel
8
-
9
8
  self.connection_class = SearchConnection
10
9
 
11
10
  custom_endpoint :execute, on: :collection, request_method: :get
@@ -13,6 +13,7 @@ module Dina
13
13
 
14
14
  @faraday = Faraday.new(site, connection_options) do |builder|
15
15
  builder.request :json
16
+ builder.response :json
16
17
  builder.adapter(*adapter_options)
17
18
  end
18
19
  yield(self) if block_given?
@@ -47,7 +48,7 @@ module Dina
47
48
  request.body = payload
48
49
  end
49
50
 
50
- attributes = JSON.parse(response.body.dup)
51
+ attributes = response.body.dup
51
52
  meta = {}
52
53
  if attributes.has_key?("hits")
53
54
  #TODO: does not work with SearchAutoComplete because response is different from Search
@@ -65,7 +66,6 @@ module Dina
65
66
 
66
67
  def use(middleware, *args, &block)
67
68
  return if faraday.builder.locked?
68
- faraday.builder.insert_before(Middleware::ParseJson, middleware, *args, &block)
69
69
  end
70
70
 
71
71
  end
@@ -3,7 +3,6 @@ require_rel 'search_connection'
3
3
 
4
4
  module Dina
5
5
  class SearchCount < BaseModel
6
-
7
6
  self.connection_class = SearchConnection
8
7
 
9
8
  custom_endpoint :execute, on: :collection, request_method: :post
@@ -3,7 +3,6 @@ require_rel 'search_connection'
3
3
 
4
4
  module Dina
5
5
  class SearchMapping < BaseModel
6
-
7
6
  self.connection_class = SearchConnection
8
7
 
9
8
  custom_endpoint :execute, on: :collection, request_method: :get
data/lib/dina/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Dina
2
2
  class Version
3
3
 
4
- MAJOR = 2
5
- MINOR = 3
4
+ MAJOR = 3
5
+ MINOR = 0
6
6
  PATCH = 0
7
7
  BUILD = 0
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0.0
4
+ version: 3.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-05-27 00:00:00.000000000 Z
12
+ date: 2024-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_api_client