labimotion 1.3.0.rc2 → 1.3.0.rc3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee43dfba01f84786e6b1dc59d125c6c8cd3a7594e6f3d9e5179268995b8366dd
4
- data.tar.gz: e15bf2f064a847b950f3320a2707de508f3c8169a966519280b71f8426a20f3e
3
+ metadata.gz: ef750ee91a207edde617086a1dadc141b83613584810eba9435836fe59b2f745
4
+ data.tar.gz: b68dfa74b8701fbd73598d8a2b67109680a70c31b92e780acef89aa968923108
5
5
  SHA512:
6
- metadata.gz: da54fef539dfc89675a40f1e1de1ab3a58a77f0e23a494912852ab78a29546af83ceeb1ef9e3b1a8f1d77d78adcc55e77a8d986b28f43810966264bdab89c230
7
- data.tar.gz: db9c675738091bd749bdea7ece8eb3e555b6063694691d81a58832b19be3f92618d61a69228ad8a820c11a4b14d7ff8b77ef817378740e0f2af108aa43867316
6
+ metadata.gz: 8fe68edfe62dc71133d5340b6242d43a3d4a6dab50ccb77531bb32898f84635d8794b16ac1185672b453dc9a8965782f7c1545ab4f556ab0d744087d7559ff24
7
+ data.tar.gz: 0ed4f34cf80aef0200681e45103ae22bf4b9fe6e02ca6772ee146aee989a40939143b3370b16b787c678c4329990491dabe331394bca851f473a573405c42a11
@@ -89,7 +89,7 @@ module Labimotion
89
89
  sk_id = sk_obj["identifier"]
90
90
  ek_obj = data.fetch(Labimotion::Prop::L_ELEMENT_KLASS).fetch(sk_obj["element_klass_id"])
91
91
  element_klass = Labimotion::ElementKlass.find_by(name: ek_obj['name']) if ek_obj.present?
92
- next if element_klass.nil? || ek_obj.nil? || ek_obj['is_generic'] == true
92
+ next if element_klass.nil? || ek_obj.nil? # || ek_obj['is_generic'] == true
93
93
 
94
94
  element_uuid = fields.fetch('element_id')
95
95
  element_type = fields.fetch('element_type')
@@ -99,7 +99,7 @@ module Labimotion
99
99
 
100
100
  if segment_klass.nil?
101
101
  skr = Labimotion::SegmentKlassesRevision.find_by(uuid: fields.fetch('klass_uuid'))
102
- segment_klass = skr.segment_klass if segment_klass.nil? && skr.present?
102
+ segment_klass = Labimotion::SegmentKlass.find_by(id: skr.segment_klass_id) if skr.present?
103
103
  end
104
104
 
105
105
  next if segment_klass.nil? || element.nil?
@@ -133,7 +133,7 @@ module Labimotion
133
133
  data.fetch('Labimotion::Element', {}).each do |uuid, fields|
134
134
  klass_id = fields["element_klass_id"]
135
135
  ek_obj = data.fetch('Labimotion::ElementKlass', {})[klass_id]
136
- ek_id = ek_obj["identifier"]
136
+ ek_id = ek_obj["identifier"] if ek_obj.present?
137
137
  element_klass = Labimotion::ElementKlass.find_by(identifier: ek_id) if ek_id.present?
138
138
  element_klass = Labimotion::ElementKlass.find_by(uuid: fields.fetch('klass_uuid')) if element_klass.nil?
139
139
 
@@ -3,5 +3,5 @@
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
5
  IS_RAILS5 = false
6
- VERSION = '1.3.0.rc2'
6
+ VERSION = '1.3.0.rc3'
7
7
  end
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: 1.3.0.rc2
4
+ version: 1.3.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin
@@ -66,10 +66,7 @@ files:
66
66
  - lib/labimotion/helpers/segment_helpers.rb
67
67
  - lib/labimotion/libs/converter.rb
68
68
  - lib/labimotion/libs/export_dataset.rb
69
- - lib/labimotion/libs/export_element copy.rb
70
69
  - lib/labimotion/libs/export_element.rb
71
- - lib/labimotion/libs/export_element2.rb
72
- - lib/labimotion/libs/export_element_bak1.rb
73
70
  - lib/labimotion/libs/nmr_mapper.rb
74
71
  - lib/labimotion/libs/properties_handler.rb
75
72
  - lib/labimotion/libs/sample_association.rb
