Class: Labimotion::Export
- Inherits:
-
Object
- Object
- Labimotion::Export
- Defined in:
- lib/labimotion/collection/export.rb
Overview
Export
Class Method Summary collapse
- .fetch_dataset_klasses(&fetch_many) ⇒ Object
- .fetch_datasets(dataset, &fetch_one) ⇒ Object
- .fetch_element_klasses(&fetch_many) ⇒ Object
- .fetch_elements(collection, uuids, fetch_many, fetch_one, fetch_containers) ⇒ Object
- .fetch_segment_klasses(&fetch_many) ⇒ Object
- .fetch_segments(element, uuids, attachments, &fetch_one) ⇒ Object
- .fetch_segments_prop(data, uuids) ⇒ Object
Class Method Details
.fetch_dataset_klasses(&fetch_many) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/labimotion/collection/export.rb', line 24 def self.fetch_dataset_klasses(&fetch_many) klasses = Labimotion::DatasetKlass.where(is_active: true) fetch_many.call(klasses, {'created_by' => 'User'}) rescue StandardError => e Labimotion.log_exception(e) end |
.fetch_datasets(dataset, &fetch_one) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/labimotion/collection/export.rb', line 88 def self.fetch_datasets(dataset, &fetch_one) return if dataset.nil? fetch_one.call(dataset, { 'element_id' => 'Container', }) fetch_one.call(dataset, { 'element_id' => dataset.element_type, 'dataset_klass_id' => 'Labimotion::DatasetKlass', }) [dataset] rescue StandardError => e Labimotion.log_exception(e) [dataset] end |
.fetch_element_klasses(&fetch_many) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/labimotion/collection/export.rb', line 7 def self.fetch_element_klasses(&fetch_many) klasses = Labimotion::ElementKlass.where(is_active: true) fetch_many.call(klasses, {'created_by' => 'User'}) rescue StandardError => e Labimotion.log_exception(e) end |
.fetch_elements(collection, uuids, fetch_many, fetch_one, fetch_containers) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/labimotion/collection/export.rb', line 31 def self.fetch_elements(collection, uuids, fetch_many, fetch_one, fetch_containers) = [] collection.elements.each do |element| fetch_one.call(element, { 'element_klass_id' => 'Labimotion::ElementKlass', 'created_by' => 'User', }) fetch_containers.call(element) end collection.elements.each do |element| element, = Labimotion::ExportUtils.fetch_properties(element, uuids, , &fetch_one) fetch_one.call(element, { 'element_klass_id' => 'Labimotion::ElementKlass', 'created_by' => 'User', }) = Labimotion::Export.fetch_segments(element, uuids, , &fetch_one) end fetch_many.call(collection.collections_elements, { 'collection_id' => 'Collection', 'element_id' => 'Labimotion::Element', }) rescue StandardError => e Labimotion.log_exception(e) end |
.fetch_segment_klasses(&fetch_many) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/labimotion/collection/export.rb', line 14 def self.fetch_segment_klasses(&fetch_many) klasses = Labimotion::SegmentKlass.where(is_active: true) fetch_many.call(klasses, { 'element_klass_id' => 'Labimotion::ElementKlass', 'created_by' => 'User' }) rescue StandardError => e Labimotion.log_exception(e) end |
.fetch_segments(element, uuids, attachments, &fetch_one) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/labimotion/collection/export.rb', line 71 def self.fetch_segments(element, uuids, , &fetch_one) element_type = element.class.name segments = Labimotion::Segment.where("element_id = ? AND element_type = ?", element.id, element_type) segments.each do |segment| segment, = Labimotion::ExportUtils.fetch_properties(segment, uuids, , &fetch_one) fetch_one.call(segment, { 'element_id' => segment.element_type, 'segment_klass_id' => 'Labimotion::SegmentKlass', 'created_by' => 'User' }) end rescue StandardError => e Labimotion.log_exception(e) end |
.fetch_segments_prop(data, uuids) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/labimotion/collection/export.rb', line 59 def self.fetch_segments_prop(data, uuids) data.fetch(Labimotion::Prop::L_SEGMENT, {}).keys.each do |key| segment = data.fetch(Labimotion::Prop::L_SEGMENT, {})[key] Labimotion::ExportUtils.fetch_seg_properties(segment, uuids) data[Labimotion::Prop::L_SEGMENT][key] = segment end data rescue StandardError => e Labimotion.log_exception(e) data end |