labimotion 1.3.2 → 1.4.0.rc2

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: 1618c815a5e643e1defe701789af1eb30a3e7e2a166bf65d0b0657893099cd38
4
- data.tar.gz: 66379371379950fb9666a7472954f9b54087b04095ce23444ce8c463c075e173
3
+ metadata.gz: 6f07e0d77afbb79bc2652b5f7edbc105133f727593a9a9cc236e17762d1b7e15
4
+ data.tar.gz: a6d9a86cd6363b5d81f1c141f56ac85974d6622c3cfd06dc21a3184610d5c76b
5
5
  SHA512:
6
- metadata.gz: f735c423f7975f6155be3d129b9b3918b8c64b019e45c146e148cefd66f5184f62d982d117b6f1c863822446776d6f9a91ba5b4be479ad79457aa9629e903286
7
- data.tar.gz: dbb7a6e448818ceceb32f885725167e99efa5bd2ef142e241c6c58f4a9dd74fa36713cf4e66434fed7cf74b3a64b1ef2830e5c2fc258cc8443216bb7e526baef
6
+ metadata.gz: 68ab2a10825518b8c7b22e0ae47aeb48c867404f857e98957082f952f7d42983bc07c50f62ff0dd71be1e6c9bb4f0843fabecdcf7f9ef40f5ce0d253b12dc4f6
7
+ data.tar.gz: c45113c276c4954803005084733c1e4e13315e9888bb0da50663b3d68577badae0cf5278e2bf1ed4d9cc80002366b981dc80563aa40657cbebf892f34b97f8f7
@@ -10,6 +10,7 @@ module Labimotion
10
10
  helpers ContainerHelpers
11
11
  helpers ParamsHelpers
12
12
  helpers CollectionHelpers
13
+ helpers UserLabelHelpers
13
14
  helpers Labimotion::SampleAssociationHelpers
14
15
  helpers Labimotion::GenericHelpers
15
16
  helpers Labimotion::ElementHelpers
@@ -327,7 +328,7 @@ module Labimotion
327
328
  Labimotion.log_exception(e, current_user)
328
329
  { error: e.message }
329
330
  end
330
- end
331
+ end
331
332
 
332
333
  desc 'Return serialized elements of current user'
333
334
  params do
@@ -336,6 +337,7 @@ module Labimotion
336
337
  optional :el_type, type: String, desc: 'element klass name'
337
338
  optional :from_date, type: Integer, desc: 'created_date from in ms'
338
339
  optional :to_date, type: Integer, desc: 'created_date to in ms'
340
+ optional :user_label, type: Integer, desc: 'user label'
339
341
  optional :filter_created_at, type: Boolean, desc: 'filter by created at or updated at'
340
342
  optional :sort_column, type: String, desc: 'sort by updated_at or selected layers property'
341
343
  end
@@ -426,7 +428,7 @@ module Labimotion
426
428
  raise e
427
429
  end
428
430
  end
429
- end
431
+ end
430
432
  end
431
433
  end
432
434
  end
@@ -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)
@@ -95,6 +95,7 @@ module Labimotion
95
95
  element.properties = update_sample_association(params[:properties], current_user, element)
96
96
  element.container = update_datamodel(params[:container], current_user)
97
97
  element.save!
98
+ update_element_labels(element, params[:user_labels], current_user.id)
98
99
  element.save_segments(segments: params[:segments], current_user_id: current_user.id)
99
100
  element
100
101
  rescue StandardError => e
@@ -108,6 +109,9 @@ module Labimotion
108
109
  properties = update_sample_association(params[:properties], current_user, element)
109
110
  params.delete(:container)
110
111
  params.delete(:properties)
112
+ update_element_labels(element, params[:user_labels], current_user.id)
113
+ params.delete(:user_labels)
114
+
111
115
  attributes = declared(params.except(:segments), include_missing: false)
112
116
  properties['pkg'] = Labimotion::Utils.pkg(properties['pkg'])
113
117
  if element.klass_uuid != properties['klass_uuid'] || element.properties != properties || element.name != params[:name]
@@ -288,6 +292,7 @@ module Labimotion
288
292
  scope = scope.elements_created_time_to(Time.at(to) + 1.day) if to && by_created_at
289
293
  scope = scope.elements_updated_time_from(Time.at(from)) if from && !by_created_at
290
294
  scope = scope.elements_updated_time_to(Time.at(to) + 1.day) if to && !by_created_at
295
+ scope = scope.by_user_label(params[:user_label]) if params[:user_label]
291
296
  scope
292
297
  rescue StandardError => e
293
298
  Labimotion.log_exception(e, current_user)
@@ -315,7 +320,7 @@ module Labimotion
315
320
  return { status: 'success', message: "The element: #{attributes['name']} has been created using version: #{attributes['version']}!" }
316
321
  end
317
322
  end
318
-
323
+
319
324
  rescue StandardError => e
320
325
  Labimotion.log_exception(e, current_user)
321
326
  return { status: 'error', message: e.message }
@@ -22,7 +22,7 @@ module Labimotion
22
22
  optional :sync_time, type: DateTime, desc: 'Klass sync_time'
23
23
  optional :version, type: String, desc: 'Klass version'
24
24
  end
25
-
25
+
26
26
  params :create_element_klass_params do
27
27
  requires :name, type: String, desc: 'Element Klass Name'
28
28
  requires :label, type: String, desc: 'Element Klass Label'
@@ -40,7 +40,7 @@ module Labimotion
40
40
  optional :desc, type: String, desc: 'Element Klass Desc'
41
41
  optional :place, type: String, desc: 'Element Klass Place'
42
42
  end
43
-
43
+
44
44
  ## Element Params
45
45
  params :create_element_params do
46
46
  requires :element_klass, type: Hash
@@ -49,18 +49,20 @@ module Labimotion
49
49
  optional :properties_release, type: Hash
50
50
  optional :collection_id, type: Integer
51
51
  requires :container, type: Hash
52
+ optional :user_labels, type: Array
52
53
  optional :segments, type: Array, desc: 'Segments'
53
54
  end
54
-
55
+
55
56
  params :update_element_params do
56
57
  requires :id, type: Integer, desc: 'element id'
57
58
  optional :name, type: String
58
59
  requires :properties, type: Hash
59
60
  optional :properties_release, type: Hash
60
61
  requires :container, type: Hash
62
+ optional :user_labels, type: Array
61
63
  optional :segments, type: Array, desc: 'Segments'
62
64
  end
63
-
65
+
64
66
  ## Segment Klass Params
65
67
  params :upload_segment_klass_params do
66
68
  requires :label, type: String, desc: 'Klass label'
@@ -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
- raise
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
- raise
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
- raise
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
- raise
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
- raise
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
- raise
307
+ properties
276
308
  end
277
309
 
278
310
  def self.create_segment_klass(sk_obj, segment_klass, element_klass, current_user_id)
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '1.3.2'
5
+ VERSION = '1.4.0.rc2'
6
6
  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.2
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-15 00:00:00.000000000 Z
12
+ date: 2024-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -122,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ">="
125
+ - - ">"
126
126
  - !ruby/object:Gem::Version
127
- version: '0'
127
+ version: 1.3.1
128
128
  requirements: []
129
129
  rubygems_version: 3.1.6
130
130
  signing_key: