labimotion 2.1.0.rc7 → 2.1.0.rc9
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 +4 -4
- data/lib/labimotion/apis/generic_element_api.rb +2 -1
- data/lib/labimotion/apis/generic_klass_api.rb +2 -1
- data/lib/labimotion/entities/element_revision_entity.rb +2 -0
- data/lib/labimotion/entities/eln_element_entity.rb +2 -0
- data/lib/labimotion/entities/properties_entity.rb +4 -0
- data/lib/labimotion/entities/segment_revision_entity.rb +2 -0
- data/lib/labimotion/helpers/converter_helpers.rb +16 -3
- data/lib/labimotion/libs/converter.rb +14 -0
- data/lib/labimotion/libs/export_element.rb +1 -0
- data/lib/labimotion/libs/nmr_mapper.rb +13 -0
- data/lib/labimotion/libs/properties_handler.rb +2 -2
- data/lib/labimotion/libs/sample_association.rb +3 -1
- data/lib/labimotion/utils/serializer.rb +2 -0
- data/lib/labimotion/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e6d531f720a6e62743918a54244a11e0487e36e832df383cc40606a4ede20241
|
|
4
|
+
data.tar.gz: 8eea6d130958617f8bf7cabe2c439c3053b768c93c292c41852f13d20116ca2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed51beb0f134c8e36e1b588f7263270448902d8bf1b17be03fc44b63f0129fcc1992606a2248c957cecd446cf7c6124babdabf515e0834f684dfc9d927254c5b
|
|
7
|
+
data.tar.gz: 1ec3c99f675ce7c32d3a497117504441da819e26073ac6aa50720e55c3ca255497b4d79919f65f8062f0eee2ee9b8f39ff723cacbe011a729434680e25a4931d
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'cgi'
|
|
3
4
|
require 'labimotion/conf'
|
|
4
5
|
require 'labimotion/libs/export_element'
|
|
5
6
|
|
|
@@ -138,7 +139,7 @@ module Labimotion
|
|
|
138
139
|
env['api.format'] = :binary
|
|
139
140
|
content_type 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
140
141
|
el_filename = export.res_name
|
|
141
|
-
filename =
|
|
142
|
+
filename = CGI.escape(el_filename)
|
|
142
143
|
# header['Content-Disposition'] = "attachment; filename=abc.docx"
|
|
143
144
|
header('Content-Disposition', "attachment; filename=\"#{filename}\"")
|
|
144
145
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'cgi'
|
|
3
4
|
require 'labimotion/version'
|
|
4
5
|
require 'labimotion/libs/export_element'
|
|
5
6
|
|
|
@@ -20,7 +21,7 @@ module Labimotion
|
|
|
20
21
|
entity.update_columns(identifier: SecureRandom.uuid) if entity&.identifier.nil?
|
|
21
22
|
env['api.format'] = :binary
|
|
22
23
|
content_type('application/json')
|
|
23
|
-
filename =
|
|
24
|
+
filename = CGI.escape("LabIMotion_#{params[:klass]}_#{entity.label}-#{Time.new.strftime("%Y%m%d%H%M%S")}.json")
|
|
24
25
|
# header['Content-Disposition'] = "attachment; filename=abc.docx"
|
|
25
26
|
header('Content-Disposition', "attachment; filename=\"#{filename}\"")
|
|
26
27
|
"Labimotion::#{params[:klass]}Entity".constantize.represent(entity)
|
|
@@ -13,6 +13,8 @@ module Labimotion
|
|
|
13
13
|
object.properties[Labimotion::Prop::LAYERS]&.keys.each do |key|
|
|
14
14
|
field_sample_molecules = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE || ss['type'] == Labimotion::FieldType::DRAG_MOLECULE }
|
|
15
15
|
field_sample_molecules.each do |field|
|
|
16
|
+
next unless field['value'].is_a?(Hash)
|
|
17
|
+
|
|
16
18
|
idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
|
17
19
|
sid = field.dig('value', 'el_id')
|
|
18
20
|
next unless sid.present?
|
|
@@ -30,6 +30,8 @@ module Labimotion
|
|
|
30
30
|
ss['type'] == Labimotion::FieldType::DRAG_SAMPLE || ss['type'] == Labimotion::FieldType::DRAG_MOLECULE
|
|
31
31
|
end
|
|
32
32
|
field_sample_molecules.each do |field|
|
|
33
|
+
next unless field['value'].is_a?(Hash)
|
|
34
|
+
|
|
33
35
|
idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
|
34
36
|
sid = field.dig('value', 'el_id')
|
|
35
37
|
next unless sid.present?
|
|
@@ -58,6 +58,8 @@ module Labimotion
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def update_sample_or_molecule_field(key, field, idx)
|
|
61
|
+
return unless field['value'].is_a?(Hash)
|
|
62
|
+
|
|
61
63
|
sid = field.dig('value', 'el_id')
|
|
62
64
|
return unless sid.present?
|
|
63
65
|
|
|
@@ -79,6 +81,8 @@ module Labimotion
|
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
def update_reaction_field(key, field, idx)
|
|
84
|
+
return unless field['value'].is_a?(Hash)
|
|
85
|
+
|
|
82
86
|
sid = field.dig('value', 'el_id')
|
|
83
87
|
return unless sid.present?
|
|
84
88
|
|
|
@@ -12,6 +12,8 @@ module Labimotion
|
|
|
12
12
|
object.properties[Labimotion::Prop::LAYERS]&.keys.each do |key|
|
|
13
13
|
field_sample_molecules = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE || ss['type'] == Labimotion::FieldType::DRAG_MOLECULE }
|
|
14
14
|
field_sample_molecules.each do |field|
|
|
15
|
+
next unless field['value'].is_a?(Hash)
|
|
16
|
+
|
|
15
17
|
idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
|
16
18
|
sid = field.dig('value', 'el_id')
|
|
17
19
|
next unless sid.present?
|
|
@@ -2,12 +2,25 @@
|
|
|
2
2
|
require 'grape'
|
|
3
3
|
|
|
4
4
|
module Labimotion
|
|
5
|
-
##
|
|
5
|
+
## ConverterHelpers
|
|
6
6
|
module ConverterHelpers
|
|
7
7
|
extend Grape::API::Helpers
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
# Update the general_description field in the container's extended_metadata
|
|
10
|
+
def self.update_general_description(container, current_user, date: nil, time: nil)
|
|
11
|
+
return unless container.present?
|
|
12
|
+
|
|
13
|
+
desc = container.extended_metadata['general_description']
|
|
14
|
+
|
|
15
|
+
general_desc = desc if desc.present? && desc.is_a?(Hash)
|
|
16
|
+
general_desc = JSON.parse(container.extended_metadata['general_description']) if desc.present? && desc.is_a?(String)
|
|
17
|
+
general_desc = {} unless general_desc.is_a?(Hash)
|
|
18
|
+
general_desc['creator'] = current_user.name if current_user.present?
|
|
19
|
+
general_desc['date'] = date if date.present?
|
|
20
|
+
general_desc['time'] = time if time.present?
|
|
21
|
+
|
|
22
|
+
container.extended_metadata['general_description'] = general_desc.to_json
|
|
23
|
+
container.save!
|
|
11
24
|
end
|
|
12
25
|
end
|
|
13
26
|
end
|
|
@@ -6,6 +6,7 @@ require 'json'
|
|
|
6
6
|
require 'date'
|
|
7
7
|
require 'labimotion/version'
|
|
8
8
|
require 'labimotion/utils/utils'
|
|
9
|
+
require 'labimotion/helpers/converter_helpers'
|
|
9
10
|
|
|
10
11
|
# rubocop: disable Metrics/AbcSize
|
|
11
12
|
# rubocop: disable Metrics/MethodLength
|
|
@@ -228,6 +229,19 @@ module Labimotion
|
|
|
228
229
|
def self.update_ds(dataset, dsr, current_user = nil) # rubocop: disable Metrics/PerceivedComplexity
|
|
229
230
|
layers = dataset.properties[Labimotion::Prop::LAYERS] || {}
|
|
230
231
|
new_prop = dataset.properties
|
|
232
|
+
|
|
233
|
+
container = dataset.element
|
|
234
|
+
|
|
235
|
+
# Extract and update general description fields
|
|
236
|
+
general_dsr = dsr.select { |ds| ds[:layer] == 'general' }
|
|
237
|
+
if general_dsr.present?
|
|
238
|
+
date = general_dsr.find { |ds| ds[:field] == 'date' }&.dig(:value)
|
|
239
|
+
time = general_dsr.find { |ds| ds[:field] == 'time' }&.dig(:value)
|
|
240
|
+
Labimotion::ConverterHelpers.update_general_description(container, current_user, date: date, time: time)
|
|
241
|
+
else
|
|
242
|
+
Labimotion::ConverterHelpers.update_general_description(container, current_user)
|
|
243
|
+
end
|
|
244
|
+
|
|
231
245
|
dsr.each do |ds|
|
|
232
246
|
layer = layers[ds[:layer]]
|
|
233
247
|
next if layer.blank? || layer[Labimotion::Prop::FIELDS].blank?
|
|
@@ -4,6 +4,7 @@ require 'labimotion/libs/dataset_builder'
|
|
|
4
4
|
require 'labimotion/version'
|
|
5
5
|
require 'labimotion/utils/mapper_utils'
|
|
6
6
|
require 'labimotion/utils/utils'
|
|
7
|
+
require 'labimotion/helpers/converter_helpers'
|
|
7
8
|
|
|
8
9
|
module Labimotion
|
|
9
10
|
## NmrMapper
|
|
@@ -61,6 +62,7 @@ module Labimotion
|
|
|
61
62
|
|
|
62
63
|
def update_ds(_cid, obj, current_user, element)
|
|
63
64
|
dataset = obj[:dataset]
|
|
65
|
+
process_general_description(obj, current_user, element)
|
|
64
66
|
dataset.properties = process_prop(obj, current_user, element)
|
|
65
67
|
dataset.save!
|
|
66
68
|
end
|
|
@@ -106,6 +108,17 @@ module Labimotion
|
|
|
106
108
|
new_prop
|
|
107
109
|
end
|
|
108
110
|
|
|
111
|
+
def process_general_description(obj, current_user, element)
|
|
112
|
+
container = obj[:dataset]&.element
|
|
113
|
+
return unless container.present?
|
|
114
|
+
|
|
115
|
+
dt = obj[:metadata]&.dig('DATE')
|
|
116
|
+
date = Labimotion::MapperUtils.format_timestamp(dt, 'date') if dt.present?
|
|
117
|
+
time = Labimotion::MapperUtils.format_timestamp(dt, 'time') if dt.present?
|
|
118
|
+
|
|
119
|
+
Labimotion::ConverterHelpers.update_general_description(container, current_user, date: date, time: time)
|
|
120
|
+
end
|
|
121
|
+
|
|
109
122
|
def process_prop(obj, current_user, element)
|
|
110
123
|
new_prop = obj[:dataset].properties
|
|
111
124
|
new_prop
|
|
@@ -8,9 +8,9 @@ module Labimotion
|
|
|
8
8
|
def check_val(field, type)
|
|
9
9
|
case type
|
|
10
10
|
when Labimotion::FieldType::DRAG_SAMPLE, Labimotion::FieldType::DRAG_ELEMENT
|
|
11
|
-
return field.dig('value', 'el_id').present?
|
|
11
|
+
return field['value'].is_a?(Hash) && field.dig('value', 'el_id').present?
|
|
12
12
|
when Labimotion::FieldType::UPLOAD
|
|
13
|
-
return field.dig('value', 'files')&.length&.positive?
|
|
13
|
+
return field['value'].is_a?(Hash) && field.dig('value', 'files')&.length&.positive?
|
|
14
14
|
when Labimotion::FieldType::TABLE
|
|
15
15
|
return field[Labimotion::Prop::SUBFIELDS]&.length&.positive? && field['sub_values']&.length&.positive?
|
|
16
16
|
end
|
|
@@ -79,6 +79,7 @@ module Labimotion
|
|
|
79
79
|
field_samples.each do |field|
|
|
80
80
|
idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
|
81
81
|
return if field.is_a?(String) || properties.is_a?(String)
|
|
82
|
+
next unless field['value'].is_a?(Hash)
|
|
82
83
|
|
|
83
84
|
sid = field.dig('value', 'el_id')
|
|
84
85
|
next if sid.blank?
|
|
@@ -102,7 +103,8 @@ module Labimotion
|
|
|
102
103
|
field_elements = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_ELEMENT }
|
|
103
104
|
field_elements.each do |field|
|
|
104
105
|
idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
|
105
|
-
|
|
106
|
+
return if field.is_a?(String) || properties.is_a?(String)
|
|
107
|
+
next unless field['value'].is_a?(Hash)
|
|
106
108
|
|
|
107
109
|
sid = field.dig('value', 'el_id')
|
|
108
110
|
next if element.nil? || sid.blank? || sid == element.id
|
|
@@ -37,6 +37,8 @@ module Labimotion
|
|
|
37
37
|
# layer = object.properties[key]
|
|
38
38
|
field_sample_molecules = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| Labimotion::FieldType::DRAG_ALL.include?(ss['type']) }
|
|
39
39
|
field_sample_molecules.each do |field|
|
|
40
|
+
next unless field['value'].is_a?(Hash)
|
|
41
|
+
|
|
40
42
|
idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
|
41
43
|
sid = field.dig('value') != '' && field.dig('value', 'el_id')
|
|
42
44
|
next unless sid.present?
|
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: 2.1.0.
|
|
4
|
+
version: 2.1.0.rc9
|
|
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: 2025-
|
|
12
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: caxlsx
|
|
@@ -175,6 +175,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
175
175
|
- - ">="
|
|
176
176
|
- !ruby/object:Gem::Version
|
|
177
177
|
version: '2.7'
|
|
178
|
+
- - "<"
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '3.4'
|
|
178
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
182
|
requirements:
|
|
180
183
|
- - ">"
|