labimotion 1.4.0.rc1 → 1.4.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labimotion/entities/properties_entity.rb +20 -0
- data/lib/labimotion/libs/export_element.rb +14 -0
- data/lib/labimotion/utils/export_utils.rb +4 -0
- data/lib/labimotion/utils/field_type.rb +2 -1
- data/lib/labimotion/utils/import_utils.rb +38 -6
- data/lib/labimotion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f07e0d77afbb79bc2652b5f7edbc105133f727593a9a9cc236e17762d1b7e15
|
4
|
+
data.tar.gz: a6d9a86cd6363b5d81f1c141f56ac85974d6622c3cfd06dc21a3184610d5c76b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68ab2a10825518b8c7b22e0ae47aeb48c867404f857e98957082f952f7d42983bc07c50f62ff0dd71be1e6c9bb4f0843fabecdcf7f9ef40f5ce0d253b12dc4f6
|
7
|
+
data.tar.gz: c45113c276c4954803005084733c1e4e13315e9888bb0da50663b3d68577badae0cf5278e2bf1ed4d9cc80002366b981dc80563aa40657cbebf892f34b97f8f7
|
@@ -23,6 +23,26 @@ module Labimotion
|
|
23
23
|
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = field['type'] == Labimotion::FieldType::DRAG_SAMPLE ? el.get_svg_path : File.join('/images', 'molecules', el.molecule_svg_file)
|
24
24
|
end
|
25
25
|
|
26
|
+
field_sys_reactions = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::SYS_REACTION }
|
27
|
+
field_sys_reactions.each do |field|
|
28
|
+
idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
29
|
+
sid = field.dig('value', 'el_id')
|
30
|
+
next unless sid.present?
|
31
|
+
|
32
|
+
el = Reaction.find_by(id: sid)
|
33
|
+
if el.blank?
|
34
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = 'ERROR'
|
35
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = ''
|
36
|
+
end
|
37
|
+
|
38
|
+
next unless el.present?
|
39
|
+
next unless object.properties.dig(Labimotion::Prop::LAYERS, key, Labimotion::Prop::FIELDS, idx, 'value').present?
|
40
|
+
|
41
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_label'] = el.short_label
|
42
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_tip'] = el.short_label
|
43
|
+
object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['el_svg'] = el.reaction_svg_file
|
44
|
+
end
|
45
|
+
|
26
46
|
field_tables = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::TABLE }
|
27
47
|
field_tables.each do |field|
|
28
48
|
idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
@@ -91,6 +91,20 @@ module Labimotion
|
|
91
91
|
obj_final = OpenStruct.new(obj_os)
|
92
92
|
field_obj[:structure] = Reporter::Docx::DiagramSample.new(obj: obj_final, format: 'png').generate
|
93
93
|
end
|
94
|
+
when Labimotion::FieldType::SYS_REACTION
|
95
|
+
val = field.fetch('value', nil)
|
96
|
+
if val.present?
|
97
|
+
instance = Reaction.find_by(id: val['el_id'])
|
98
|
+
field_obj[:value] = val['el_label']
|
99
|
+
field_obj[:has_structure] = true
|
100
|
+
obj_os = Entities::ReactionReportEntity.new(
|
101
|
+
instance,
|
102
|
+
current_user: @current_user,
|
103
|
+
detail_levels: ElementDetailLevelCalculator.new(user: @current_user, element: instance).detail_levels,
|
104
|
+
).serializable_hash
|
105
|
+
obj_final = OpenStruct.new(obj_os)
|
106
|
+
field_obj[:structure] = Reporter::Docx::DiagramReaction.new(obj: obj_final, format: 'png').generate
|
107
|
+
end
|
94
108
|
when Labimotion::FieldType::DRAG_MOLECULE
|
95
109
|
val = field.fetch('value', nil)
|
96
110
|
if val.present?
|
@@ -20,6 +20,8 @@ module Labimotion
|
|
20
20
|
case name
|
21
21
|
when Labimotion::FieldType::DRAG_ELEMENT
|
22
22
|
Labimotion::Prop::L_ELEMENT
|
23
|
+
when Labimotion::FieldType::SYS_REACTION
|
24
|
+
Labimotion::Prop::REACTION
|
23
25
|
when Labimotion::FieldType::DRAG_SAMPLE
|
24
26
|
Labimotion::Prop::SAMPLE
|
25
27
|
when Labimotion::FieldType::DRAG_MOLECULE
|
@@ -167,6 +169,7 @@ module Labimotion
|
|
167
169
|
properties[Labimotion::Prop::LAYERS].keys.each do |key|
|
168
170
|
properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::DRAG_ELEMENT)
|
169
171
|
properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::DRAG_SAMPLE)
|
172
|
+
properties = set_seg_prop(properties, uuids, key, Labimotion::FieldType::SYS_REACTION)
|
170
173
|
end
|
171
174
|
segment['properties'] = properties
|
172
175
|
segment
|
@@ -183,6 +186,7 @@ module Labimotion
|
|
183
186
|
properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_ELEMENT, &fetch_one)
|
184
187
|
properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_MOLECULE, &fetch_one)
|
185
188
|
properties = set_prop(properties, uuids, key, Labimotion::FieldType::DRAG_SAMPLE, &fetch_one)
|
189
|
+
properties = set_prop(properties, uuids, key, Labimotion::FieldType::SYS_REACTION, &fetch_one)
|
186
190
|
properties, attachments = set_upload(instance, properties, attachments, uuids, key, Labimotion::FieldType::UPLOAD, &fetch_one)
|
187
191
|
properties = set_table(properties, uuids, key, Labimotion::FieldType::TABLE, &fetch_one)
|
188
192
|
end
|
@@ -11,13 +11,14 @@ module Labimotion
|
|
11
11
|
WF_NEXT = 'wf-next'.freeze
|
12
12
|
TEXT_FORMULA = 'text-formula'.freeze
|
13
13
|
SYSTEM_DEFINED = 'system-defined'.freeze
|
14
|
+
SYS_REACTION = 'sys-reaction'.freeze
|
14
15
|
DRAG = 'drag'.freeze
|
15
16
|
DRAG_ELEMENT = 'drag_element'.freeze
|
16
17
|
DRAG_MOLECULE = 'drag_molecule'.freeze
|
17
18
|
DRAG_SAMPLE = 'drag_sample'.freeze
|
18
19
|
DRAG_REACTION = 'drag_reaction'.freeze
|
19
20
|
DRAG_MS = [DRAG_MOLECULE, DRAG_SAMPLE].freeze
|
20
|
-
DRAG_ALL = [DRAG_ELEMENT, DRAG_MOLECULE, DRAG_SAMPLE, DRAG_REACTION].freeze
|
21
|
+
DRAG_ALL = [DRAG_ELEMENT, DRAG_MOLECULE, DRAG_SAMPLE, DRAG_REACTION, SYS_REACTION].freeze
|
21
22
|
TABLE = 'table'.freeze
|
22
23
|
UPLOAD = 'upload'.freeze
|
23
24
|
TEXT = 'text'.freeze
|
@@ -51,6 +51,21 @@ module Labimotion
|
|
51
51
|
value
|
52
52
|
end
|
53
53
|
|
54
|
+
def proc_assign_reaction(value, reaction)
|
55
|
+
return {} if reaction.nil?
|
56
|
+
|
57
|
+
value = {} if value.nil? || value.is_a?(String)
|
58
|
+
value['el_id'] = reaction.id
|
59
|
+
value['el_type'] = 'reaction' if value['el_type'].nil?
|
60
|
+
value['el_tip'] = reaction.short_label
|
61
|
+
value['el_label'] = reaction.short_label
|
62
|
+
value['el_svg'] = reaction.reaction_svg_file
|
63
|
+
value
|
64
|
+
rescue StandardError => e
|
65
|
+
Labimotion.log_exception(e)
|
66
|
+
value
|
67
|
+
end
|
68
|
+
|
54
69
|
def proc_assign_element(value, element)
|
55
70
|
return {} if element.nil?
|
56
71
|
|
@@ -136,6 +151,22 @@ module Labimotion
|
|
136
151
|
end
|
137
152
|
end
|
138
153
|
|
154
|
+
def self.proc_reaction(layer, key, data, instances, properties)
|
155
|
+
fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::SYS_REACTION }
|
156
|
+
fields.each do |field|
|
157
|
+
idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
158
|
+
id = field["value"] && field["value"]["el_id"] unless idx.nil?
|
159
|
+
reaction = instances.fetch(Labimotion::Prop::REACTION, nil)&.fetch(id, nil)
|
160
|
+
val = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']
|
161
|
+
val = proc_assign_reaction(val, reaction)
|
162
|
+
properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = val
|
163
|
+
end
|
164
|
+
properties
|
165
|
+
rescue StandardError => e
|
166
|
+
Labimotion.log_exception(e)
|
167
|
+
properties
|
168
|
+
end
|
169
|
+
|
139
170
|
def self.proc_sample(layer, key, data, instances, properties)
|
140
171
|
fields = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE }
|
141
172
|
fields.each do |field|
|
@@ -149,7 +180,7 @@ module Labimotion
|
|
149
180
|
properties
|
150
181
|
rescue StandardError => e
|
151
182
|
Labimotion.log_exception(e)
|
152
|
-
|
183
|
+
properties
|
153
184
|
end
|
154
185
|
|
155
186
|
def self.proc_element(layer, key, data, instances, properties, elements)
|
@@ -169,7 +200,7 @@ module Labimotion
|
|
169
200
|
properties
|
170
201
|
rescue StandardError => e
|
171
202
|
Labimotion.log_exception(e)
|
172
|
-
|
203
|
+
properties
|
173
204
|
end
|
174
205
|
|
175
206
|
def self.proc_upload(layer, key, data, instances, attachments, element)
|
@@ -221,7 +252,7 @@ module Labimotion
|
|
221
252
|
properties
|
222
253
|
rescue StandardError => e
|
223
254
|
Labimotion.log_exception(e)
|
224
|
-
|
255
|
+
properties
|
225
256
|
end
|
226
257
|
|
227
258
|
|
@@ -237,7 +268,7 @@ module Labimotion
|
|
237
268
|
properties
|
238
269
|
rescue StandardError => e
|
239
270
|
Labimotion.log_exception(e)
|
240
|
-
|
271
|
+
properties
|
241
272
|
end
|
242
273
|
|
243
274
|
def self.properties_handler(data, instances, attachments, elmenet, elements)
|
@@ -246,6 +277,7 @@ module Labimotion
|
|
246
277
|
layer = properties[Labimotion::Prop::LAYERS][key]
|
247
278
|
properties = proc_molecule(layer, key, data, properties)
|
248
279
|
properties = proc_upload(layer, key, data, instances, attachments, elmenet)
|
280
|
+
properties = proc_reaction(layer, key, data, instances, properties)
|
249
281
|
properties = proc_sample(layer, key, data, instances, properties)
|
250
282
|
properties = proc_element(layer, key, data, instances, properties, elements) # unless elements.nil?
|
251
283
|
properties = proc_table(layer, key, data, instances, properties)
|
@@ -253,7 +285,7 @@ module Labimotion
|
|
253
285
|
properties
|
254
286
|
rescue StandardError => e
|
255
287
|
Labimotion.log_exception(e)
|
256
|
-
|
288
|
+
properties
|
257
289
|
end
|
258
290
|
|
259
291
|
def self.process_ai(data, instances)
|
@@ -272,7 +304,7 @@ module Labimotion
|
|
272
304
|
end
|
273
305
|
rescue StandardError => e
|
274
306
|
Labimotion.log_exception(e)
|
275
|
-
|
307
|
+
properties
|
276
308
|
end
|
277
309
|
|
278
310
|
def self.create_segment_klass(sk_obj, segment_klass, element_klass, current_user_id)
|
data/lib/labimotion/version.rb
CHANGED
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.4.0.
|
4
|
+
version: 1.4.0.rc2
|
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: 2024-05-
|
12
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|