dina 0.1.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 +7 -0
- data/lib/dina/authentication/authentication.rb +100 -0
- data/lib/dina/casters/array_caster.rb +14 -0
- data/lib/dina/casters/multilingual_description.rb +42 -0
- data/lib/dina/casters/multilingual_description_caster.rb +13 -0
- data/lib/dina/casters/multilingual_title.rb +42 -0
- data/lib/dina/casters/multilingual_title_caster.rb +13 -0
- data/lib/dina/casters/object_caster.rb +11 -0
- data/lib/dina/components/determination.rb +31 -0
- data/lib/dina/components/georeference_assertion.rb +26 -0
- data/lib/dina/exceptions.rb +4 -0
- data/lib/dina/models/acquisition_event.rb +24 -0
- data/lib/dina/models/assemblage.rb +27 -0
- data/lib/dina/models/attachment.rb +19 -0
- data/lib/dina/models/base_model.rb +45 -0
- data/lib/dina/models/bucket.rb +8 -0
- data/lib/dina/models/collecting_event.rb +76 -0
- data/lib/dina/models/collecting_method.rb +23 -0
- data/lib/dina/models/collection.rb +40 -0
- data/lib/dina/models/derivative.rb +26 -0
- data/lib/dina/models/file.rb +40 -0
- data/lib/dina/models/identifier.rb +67 -0
- data/lib/dina/models/institution.rb +25 -0
- data/lib/dina/models/managed_attribute.rb +43 -0
- data/lib/dina/models/material_sample.rb +62 -0
- data/lib/dina/models/object_store.rb +50 -0
- data/lib/dina/models/object_store_managed_attribute.rb +39 -0
- data/lib/dina/models/object_subtype.rb +15 -0
- data/lib/dina/models/organism.rb +26 -0
- data/lib/dina/models/organization.rb +42 -0
- data/lib/dina/models/person.rb +43 -0
- data/lib/dina/models/preparation_type.rb +23 -0
- data/lib/dina/models/project.rb +28 -0
- data/lib/dina/models/protocol.rb +25 -0
- data/lib/dina/models/storage_unit.rb +26 -0
- data/lib/dina/models/storage_unit_type.rb +22 -0
- data/lib/dina/models/user.rb +26 -0
- data/lib/dina/search/base_search.rb +32 -0
- data/lib/dina/search/search.rb +20 -0
- data/lib/dina/search/search_autocomplete.rb +26 -0
- data/lib/dina/search/search_count.rb +20 -0
- data/lib/dina/search/search_mapping.rb +19 -0
- data/lib/dina/utils/identifier.rb +62 -0
- data/lib/dina/utils/identifier_type.rb +16 -0
- data/lib/dina/version.rb +14 -0
- data/lib/dina.rb +17 -0
- metadata +201 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Identifier < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :namespace, type: :string
|
7
|
+
property :value, type: :string
|
8
|
+
property :createdBy, type: :string
|
9
|
+
property :createdOn, type: :time
|
10
|
+
|
11
|
+
def self.endpoint_path
|
12
|
+
"agent-api/"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.table_name
|
16
|
+
"identifier"
|
17
|
+
end
|
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
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Institution < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :name, type: :string
|
7
|
+
property :multilingualDescription, type: :multilingual_description
|
8
|
+
property :webpage, type: :string
|
9
|
+
property :address, type: :string
|
10
|
+
property :remarks, type: :string
|
11
|
+
property :createdBy, type: :string
|
12
|
+
property :createdOn, type: :time
|
13
|
+
|
14
|
+
has_many :collections, class_name: "Collection"
|
15
|
+
|
16
|
+
def self.endpoint_path
|
17
|
+
"collection-api/"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.table_name
|
21
|
+
"institution"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class ManagedAttribute < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
property :name, type: :string
|
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
|
11
|
+
property :acceptedValues, type: :array
|
12
|
+
property :multilingualDescription, type: :multilingual_description
|
13
|
+
property :createdBy, type: :string
|
14
|
+
property :createdOn, type: :time
|
15
|
+
|
16
|
+
validates_presence_of :group
|
17
|
+
|
18
|
+
def self.endpoint_path
|
19
|
+
"collection-api/"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.table_name
|
23
|
+
"managed-attribute"
|
24
|
+
end
|
25
|
+
|
26
|
+
def english_description=(desc)
|
27
|
+
description[:en] = desc
|
28
|
+
end
|
29
|
+
|
30
|
+
def english_description
|
31
|
+
description[:en]
|
32
|
+
end
|
33
|
+
|
34
|
+
def french_description=(desc)
|
35
|
+
description[:fr] = desc
|
36
|
+
end
|
37
|
+
|
38
|
+
def french_description
|
39
|
+
description[:fr]
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class MaterialSample < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :dwcCatalogNumber, type: :string
|
7
|
+
property :materialSampleName, type: :string
|
8
|
+
property :materialSampleType, type: :string
|
9
|
+
property :createdBy, type: :string
|
10
|
+
property :createdOn, type: :time
|
11
|
+
property :barcode, type: :string
|
12
|
+
property :group, type: :string
|
13
|
+
property :managedAttributes, type: :object
|
14
|
+
property :dwcOtherCatalogNumbers, type: :array
|
15
|
+
property :preparationMethod, type: :string
|
16
|
+
property :preservationType, type: :string
|
17
|
+
property :preparationFixative, type: :string
|
18
|
+
property :preparationMaterials, type: :string
|
19
|
+
property :preparationSubstrate, type: :string
|
20
|
+
property :preparationDate, type: :time
|
21
|
+
property :preparationRemarks, type: :string
|
22
|
+
property :dwcDegreeOfEstablishment, type: :string
|
23
|
+
property :materialSampleState, type: :string
|
24
|
+
property :stateChangedOn, type: :time
|
25
|
+
property :stateChangeRemarks, type: :string
|
26
|
+
property :materialSampleRemarks, type: :string
|
27
|
+
property :materialSampleChildren, type: :array
|
28
|
+
property :associations, type: :array, default: []
|
29
|
+
property :tags, type: :array, default: []
|
30
|
+
property :publiclyReleasable, type: :boolean
|
31
|
+
property :notPubliclyReleasableReason, type: :string
|
32
|
+
property :hostOrganism, type: :object, default: { name: nil, remarks: nil }
|
33
|
+
property :scheduledActions, type: :object
|
34
|
+
property :hierarchy, type: :object
|
35
|
+
property :allowDuplicateName, type: :boolean
|
36
|
+
|
37
|
+
has_one :collection
|
38
|
+
has_one :parent_material_sample, class_name: "MaterialSample"
|
39
|
+
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"
|
46
|
+
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
|
49
|
+
has_many :organism, class_name: "Organism"
|
50
|
+
|
51
|
+
validates_presence_of :group, :materialSampleName
|
52
|
+
|
53
|
+
def self.endpoint_path
|
54
|
+
"collection-api/"
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.table_name
|
58
|
+
"material-sample"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class ObjectStore < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
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
|
+
property :dcFormat, type: :string
|
14
|
+
property :dcType, type: :string
|
15
|
+
property :acDigitizationDate, type: :time
|
16
|
+
property :acCaption, type: :string
|
17
|
+
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
|
+
property :originalFilename, type: :string
|
24
|
+
property :acHashFunction, type: :string, default: "SHA-1"
|
25
|
+
property :acHashValue, type: :string
|
26
|
+
property :acSubtype, type: :string
|
27
|
+
property :publiclyReleasable, type: :boolean, default: true
|
28
|
+
property :notPubliclyReleasableReason, type: :string
|
29
|
+
property :acTags, type: :string
|
30
|
+
property :resourceExternalURL, type: :string
|
31
|
+
property :managedAttributes, type: :object
|
32
|
+
property :createdBy, type: :string
|
33
|
+
property :createdOn, type: :time
|
34
|
+
|
35
|
+
has_one :ac_metadata_creator, class_name: "Person"
|
36
|
+
has_one :dc_creator, class_name: "Person"
|
37
|
+
has_many :derivatives, class_name: "Derivative"
|
38
|
+
|
39
|
+
validates_presence_of :group
|
40
|
+
|
41
|
+
def self.endpoint_path
|
42
|
+
"objectstore-api/"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.table_name
|
46
|
+
"metadata"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class ObjectStoreManagedAttribute < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :name, type: :string
|
7
|
+
property :key, type: :string
|
8
|
+
property :managedAttributeType, type: :string
|
9
|
+
property :acceptedValues, type: :array
|
10
|
+
property :multilingualDescription, type: :multilingual_description
|
11
|
+
property :createdBy, type: :string
|
12
|
+
property :createdOn, type: :time
|
13
|
+
|
14
|
+
def self.endpoint_path
|
15
|
+
"objectstore-api/"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.table_name
|
19
|
+
"managed-attribute"
|
20
|
+
end
|
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
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class ObjectSubtype < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
|
7
|
+
def self.endpoint_path
|
8
|
+
"objectstore-api/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.table_name
|
12
|
+
"object-subtype"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Organism < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
property :lifeStage, type: :string
|
8
|
+
property :sex, type: :string
|
9
|
+
property :remarks, type: :string
|
10
|
+
property :isTarget, type: :boolean
|
11
|
+
property :determination, type: :array, default: []
|
12
|
+
property :createdBy, type: :string
|
13
|
+
property :createdOn, type: :time
|
14
|
+
|
15
|
+
validates_presence_of :group
|
16
|
+
|
17
|
+
def self.endpoint_path
|
18
|
+
"collection-api/"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.table_name
|
22
|
+
"organism"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Organization < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
#NOTE: should be type: :multilingual_description but API not adjusted
|
7
|
+
property :names, type: :array, default: [{languageCode: "EN", name: nil}, {languageCode: "FR", name: nil}]
|
8
|
+
property :aliases, type: :array, default: []
|
9
|
+
property :createdBy, type: :string
|
10
|
+
property :createdOn, type: :time
|
11
|
+
|
12
|
+
validates :english_name, presence: true, on: :create
|
13
|
+
validates :french_name, presence: true, on: :create
|
14
|
+
|
15
|
+
def self.endpoint_path
|
16
|
+
"agent-api/"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.table_name
|
20
|
+
"organization"
|
21
|
+
end
|
22
|
+
|
23
|
+
def english_name=(name)
|
24
|
+
names.delete_if{|o| o[:languageCode] == "EN"}
|
25
|
+
names << { languageCode: "EN", name: name }
|
26
|
+
end
|
27
|
+
|
28
|
+
def english_name
|
29
|
+
names.select{|o| o[:languageCode] == "EN"}.first[:name]
|
30
|
+
end
|
31
|
+
|
32
|
+
def french_name=(name)
|
33
|
+
names.delete_if{|o| o[:languageCode] == "FR"}
|
34
|
+
names << { languageCode: "FR", name: name }
|
35
|
+
end
|
36
|
+
|
37
|
+
def french_name
|
38
|
+
names.select{|o| o[:languageCode] == "FR"}.first[:name]
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Person < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :displayName, type: :string, default: nil
|
7
|
+
property :givenNames, type: :string
|
8
|
+
property :familyNames, type: :string
|
9
|
+
property :email, type: :string
|
10
|
+
property :webpage, type: :string
|
11
|
+
property :remarks, type: :string
|
12
|
+
property :aliases, type: :array, default: []
|
13
|
+
property :createdBy, type: :string
|
14
|
+
property :createdOn, type: :time
|
15
|
+
|
16
|
+
has_many :organizations
|
17
|
+
has_many :identifiers
|
18
|
+
|
19
|
+
validates_presence_of :familyNames
|
20
|
+
|
21
|
+
def self.endpoint_path
|
22
|
+
"agent-api/"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.table_name
|
26
|
+
"person"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.find_by_email(email)
|
30
|
+
where("email": email).all.first
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def set_defaults
|
36
|
+
if self.displayName.nil? || self.displayName == ""
|
37
|
+
self.displayName = [familyNames, givenNames].compact.join(", ")
|
38
|
+
end
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class PreparationType < 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
|
13
|
+
|
14
|
+
def self.endpoint_path
|
15
|
+
"collection-api/"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.table_name
|
19
|
+
"preparation-type"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Project < 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 :startDate, type: :string
|
10
|
+
property :endDate, type: :string
|
11
|
+
property :status, type: :string
|
12
|
+
property :createdBy, type: :string
|
13
|
+
property :createdOn, type: :time
|
14
|
+
|
15
|
+
has_many :attachment, class_name: "ObjectStore"
|
16
|
+
|
17
|
+
validates_presence_of :group
|
18
|
+
|
19
|
+
def self.endpoint_path
|
20
|
+
"collection-api/"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.table_name
|
24
|
+
"project"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Protocol < 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
|
+
has_many :attachment, class_name: "ObjectStore"
|
13
|
+
|
14
|
+
validates_presence_of :group
|
15
|
+
|
16
|
+
def self.endpoint_path
|
17
|
+
"collection-api/"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.table_name
|
21
|
+
"protocol"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class StorageUnit < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
property :name, type: :string
|
8
|
+
property :storageUnitChildren, type: :array
|
9
|
+
property :hierarchy, type: :string
|
10
|
+
property :createdBy, type: :string
|
11
|
+
property :createdOn, type: :time
|
12
|
+
|
13
|
+
has_one :storage_unit_type
|
14
|
+
has_one :parent_storage_unit, class_name: "StorageUnit"
|
15
|
+
|
16
|
+
validates_presence_of :group
|
17
|
+
|
18
|
+
def self.endpoint_path
|
19
|
+
"collection-api/"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.table_name
|
23
|
+
"storage-unit"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class StorageUnitType < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :group, type: :string
|
7
|
+
property :name, type: :string
|
8
|
+
property :isInseperable, type: :boolean
|
9
|
+
property :createdBy, type: :string
|
10
|
+
property :createdOn, type: :time
|
11
|
+
|
12
|
+
validates_presence_of :group
|
13
|
+
|
14
|
+
def self.endpoint_path
|
15
|
+
"collection-api/"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.table_name
|
19
|
+
"storage-unit-type"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_rel 'base_model'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class User < BaseModel
|
5
|
+
property :id, type: :string, default: SecureRandom.uuid
|
6
|
+
property :username, type: :string
|
7
|
+
property :firstName, type: :string
|
8
|
+
property :lastName, type: :string
|
9
|
+
property :agentId, type: :string
|
10
|
+
property :emailAddress, type: :string
|
11
|
+
property :rolesPerGroup, type: :object
|
12
|
+
property :createdBy, type: :string
|
13
|
+
property :createdOn, type: :time
|
14
|
+
|
15
|
+
validates_presence_of :username
|
16
|
+
|
17
|
+
def self.endpoint_path
|
18
|
+
"user-api/"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.table_name
|
22
|
+
"user"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Dina
|
2
|
+
class BaseSearch
|
3
|
+
|
4
|
+
def self.endpoint
|
5
|
+
Settings.server.endpoint
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.endpoint_path
|
9
|
+
"search-api/search-ws/"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.index_name(index:)
|
13
|
+
return nil if !index
|
14
|
+
"dina_#{index}_index"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.execute(params, method: :get, payload: {})
|
18
|
+
begin
|
19
|
+
response = RestClient::Request.execute(
|
20
|
+
method: method,
|
21
|
+
url: endpoint + endpoint_path + "?" + params.to_query,
|
22
|
+
payload: payload.to_json,
|
23
|
+
headers: { accept: 'application/json', content_type: 'application/json' }
|
24
|
+
)
|
25
|
+
JSON.parse(response, symbolize_names: true)
|
26
|
+
rescue RestClient::ExceptionWithResponse => e
|
27
|
+
e.response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_rel 'base_search'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class Search < BaseSearch
|
5
|
+
|
6
|
+
def self.endpoint_path
|
7
|
+
"search-api/search-ws/search"
|
8
|
+
end
|
9
|
+
|
10
|
+
# index values: "agent", "material_sample", "object_store"
|
11
|
+
# payload is a hash in the form of an Elasticsearch body
|
12
|
+
def self.execute(index:, payload: { query: { match_all: {} } })
|
13
|
+
params = {
|
14
|
+
indexName: index_name(index: index)
|
15
|
+
}
|
16
|
+
super(params.compact, method: :post, payload: payload)[:hits]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_rel 'base_search'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class SearchAutocomplete < BaseSearch
|
5
|
+
|
6
|
+
def self.endpoint_path
|
7
|
+
"search-api/search-ws/auto-complete"
|
8
|
+
end
|
9
|
+
|
10
|
+
# index values: "agent", "material_sample", "object_store"
|
11
|
+
# known autocomplete fields:
|
12
|
+
# agent: data.attributes.displayName
|
13
|
+
# material_sample: included.attributes.dwcRecordedBy, included.attributes.verbatimDeterminer
|
14
|
+
# object_store: none
|
15
|
+
def self.execute(term:, index:, field: nil, group: nil)
|
16
|
+
params = {
|
17
|
+
prefix: term,
|
18
|
+
indexName: index_name(index: index),
|
19
|
+
autoCompleteField: field,
|
20
|
+
group: group
|
21
|
+
}
|
22
|
+
super(params.compact)[:hits]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_rel 'base_search'
|
2
|
+
|
3
|
+
module Dina
|
4
|
+
class SearchCount < BaseSearch
|
5
|
+
|
6
|
+
def self.endpoint_path
|
7
|
+
"search-api/search-ws/count"
|
8
|
+
end
|
9
|
+
|
10
|
+
# index values: "agent", "material_sample", "object_store"
|
11
|
+
# Payload is a has like: {query: {bool: {filter: {term: {"data.attributes.group": "dao"}}}}}
|
12
|
+
def self.execute(index:, payload: {})
|
13
|
+
params = {
|
14
|
+
indexName: index_name(index: index)
|
15
|
+
}
|
16
|
+
super(params.compact, method: :post, payload: payload)[:count]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|