Class: Labimotion::ExportUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/labimotion/utils/export_utils.rb

Class Method Summary collapse

Class Method Details

.fetch_properties(instance, uuids, attachments, &fetch_one) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/labimotion/utils/export_utils.rb', line 181

def self.fetch_properties(instance, uuids, attachments, &fetch_one)
  attachments = [] if attachments.nil?
  properties = instance.properties
  properties[Labimotion::Prop::LAYERS].keys.each do |key|
    properties = set_ai(instance, properties, uuids, key)
    properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_ELEMENT, &fetch_one)
    properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_MOLECULE, &fetch_one)
    properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_SAMPLE, &fetch_one)
    properties = set_prop(properties, uuids, key, Labimotion::FieldType::SYS_REACTION, &fetch_one)
    properties, attachments = set_upload(instance, properties, attachments, uuids, key, Labimotion::FieldType::UPLOAD, &fetch_one)
    properties = set_table(properties, uuids, key, Labimotion::FieldType::TABLE, &fetch_one)
  end
  instance.properties = properties
  [instance, attachments]
rescue StandardError => e
  Labimotion.log_exception(e)
  [instance, attachments]
end

.fetch_seg_properties(segment, uuids) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/labimotion/utils/export_utils.rb', line 167

def self.fetch_seg_properties(segment, uuids)
  properties = segment['properties'] || {}
  properties[Labimotion::Prop::LAYERS].keys.each do |key|
    properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::DRAG_ELEMENT)
    properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::DRAG_SAMPLE)
    properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::SYS_REACTION)
  end
  segment['properties'] = properties
  segment
rescue StandardError => e
  Labimotion.log_exception(e)
  segment
end