labimotion 1.4.0 → 2.0.0.rc8
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/labimotion/apis/converter_api.rb +2 -2
- data/lib/labimotion/apis/generic_element_api.rb +1 -0
- data/lib/labimotion/apis/generic_klass_api.rb +3 -2
- data/lib/labimotion/apis/labimotion_api.rb +13 -0
- data/lib/labimotion/apis/standard_api.rb +25 -0
- data/lib/labimotion/apis/standard_layer_api.rb +87 -0
- data/lib/labimotion/apis/vocabulary_api.rb +93 -0
- data/lib/labimotion/constants.rb +25 -0
- data/lib/labimotion/entities/dataset_entity.rb +1 -1
- data/lib/labimotion/entities/element_entity.rb +1 -0
- data/lib/labimotion/entities/properties_entity.rb +229 -56
- data/lib/labimotion/entities/segment_entity.rb +0 -1
- data/lib/labimotion/entities/vocabulary_entity.rb +29 -0
- data/lib/labimotion/helpers/element_helpers.rb +10 -7
- data/lib/labimotion/helpers/generic_helpers.rb +6 -1
- data/lib/labimotion/helpers/param_helpers.rb +121 -82
- data/lib/labimotion/helpers/segment_helpers.rb +1 -1
- data/lib/labimotion/helpers/vocabulary_helpers.rb +16 -0
- data/lib/labimotion/libs/converter.rb +16 -35
- data/lib/labimotion/libs/data/mapper/Chemwiki.json +236 -0
- data/lib/labimotion/libs/data/mapper/Source.json +78 -0
- data/lib/labimotion/libs/data/vocab/Standard.json +385 -0
- data/lib/labimotion/libs/data/vocab/System.json +131 -0
- data/lib/labimotion/libs/dataset_builder.rb +70 -0
- data/lib/labimotion/libs/export_dataset.rb +343 -98
- data/lib/labimotion/libs/nmr_mapper.rb +204 -246
- data/lib/labimotion/libs/sample_association.rb +4 -0
- data/lib/labimotion/libs/vocabulary_handler.rb +118 -0
- data/lib/labimotion/models/concerns/attachment_converter.rb +5 -4
- data/lib/labimotion/models/concerns/datasetable.rb +1 -0
- data/lib/labimotion/models/concerns/generic_klass_revisions.rb +1 -0
- data/lib/labimotion/models/concerns/generic_revisions.rb +3 -0
- data/lib/labimotion/models/concerns/segmentable.rb +2 -0
- data/lib/labimotion/models/element.rb +3 -0
- data/lib/labimotion/models/std_layer.rb +9 -0
- data/lib/labimotion/models/std_layers_revision.rb +9 -0
- data/lib/labimotion/models/vocabulary.rb +12 -0
- data/lib/labimotion/utils/mapper_utils.rb +169 -0
- data/lib/labimotion/utils/utils.rb +21 -0
- data/lib/labimotion/version.rb +1 -1
- data/lib/labimotion.rb +13 -3
- metadata +25 -5
@@ -0,0 +1,131 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 1,
|
4
|
+
"identifier": "dateTime-create",
|
5
|
+
"name": "create_time",
|
6
|
+
"label": "Create Time",
|
7
|
+
"field_type": "datetime",
|
8
|
+
"opid": 9,
|
9
|
+
"term_id": "NCIT_C164483",
|
10
|
+
"ontology": {
|
11
|
+
"id": "ncit:class:http://purl.obolibrary.org/obo/NCIT_C164483",
|
12
|
+
"iri": "http://purl.obolibrary.org/obo/NCIT_C164483",
|
13
|
+
"type": "class",
|
14
|
+
"label": "Created Date",
|
15
|
+
"obo_id": "NCIT:C164483",
|
16
|
+
"short_form": "NCIT_C164483",
|
17
|
+
"description": [
|
18
|
+
"The date on which the activity or entity is created."
|
19
|
+
],
|
20
|
+
"ontology_name": "ncit",
|
21
|
+
"ontology_prefix": "NCIT"
|
22
|
+
},
|
23
|
+
"source": "System",
|
24
|
+
"voc": {
|
25
|
+
"source": "System"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"id": 2,
|
30
|
+
"identifier": "dateTime-update",
|
31
|
+
"name": "update_time",
|
32
|
+
"label": "Update Time",
|
33
|
+
"field_type": "datetime",
|
34
|
+
"opid": 9,
|
35
|
+
"term_id": "NCIT_C25164",
|
36
|
+
"ontology": {
|
37
|
+
"id": "ncit:class:http://purl.obolibrary.org/obo/NCIT_C25710",
|
38
|
+
"iri": "http://purl.obolibrary.org/obo/NCIT_C25710",
|
39
|
+
"short_form": "NCIT_C25710",
|
40
|
+
"obo_id": "NCIT:C25710",
|
41
|
+
"label": "Update",
|
42
|
+
"description": [
|
43
|
+
"Make current; supply with recent information or technology."
|
44
|
+
],
|
45
|
+
"ontology_name": "ncit",
|
46
|
+
"ontology_prefix": "NCIT",
|
47
|
+
"type": "class"
|
48
|
+
},
|
49
|
+
"source": "System",
|
50
|
+
"voc": {
|
51
|
+
"source": "System"
|
52
|
+
}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"id": 4,
|
56
|
+
"identifier": "user-name",
|
57
|
+
"name": "creator",
|
58
|
+
"label": "Creator",
|
59
|
+
"field_type": "text",
|
60
|
+
"opid": 9,
|
61
|
+
"term_id": "NCIT_C42628",
|
62
|
+
"ontology": {
|
63
|
+
"id": "ncit:class:http://purl.obolibrary.org/obo/NCIT_C42628",
|
64
|
+
"iri": "http://purl.obolibrary.org/obo/NCIT_C42628",
|
65
|
+
"type": "class",
|
66
|
+
"label": "Created By",
|
67
|
+
"obo_id": "NCIT:C42628",
|
68
|
+
"short_form": "NCIT_C42628",
|
69
|
+
"description": [
|
70
|
+
"Indicates the person or authoritative body who brought the item into existence."
|
71
|
+
],
|
72
|
+
"ontology_name": "ncit",
|
73
|
+
"ontology_prefix": "NCIT"
|
74
|
+
},
|
75
|
+
"source": "User",
|
76
|
+
"voc": {
|
77
|
+
"source": "User"
|
78
|
+
}
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"id": 2,
|
82
|
+
"identifier": "element-id",
|
83
|
+
"name": "element_id",
|
84
|
+
"label": "Element Id",
|
85
|
+
"field_type": "text",
|
86
|
+
"opid": 9,
|
87
|
+
"term_id": "NCIT_C25364",
|
88
|
+
"source": "Element",
|
89
|
+
"voc": {
|
90
|
+
"source": "Element"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"id": 5,
|
95
|
+
"identifier": "element-name",
|
96
|
+
"name": "element_name",
|
97
|
+
"label": "Element Name",
|
98
|
+
"field_type": "text",
|
99
|
+
"opid": 8,
|
100
|
+
"term_id": "NCIT_C42694",
|
101
|
+
"source": "Element",
|
102
|
+
"voc": {
|
103
|
+
"source": "Element"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"id": 3,
|
108
|
+
"identifier": "element-short_label",
|
109
|
+
"name": "element_short_label",
|
110
|
+
"label": "Element Short Label",
|
111
|
+
"field_type": "text",
|
112
|
+
"opid": 9,
|
113
|
+
"term_id": "NCIT_C45561",
|
114
|
+
"source": "Element",
|
115
|
+
"voc": {
|
116
|
+
"source": "Element"
|
117
|
+
}
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"id": 3,
|
121
|
+
"identifier": "element-class",
|
122
|
+
"name": "element_class",
|
123
|
+
"label": "Element Class",
|
124
|
+
"field_type": "text",
|
125
|
+
"opid": 9,
|
126
|
+
"source": "Element",
|
127
|
+
"voc": {
|
128
|
+
"source": "Element"
|
129
|
+
}
|
130
|
+
}
|
131
|
+
]
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'labimotion/utils/utils'
|
4
|
+
require 'labimotion/version'
|
5
|
+
|
6
|
+
module Labimotion
|
7
|
+
class DatasetBuilder
|
8
|
+
def self.build(container, content)
|
9
|
+
return unless valid_input?(container, content)
|
10
|
+
|
11
|
+
create_dataset_with_metadata(container, content)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.valid_input?(container, content)
|
17
|
+
container.present? &&
|
18
|
+
content.present? &&
|
19
|
+
content[:ols].present? &&
|
20
|
+
content[:metadata].present?
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.create_dataset_with_metadata(container, content)
|
24
|
+
klass = find_dataset_klass(content[:ols])
|
25
|
+
return unless klass
|
26
|
+
|
27
|
+
dataset = create_dataset(container, klass)
|
28
|
+
build_result(dataset, content)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find_dataset_klass(ols_term_id)
|
32
|
+
Labimotion::DatasetKlass.find_by(ols_term_id: ols_term_id)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.create_dataset(container, klass)
|
36
|
+
uuid = SecureRandom.uuid
|
37
|
+
props = prepare_properties(klass, uuid)
|
38
|
+
|
39
|
+
Labimotion::Dataset.create!(
|
40
|
+
uuid: uuid,
|
41
|
+
dataset_klass_id: klass.id,
|
42
|
+
element_type: 'Container',
|
43
|
+
element_id: container.id,
|
44
|
+
properties: props,
|
45
|
+
properties_release: klass.properties_release,
|
46
|
+
klass_uuid: klass.uuid
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.prepare_properties(klass, uuid)
|
51
|
+
props = klass.properties_release
|
52
|
+
props['uuid'] = uuid
|
53
|
+
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
54
|
+
props['klass'] = 'Dataset'
|
55
|
+
props
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.build_result(dataset, content)
|
59
|
+
{
|
60
|
+
dataset: dataset,
|
61
|
+
metadata: content[:metadata],
|
62
|
+
ols: content[:ols],
|
63
|
+
parameters: content[:parameters]
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
private_class_method :valid_input?, :create_dataset_with_metadata, :find_dataset_klass, :create_dataset,
|
68
|
+
:prepare_properties, :build_result
|
69
|
+
end
|
70
|
+
end
|