labimotion 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e2976eacd1dbe12aa1caefd59638628b544d64ebd2757b677bc527e18230c1c
|
4
|
+
data.tar.gz: f1ee1381e67ab62bd66b4178f25346988c471b34c1da917e010e7753a83279ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8d3ca3477cfecd469e1d5e1a41be249a5b69da8647478ebd24a6144498dc5a110a4976f6cec56f10bc6fca013872dba164aa47be7402d511219a50d78ce8309
|
7
|
+
data.tar.gz: c6098201eb9ef587b0201e35c56b1146697e19dfead041aad7fb2b515ed4e38db2c00051508b0d631faeb979fc62edb287add0ad9be76c243da30d69d8230949
|
@@ -19,28 +19,31 @@ module Labimotion
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.process_ds(id, current_user = {})
|
22
|
-
att = Attachment.find_by(
|
23
|
-
return if att.nil?
|
22
|
+
att = Attachment.find_by(id: id, con_state: Labimotion::ConState::CONVERTED)
|
23
|
+
return if att.nil? || att.attachable_id.nil? || att.attachable_type != 'Container'
|
24
24
|
|
25
25
|
dsr = []
|
26
26
|
ols = nil
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
if Labimotion::IS_RAILS5 == true
|
28
|
+
Zip::File.open(att.store.path) do |zip_file|
|
29
|
+
res = Labimotion::Converter.collect_metadata(zip_file) if att.filename.split('.')&.last == 'zip'
|
30
|
+
ols = res[:o] unless res&.dig(:o).nil?
|
31
|
+
dsr.push(res[:d]) unless res&.dig(:d).nil?
|
32
|
+
end
|
33
|
+
else
|
34
|
+
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
35
|
+
res = Labimotion::Converter.collect_metadata(zip_file) if att.filename.split('.')&.last == 'zip'
|
36
|
+
ols = res[:o] unless res&.dig(:o).nil?
|
37
|
+
dsr.push(res[:d]) unless res&.dig(:d).nil?
|
38
|
+
end
|
32
39
|
end
|
33
40
|
dsr.flatten!
|
34
|
-
|
35
|
-
dataset = build_ds(id, ols)
|
41
|
+
dataset = build_ds(att.attachable_id, ols)
|
36
42
|
update_ds(dataset, dsr, current_user) if dataset.present?
|
37
|
-
|
38
|
-
|
43
|
+
att.update_column(:con_state, Labimotion::ConState::COMPLETED)
|
39
44
|
rescue StandardError => e
|
40
45
|
Labimotion::Converter.logger.error ["Att ID: #{att&.id}, OLS: #{ols}", "DSR: #{dsr}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
|
41
46
|
raise e
|
42
|
-
ensure
|
43
|
-
## tmp_file&.close
|
44
47
|
end
|
45
48
|
|
46
49
|
def self.uri(api_name)
|
@@ -149,19 +152,7 @@ module Labimotion
|
|
149
152
|
primary_store = Rails.configuration.storage.primary_store
|
150
153
|
att.update!(storage: primary_store)
|
151
154
|
end
|
152
|
-
|
153
|
-
if Labimotion::IS_RAILS5 == true
|
154
|
-
Zip::File.open(tmp_file.path) do |zip_file|
|
155
|
-
res = Labimotion::Converter.collect_metadata(zip_file) if name.split('.')&.last == 'zip'
|
156
|
-
ols = res[:o] unless res&.dig(:o).nil?
|
157
|
-
dsr.push(res[:d]) unless res&.dig(:d).nil?
|
158
|
-
end
|
159
|
-
|
160
|
-
dsr.flatten!
|
161
|
-
if dsr.length.positive? && name.split('.')&.last == 'zip'
|
162
|
-
Labimotion::Converter.ts('write', att.attachable_id, ols: ols, info: dsr)
|
163
|
-
end
|
164
|
-
end
|
155
|
+
process_ds(att.id)
|
165
156
|
rescue StandardError => e
|
166
157
|
raise e
|
167
158
|
ensure
|
@@ -205,23 +196,20 @@ module Labimotion
|
|
205
196
|
end
|
206
197
|
|
207
198
|
def self.jcamp_converter(id)
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
data = Labimotion::Converter.vor_conv(id)
|
212
|
-
return if data.nil?
|
199
|
+
data = Labimotion::Converter.vor_conv(id)
|
200
|
+
return if data.nil?
|
213
201
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
end
|
202
|
+
Labimotion::Converter.process(data)
|
203
|
+
rescue StandardError => e
|
204
|
+
Labimotion::Converter.logger.error ["jcamp_converter fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
|
205
|
+
Labimotion::ConState::ERROR
|
219
206
|
end
|
220
207
|
|
221
208
|
def self.generate_ds(att_id, current_user = {})
|
222
209
|
dsr_info = Labimotion::Converter.fetch_dsr(att_id)
|
223
210
|
begin
|
224
211
|
return unless dsr_info && dsr_info[:info]&.length.positive?
|
212
|
+
|
225
213
|
dataset = Labimotion::Converter.build_ds(att_id, dsr_info[:ols])
|
226
214
|
Labimotion::Converter.update_ds(dataset, dsr_info[:info], current_user) if dataset.present?
|
227
215
|
rescue StandardError => e
|
@@ -351,6 +339,15 @@ module Labimotion
|
|
351
339
|
end
|
352
340
|
res
|
353
341
|
end
|
342
|
+
|
343
|
+
def self.metadata(id)
|
344
|
+
att = Attachment.find(id)
|
345
|
+
return if att.nil? || att.attachable_id.nil? || att.attachable_type != 'Container'
|
346
|
+
|
347
|
+
ds = Labimotion::Dataset.find_by(element_type: 'Container', element_id: att.attachable_id)
|
348
|
+
att.update_column(:con_state, Labimotion::ConState::COMPLETED) if ds.present?
|
349
|
+
process_ds(att.id) if ds.nil?
|
350
|
+
end
|
354
351
|
end
|
355
352
|
end
|
356
353
|
|
@@ -7,21 +7,23 @@ module Labimotion
|
|
7
7
|
## NmrMapper
|
8
8
|
class NmrMapper
|
9
9
|
def self.process_ds(id, current_user = {})
|
10
|
-
att = Attachment.find_by(
|
10
|
+
att = Attachment.find_by(id: id, con_state: Labimotion::ConState::NMR)
|
11
11
|
return if att.nil?
|
12
12
|
|
13
|
-
content = is_brucker_binary(id
|
13
|
+
content = is_brucker_binary(id)
|
14
14
|
if content.nil?
|
15
|
-
|
15
|
+
Labimotion::ConState::NONE
|
16
16
|
else
|
17
17
|
data = process(att, id, content)
|
18
|
-
generate_ds(id, data, current_user)
|
19
|
-
|
18
|
+
generate_ds(id, att.attachable_id, data, current_user)
|
19
|
+
Labimotion::ConState::COMPLETED
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.is_brucker_binary(id
|
24
|
-
|
23
|
+
def self.is_brucker_binary(id)
|
24
|
+
att = Attachment.find_by(id: id, con_state: Labimotion::ConState::NMR)
|
25
|
+
return if att.nil?
|
26
|
+
|
25
27
|
if Labimotion::IS_RAILS5 == true
|
26
28
|
Zip::File.open(att.store.path) do |zip_file|
|
27
29
|
zip_file.each do |entry|
|
@@ -76,16 +78,14 @@ module Labimotion
|
|
76
78
|
end
|
77
79
|
|
78
80
|
|
79
|
-
def self.generate_ds(id, data, current_user = {})
|
80
|
-
|
81
|
-
return if data.nil?
|
81
|
+
def self.generate_ds(id, cid, data, current_user = {})
|
82
|
+
return if data.nil? || cid.nil?
|
82
83
|
|
83
|
-
obj = Labimotion::NmrMapper.build_ds(
|
84
|
+
obj = Labimotion::NmrMapper.build_ds(cid, data[:content])
|
84
85
|
return if obj.nil? || obj[:ols].nil?
|
85
86
|
|
86
|
-
Labimotion::NmrMapper.update_ds_1h(
|
87
|
-
Labimotion::NmrMapper.update_ds_1h(
|
88
|
-
Labimotion::NmrMapper.clean(id)
|
87
|
+
Labimotion::NmrMapper.update_ds_1h(cid, obj, current_user) if obj[:ols] == 'CHMO:0000593'
|
88
|
+
Labimotion::NmrMapper.update_ds_1h(cid, obj, current_user) if obj[:ols] == 'CHMO:0000595'
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.update_ds_13c(id, obj)
|
@@ -10,6 +10,7 @@ module Labimotion
|
|
10
10
|
after_update :exec_converter
|
11
11
|
def init_converter
|
12
12
|
return if self.has_attribute?(:con_state) == false || con_state.present?
|
13
|
+
|
13
14
|
if Rails.configuration.try(:converter).try(:url) && ACCEPTED_FORMATS.include?(File.extname(filename&.downcase))
|
14
15
|
self.con_state = Labimotion::ConState::WAIT
|
15
16
|
end
|
@@ -22,34 +23,20 @@ module Labimotion
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def exec_converter
|
25
|
-
return if self.has_attribute?(:con_state) == false || !con_state.present?
|
26
|
-
|
27
|
-
#return if attachable_id.nil?
|
28
|
-
return if Labimotion::IS_RAILS5 == false && self.con_state != Labimotion::ConState::WAIT
|
29
|
-
|
30
26
|
return if self.has_attribute?(:con_state) == false || self.con_state.nil? || self.con_state == Labimotion::ConState::NONE
|
31
27
|
|
28
|
+
return if attachable_id.nil? && self.con_state != Labimotion::ConState::WAIT
|
29
|
+
|
32
30
|
case con_state
|
33
31
|
when Labimotion::ConState::NMR
|
34
|
-
|
35
|
-
|
36
|
-
else
|
37
|
-
content = Labimotion::NmrMapper.is_brucker_binary(id)
|
38
|
-
end
|
39
|
-
if content.nil?
|
40
|
-
self.con_state = Labimotion::ConState::NONE
|
41
|
-
else
|
42
|
-
if Labimotion::IS_RAILS5 == true
|
43
|
-
Labimotion::NmrMapperRepo.process(id, content)
|
44
|
-
else
|
45
|
-
Labimotion::NmrMapper.process(id, content)
|
46
|
-
end
|
47
|
-
self.con_state = Labimotion::ConState::PROCESSED
|
48
|
-
end
|
32
|
+
self.con_state = Labimotion::NmrMapper.process_ds(id)
|
33
|
+
update_column(:con_state, con_state)
|
49
34
|
when Labimotion::ConState::WAIT
|
50
35
|
self.con_state = Labimotion::Converter.jcamp_converter(id)
|
36
|
+
update_column(:con_state, con_state)
|
37
|
+
when Labimotion::ConState::CONVERTED
|
38
|
+
Labimotion::Converter.metadata(id)
|
51
39
|
end
|
52
|
-
update_column(:con_state, con_state)
|
53
40
|
end
|
54
41
|
end
|
55
42
|
end
|
data/lib/labimotion/version.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
## Labimotion Version
|
4
4
|
module Labimotion
|
5
5
|
IS_RAILS5 = true
|
6
|
-
VERSION_ELN = '1.0.
|
7
|
-
VERSION_REPO = '0.3.
|
6
|
+
VERSION_ELN = '1.0.17'
|
7
|
+
VERSION_REPO = '0.3.3'
|
8
8
|
|
9
9
|
VERSION = Labimotion::VERSION_REPO if Labimotion::IS_RAILS5 == true
|
10
10
|
VERSION = Labimotion::VERSION_ELN if Labimotion::IS_RAILS5 == false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: labimotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chia-Lin Lin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-10-
|
12
|
+
date: 2023-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- lib/labimotion/libs/converter.rb
|
67
67
|
- lib/labimotion/libs/export_dataset.rb
|
68
68
|
- lib/labimotion/libs/nmr_mapper.rb
|
69
|
-
- lib/labimotion/libs/nmr_mapper_repo.rb
|
70
69
|
- lib/labimotion/libs/template_hub.rb
|
71
70
|
- lib/labimotion/models/collections_element.rb
|
72
71
|
- lib/labimotion/models/concerns/attachment_converter.rb
|
@@ -1,278 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'labimotion/version'
|
3
|
-
require 'labimotion/utils/utils'
|
4
|
-
|
5
|
-
module Labimotion
|
6
|
-
class NmrMapperRepo
|
7
|
-
def self.is_brucker_binary(id)
|
8
|
-
att = Attachment.find(id)
|
9
|
-
if Labimotion::IS_RAILS5 == true
|
10
|
-
Zip::File.open(att.store.path) do |zip_file|
|
11
|
-
zip_file.each do |entry|
|
12
|
-
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
13
|
-
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
14
|
-
return metadata
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
else
|
19
|
-
if att&.attachment_attacher&.file&.url
|
20
|
-
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
21
|
-
zip_file.each do |entry|
|
22
|
-
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
23
|
-
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
24
|
-
return metadata
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.process(id, content)
|
35
|
-
att = Attachment.find(id)
|
36
|
-
lines = content.split("\n").reject(&:empty?)
|
37
|
-
metadata = {}
|
38
|
-
lines.map do |ln|
|
39
|
-
arr = ln.split(/\s+/)
|
40
|
-
metadata[arr[0]] = arr[1..-1].join(' ') if arr.length > 1
|
41
|
-
end
|
42
|
-
ols = 'CHMO:0000593' if metadata['NUC1'] == '1H'
|
43
|
-
ols = 'CHMO:0000595' if metadata['NUC1'] == '13C'
|
44
|
-
if content.present? && att.present?
|
45
|
-
Labimotion::NmrMapper.ts('write', att.attachable_id,
|
46
|
-
content: { metadata: metadata, ols: ols })
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.fetch_content(id)
|
51
|
-
Labimotion::NmrMapper.ts('read', id)
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.generate_ds(id, current_user = {})
|
55
|
-
data = Labimotion::NmrMapper.fetch_content(id)
|
56
|
-
return if data.nil?
|
57
|
-
|
58
|
-
obj = Labimotion::NmrMapper.build_ds(id, data[:content])
|
59
|
-
return if obj.nil? || obj[:ols].nil?
|
60
|
-
|
61
|
-
Labimotion::NmrMapper.update_ds_1h(id, obj, current_user) if obj[:ols] == 'CHMO:0000593'
|
62
|
-
Labimotion::NmrMapper.update_ds_1h(id, obj, current_user) if obj[:ols] == 'CHMO:0000595'
|
63
|
-
Labimotion::NmrMapper.clean(id)
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.update_ds_13c(id, obj)
|
67
|
-
# dataset = obj[:dataset]
|
68
|
-
# metadata = obj[:metadata]
|
69
|
-
# new_prop = dataset.properties
|
70
|
-
|
71
|
-
# dataset.properties = new_prop
|
72
|
-
# dataset.save!
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.set_data(prop, field, idx, layer_name, field_name, value)
|
76
|
-
return if field['field'] != field_name || value&.empty?
|
77
|
-
|
78
|
-
field['value'] = value
|
79
|
-
prop['layers'][layer_name]['fields'][idx] = field
|
80
|
-
prop
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.update_ds_1h(id, obj, current_user)
|
84
|
-
dataset = obj[:dataset]
|
85
|
-
metadata = obj[:metadata]
|
86
|
-
new_prop = dataset.properties
|
87
|
-
new_prop.dig('layers', 'general', 'fields')&.each_with_index do |fi, idx|
|
88
|
-
# new_prop = set_data(new_prop, fi, idx, 'general', 'title', metadata['NAME'])
|
89
|
-
if fi['field'] == 'title' && metadata['NAME'].present?
|
90
|
-
## fi['label'] = fi['label']
|
91
|
-
fi['value'] = metadata['NAME']
|
92
|
-
fi['device'] = metadata['NAME']
|
93
|
-
fi['dkey'] = 'NAME'
|
94
|
-
new_prop['layers']['general']['fields'][idx] = fi
|
95
|
-
end
|
96
|
-
|
97
|
-
if fi['field'] == 'date' && metadata['Date_'].present?
|
98
|
-
## fi['label'] = fi['label']
|
99
|
-
fi['value'] = metadata['Date_']
|
100
|
-
fi['device'] = metadata['Date_']
|
101
|
-
fi['dkey'] = 'Date_'
|
102
|
-
new_prop['layers']['general']['fields'][idx] = fi
|
103
|
-
end
|
104
|
-
|
105
|
-
if fi['field'] == 'time' && metadata['Time'].present?
|
106
|
-
## fi['label'] = fi['label']
|
107
|
-
fi['value'] = metadata['Time']
|
108
|
-
fi['device'] = metadata['Time']
|
109
|
-
fi['dkey'] = 'Time'
|
110
|
-
new_prop['layers']['general']['fields'][idx] = fi
|
111
|
-
end
|
112
|
-
|
113
|
-
if fi['field'] == 'creator' && current_user.present?
|
114
|
-
## fi['label'] = fi['label']
|
115
|
-
fi['value'] = current_user.name
|
116
|
-
new_prop['layers']['general']['fields'][idx] = fi
|
117
|
-
end
|
118
|
-
end
|
119
|
-
element = Container.find(id)&.root_element
|
120
|
-
element.present? && element&.class&.name == 'Sample' && new_prop.dig('layers', 'sample_details', 'fields')&.each_with_index do |fi, idx|
|
121
|
-
if fi['field'] == 'label'
|
122
|
-
fi['value'] = element.short_label
|
123
|
-
new_prop['layers']['sample_details']['fields'][idx] = fi
|
124
|
-
end
|
125
|
-
if fi['field'] == 'id'
|
126
|
-
fi['value'] = element.id
|
127
|
-
new_prop['layers']['sample_details']['fields'][idx] = fi
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
new_prop.dig('layers', 'instrument', 'fields')&.each_with_index do |fi, idx|
|
132
|
-
if fi['field'] == 'instrument' && metadata['INSTRUM'].present?
|
133
|
-
# fi['label'] = fi['label']
|
134
|
-
fi['value'] = metadata['INSTRUM']
|
135
|
-
fi['device'] = metadata['INSTRUM']
|
136
|
-
fi['dkey'] = 'INSTRUM'
|
137
|
-
new_prop['layers']['instrument']['fields'][idx] = fi
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
new_prop.dig('layers', 'equipment', 'fields')&.each_with_index do |fi, idx|
|
143
|
-
if fi['field'] == 'probehead' && metadata['PROBHD'].present?
|
144
|
-
# fi['label'] = fi['label']
|
145
|
-
fi['value'] = metadata['PROBHD']
|
146
|
-
fi['device'] = metadata['PROBHD']
|
147
|
-
fi['dkey'] = 'PROBHD'
|
148
|
-
new_prop['layers']['equipment']['fields'][idx] = fi
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
new_prop.dig('layers', 'sample_preparation', 'fields')&.each_with_index do |fi, idx|
|
153
|
-
if fi['field'] == 'solvent' && metadata['SOLVENT'].present?
|
154
|
-
# fi['label'] = fi['label']
|
155
|
-
fi['value'] = metadata['SOLVENT']
|
156
|
-
fi['device'] = metadata['SOLVENT']
|
157
|
-
fi['dkey'] = 'SOLVENT'
|
158
|
-
fi['value'] = 'chloroform-D1 (CDCl3)' if metadata['SOLVENT'] == 'CDCl3'
|
159
|
-
new_prop['layers']['sample_preparation']['fields'][idx] = fi
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
|
164
|
-
new_prop.dig('layers', 'set', 'fields')&.each_with_index do |fi, idx|
|
165
|
-
if fi['field'] == 'temperature' && metadata['TE'].present?
|
166
|
-
# fi['label'] = fi['label']
|
167
|
-
fi['value'] = metadata['TE'].split(/\s+/).first
|
168
|
-
fi['device'] = metadata['TE']
|
169
|
-
fi['dkey'] = 'TE'
|
170
|
-
fi['value_system'] = metadata['TE'].split(/\s+/).last
|
171
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
172
|
-
end
|
173
|
-
if fi['field'] == 'ns' && metadata['NS'].present?
|
174
|
-
# fi['label'] = fi['label']
|
175
|
-
fi['value'] = metadata['NS']
|
176
|
-
fi['device'] = metadata['NS']
|
177
|
-
fi['dkey'] = 'NS'
|
178
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
179
|
-
end
|
180
|
-
if fi['field'] == 'PULPROG' && metadata['PULPROG'].present?
|
181
|
-
# fi['label'] = fi['label']
|
182
|
-
fi['value'] = metadata['PULPROG']
|
183
|
-
fi['device'] = metadata['PULPROG']
|
184
|
-
fi['dkey'] = 'PULPROG'
|
185
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
186
|
-
end
|
187
|
-
if fi['field'] == 'td' && metadata['TD'].present?
|
188
|
-
# fi['label'] = fi['label']
|
189
|
-
fi['value'] = metadata['TD']
|
190
|
-
fi['device'] = metadata['TD']
|
191
|
-
fi['dkey'] = 'TD'
|
192
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
193
|
-
end
|
194
|
-
if fi['field'] == 'done' && metadata['D1'].present?
|
195
|
-
# fi['label'] = fi['label']
|
196
|
-
fi['value'] = metadata['D1']
|
197
|
-
fi['device'] = metadata['D1']
|
198
|
-
fi['dkey'] = 'D1'
|
199
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
200
|
-
end
|
201
|
-
if fi['field'] == 'sf' && metadata['SF'].present?
|
202
|
-
## fi['label'] = fi['label']
|
203
|
-
fi['value'] = metadata['SF']
|
204
|
-
fi['device'] = metadata['SF']
|
205
|
-
fi['dkey'] = 'SF'
|
206
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
207
|
-
end
|
208
|
-
if fi['field'] == 'sfoone' && metadata['SFO1'].present?
|
209
|
-
## fi['label'] = fi['label']
|
210
|
-
fi['value'] = metadata['SFO1']
|
211
|
-
fi['device'] = metadata['SFO1']
|
212
|
-
fi['dkey'] = 'SFO1'
|
213
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
214
|
-
end
|
215
|
-
if fi['field'] == 'sfotwo' && metadata['SFO2'].present?
|
216
|
-
## fi['label'] = fi['label']
|
217
|
-
fi['value'] = metadata['SFO2']
|
218
|
-
fi['device'] = metadata['SFO2']
|
219
|
-
fi['dkey'] = 'SFO2'
|
220
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
221
|
-
end
|
222
|
-
if fi['field'] == 'nucone' && metadata['NUC1'].present?
|
223
|
-
## fi['label'] = fi['label']
|
224
|
-
fi['value'] = metadata['NUC1']
|
225
|
-
fi['device'] = metadata['NUC1']
|
226
|
-
fi['dkey'] = 'NUC1'
|
227
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
228
|
-
end
|
229
|
-
if fi['field'] == 'nuctwo' && metadata['NUC2'].present?
|
230
|
-
## fi['label'] = fi['label']
|
231
|
-
fi['value'] = metadata['NUC2']
|
232
|
-
fi['device'] = metadata['NUC2']
|
233
|
-
fi['dkey'] = 'NUC2'
|
234
|
-
new_prop['layers']['set']['fields'][idx] = fi
|
235
|
-
end
|
236
|
-
end
|
237
|
-
dataset.properties = new_prop
|
238
|
-
dataset.save!
|
239
|
-
end
|
240
|
-
|
241
|
-
|
242
|
-
def self.ts(method, identifier, params = nil)
|
243
|
-
Rails.cache.send(method, "#{Labimotion::NmrMapper.new.class.name}#{identifier}", params)end
|
244
|
-
|
245
|
-
def self.clean(id)
|
246
|
-
Labimotion::NmrMapper.ts('delete', id)
|
247
|
-
end
|
248
|
-
|
249
|
-
def self.build_ds(id, content)
|
250
|
-
ds = Container.find_by(id: id)
|
251
|
-
return if ds.nil? || content.nil?
|
252
|
-
|
253
|
-
ols = content[:ols]
|
254
|
-
metadata = content[:metadata]
|
255
|
-
|
256
|
-
return if ols.nil? || metadata.nil?
|
257
|
-
|
258
|
-
klass = Labimotion::DatasetKlass.find_by(ols_term_id: ols)
|
259
|
-
return if klass.nil?
|
260
|
-
|
261
|
-
uuid = SecureRandom.uuid
|
262
|
-
props = klass.properties_release
|
263
|
-
props['uuid'] = uuid
|
264
|
-
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
265
|
-
props['klass'] = 'Dataset'
|
266
|
-
dataset = Labimotion::Dataset.create!(
|
267
|
-
uuid: uuid,
|
268
|
-
dataset_klass_id: klass.id,
|
269
|
-
element_type: 'Container',
|
270
|
-
element_id: ds.id,
|
271
|
-
properties: props,
|
272
|
-
properties_release: klass.properties_release,
|
273
|
-
klass_uuid: klass.uuid
|
274
|
-
)
|
275
|
-
{ dataset: dataset, metadata: metadata, ols: ols }
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|