@@ -106,7 +103,7 @@ files:
106
103
  - lib/labimotion/utils/serializer.rb
107
104
  - lib/labimotion/utils/utils.rb
108
105
  - lib/labimotion/version.rb
109
- homepage: https://gitlab.kit.edu/kit/labimotion/labimotion
106
+ homepage: https://github.com/LabIMotion/labimotion
110
107
  licenses:
111
108
  - AGPL-3.0
112
109
  metadata: {}
@@ -1,204 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'export_table'
3
- require 'labimotion/version'
4
- require 'sablon'
5
-
6
- module Labimotion
7
- class ExportElement
8
- def initialize(current_user, element, export_format)
9
- @current_user = current_user
10
- @element = element
11
- @properties = element.properties
12
- @options = element.properties_release[Labimotion::Prop::SEL_OPTIONS]
13
- @export_format = export_format
14
- rescue StandardError => e
15
- Labimotion.log_exception(e)
16
- byebug
17
- end
18
-
19
- def build_layers
20
- objs = []
21
- @properties[Labimotion::Prop::LAYERS]&.keys&.sort_by { |key| @properties[Labimotion::Prop::LAYERS][key]['position'] }&.each do |key|
22
- layer = @properties[Labimotion::Prop::LAYERS][key] || {}
23
-
24
- ## Build fields html
25
- # field_objs = build_fields_html(layer) if layer[Labimotion::Prop::FIELDS]&.length&.positive?
26
- # field_html = Sablon.content(:html, field_objs) if field_objs.present?
27
- field_objs = build_fields(layer)
28
-
29
- layer_info = {
30
- label: layer['label'],
31
- layer: layer['layer'],
32
- cols: layer['cols'],
33
- timeRecord: layer['timeRecord'],
34
- fields: field_objs
35
- }
36
- objs.push(layer_info)
37
- end
38
- objs
39
- rescue StandardError => e
40
- Labimotion.log_exception(e)
41
- byebug
42
- end
43
-
44
- def build_field(layer, field)
45
- field_obj = {}
46
- field_obj[:label] = field['label']
47
- field_obj[:field] = field['field']
48
- field_obj[:type] = field['type']
49
-
50
- field_obj.merge!(field.slice('value', 'value_system'))
51
-
52
- case field['type']
53
- when Labimotion::FieldType::DRAG_ELEMENT
54
- field_obj[:value] = (field['value'] && field['value']['el_label']) || ''
55
- field_obj[:obj] = field['value'] ### change to object
56
- when Labimotion::FieldType::DRAG_SAMPLE
57
- val = field.fetch('value', {})
58
- instance = Sample.find_by(id: val['el_id'])
59
- field_obj[:value] = val['el_label']
60
- field_obj[:has_structure] = true
61
- obj_os = Entities::SampleReportEntity.new(
62
- instance,
63
- current_user: @current_user,
64
- detail_levels: ElementDetailLevelCalculator.new(user: @current_user, element: instance).detail_levels,
65
- ).serializable_hash
66
- field_obj[:structure] = Reporter::Docx::DiagramSample.new(obj: obj_os, format: 'png').generate
67
- when Labimotion::FieldType::DRAG_MOLECULE
68
- val = field.fetch('value', {})
69
- obj = Molecule.find_by(id: val['el_id'])
70
- field_obj[:value] = val['el_label']
71
- # field_obj[:has_structure] = true
72
- # field_obj[:structure] = Reporter::Docx::DiagramSample.new(obj: obj, format: 'png').generate
73
- when Labimotion::FieldType::SELECT
74
- field_obj[:value] = @options.fetch(field['option_layers'], nil)&.fetch('options', nil)&.find { |ss| ss['key'] == field['value'] }&.fetch('label', nil) || field['value']
75
- when Labimotion::FieldType::UPLOAD
76
- files = field.fetch('value', nil)&.fetch('files', [])
77
- val = files&.map { |file| "#{file['filename']} #{file['label']}" }&.join('\n')
78
- field_obj[:value] = val
79
- when Labimotion::FieldType::TABLE
80
- field_obj[:value] = 'this is a table' ## to be handled
81
- when Labimotion::FieldType::INPUT_GROUP
82
- field_obj[:value] = 'this is a input group' ## to be handled
83
- end
84
- field_obj
85
- rescue StandardError => e
86
- Labimotion.log_exception(e)
87
- byebug
88
- end
89
-
90
- def build_fields(layer)
91
- fields = layer[Labimotion::Prop::FIELDS] || []
92
- field_objs = []
93
- fields.each do |field|
94
- field_obj = build_field(layer, field)
95
- field_objs.push(field_obj)
96
- end
97
- field_objs
98
- rescue StandardError => e
99
- Labimotion.log_exception(e)
100
- byebug
101
- end
102
-
103
- def to_docx
104
- # location = Rails.root.join('lib', 'template', 'Labimotion.docx')
105
- location = Rails.root.join('lib', 'template', 'Labimotion_lines.docx')
106
- File.exist?(location)
107
- template = Sablon.template(location)
108
- layers = build_layers
109
- context = {
110
- name: @element.name,
111
- short_label: @element.short_label,
112
- date: Time.now.strftime('%d/%m/%Y'),
113
- author: @current_user.name,
114
- layers: layers
115
- }
116
- output = "Labimotion1.docx"
117
- template.render_to_file File.expand_path(output), context
118
- File.read(output)
119
- rescue StandardError => e
120
- Labimotion.log_exception(e)
121
- byebug
122
- end
123
-
124
-
125
- def build_field_html(layer, field, cols)
126
- case field['type']
127
- when Labimotion::FieldType::DRAG_SAMPLE, Labimotion::FieldType::DRAG_ELEMENT, Labimotion::FieldType::DRAG_MOLECULE
128
- val = (field['value'] && field['value']['el_label']) || ''
129
- when Labimotion::FieldType::UPLOAD
130
- val = (field['value'] && field['value']['files'] && field['value']['files'].first && field['value']['files'].first['filename'] ) || ''
131
- else
132
- val = field['value']
133
- end
134
- htd = field['hasOwnRow'] == true ? "<td colspan=#{cols}>" : '<td>'
135
- "#{htd}<b>#{field['label']}: </b><br />#{val}</td>"
136
- rescue StandardError => e
137
- Labimotion.log_exception(e)
138
- byebug
139
- end
140
-
141
- def build_fields_html(layer)
142
- fields = layer[Labimotion::Prop::FIELDS] || []
143
- field_objs = []
144
- cols = layer['cols'] || 0
145
- field_objs.push('<table style="width: 4000dxa"><tr>')
146
- fields.each do |field|
147
- if cols&.zero? || field['hasOwnRow'] == true
148
- field_objs.push('</tr><tr>')
149
- cols = layer['cols']
150
- end
151
- field_obj = build_field_html(layer, field, layer['cols'])
152
- field_objs.push(field_obj)
153
- cols -= 1
154
- cols = 0 if field['hasOwnRow'] == true
155
- end
156
- field_objs.push('</tr></table>')
157
- field_objs&.join("")&.gsub('<tr></tr>', '')
158
- rescue StandardError => e
159
- Labimotion.log_exception(e)
160
- byebug
161
- end
162
-
163
-
164
- def build_layers_html
165
- layer_html = []
166
- first_line = true
167
- @properties[Labimotion::Prop::LAYERS]&.keys&.each do |key|
168
- layer_html.push('</tr></table>') if first_line == false
169
- layer = @properties[Labimotion::Prop::LAYERS][key] || {}
170
- fields = layer[Labimotion::Prop::FIELDS] || []
171
- layer_html.push("<h2><b>Layer:#{layer['label']}</b></h2>")
172
- layer_html.push('<table><tr>')
173
- cols = layer['cols']
174
- fields.each do |field|
175
- if (cols === 0)
176
- layer_html.push('</tr><tr>')
177
- end
178
-
179
- val = field['value'].is_a?(Hash) ? field['value']['el_label'] : field['value']
180
- layer_html.push("<td>#{field['label']}: <br />#{val}</td>")
181
- cols -= 1
182
- end
183
- first_line = false
184
- end
185
- layer_html.push('</tr></table>')
186
- byebug
187
- layer_html.join('')
188
- rescue StandardError => e
189
- Labimotion.log_exception(e)
190
- byebug
191
- end
192
-
193
- def html_labimotion
194
- layers_html = build_layers_html
195
- html_body = <<-HTML.strip
196
- #{layers_html}
197
- HTML
198
- html_body
199
- rescue StandardError => e
200
- Labimotion.log_exception(e)
201
- byebug
202
- end
203
- end
204
- end
@@ -1,160 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'export_table'
3
- require 'labimotion/version'
4
- require 'sablon'
5
-
6
- module Labimotion
7
- class ExportElement
8
- def initialize(current_user, element, export_format)
9
- @current_user = current_user
10
- @element = element
11
- @properties = element.properties
12
- @export_format = export_format
13
- rescue StandardError => e
14
- Labimotion.log_exception(e)
15
- byebug
16
- end
17
-
18
- def build_field(layer, field)
19
- field_obj = {}
20
- field_obj[:label] = field['label']
21
- field_obj[:field] = field['field']
22
- field_obj[:type] = field['type']
23
-
24
- case field['type']
25
- when Labimotion::FieldType::DRAG_SAMPLE, Labimotion::FieldType::DRAG_ELEMENT, Labimotion::FieldType::DRAG_MOLECULE
26
- field_obj[:value] = field['value']['el_label']
27
- else
28
- field_obj[:value] = field['value']
29
- end
30
- field_obj
31
- rescue StandardError => e
32
- Labimotion.log_exception(e)
33
- byebug
34
- end
35
-
36
- def build_fields(layer, fields)
37
- field_objs = []
38
- fields.each do |field|
39
- field_obj = build_field(layer, field)
40
- field_objs.push(field_obj)
41
- end
42
- field_objs
43
- rescue StandardError => e
44
- Labimotion.log_exception(e)
45
- byebug
46
- end
47
-
48
- def build_layers
49
- objs = []
50
- @properties[Labimotion::Prop::LAYERS]&.keys&.each do |key|
51
- layer = @properties[Labimotion::Prop::LAYERS][key] || {}
52
- field_objs = build_fields_html(layer)
53
- field_html = Sablon.content(:html, field_objs)
54
- layer_info = {
55
- label: layer['label'],
56
- layer: layer['layer'],
57
- cols: layer['cols'],
58
- timeRecord: layer['timeRecord'],
59
- fields: field_html
60
- }
61
- objs.push(layer_info)
62
- end
63
- objs
64
- rescue StandardError => e
65
- Labimotion.log_exception(e)
66
- byebug
67
- end
68
-
69
-
70
- def build_field_html(layer, field)
71
- case field['type']
72
- when Labimotion::FieldType::DRAG_SAMPLE, Labimotion::FieldType::DRAG_ELEMENT, Labimotion::FieldType::DRAG_MOLECULE
73
- val = field['value']['el_label']
74
- else
75
- val = field['value']
76
- end
77
- "<td><b>#{field['label']}: </b><br />#{val}</td>"
78
- rescue StandardError => e
79
- Labimotion.log_exception(e)
80
- byebug
81
- end
82
-
83
- def build_fields_html(layer)
84
- fields = layer[Labimotion::Prop::FIELDS] || []
85
- field_objs = []
86
- cols = layer['cols']
87
- field_objs.push('<table><tr>')
88
- fields.each do |field|
89
- field_objs.push('</tr><tr>') if (cols === 0)
90
- field_obj = build_field_html(layer, field)
91
- field_objs.push(field_obj)
92
- cols -= 1
93
- end
94
- field_objs.push('</tr></table>')
95
- field_objs.join("")
96
- rescue StandardError => e
97
- Labimotion.log_exception(e)
98
- byebug
99
- end
100
-
101
- def build_layers_html
102
- layer_html = []
103
- first_line = true
104
- @properties[Labimotion::Prop::LAYERS]&.keys&.each do |key|
105
- layer_html.push('</tr></table>') if first_line == false
106
- layer = @properties[Labimotion::Prop::LAYERS][key] || {}
107
- fields = layer[Labimotion::Prop::FIELDS] || []
108
- layer_html.push("<h2><b>Layer:#{layer['label']}</b></h2>")
109
- layer_html.push('<table><tr>')
110
- cols = layer['cols']
111
- fields.each do |field|
112
- if (cols === 0)
113
- layer_html.push("</tr><tr>")
114
- end
115
-
116
- val = field['value'].is_a?(Hash) ? field['value']['el_label'] : field['value']
117
- layer_html.push("<td>#{field['label']}: <br />#{val}</td>")
118
- cols -= 1
119
- end
120
- first_line = false
121
- end
122
- layer_html.push('</tr></table>')
123
- layer_html.join('')
124
-
125
-
126
- rescue StandardError => e
127
- Labimotion.log_exception(e)
128
- byebug
129
- end
130
-
131
- def html_labimotion
132
- layers_html = build_layers_html
133
- html_body = <<-HTML.strip
134
- #{layers_html}
135
- HTML
136
- html_body
137
- rescue StandardError => e
138
- Labimotion.log_exception(e)
139
- byebug
140
- end
141
-
142
- def to_docx
143
- location = Rails.root.join('lib', 'template', 'Labimotion.docx')
144
- File.exist?(location)
145
- template = Sablon.template(location)
146
- layers = build_layers
147
- context = {
148
- name: @element.name,
149
- short_label: @element.short_label,
150
- layers: layers
151
- }
152
- output = "Labimotion1.docx"
153
- template.render_to_file File.expand_path(output), context
154
- File.read(output)
155
- rescue StandardError => e
156
- Labimotion.log_exception(e)
157
- byebug
158
- end
159
- end
160
- end
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'export_table'
3
- require 'labimotion/version'
4
- require 'sablon'
5
-
6
- module Labimotion
7
- class ExportElementBak1
8
- def initialize(current_user, element, export_format)
9
- @current_user = current_user
10
- @element = element
11
- @properties = element.properties
12
- @export_format = export_format
13
- rescue StandardError => e
14
- Labimotion.log_exception(e)
15
- byebug
16
- end
17
-
18
- def build_field(layer, field)
19
- field_obj = {}
20
- field_obj[:label] = field['label']
21
- field_obj[:field] = field['field']
22
- field_obj[:type] = field['type']
23
-
24
- case field['type']
25
- when Labimotion::FieldType::DRAG_SAMPLE, Labimotion::FieldType::DRAG_ELEMENT, Labimotion::FieldType::DRAG_MOLECULE
26
- field_obj[:value] = field['value']['el_label']
27
- else
28
- field_obj[:value] = field['value']
29
- end
30
- field_obj
31
- rescue StandardError => e
32
- Labimotion.log_exception(e)
33
- byebug
34
- end
35
-
36
- def build_fields(layer, fields)
37
- field_objs = []
38
- fields.each do |field|
39
- field_obj = build_field(layer, field)
40
- field_objs.push(field_obj)
41
- end
42
- field_objs
43
- rescue StandardError => e
44
- Labimotion.log_exception(e)
45
- byebug
46
- end
47
- def build_layers
48
- objs = []
49
- @properties[Labimotion::Prop::LAYERS]&.keys&.each do |key|
50
- layer = @properties[Labimotion::Prop::LAYERS][key] || {}
51
- fields = layer[Labimotion::Prop::FIELDS] || []
52
- field_objs = build_fields(layer, fields)
53
-
54
- layer_info = {
55
- label: layer['label'],
56
- layer: layer['layer'],
57
- cols: layer['cols'],
58
- fields: field_objs
59
- }
60
- objs.push(layer_info)
61
- end
62
- objs
63
- rescue StandardError => e
64
- Labimotion.log_exception(e)
65
- byebug
66
- end
67
-
68
- def html_sample
69
- html_body = <<-HTML.strip
70
- <p style="text-align: right; background-color: #FFFF00">
71
- Right aligned content with a yellow background color.
72
- </p>
73
- <div>
74
- <span style="color: #123456">Inline styles</span> are possible as well
75
- </div>
76
- <table>
77
- <tr>
78
- <th>Company</th>
79
- <th>Contact</th>
80
- <th>Country</th>
81
- </tr>
82
- <tr>
83
- <td>Alfreds Futterkiste</td>
84
- <td>Maria Anders</td>
85
- <td>Germany</td>
86
- </tr>
87
- </table>
88
-
89
- HTML
90
- html_body
91
- rescue StandardError => e
92
- Labimotion.log_exception(e)
93
- byebug
94
- end
95
-
96
- def to_docx
97
- location = Rails.root.join('lib', 'template', 'Labimotion.docx')
98
- File.exist?(location)
99
- template = Sablon.template(location)
100
- layers = build_layers
101
- byebug
102
- html_body = html_sample
103
- html_content = Sablon.content(:html, html_body)
104
- context = {
105
- name: @element.name,
106
- short_label: @element.short_label,
107
- layers: layers,
108
- html_sample: html_content
109
- }
110
- output = "Labimotion1.docx"
111
- template.render_to_file File.expand_path(output), context
112
- File.read(output)
113
- rescue StandardError => e
114
- Labimotion.log_exception(e)
115
- byebug
116
- end
117
- end
118
- end