Class: Labimotion::NmrMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/labimotion/libs/nmr_mapper.rb

Overview

NmrMapper

Defined Under Namespace

Modules: Constants

Class Method Summary collapse

Class Method Details

.build_ds(id, content) ⇒ Object



68
69
70
71
72
73
# File 'lib/labimotion/libs/nmr_mapper.rb', line 68

def build_ds(id, content)
  ds = find_container(id)
  return if ds.nil? || content.nil?

  Labimotion::DatasetBuilder.build(ds, content)
end

.generate_ds(_id, cid, data, current_user = {}, element = nil) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/labimotion/libs/nmr_mapper.rb', line 53

def generate_ds(_id, cid, data, current_user = {}, element = nil)
  return if data.nil? || cid.nil?

  obj = Labimotion::NmrMapper.build_ds(cid, data[:content])
  return if obj.nil? || obj[:ols].nil?

  Labimotion::NmrMapper.update_ds(cid, obj, current_user, element)
end

.process(att) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/labimotion/libs/nmr_mapper.rb', line 41

def process(att)
  config = Labimotion::MapperUtils.load_brucker_config
  return if config.nil?

  attacher = att&.attachment_attacher
  extracted_data = Labimotion::MapperUtils.extract_data_from_zip(attacher&.file&.url, config['sourceMap'])
  return if extracted_data.nil?

  extracted_data[:parameters] = config['sourceMap']['parameters']
  extracted_data
end

.process_ds(id, current_user = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/labimotion/libs/nmr_mapper.rb', line 31

def process_ds(id, current_user = {})
  att = find_attachment(id)
  return Labimotion::ConState::NONE if att.nil?

  result = process(att)
  return Labimotion::ConState::NONE if result.nil?

  handle_process_result(result, att, id, current_user)
end

.update_ds(_cid, obj, current_user, element) ⇒ Object



62
63
64
65
66
# File 'lib/labimotion/libs/nmr_mapper.rb', line 62

def update_ds(_cid, obj, current_user, element)
  dataset = obj[:dataset]
  dataset.properties = process_prop(obj, current_user, element)
  dataset.save!
end