labimotion 2.1.0.rc8 → 2.1.0.rc10
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/helpers/converter_helpers.rb +16 -3
- data/lib/labimotion/libs/converter.rb +14 -0
- data/lib/labimotion/libs/export_element.rb +10 -2
- data/lib/labimotion/libs/nmr_mapper.rb +13 -0
- data/lib/labimotion/utils/units.rb +609 -468
- data/lib/labimotion/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d9456ffe5c3e059a5e8dfc78ca671f0565c051bad7473c91e609de05d43b4d1
|
|
4
|
+
data.tar.gz: d05ebbe88cd259e6c88fdc2d7948e5369646d6ec00260eb113db61ffcf29cc37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f77618f29d0a9c79e45f9c8bbdb30e387c79566966add00c7172877e40bdceca94f655b5e48a666325152f24a7d4b3f3e90873e6f2db94c20653025d7fb0e48
|
|
7
|
+
data.tar.gz: 0d0c5438dc13b8b9025311151938abdfaca59e1c5f89b29978f97bc406e109ce22fccefa38df57084a1d76a0b31bfdd1681483bcb116831e368019673389225e
|
|
@@ -2,12 +2,25 @@
|
|
|
2
2
|
require 'grape'
|
|
3
3
|
|
|
4
4
|
module Labimotion
|
|
5
|
-
##
|
|
5
|
+
## ConverterHelpers
|
|
6
6
|
module ConverterHelpers
|
|
7
7
|
extend Grape::API::Helpers
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
# Update the general_description field in the container's extended_metadata
|
|
10
|
+
def self.update_general_description(container, current_user, date: nil, time: nil)
|
|
11
|
+
return unless container.present?
|
|
12
|
+
|
|
13
|
+
desc = container.extended_metadata['general_description']
|
|
14
|
+
|
|
15
|
+
general_desc = desc if desc.present? && desc.is_a?(Hash)
|
|
16
|
+
general_desc = JSON.parse(container.extended_metadata['general_description']) if desc.present? && desc.is_a?(String)
|
|
17
|
+
general_desc = {} unless general_desc.is_a?(Hash)
|
|
18
|
+
general_desc['creator'] = current_user.name if current_user.present?
|
|
19
|
+
general_desc['date'] = date if date.present?
|
|
20
|
+
general_desc['time'] = time if time.present?
|
|
21
|
+
|
|
22
|
+
container.extended_metadata['general_description'] = general_desc.to_json
|
|
23
|
+
container.save!
|
|
11
24
|
end
|
|
12
25
|
end
|
|
13
26
|
end
|
|
@@ -6,6 +6,7 @@ require 'json'
|
|
|
6
6
|
require 'date'
|
|
7
7
|
require 'labimotion/version'
|
|
8
8
|
require 'labimotion/utils/utils'
|
|
9
|
+
require 'labimotion/helpers/converter_helpers'
|
|
9
10
|
|
|
10
11
|
# rubocop: disable Metrics/AbcSize
|
|
11
12
|
# rubocop: disable Metrics/MethodLength
|
|
@@ -228,6 +229,19 @@ module Labimotion
|
|
|
228
229
|
def self.update_ds(dataset, dsr, current_user = nil) # rubocop: disable Metrics/PerceivedComplexity
|
|
229
230
|
layers = dataset.properties[Labimotion::Prop::LAYERS] || {}
|
|
230
231
|
new_prop = dataset.properties
|
|
232
|
+
|
|
233
|
+
container = dataset.element
|
|
234
|
+
|
|
235
|
+
# Extract and update general description fields
|
|
236
|
+
general_dsr = dsr.select { |ds| ds[:layer] == 'general' }
|
|
237
|
+
if general_dsr.present?
|
|
238
|
+
date = general_dsr.find { |ds| ds[:field] == 'date' }&.dig(:value)
|
|
239
|
+
time = general_dsr.find { |ds| ds[:field] == 'time' }&.dig(:value)
|
|
240
|
+
Labimotion::ConverterHelpers.update_general_description(container, current_user, date: date, time: time)
|
|
241
|
+
else
|
|
242
|
+
Labimotion::ConverterHelpers.update_general_description(container, current_user)
|
|
243
|
+
end
|
|
244
|
+
|
|
231
245
|
dsr.each do |ds|
|
|
232
246
|
layer = layers[ds[:layer]]
|
|
233
247
|
next if layer.blank? || layer[Labimotion::Prop::FIELDS].blank?
|
|
@@ -36,6 +36,13 @@ module Labimotion
|
|
|
36
36
|
Labimotion.log_exception(e)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
def sample_url
|
|
40
|
+
protocol = Rails.env.production? ? 'https' : 'http'
|
|
41
|
+
host = ENV['PUBLIC_URL'] || 'localhost:3000'
|
|
42
|
+
api = 'mydb/collection/all/sample'
|
|
43
|
+
"#{protocol}://#{host}/#{api}"
|
|
44
|
+
end
|
|
45
|
+
|
|
39
46
|
def build_layers
|
|
40
47
|
objs = []
|
|
41
48
|
@properties[Labimotion::Prop::LAYERS]&.keys&.sort_by do |key|
|
|
@@ -183,7 +190,8 @@ module Labimotion
|
|
|
183
190
|
name = val['el_name'].present? ? "Name: [#{val['el_name']}] \n" : ''
|
|
184
191
|
ext = val['el_external_label'].present? ? "Ext. Label: [#{val['el_external_label']}] \n" : ''
|
|
185
192
|
mass = val['el_molecular_weight'].present? ? "Mass: [#{val['el_molecular_weight']}] \n" : ''
|
|
186
|
-
"#{
|
|
193
|
+
url = val['el_id'].present? ? "#{sample_url}/#{val['el_id']}" : ''
|
|
194
|
+
"#{label}#{name}#{ext}#{mass}#{url}"
|
|
187
195
|
when Labimotion::FieldType::DRAG_MOLECULE
|
|
188
196
|
val = sub_val[sub_field['id']]['value'] || {}
|
|
189
197
|
smile = val['el_smiles'].present? ? "SMILES: [#{val['el_smiles']}] \n" : ''
|
|
@@ -194,7 +202,7 @@ module Labimotion
|
|
|
194
202
|
when Labimotion::FieldType::SELECT
|
|
195
203
|
sub_val[sub_field['id']]['value']
|
|
196
204
|
when Labimotion::FieldType::SYSTEM_DEFINED
|
|
197
|
-
unit = Labimotion::Units::FIELDS.find { |o| o[:field] == sub_field['option_layers'] }&.fetch(:units, [])&.find { |u| u[:key] == sub_field['value_system'] }&.fetch(:label, '')
|
|
205
|
+
unit = Labimotion::Units::FIELDS.find { |o| o[:field] == sub_field['option_layers'] }&.fetch(:units, [])&.find { |u| u[:key] == sub_val[sub_field['id']]['value_system'] }&.fetch(:label, '')
|
|
198
206
|
val = sub_val[sub_field['id']]['value'].to_s + ' ' + unit
|
|
199
207
|
val = Sablon.content(:html, "<div>" + val + "</div>") if val.include? '<'
|
|
200
208
|
val
|
|
@@ -4,6 +4,7 @@ require 'labimotion/libs/dataset_builder'
|
|
|
4
4
|
require 'labimotion/version'
|
|
5
5
|
require 'labimotion/utils/mapper_utils'
|
|
6
6
|
require 'labimotion/utils/utils'
|
|
7
|
+
require 'labimotion/helpers/converter_helpers'
|
|
7
8
|
|
|
8
9
|
module Labimotion
|
|
9
10
|
## NmrMapper
|
|
@@ -61,6 +62,7 @@ module Labimotion
|
|
|
61
62
|
|
|
62
63
|
def update_ds(_cid, obj, current_user, element)
|
|
63
64
|
dataset = obj[:dataset]
|
|
65
|
+
process_general_description(obj, current_user, element)
|
|
64
66
|
dataset.properties = process_prop(obj, current_user, element)
|
|
65
67
|
dataset.save!
|
|
66
68
|
end
|
|
@@ -106,6 +108,17 @@ module Labimotion
|
|
|
106
108
|
new_prop
|
|
107
109
|
end
|
|
108
110
|
|
|
111
|
+
def process_general_description(obj, current_user, element)
|
|
112
|
+
container = obj[:dataset]&.element
|
|
113
|
+
return unless container.present?
|
|
114
|
+
|
|
115
|
+
dt = obj[:metadata]&.dig('DATE')
|
|
116
|
+
date = Labimotion::MapperUtils.format_timestamp(dt, 'date') if dt.present?
|
|
117
|
+
time = Labimotion::MapperUtils.format_timestamp(dt, 'time') if dt.present?
|
|
118
|
+
|
|
119
|
+
Labimotion::ConverterHelpers.update_general_description(container, current_user, date: date, time: time)
|
|
120
|
+
end
|
|
121
|
+
|
|
109
122
|
def process_prop(obj, current_user, element)
|
|
110
123
|
new_prop = obj[:dataset].properties
|
|
111
124
|
new_prop
|