dina 0.4.0.0 → 0.4.2.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 +4 -4
- data/lib/dina/json_api_client_patch.rb +11 -0
- data/lib/dina/models/{identifier.rb → agent/identifier.rb} +3 -1
- data/lib/dina/models/{organization.rb → agent/organization.rb} +1 -1
- data/lib/dina/models/{person.rb → agent/person.rb} +21 -1
- data/lib/dina/models/{collecting_event.rb → material_sample/collecting_event.rb} +1 -1
- data/lib/dina/models/{collecting_method.rb → material_sample/collecting_method.rb} +1 -1
- data/lib/dina/models/{collection.rb → material_sample/collection.rb} +1 -1
- data/lib/dina/models/{collection_sequence_generator.rb → material_sample/collection_sequence_generator.rb} +1 -1
- data/lib/dina/models/{material_sample.rb → material_sample/material_sample.rb} +1 -1
- data/lib/dina/models/{organism.rb → material_sample/organism.rb} +1 -1
- data/lib/dina/models/{preparation_method.rb → material_sample/preparation_method.rb} +1 -1
- data/lib/dina/models/{preparation_type.rb → material_sample/preparation_type.rb} +1 -1
- data/lib/dina/models/{project.rb → material_sample/project.rb} +1 -1
- data/lib/dina/models/{protocol.rb → material_sample/protocol.rb} +1 -1
- data/lib/dina/models/{derivative.rb → object_store/derivative.rb} +1 -1
- data/lib/dina/models/{file.rb → object_store/file.rb} +0 -0
- data/lib/dina/models/{object_store.rb → object_store/object_store.rb} +1 -1
- data/lib/dina/models/{object_store_managed_attribute.rb → object_store/object_store_managed_attribute.rb} +1 -1
- data/lib/dina/models/{object_subtype.rb → object_store/object_subtype.rb} +1 -1
- data/lib/dina/models/sequence/index_set.rb +19 -0
- data/lib/dina/models/sequence/molecular_sample.rb +19 -0
- data/lib/dina/models/sequence/ngs_workflow.rb +19 -0
- data/lib/dina/models/sequence/pcr_batch.rb +19 -0
- data/lib/dina/models/sequence/pcr_primer.rb +19 -0
- data/lib/dina/models/sequence/product.rb +19 -0
- data/lib/dina/models/sequence/region.rb +19 -0
- data/lib/dina/models/sequence/thermocycler_profile.rb +19 -0
- data/lib/dina/models/{storage_unit.rb → storage/storage_unit.rb} +1 -1
- data/lib/dina/models/{storage_unit_type.rb → storage/storage_unit_type.rb} +1 -1
- data/lib/dina/models/{transaction.rb → transaction/transaction.rb} +1 -1
- data/lib/dina/search/base_search.rb +22 -6
- data/lib/dina/search/search.rb +7 -2
- data/lib/dina/search/search_autocomplete.rb +10 -2
- data/lib/dina/search/search_count.rb +8 -3
- data/lib/dina/search/search_mapping.rb +5 -1
- data/lib/dina/version.rb +1 -1
- metadata +46 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 868b096ec196f62ae6cf4507cadf08c277b26f462957873140abc93ecf88a1a6
|
4
|
+
data.tar.gz: 26c127ec2bf4e6e9c990b4361aff69d1ce9f6a5e578ae01065472e8ede524bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fcd3ceca0594b95caaea14870a0ff6ebc9284fab58eac5e98bd236c04e8235b4fb542c720cba9c394b63b719a4883642f82e0871b347a9a18c5225c8e42e5b6
|
7
|
+
data.tar.gz: 95d262c72d8955a9eb944886efcd0784af500f4f8235846bc062a69d5128652e0af0260d85f7243bd608e8d2bd3f895a309cc752baac6b742282f84db658f88e
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Monkeypatch the data method because the relations urls in the DINA JSON:API spec are incorrectly formed through its frontend proxy
|
2
|
+
module JsonApiClient
|
3
|
+
module Associations
|
4
|
+
class BaseAssociation
|
5
|
+
def data(url)
|
6
|
+
url.sub!("/api/v1/", "/api/#{association_class.requestor.instance_variable_get(:@klass).endpoint_path}")
|
7
|
+
from_result_set(association_class.requestor.linked(url))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_rel 'base_model'
|
1
|
+
require_rel '../base_model'
|
2
2
|
|
3
3
|
module Dina
|
4
4
|
class Identifier < BaseModel
|
@@ -8,6 +8,8 @@ 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"
|
12
|
+
|
11
13
|
def self.endpoint_path
|
12
14
|
"agent-api/"
|
13
15
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_rel 'base_model'
|
1
|
+
require_rel '../base_model'
|
2
2
|
|
3
3
|
module Dina
|
4
4
|
class Person < BaseModel
|
@@ -35,6 +35,26 @@ module Dina
|
|
35
35
|
where("email": email).all
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.search_by_name(name)
|
39
|
+
payload = {
|
40
|
+
query: {
|
41
|
+
multi_match: {
|
42
|
+
query: name,
|
43
|
+
type: :cross_fields,
|
44
|
+
fields: [
|
45
|
+
"data.attributes.familyNames^3",
|
46
|
+
"data.attributes.givenNames",
|
47
|
+
"data.attributes.displayName^5",
|
48
|
+
"data.attributes.aliases",
|
49
|
+
"data.attributes.displayName.autocomplete"
|
50
|
+
]
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
hits = Dina::Search.execute(index: "agent", payload: payload)[:hits]
|
55
|
+
hits.map{|a| self.find(a[:_source][:data][:id]).first }
|
56
|
+
end
|
57
|
+
|
38
58
|
private
|
39
59
|
|
40
60
|
def on_before_save
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class IndexSet < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"index-set"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class MolecularSample < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"molecular-sample"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class NgsWorkflow < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"chain"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class PcrBatch < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"pcr-batch"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class PcrPrimer < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"pcr-primer"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Product < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"product"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Region < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"region"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_rel '../base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class ThermocyclerProfile < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
|
8
|
+
validates_presence_of :group, message: "group is required"
|
9
|
+
|
10
|
+
def self.endpoint_path
|
11
|
+
"seqdb-api/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.table_name
|
15
|
+
"thermocycler-profile"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -2,26 +2,42 @@ module Dina
|
|
2
2
|
class BaseSearch
|
3
3
|
|
4
4
|
def self.endpoint
|
5
|
-
|
5
|
+
Dina::Authentication.endpoint_url
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.endpoint_path
|
9
9
|
"search-api/search-ws/"
|
10
10
|
end
|
11
11
|
|
12
|
+
# Sets the search index name
|
13
|
+
#
|
14
|
+
# @param index [String] the search index; options are "agent", "material_sample", "object_store"
|
15
|
+
#
|
16
|
+
# @return [String] the internally-recognized search index name
|
12
17
|
def self.index_name(index:)
|
13
18
|
return nil if !index
|
14
19
|
"dina_#{index}_index"
|
15
20
|
end
|
16
21
|
|
22
|
+
# Executes a search
|
23
|
+
#
|
24
|
+
# @param params [Hash] the parameters to be included in the endpoint URL
|
25
|
+
# @param method [Symbol] the request type as :get or :post
|
26
|
+
# @param payload [Hash] the elasticsearch query
|
27
|
+
#
|
28
|
+
# @return [Hash] the search response with symbolized keys
|
17
29
|
def self.execute(params, method: :get, payload: {})
|
18
30
|
begin
|
19
31
|
response = RestClient::Request.execute(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
32
|
+
method: method,
|
33
|
+
url: endpoint + endpoint_path + "?" + params.to_query,
|
34
|
+
payload: payload.to_json,
|
35
|
+
headers: {
|
36
|
+
accept: 'application/json',
|
37
|
+
content_type: 'application/json',
|
38
|
+
authorization: Dina::Authentication.header
|
39
|
+
}
|
40
|
+
)
|
25
41
|
JSON.parse(response, symbolize_names: true)
|
26
42
|
rescue RestClient::ExceptionWithResponse => e
|
27
43
|
e.response
|
data/lib/dina/search/search.rb
CHANGED
@@ -7,8 +7,13 @@ module Dina
|
|
7
7
|
"search-api/search-ws/search"
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
10
|
+
# Executes a search
|
11
|
+
#
|
12
|
+
# @param index [String] the index, accepted value is one of "agent", "material_sample", "object_store"
|
13
|
+
# @param payload [Hash] the payload hash as an Elasticsearch-formatted body
|
14
|
+
# => { query: { match_all: {} }
|
15
|
+
#
|
16
|
+
# @return [Hash] the search result with symbolized keys
|
12
17
|
def self.execute(index:, payload: { query: { match_all: {} } })
|
13
18
|
params = {
|
14
19
|
indexName: index_name(index: index)
|
@@ -7,11 +7,19 @@ module Dina
|
|
7
7
|
"search-api/search-ws/auto-complete"
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
10
|
+
# Executes an autocomplete search
|
11
|
+
#
|
12
|
+
# Known field values (dependent on chosen index):
|
12
13
|
# agent: data.attributes.displayName
|
13
14
|
# material_sample: included.attributes.dwcRecordedBy, included.attributes.verbatimDeterminer
|
14
15
|
# object_store: none
|
16
|
+
#
|
17
|
+
# @param term [String] the search term
|
18
|
+
# @param index [String] the index, accepted value is one of "agent", "material_sample", "object_store"
|
19
|
+
# @param field [String]
|
20
|
+
# @param group [String] the DINA group name
|
21
|
+
#
|
22
|
+
# @return [Hash] the search result with symbolized keys
|
15
23
|
def self.execute(term:, index:, field: nil, group: nil)
|
16
24
|
params = {
|
17
25
|
prefix: term,
|
@@ -7,9 +7,14 @@ module Dina
|
|
7
7
|
"search-api/search-ws/count"
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
10
|
+
# Executes an count search
|
11
|
+
#
|
12
|
+
# @param index [String] the index, accepted value is one of "agent", "material_sample", "object_store"
|
13
|
+
# @param payload [Hash] the Elasticsearch query hash
|
14
|
+
# => Example: {query: {bool: {filter: {term: {"data.attributes.group": "dao"}}}}}
|
15
|
+
#
|
16
|
+
# @return [Integer] the count of items in the index according to the query/filter
|
17
|
+
def self.execute(index:, payload: { query: { match_all: {} }})
|
13
18
|
params = {
|
14
19
|
indexName: index_name(index: index)
|
15
20
|
}
|
@@ -7,7 +7,11 @@ module Dina
|
|
7
7
|
"search-api/search-ws/mapping"
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
10
|
+
# Return the search mapping document
|
11
|
+
#
|
12
|
+
# @param index [String] the index, accepted value is one of "agent", "material_sample", "object_store"
|
13
|
+
#
|
14
|
+
# @return [Hash] the mapping document as a hash with symbolized keys
|
11
15
|
def self.execute(index:)
|
12
16
|
params = {
|
13
17
|
indexName: index_name(index: index)
|
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.
|
4
|
+
version: 0.4.2.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-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rest-client
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.1.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,33 +155,42 @@ files:
|
|
141
155
|
- lib/dina/components/georeference_assertion.rb
|
142
156
|
- lib/dina/components/shipment.rb
|
143
157
|
- lib/dina/exceptions.rb
|
158
|
+
- lib/dina/json_api_client_patch.rb
|
144
159
|
- lib/dina/models/acquisition_event.rb
|
160
|
+
- lib/dina/models/agent/identifier.rb
|
161
|
+
- lib/dina/models/agent/organization.rb
|
162
|
+
- lib/dina/models/agent/person.rb
|
145
163
|
- lib/dina/models/assemblage.rb
|
146
164
|
- lib/dina/models/attachment.rb
|
147
165
|
- lib/dina/models/base_model.rb
|
148
|
-
- lib/dina/models/collecting_event.rb
|
149
|
-
- lib/dina/models/collecting_method.rb
|
150
|
-
- lib/dina/models/collection.rb
|
151
|
-
- lib/dina/models/collection_sequence_generator.rb
|
152
|
-
- lib/dina/models/derivative.rb
|
153
|
-
- lib/dina/models/file.rb
|
154
|
-
- lib/dina/models/identifier.rb
|
155
166
|
- lib/dina/models/institution.rb
|
156
167
|
- lib/dina/models/managed_attribute.rb
|
157
|
-
- lib/dina/models/material_sample.rb
|
158
|
-
- lib/dina/models/
|
159
|
-
- lib/dina/models/
|
160
|
-
- lib/dina/models/
|
161
|
-
- lib/dina/models/
|
162
|
-
- lib/dina/models/
|
163
|
-
- lib/dina/models/
|
164
|
-
- lib/dina/models/
|
165
|
-
- lib/dina/models/
|
166
|
-
- lib/dina/models/
|
167
|
-
- lib/dina/models/
|
168
|
-
- lib/dina/models/
|
169
|
-
- lib/dina/models/
|
170
|
-
- lib/dina/models/
|
168
|
+
- lib/dina/models/material_sample/collecting_event.rb
|
169
|
+
- lib/dina/models/material_sample/collecting_method.rb
|
170
|
+
- lib/dina/models/material_sample/collection.rb
|
171
|
+
- lib/dina/models/material_sample/collection_sequence_generator.rb
|
172
|
+
- lib/dina/models/material_sample/material_sample.rb
|
173
|
+
- lib/dina/models/material_sample/organism.rb
|
174
|
+
- lib/dina/models/material_sample/preparation_method.rb
|
175
|
+
- lib/dina/models/material_sample/preparation_type.rb
|
176
|
+
- lib/dina/models/material_sample/project.rb
|
177
|
+
- lib/dina/models/material_sample/protocol.rb
|
178
|
+
- lib/dina/models/object_store/derivative.rb
|
179
|
+
- lib/dina/models/object_store/file.rb
|
180
|
+
- lib/dina/models/object_store/object_store.rb
|
181
|
+
- lib/dina/models/object_store/object_store_managed_attribute.rb
|
182
|
+
- lib/dina/models/object_store/object_subtype.rb
|
183
|
+
- lib/dina/models/sequence/index_set.rb
|
184
|
+
- lib/dina/models/sequence/molecular_sample.rb
|
185
|
+
- lib/dina/models/sequence/ngs_workflow.rb
|
186
|
+
- lib/dina/models/sequence/pcr_batch.rb
|
187
|
+
- lib/dina/models/sequence/pcr_primer.rb
|
188
|
+
- lib/dina/models/sequence/product.rb
|
189
|
+
- lib/dina/models/sequence/region.rb
|
190
|
+
- lib/dina/models/sequence/thermocycler_profile.rb
|
191
|
+
- lib/dina/models/storage/storage_unit.rb
|
192
|
+
- lib/dina/models/storage/storage_unit_type.rb
|
193
|
+
- lib/dina/models/transaction/transaction.rb
|
171
194
|
- lib/dina/models/user.rb
|
172
195
|
- lib/dina/search/base_search.rb
|
173
196
|
- lib/dina/search/search.rb
|