labimotion 2.0.0.rc2 → 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/standard_api.rb +1 -2
- data/lib/labimotion/apis/standard_layer_api.rb +4 -17
- data/lib/labimotion/apis/vocabulary_api.rb +5 -19
- data/lib/labimotion/constants.rb +25 -0
- data/lib/labimotion/entities/dataset_entity.rb +0 -1
- data/lib/labimotion/entities/element_entity.rb +1 -0
- data/lib/labimotion/entities/properties_entity.rb +102 -41
- data/lib/labimotion/entities/segment_entity.rb +0 -2
- data/lib/labimotion/entities/vocabulary_entity.rb +0 -10
- data/lib/labimotion/helpers/element_helpers.rb +4 -3
- data/lib/labimotion/helpers/generic_helpers.rb +6 -1
- data/lib/labimotion/helpers/param_helpers.rb +0 -16
- data/lib/labimotion/libs/converter.rb +0 -1
- data/lib/labimotion/libs/data/mapper/Chemwiki.json +236 -0
- data/lib/labimotion/libs/data/mapper/Source.json +78 -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 -247
- 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/element.rb +3 -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 +3 -3
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53e20059dd2a04452a513beb5024c762f8596d5694874c67b58d64baaf0ce47
|
4
|
+
data.tar.gz: d6b10330fe1dbce975b54a799e5a25d4cb13202fcf7b0a909ae9204fa1442146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 118380f7c4b0483f3ceb7b80d5aa324db7d3fcde3e0b7a5ee66a92a02528fd8e8b352072c79fce563c9955eedc7efcf199e1f1645d391736c54715993f8d4c1d
|
7
|
+
data.tar.gz: c23b0428e3854382643548c08abdd0b875efbcdc052b7b6dd7a612996781056679dc23ce09d46b99e844c1e69016bd17dc54d9dd6d99bbfe1d22a6ce9bd06c44
|
@@ -13,8 +13,7 @@ module Labimotion
|
|
13
13
|
use :create_std_layer_params
|
14
14
|
end
|
15
15
|
post do
|
16
|
-
|
17
|
-
# create_element_klass(current_user, params)
|
16
|
+
authenticate_admin!('standard_layers')
|
18
17
|
create_std_layer(current_user, params)
|
19
18
|
status 201
|
20
19
|
rescue ActiveRecord::RecordInvalid => e
|
@@ -7,14 +7,13 @@ module Labimotion
|
|
7
7
|
class StandardLayerAPI < Grape::API
|
8
8
|
include Grape::Kaminari
|
9
9
|
helpers Labimotion::ParamHelpers
|
10
|
+
helpers Labimotion::GenericHelpers
|
10
11
|
|
11
12
|
resource :layers do
|
12
13
|
namespace :get_all_layers do
|
13
14
|
desc 'get all standard layers for designer'
|
14
15
|
get do
|
15
16
|
list = Labimotion::StdLayer.all.sort_by { |e| e.name }
|
16
|
-
# present list, with: Labimotion::StdLayer, root: 'klass'
|
17
|
-
# data = Labimotion::StdLayer.represent(col_tree, serializable: true)
|
18
17
|
return { mc: 'ss00', data: list }
|
19
18
|
rescue StandardError => e
|
20
19
|
Labimotion.log_exception(e, current_user)
|
@@ -24,17 +23,9 @@ module Labimotion
|
|
24
23
|
|
25
24
|
namespace :get_standard_layer do
|
26
25
|
desc 'get standard layer by id'
|
27
|
-
# params do
|
28
|
-
# requires :id, type: Integer, desc: 'Layer id'
|
29
|
-
# end
|
30
26
|
route_param :id do
|
31
|
-
before do
|
32
|
-
# @element_policy = ElementPolicy.new(current_user, Labimotion::Element.find(params[:id]))
|
33
|
-
# error!('401 Unauthorized', 401) unless current_user.matrix_check_by_name('genericElement') && @element_policy.read?
|
34
|
-
# rescue ActiveRecord::RecordNotFound
|
35
|
-
# error!('404 Not Found', 404)
|
36
|
-
end
|
37
27
|
get do
|
28
|
+
authenticate_admin!('standard_layers')
|
38
29
|
entity = Labimotion::StdLayer.find(params[:id])
|
39
30
|
return { mc: 'ss00', data: entity }
|
40
31
|
rescue StandardError => e
|
@@ -50,13 +41,9 @@ module Labimotion
|
|
50
41
|
use :std_layer_save
|
51
42
|
end
|
52
43
|
before do
|
44
|
+
authenticate_admin!('standard_layers')
|
53
45
|
cur_layer = Labimotion::StdLayer.find_by(name: params[:key])
|
54
46
|
error!('Error! duplicate name', 409) if cur_layer.present?
|
55
|
-
# @element_policy = ElementPolicy.new(current_user, Labimotion::Element.find(params[:id]))
|
56
|
-
# error!('401 Unauthorized', 401) unless current_user.matrix_check_by_name('genericElement') && @element_policy.read?
|
57
|
-
# rescue ActiveRecord::RecordNotFound
|
58
|
-
# Labimotion.log_exception(e, current_user)
|
59
|
-
# error!('404 Not Found', 404)
|
60
47
|
end
|
61
48
|
post do
|
62
49
|
attributes = {
|
@@ -83,7 +70,7 @@ module Labimotion
|
|
83
70
|
end
|
84
71
|
route_param :id do
|
85
72
|
before do
|
86
|
-
|
73
|
+
authenticate_admin!('standard_layers')
|
87
74
|
end
|
88
75
|
delete do
|
89
76
|
entity = Labimotion::StdLayer.find(params[:id])
|
@@ -7,6 +7,7 @@ module Labimotion
|
|
7
7
|
class VocabularyAPI < Grape::API
|
8
8
|
include Grape::Kaminari
|
9
9
|
helpers Labimotion::ParamHelpers
|
10
|
+
helpers Labimotion::GenericHelpers
|
10
11
|
|
11
12
|
resource :vocab do
|
12
13
|
namespace :save_vocabulary do
|
@@ -15,7 +16,7 @@ module Labimotion
|
|
15
16
|
use :vocab_save
|
16
17
|
end
|
17
18
|
before do
|
18
|
-
|
19
|
+
authenticate_admin!('vocabularies')
|
19
20
|
rescue ActiveRecord::RecordNotFound
|
20
21
|
error!('404 Not Found', 404)
|
21
22
|
end
|
@@ -46,17 +47,8 @@ module Labimotion
|
|
46
47
|
namespace :get_all_vocabularies do
|
47
48
|
desc 'get all standard layers for designer'
|
48
49
|
get do
|
49
|
-
|
50
|
-
# Dir.glob(Rails.public_path.join('generic', 'vocabularies', '*.json')).each do |file_path|
|
51
|
-
# file_content = File.read(file_path)
|
52
|
-
# json_data = JSON.parse(file_content)
|
53
|
-
# merged_data.concat(json_data)
|
54
|
-
# end
|
55
|
-
|
56
|
-
# list = Labimotion::Vocabulary.all.sort_by { |e| e.name }
|
57
|
-
# present list, with: Labimotion::StdLayer, root: 'klass'
|
50
|
+
authenticate_admin!('vocabularies')
|
58
51
|
combined_data = Labimotion::VocabularyHandler.load_all_vocabularies
|
59
|
-
# combined_data = Labimotion::VocabularyEntity.represent(vocabularies, serializable: true)
|
60
52
|
return { mc: 'ss00', data: combined_data }
|
61
53
|
rescue StandardError => e
|
62
54
|
Labimotion.log_exception(e, current_user)
|
@@ -67,15 +59,9 @@ module Labimotion
|
|
67
59
|
namespace :field_klasses do
|
68
60
|
desc 'get all field klasses for admin function'
|
69
61
|
get do
|
70
|
-
|
71
|
-
# file_content = File.read(file_path)
|
72
|
-
# json_data = JSON.parse(file_content)
|
73
|
-
# merged_data.concat(json_data)
|
74
|
-
# end
|
62
|
+
authenticate_admin!('vocabularies')
|
75
63
|
vocabularies = Labimotion::VocabularyHandler.load_app_vocabularies
|
76
64
|
merged_data = Labimotion::FieldKlassEntity.represent(vocabularies, serializable: true)
|
77
|
-
# list = Labimotion::Vocabulary.all.sort_by { |e| e.name }
|
78
|
-
# present list, with: Labimotion::VocabularyEntity, root: 'klass'
|
79
65
|
merged_data
|
80
66
|
rescue StandardError => e
|
81
67
|
Labimotion.log_exception(e, current_user)
|
@@ -90,7 +76,7 @@ module Labimotion
|
|
90
76
|
end
|
91
77
|
route_param :id do
|
92
78
|
before do
|
93
|
-
|
79
|
+
authenticate_admin!('vocabularies')
|
94
80
|
end
|
95
81
|
delete do
|
96
82
|
entity = Labimotion::Vocabulary.find(params[:id])
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Labimotion
|
4
|
+
module Constants
|
5
|
+
module DateTime
|
6
|
+
DATE_FORMAT = '%Y-%m-%d'
|
7
|
+
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
|
8
|
+
TIME_FORMAT = '%H:%M:%S %Z'
|
9
|
+
TIME_ZONE = 'UTC'
|
10
|
+
end
|
11
|
+
|
12
|
+
module File
|
13
|
+
ENCODING = 'UTF-8'
|
14
|
+
end
|
15
|
+
|
16
|
+
module CHMO
|
17
|
+
CV = 'Cyclic Voltammetry'
|
18
|
+
end
|
19
|
+
|
20
|
+
module Mapper
|
21
|
+
NMR_CONFIG = ::File.join(__dir__, 'libs', 'data', 'mapper', 'Source.json').freeze
|
22
|
+
WIKI_CONFIG = ::File.join(__dir__, 'libs', 'data', 'mapper', 'Chemwiki.json').freeze
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -12,7 +12,7 @@ module Labimotion
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def process_layers
|
15
|
-
(object&.properties.is_a?(Hash) && object.properties[Labimotion::Prop::LAYERS]&.keys || []).each do |key|
|
15
|
+
(object&.properties.is_a?(Hash) && (object.properties[Labimotion::Prop::LAYERS]&.keys || [])).each do |key|
|
16
16
|
yield(key, object.properties[Labimotion::Prop::LAYERS][key])
|
17
17
|
end
|
18
18
|
end
|
@@ -25,7 +25,8 @@ module Labimotion
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def process_sample_and_molecule_fields(key, layer)
|
28
|
-
select_fields(layer,
|
28
|
+
select_fields(layer,
|
29
|
+
[Labimotion::FieldType::DRAG_SAMPLE, Labimotion::FieldType::DRAG_MOLECULE]).each do |field, idx|
|
29
30
|
update_sample_or_molecule_field(key, field, idx)
|
30
31
|
end
|
31
32
|
end
|
@@ -60,13 +61,20 @@ module Labimotion
|
|
60
61
|
return unless sid.present?
|
61
62
|
|
62
63
|
el = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? Sample.find_by(id: sid) : Molecule.find_by(id: sid)
|
63
|
-
return unless el.present? && object.properties.dig(Labimotion::Prop::LAYERS, key, Labimotion::Prop::FIELDS, idx,
|
64
|
+
return unless el.present? && object.properties.dig(Labimotion::Prop::LAYERS, key, Labimotion::Prop::FIELDS, idx,
|
65
|
+
'value').present?
|
64
66
|
|
67
|
+
label = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el&.short_label : el.iupac_name
|
65
68
|
update_field_value(key, idx, {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
'el_label' => label,
|
70
|
+
'el_tip' => label,
|
71
|
+
'el_svg' => if field['type'] == Labimotion::FieldType::DRAG_SAMPLE
|
72
|
+
el&.get_svg_path
|
73
|
+
else
|
74
|
+
File.join('/images',
|
75
|
+
'molecules', el&.molecule_svg_file || 'nosvg')
|
76
|
+
end
|
77
|
+
})
|
70
78
|
end
|
71
79
|
|
72
80
|
def update_reaction_field(key, field, idx)
|
@@ -79,23 +87,34 @@ module Labimotion
|
|
79
87
|
return
|
80
88
|
end
|
81
89
|
|
82
|
-
return unless object.properties.dig(Labimotion::Prop::LAYERS, key, Labimotion::Prop::FIELDS, idx,
|
90
|
+
return unless object.properties.dig(Labimotion::Prop::LAYERS, key, Labimotion::Prop::FIELDS, idx,
|
91
|
+
'value').present?
|
83
92
|
|
84
93
|
update_field_value(key, idx, {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
94
|
+
'el_label' => el.short_label,
|
95
|
+
'el_tip' => el.short_label,
|
96
|
+
'el_svg' => el.reaction_svg_file
|
97
|
+
})
|
89
98
|
end
|
90
99
|
|
91
100
|
def update_table_field(key, field, idx)
|
92
101
|
return unless field['sub_values'].present? && field[Labimotion::Prop::SUBFIELDS].present?
|
93
102
|
|
94
|
-
field_table_molecules = field[Labimotion::Prop::SUBFIELDS].select
|
95
|
-
|
103
|
+
field_table_molecules = field[Labimotion::Prop::SUBFIELDS].select do |ss|
|
104
|
+
ss['type'] == Labimotion::FieldType::DRAG_MOLECULE
|
105
|
+
end
|
106
|
+
if field_table_molecules.present?
|
107
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx] =
|
108
|
+
set_table(field, field_table_molecules, Labimotion::Prop::MOLECULE)
|
109
|
+
end
|
110
|
+
|
111
|
+
field_table_samples = field[Labimotion::Prop::SUBFIELDS].select do |ss|
|
112
|
+
ss['type'] == Labimotion::FieldType::DRAG_SAMPLE
|
113
|
+
end
|
114
|
+
return unless field_table_samples.present?
|
96
115
|
|
97
|
-
|
98
|
-
|
116
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx] =
|
117
|
+
set_table(field, field_table_samples, Labimotion::Prop::SAMPLE)
|
99
118
|
end
|
100
119
|
|
101
120
|
def update_voc_field(key, field, idx)
|
@@ -122,9 +141,9 @@ module Labimotion
|
|
122
141
|
end
|
123
142
|
|
124
143
|
def update_element_voc_field(key, field, idx, root_element)
|
125
|
-
|
126
|
-
|
127
|
-
|
144
|
+
return unless field['identifier'] == 'element.name'
|
145
|
+
|
146
|
+
update_field_value(key, idx, root_element&.name)
|
128
147
|
end
|
129
148
|
|
130
149
|
def update_segment_voc_field(key, field, idx, root_element)
|
@@ -132,21 +151,28 @@ module Labimotion
|
|
132
151
|
return if segs.empty? || field['layer_id'].blank? || field['field_id'].blank?
|
133
152
|
|
134
153
|
seg = segs&.first
|
135
|
-
seg_fields = seg.properties.dig(Labimotion::Prop::LAYERS, field['layer_id'],
|
154
|
+
seg_fields = seg.properties.dig(Labimotion::Prop::LAYERS, field['layer_id'],
|
155
|
+
Labimotion::Prop::FIELDS).select do |ff|
|
156
|
+
ff['field'] == field['field_id']
|
157
|
+
end
|
136
158
|
seg_field = seg_fields&.first
|
137
159
|
update_field_value(key, idx, seg_field['value'])
|
138
160
|
end
|
139
161
|
|
140
162
|
def update_dataset_voc_field(key, field, idx, root_element)
|
141
|
-
dk = DatasetKlass.find_by(identifier: field[
|
142
|
-
dk[
|
143
|
-
anas = root_element.analyses.select
|
163
|
+
dk = DatasetKlass.find_by(identifier: field['source_id'])
|
164
|
+
dk['ols_term_id']
|
165
|
+
anas = root_element.analyses.select do |ana|
|
166
|
+
ana.extended_metadata['kind'].split('|')&.first&.strip == dk['ols_term_id']
|
167
|
+
end
|
144
168
|
anas.each do |ana|
|
145
169
|
ana.children.each do |cds|
|
146
170
|
next unless cds.dataset.present?
|
147
171
|
|
148
172
|
ds_prop = cds.dataset.properties
|
149
|
-
ds_fields = ds_prop.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select
|
173
|
+
ds_fields = ds_prop.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select do |ff|
|
174
|
+
ff['field'] == field['field_id']
|
175
|
+
end
|
150
176
|
ds_field = ds_fields&.first
|
151
177
|
if object.properties[Labimotion::Prop::LAYERS][key].present? && ds_field['value'].present?
|
152
178
|
update_field_value(key, idx, ds_field['value'])
|
@@ -155,15 +181,38 @@ module Labimotion
|
|
155
181
|
end
|
156
182
|
end
|
157
183
|
|
158
|
-
def update_field_value(key, idx, value)
|
159
|
-
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]
|
184
|
+
def update_field_value(key, idx, value, act = 'merge')
|
185
|
+
field_path = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]
|
186
|
+
original_value = field_path['value']
|
187
|
+
|
188
|
+
field_path['value'] = merge_values(original_value, value, act)
|
189
|
+
end
|
190
|
+
|
191
|
+
def merge_by_type(original_value, new_value)
|
192
|
+
if original_value.is_a?(Hash)
|
193
|
+
merge_hash_values(original_value, new_value)
|
194
|
+
# elsif original_value.is_a?(Array)
|
195
|
+
# merge_array_values(original_value, new_value)
|
196
|
+
else
|
197
|
+
new_value
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def merge_values(original_value, new_value, act)
|
202
|
+
return new_value if act == 'overwrite'
|
203
|
+
return new_value if original_value.blank?
|
204
|
+
return original_value if new_value.blank?
|
205
|
+
|
206
|
+
merge_by_type(original_value, new_value)
|
160
207
|
end
|
161
208
|
|
162
209
|
def set_table(field, field_table_objs, obj)
|
163
210
|
col_ids = field_table_objs.map { |x| x.values[0] }
|
164
211
|
col_ids.each do |col_id|
|
165
212
|
field['sub_values'].each do |sub_value|
|
166
|
-
|
213
|
+
unless sub_value[col_id].present? && sub_value[col_id]['value'].present? && sub_value[col_id]['value']['el_id'].present?
|
214
|
+
next
|
215
|
+
end
|
167
216
|
|
168
217
|
find_obj = obj.constantize.find_by(id: sub_value[col_id]['value']['el_id'])
|
169
218
|
next if find_obj.blank?
|
@@ -181,23 +230,35 @@ module Labimotion
|
|
181
230
|
|
182
231
|
def update_molecule_sub_value(sub_value, col_id, find_obj)
|
183
232
|
sub_value[col_id]['value'].merge!({
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
233
|
+
'el_svg' => File.join('/images', 'molecules', find_obj.molecule_svg_file),
|
234
|
+
'el_inchikey' => find_obj.inchikey,
|
235
|
+
'el_smiles' => find_obj.cano_smiles,
|
236
|
+
'el_iupac' => find_obj.iupac_name,
|
237
|
+
'el_molecular_weight' => find_obj.molecular_weight
|
238
|
+
})
|
190
239
|
end
|
191
240
|
|
192
241
|
def update_sample_sub_value(sub_value, col_id, find_obj)
|
193
242
|
sub_value[col_id]['value'].merge!({
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
243
|
+
'el_svg' => find_obj.get_svg_path,
|
244
|
+
'el_label' => find_obj.short_label,
|
245
|
+
'el_short_label' => find_obj.short_label,
|
246
|
+
'el_name' => find_obj.name,
|
247
|
+
'el_external_label' => find_obj.external_label,
|
248
|
+
'el_molecular_weight' => find_obj.decoupled ? find_obj.molecular_mass : find_obj.molecule.molecular_weight
|
249
|
+
})
|
250
|
+
end
|
251
|
+
|
252
|
+
def merge_hash_values(original, new_value)
|
253
|
+
return original unless new_value.is_a?(Hash)
|
254
|
+
|
255
|
+
original.merge(new_value)
|
256
|
+
end
|
257
|
+
|
258
|
+
def merge_array_values(original, new_value)
|
259
|
+
return original unless new_value.respond_to?(:to_a)
|
260
|
+
|
261
|
+
(original + new_value.to_a).uniq
|
201
262
|
end
|
202
263
|
end
|
203
|
-
end
|
264
|
+
end
|
@@ -6,16 +6,6 @@ module Labimotion
|
|
6
6
|
class VocabularyEntity < ApplicationEntity
|
7
7
|
expose :id, :identifier, :name, :label, :field_type, :opid, :term_id,
|
8
8
|
:field_id, :properties, :source, :source_id, :layer_id
|
9
|
-
# expose :source do |obj|
|
10
|
-
# (obj[:properties] && obj[:properties]['voc'] && obj[:properties]['voc']['source']) || ''
|
11
|
-
# end
|
12
|
-
# expose :source_id do |obj|
|
13
|
-
# (obj[:properties] && obj[:properties]['voc'] && obj[:properties]['voc']['source_id']) || ''
|
14
|
-
# end
|
15
|
-
# expose :layer_id do |obj|
|
16
|
-
# (obj[:properties] && obj[:properties]['voc'] && obj[:properties]['voc']['layer_id']) || ''
|
17
|
-
# end
|
18
|
-
|
19
9
|
expose :voc do |obj|
|
20
10
|
voc = (obj[:properties] && obj[:properties]['voc']) || {}
|
21
11
|
|
@@ -127,12 +127,13 @@ module Labimotion
|
|
127
127
|
attributes['properties']['uuid'] = uuid
|
128
128
|
attributes['uuid'] = uuid
|
129
129
|
attributes['klass_uuid'] = properties['klass_uuid']
|
130
|
-
element.
|
130
|
+
element.update_columns(attributes)
|
131
131
|
end
|
132
132
|
element.save_segments(segments: params[:segments], current_user_id: current_user.id)
|
133
133
|
element.reload
|
134
|
-
|
135
|
-
element.
|
134
|
+
element.properties = update_vocabularies(element.properties, current_user, element)
|
135
|
+
## element.user_for_revision = current_user
|
136
|
+
element.save!
|
136
137
|
element
|
137
138
|
rescue StandardError => e
|
138
139
|
Labimotion.log_exception(e, current_user)
|
@@ -9,7 +9,12 @@ module Labimotion
|
|
9
9
|
extend Grape::API::Helpers
|
10
10
|
|
11
11
|
def authenticate_admin!(type)
|
12
|
-
error!('401 Unauthorized', 401)
|
12
|
+
unauthorized = -> { error!('401 Unauthorized', 401) }
|
13
|
+
if %w[standard_layers vocabularies].include?(type)
|
14
|
+
unauthorized.call unless current_user.generic_admin.values_at('elements', 'segments', 'datasets').any?
|
15
|
+
else
|
16
|
+
unauthorized.call unless current_user.generic_admin[type]
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
def fetch_klass(name, id)
|
@@ -134,21 +134,5 @@ module Labimotion
|
|
134
134
|
optional :select_options, type: Hash, desc: 'selections'
|
135
135
|
optional :option_layers, type: String, desc: 'option'
|
136
136
|
end
|
137
|
-
|
138
|
-
# params :vocabulary_save do
|
139
|
-
# requires :type, type: String, desc: 'type'
|
140
|
-
# requires :field, type: String, desc: 'field'
|
141
|
-
# optional :default, type: String, desc: 'default'
|
142
|
-
# optional :description, type: String, desc: 'description'
|
143
|
-
# optional :label, type: String, desc: 'label'
|
144
|
-
# optional :position, type: Integer, desc: 'position'
|
145
|
-
# optional :ontology, type: Hash, desc: 'ontology'
|
146
|
-
# optional :required, type: Boolean, desc: 'is required?'
|
147
|
-
# optional :sub_fields, type: Array, desc: 'sub_fields'
|
148
|
-
# optional :text_sub_fields, type: Array, desc: 'text_sub_fields'
|
149
|
-
# optional :source_type, type: String, desc: 'source type'
|
150
|
-
# optional :source_id, type: String, desc: 'source id'
|
151
|
-
# optional :layer_id, type: String, desc: 'layer id'
|
152
|
-
# end
|
153
137
|
end
|
154
138
|
end
|
@@ -123,7 +123,6 @@ module Labimotion
|
|
123
123
|
tmp_file.write(response.parsed_response)
|
124
124
|
tmp_file.rewind
|
125
125
|
|
126
|
-
# name = response&.headers && response&.headers['content-disposition']&.split('=')&.last
|
127
126
|
filename = oat.filename
|
128
127
|
name = "#{File.basename(filename, '.*')}.zip"
|
129
128
|
att = Attachment.new(
|