labimotion 0.1.18 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labimotion/apis/generic_dataset_api.rb +3 -4
- data/lib/labimotion/apis/generic_element_api.rb +5 -53
- data/lib/labimotion/apis/labimotion_hub_api.rb +4 -13
- data/lib/labimotion/apis/segment_api.rb +3 -4
- data/lib/labimotion/entities/generic_public_entity.rb +0 -2
- data/lib/labimotion/helpers/dataset_helpers.rb +8 -18
- data/lib/labimotion/helpers/element_helpers.rb +26 -64
- data/lib/labimotion/helpers/generic_helpers.rb +52 -28
- data/lib/labimotion/helpers/segment_helpers.rb +12 -27
- data/lib/labimotion/libs/converter.rb +11 -19
- data/lib/labimotion/libs/export_dataset.rb +3 -13
- data/lib/labimotion/libs/nmr_mapper.rb +4 -17
- data/lib/labimotion/libs/nmr_mapper_repo.rb +7 -22
- data/lib/labimotion/libs/template_hub.rb +6 -16
- data/lib/labimotion/models/concerns/attachment_converter.rb +0 -1
- data/lib/labimotion/models/concerns/datasetable.rb +10 -6
- data/lib/labimotion/models/concerns/generic_klass_revisions.rb +10 -17
- data/lib/labimotion/models/concerns/segmentable.rb +14 -8
- data/lib/labimotion/models/element.rb +1 -2
- data/lib/labimotion/models/element_klass.rb +4 -0
- data/lib/labimotion/utils/utils.rb +0 -32
- data/lib/labimotion/version.rb +3 -7
- data/lib/labimotion.rb +1 -1
- metadata +5 -6
- data/lib/labimotion/models/hub_log.rb +0 -8
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'grape'
|
3
3
|
require 'labimotion/models/segment_klass'
|
4
|
-
require 'labimotion/utils/utils'
|
5
|
-
|
6
4
|
module Labimotion
|
7
5
|
## ElementHelpers
|
8
6
|
module SegmentHelpers
|
@@ -28,7 +26,8 @@ module Labimotion
|
|
28
26
|
attributes = declared(params, include_missing: false)
|
29
27
|
attributes[:properties_template]['uuid'] = uuid if attributes[:properties_template].present?
|
30
28
|
template = (attributes[:properties_template].presence || template)
|
31
|
-
template['
|
29
|
+
template['eln'] = Chemotion::Application.config.version
|
30
|
+
template['labimotion'] = Labimotion::VERSION
|
32
31
|
template['klass'] = 'SegmentKlass'
|
33
32
|
attributes.merge!(properties_template: template, element_klass: @klass, created_by: current_user.id,
|
34
33
|
place: place)
|
@@ -38,7 +37,7 @@ module Labimotion
|
|
38
37
|
attributes[:properties_release] = attributes[:properties_template]
|
39
38
|
klass = Labimotion::SegmentKlass.create!(attributes)
|
40
39
|
klass.reload
|
41
|
-
klass.create_klasses_revision(current_user)
|
40
|
+
klass.create_klasses_revision(current_user.id)
|
42
41
|
klass
|
43
42
|
rescue StandardError => e
|
44
43
|
Labimotion.log_exception(e, current_user)
|
@@ -63,11 +62,10 @@ module Labimotion
|
|
63
62
|
raise e
|
64
63
|
end
|
65
64
|
|
66
|
-
def create_repo_klass(params, current_user
|
67
|
-
response = Labimotion::TemplateHub.fetch_identifier('SegmentKlass', params[:identifier]
|
68
|
-
attributes = response.slice('label', 'desc', 'uuid', 'identifier', 'released_at',
|
69
|
-
attributes['
|
70
|
-
attributes['properties_template'] = attributes['properties_release']
|
65
|
+
def create_repo_klass(params, current_user)
|
66
|
+
response = Labimotion::TemplateHub.fetch_identifier('SegmentKlass', params[:identifier])
|
67
|
+
attributes = response.slice('label', 'desc', 'uuid', 'identifier', 'released_at') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
68
|
+
attributes['properties_template'] = response['properties_release']
|
71
69
|
attributes['place'] = ((Labimotion::SegmentKlass.all.length * 10) || 0) + 10
|
72
70
|
attributes['is_active'] = false
|
73
71
|
attributes['updated_by'] = current_user.id
|
@@ -75,8 +73,8 @@ module Labimotion
|
|
75
73
|
attributes['sync_time'] = DateTime.now
|
76
74
|
|
77
75
|
element_klass = Labimotion::ElementKlass.find_by(identifier: response['element_klass']['identifier'])
|
78
|
-
element_klass = Labimotion::ElementKlass.find_by(name: response['element_klass']['name']
|
79
|
-
return {
|
76
|
+
element_klass = Labimotion::ElementKlass.find_by(name: response['element_klass']['name']) if element_klass.nil?
|
77
|
+
return { error: 'ElementKlass not found' } if element_klass.nil?
|
80
78
|
|
81
79
|
# el_attributes = response['element_klass'].slice('name', 'label', 'desc', 'uuid', 'identifier', 'icon_name', 'klass_prefix', 'is_generic', 'released_at')
|
82
80
|
# el_attributes['properties_template'] = response['element_klass']['properties_release']
|
@@ -85,23 +83,10 @@ module Labimotion
|
|
85
83
|
attributes['element_klass_id'] = element_klass.id
|
86
84
|
segment_klass = Labimotion::SegmentKlass.find_by(identifier: attributes['identifier'])
|
87
85
|
if segment_klass.present?
|
88
|
-
|
89
|
-
{ status: 'success', message: "This segment: #{attributes['label']} has the latest version!" }
|
90
|
-
else
|
91
|
-
segment_klass.update!(attributes)
|
92
|
-
segment_klass.create_klasses_revision(current_user)
|
93
|
-
{ status: 'success', message: "This segment: [#{attributes['label']}] has been upgraded to the version: #{attributes['version']}!" }
|
94
|
-
end
|
86
|
+
segment_klass.update!(attributes)
|
95
87
|
else
|
96
|
-
|
97
|
-
|
98
|
-
{ status: 'error', message: "The segment [#{attributes['label']}] is already in use." }
|
99
|
-
else
|
100
|
-
attributes['created_by'] = current_user.id
|
101
|
-
segment_klass = Labimotion::SegmentKlass.create!(attributes)
|
102
|
-
segment_klass.create_klasses_revision(current_user)
|
103
|
-
{ status: 'success', message: "The segment: #{attributes['label']} has been created using version: #{attributes['version']}!" }
|
104
|
-
end
|
88
|
+
attributes['created_by'] = current_user.id
|
89
|
+
Labimotion::SegmentKlass.create!(attributes)
|
105
90
|
end
|
106
91
|
rescue StandardError => e
|
107
92
|
Labimotion.log_exception(e, current_user)
|
@@ -5,7 +5,6 @@ require 'uri'
|
|
5
5
|
require 'json'
|
6
6
|
require 'date'
|
7
7
|
require 'labimotion/version'
|
8
|
-
require 'labimotion/utils/utils'
|
9
8
|
|
10
9
|
# rubocop: disable Metrics/AbcSize
|
11
10
|
# rubocop: disable Metrics/MethodLength
|
@@ -117,7 +116,7 @@ module Labimotion
|
|
117
116
|
)
|
118
117
|
# att.attachment_attacher.attach(tmp_file)
|
119
118
|
if att.valid? && Labimotion::IS_RAILS5 == false
|
120
|
-
|
119
|
+
att.attachment_attacher.create_derivatives
|
121
120
|
att.save!
|
122
121
|
end
|
123
122
|
if att.valid? && Labimotion::IS_RAILS5 == true
|
@@ -144,16 +143,12 @@ module Labimotion
|
|
144
143
|
end
|
145
144
|
|
146
145
|
def self.process(data)
|
147
|
-
return
|
146
|
+
return if data[:a]&.attachable_type != 'Container'
|
147
|
+
|
148
148
|
response = nil
|
149
149
|
begin
|
150
150
|
ofile = Rails.root.join(data[:f], data[:a].filename)
|
151
|
-
|
152
|
-
FileUtils.cp(data[:a].store.path, ofile)
|
153
|
-
else
|
154
|
-
FileUtils.cp(data[:a].attachment_url, ofile)
|
155
|
-
end
|
156
|
-
|
151
|
+
FileUtils.cp(data[:a].store.path, ofile)
|
157
152
|
File.open(ofile, 'r') do |f|
|
158
153
|
body = { file: f }
|
159
154
|
response = HTTParty.post(
|
@@ -165,14 +160,12 @@ module Labimotion
|
|
165
160
|
end
|
166
161
|
if response.ok?
|
167
162
|
Labimotion::Converter.handle_response(data[:a], response)
|
168
|
-
Labimotion::ConState::PROCESSED
|
169
163
|
else
|
170
164
|
Labimotion::Converter.logger.error ["Converter Response Error: id: [#{data[:a]&.id}], filename: [#{data[:a]&.filename}], response: #{response}"].join($INPUT_RECORD_SEPARATOR)
|
171
|
-
Labimotion::ConState::ERROR
|
172
165
|
end
|
166
|
+
response
|
173
167
|
rescue StandardError => e
|
174
|
-
|
175
|
-
Labimotion::ConState::ERROR
|
168
|
+
raise e
|
176
169
|
ensure
|
177
170
|
FileUtils.rm_f(ofile)
|
178
171
|
end
|
@@ -181,14 +174,14 @@ module Labimotion
|
|
181
174
|
def self.jcamp_converter(id)
|
182
175
|
resp = nil
|
183
176
|
begin
|
184
|
-
|
185
177
|
data = Labimotion::Converter.vor_conv(id)
|
186
178
|
return if data.nil?
|
187
179
|
|
188
|
-
Labimotion::Converter.process(data)
|
180
|
+
resp = Labimotion::Converter.process(data)
|
181
|
+
resp&.success? ? Labimotion::ConState::PROCESSED : Labimotion::ConState::ERROR
|
189
182
|
rescue StandardError => e
|
190
|
-
Labimotion::Converter.logger.error ["jcamp_converter fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
|
191
183
|
Labimotion::ConState::ERROR
|
184
|
+
Labimotion::Converter.logger.error ["jcamp_converter fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
|
192
185
|
end
|
193
186
|
end
|
194
187
|
|
@@ -216,7 +209,8 @@ module Labimotion
|
|
216
209
|
uuid = SecureRandom.uuid
|
217
210
|
props = klass.properties_release
|
218
211
|
props['uuid'] = uuid
|
219
|
-
props['
|
212
|
+
props['eln'] = Chemotion::Application.config.version
|
213
|
+
props['labimotion'] = Labimotion::VERSION
|
220
214
|
props['klass'] = 'Dataset'
|
221
215
|
Labimotion::Dataset.create!(
|
222
216
|
uuid: uuid,
|
@@ -234,8 +228,6 @@ module Labimotion
|
|
234
228
|
new_prop = dataset.properties
|
235
229
|
dsr.each do |ds|
|
236
230
|
layer = layers[ds[:layer]]
|
237
|
-
next if layer.nil? || layer['fields'].nil?
|
238
|
-
|
239
231
|
fields = layer['fields'].select{ |f| f['field'] == ds[:field] }
|
240
232
|
fi = fields&.first
|
241
233
|
idx = layer['fields'].find_index(fi)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'export_table'
|
3
|
-
require 'labimotion/version'
|
4
3
|
|
5
4
|
module Labimotion
|
6
5
|
## ExportDataset
|
@@ -102,18 +101,9 @@ module Labimotion
|
|
102
101
|
cds.attachments.where(aasm_state: 'csv').each do |att|
|
103
102
|
name = File.basename(att.filename, '.csv')
|
104
103
|
sheet = @xfile.workbook.add_worksheet(name: name)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
fi.each_line do |line|
|
109
|
-
sheet.add_row(line.split(','))
|
110
|
-
end
|
111
|
-
end
|
112
|
-
else
|
113
|
-
File.open(att.attachment_url) do |fi|
|
114
|
-
fi.each_line do |line|
|
115
|
-
sheet.add_row(line.split(','))
|
116
|
-
end
|
104
|
+
File.open(att.store.path) do |fi|
|
105
|
+
fi.each_line do |line|
|
106
|
+
sheet.add_row(line.split(','))
|
117
107
|
end
|
118
108
|
end
|
119
109
|
end
|
@@ -1,15 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'labimotion/version'
|
4
|
-
require 'labimotion/utils/utils'
|
5
|
-
|
6
3
|
module Labimotion
|
7
4
|
## NmrMapper
|
8
5
|
class NmrMapper
|
9
6
|
def self.is_brucker_binary(id)
|
10
7
|
att = Attachment.find(id)
|
11
|
-
if
|
12
|
-
Zip::File.open(att.
|
8
|
+
if att&.attachment_attacher&.file&.url
|
9
|
+
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
13
10
|
zip_file.each do |entry|
|
14
11
|
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
15
12
|
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
@@ -17,17 +14,6 @@ module Labimotion
|
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
20
|
-
else
|
21
|
-
if att&.attachment_attacher&.file&.url
|
22
|
-
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
23
|
-
zip_file.each do |entry|
|
24
|
-
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
25
|
-
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
26
|
-
return metadata
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
17
|
end
|
32
18
|
nil
|
33
19
|
end
|
@@ -261,7 +247,8 @@ module Labimotion
|
|
261
247
|
uuid = SecureRandom.uuid
|
262
248
|
props = klass.properties_release
|
263
249
|
props['uuid'] = uuid
|
264
|
-
props['
|
250
|
+
props['eln'] = Chemotion::Application.config.version
|
251
|
+
props['labimotion'] = Labimotion::VERSION
|
265
252
|
props['klass'] = 'Dataset'
|
266
253
|
dataset = Labimotion::Dataset.create!(
|
267
254
|
uuid: uuid,
|
@@ -1,33 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'labimotion/version'
|
3
|
-
require 'labimotion/utils/utils'
|
4
2
|
|
5
3
|
module Labimotion
|
6
4
|
class NmrMapperRepo
|
7
5
|
def self.is_brucker_binary(id)
|
8
6
|
att = Attachment.find(id)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return metadata
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
else
|
19
|
-
if att&.attachment_attacher&.file&.url
|
20
|
-
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
21
|
-
zip_file.each do |entry|
|
22
|
-
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
23
|
-
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
24
|
-
return metadata
|
25
|
-
end
|
26
|
-
end
|
7
|
+
Zip::File.open(att.store.path) do |zip_file|
|
8
|
+
zip_file.each do |entry|
|
9
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
10
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
11
|
+
return metadata
|
27
12
|
end
|
28
13
|
end
|
29
14
|
end
|
30
|
-
|
31
15
|
nil
|
32
16
|
end
|
33
17
|
|
@@ -261,7 +245,8 @@ module Labimotion
|
|
261
245
|
uuid = SecureRandom.uuid
|
262
246
|
props = klass.properties_release
|
263
247
|
props['uuid'] = uuid
|
264
|
-
props['
|
248
|
+
props['eln'] = Chemotion::Application.config.version
|
249
|
+
props['labimotion'] = Labimotion::VERSION
|
265
250
|
props['klass'] = 'Dataset'
|
266
251
|
dataset = Labimotion::Dataset.create!(
|
267
252
|
uuid: uuid,
|
@@ -20,7 +20,7 @@ module Labimotion
|
|
20
20
|
|
21
21
|
|
22
22
|
def self.header(opt = {})
|
23
|
-
opt || { timeout
|
23
|
+
opt || { :timeout => 10, :headers => {'Content-Type' => 'text/json'} }
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.handle_response(oat, response) # rubocop: disable Metrics/PerceivedComplexity
|
@@ -35,26 +35,16 @@ module Labimotion
|
|
35
35
|
|
36
36
|
def self.list(klass)
|
37
37
|
body = { klass: klass }
|
38
|
-
response = HTTParty.get("#{uri('list')}?klass=#{klass}",
|
38
|
+
response = HTTParty.get("#{uri('list')}?klass=#{klass}", header)
|
39
39
|
# response.parsed_response if response.code == 200
|
40
40
|
JSON.parse(response.body) if response.code == 200
|
41
|
-
rescue StandardError => e
|
42
|
-
Labimotion.log_exception(e)
|
43
|
-
error!('Cannot connect to Chemotion Repository', 401)
|
44
41
|
end
|
45
42
|
|
46
|
-
def self.fetch_identifier(klass, identifier
|
47
|
-
body = { klass: klass, identifier: identifier
|
48
|
-
response = HTTParty.
|
49
|
-
uri('fetch'),
|
50
|
-
body: body,
|
51
|
-
timeout: 10
|
52
|
-
)
|
43
|
+
def self.fetch_identifier(klass, identifier)
|
44
|
+
# body = { klass: klass, identifier: identifier }
|
45
|
+
response = HTTParty.get("#{uri('fetch')}?klass=#{klass}&identifier=#{identifier}", header)
|
53
46
|
# response.parsed_response if response.code == 200
|
54
|
-
JSON.parse(response.body) if response.code ==
|
55
|
-
rescue StandardError => e
|
56
|
-
Labimotion.log_exception(e)
|
57
|
-
error!('Cannot connect to Chemotion Repository', 401)
|
47
|
+
JSON.parse(response.body) if response.code == 200
|
58
48
|
end
|
59
49
|
end
|
60
50
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Datasetable concern
|
4
|
-
require 'labimotion/utils/utils'
|
5
4
|
|
6
5
|
module Labimotion
|
7
6
|
## Datasetable concern
|
@@ -22,18 +21,23 @@ module Labimotion
|
|
22
21
|
klass = Labimotion::DatasetKlass.find_by(id: args[:dataset_klass_id])
|
23
22
|
uuid = SecureRandom.uuid
|
24
23
|
props = args[:properties]
|
25
|
-
props['
|
26
|
-
props['
|
27
|
-
props['uuid'] = uuid
|
28
|
-
props['klass'] = 'Dataset'
|
29
|
-
|
24
|
+
props['eln'] = Chemotion::Application.config.version
|
25
|
+
props['labimotion'] = Labimotion::VERSION
|
30
26
|
ds = Labimotion::Dataset.find_by(element_type: self.class.name, element_id: id)
|
31
27
|
if ds.present? && (ds.klass_uuid != props['klass_uuid'] || ds.properties != props)
|
28
|
+
props['uuid'] = uuid
|
29
|
+
props['eln'] = Chemotion::Application.config.version
|
30
|
+
props['labimotion'] = Labimotion::VERSION
|
31
|
+
props['klass'] = 'Dataset'
|
32
32
|
ds.update!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], properties: props, klass_uuid: props['klass_uuid'])
|
33
33
|
end
|
34
34
|
return if ds.present?
|
35
35
|
|
36
|
+
props['uuid'] = uuid
|
36
37
|
props['klass_uuid'] = klass.uuid
|
38
|
+
props['eln'] = Chemotion::Application.config.version
|
39
|
+
props['labimotion'] = Labimotion::VERSION
|
40
|
+
props['klass'] = 'Dataset'
|
37
41
|
Labimotion::Dataset.create!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], element_type: self.class.name, element_id: id, properties: props, klass_uuid: klass.uuid)
|
38
42
|
end
|
39
43
|
|
@@ -1,40 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Labimotion
|
4
|
-
|
5
|
-
module GenericKlassRevisions
|
4
|
+
module GenericKlassRevisions
|
6
5
|
extend ActiveSupport::Concern
|
7
6
|
included do
|
8
7
|
# has_many :element_klasses_revisions, dependent: :destroy
|
9
8
|
end
|
10
9
|
|
11
|
-
def create_klasses_revision(
|
10
|
+
def create_klasses_revision(user_id=0)
|
12
11
|
properties_release = properties_template
|
13
|
-
|
12
|
+
# (properties_release['layers'] || {}).keys.each do |key|
|
13
|
+
# properties_release['layers'][key]['layer'] = properties_release['layers'][key]['key']
|
14
|
+
# end
|
14
15
|
|
15
|
-
if properties_release['
|
16
|
-
elements = (properties_release['
|
16
|
+
if properties_release['flow'].present?
|
17
|
+
elements = (properties_release['flow']['elements'] || []).map do |el|
|
17
18
|
if el['data'].present? && el['data']['lKey'].present?
|
18
19
|
layer = properties_release['layers'][el['data']['lKey']]
|
19
20
|
el['data']['layer'] = layer if layer.present?
|
20
21
|
end
|
21
22
|
el
|
22
23
|
end
|
23
|
-
properties_release['
|
24
|
+
properties_release['flow']['elements'] = elements
|
24
25
|
end
|
25
|
-
klass_attributes = {
|
26
|
-
uuid: properties_template['uuid'],
|
27
|
-
properties_template: properties_release,
|
28
|
-
properties_release: properties_release,
|
29
|
-
released_at: DateTime.now,
|
30
|
-
updated_by: current_user&.id,
|
31
|
-
released_by: current_user&.id,
|
32
|
-
}
|
33
26
|
|
34
|
-
self.update!(
|
27
|
+
self.update!({ uuid: properties_template['uuid'], properties_release: properties_release, released_at: DateTime.now })
|
35
28
|
reload
|
36
29
|
attributes = {
|
37
|
-
released_by:
|
30
|
+
released_by: user_id,
|
38
31
|
uuid: uuid,
|
39
32
|
version: version,
|
40
33
|
properties_release: properties_release,
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'labimotion/utils/utils'
|
4
|
-
|
5
3
|
module Labimotion
|
6
4
|
# Segmentable concern
|
7
5
|
module Segmentable
|
@@ -41,24 +39,32 @@ module Labimotion
|
|
41
39
|
|
42
40
|
def save_segments(**args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
43
41
|
return if args[:segments].nil?
|
42
|
+
|
44
43
|
segments = []
|
45
|
-
args[:segments]
|
44
|
+
args[:segments].each do |seg|
|
46
45
|
klass = Labimotion::SegmentKlass.find_by(id: seg['segment_klass_id'])
|
47
46
|
uuid = SecureRandom.uuid
|
48
47
|
props = seg['properties']
|
49
|
-
props['
|
50
|
-
props['
|
51
|
-
props['uuid'] = uuid
|
52
|
-
props['klass'] = 'Segment'
|
48
|
+
props['eln'] = Chemotion::Application.config.version
|
49
|
+
props['labimotion'] = Labimotion::VERSION
|
53
50
|
segment = Labimotion::Segment.find_by(element_type: Labimotion::Utils.element_name(self.class.name), element_id: self.id, segment_klass_id: seg['segment_klass_id'])
|
54
51
|
if segment.present? && (segment.klass_uuid != props['klass_uuid'] || segment.properties != props)
|
52
|
+
props['uuid'] = uuid
|
53
|
+
props['eln'] = Chemotion::Application.config.version
|
54
|
+
props['labimotion'] = Labimotion::VERSION
|
55
|
+
props['klass'] = 'Segment'
|
56
|
+
|
55
57
|
segment.update!(properties_release: klass.properties_release, properties: props, uuid: uuid, klass_uuid: props['klass_uuid'])
|
56
58
|
segments.push(segment)
|
57
59
|
end
|
58
60
|
next if segment.present?
|
59
61
|
|
62
|
+
props['uuid'] = uuid
|
60
63
|
props['klass_uuid'] = klass.uuid
|
61
|
-
|
64
|
+
props['eln'] = Chemotion::Application.config.version
|
65
|
+
props['labimotion'] = Labimotion::VERSION
|
66
|
+
props['klass'] = 'Segment'
|
67
|
+
segment = Labimotion::Segment.create!(properties_release: klass.properties_release, segment_klass_id: seg['segment_klass_id'], element_type: Labimotion::Utils.element_name(self.class.name), element_id: self.id, properties: props, created_by: args[:current_user_id], uuid: uuid, klass_uuid: klass.uuid)
|
62
68
|
segments.push(segment)
|
63
69
|
end
|
64
70
|
segments
|
@@ -7,8 +7,7 @@ module Labimotion
|
|
7
7
|
class Element < ApplicationRecord
|
8
8
|
acts_as_paranoid
|
9
9
|
self.table_name = :elements
|
10
|
-
include PgSearch
|
11
|
-
include PgSearch::Model if Labimotion::IS_RAILS5 == false
|
10
|
+
include PgSearch::Model
|
12
11
|
include ElementUIStateScopes
|
13
12
|
include Collectable
|
14
13
|
## include AnalysisCodes
|
@@ -23,6 +23,7 @@ module Labimotion
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
+
|
26
27
|
def migrate_workflow
|
27
28
|
return if properties_template.nil? || properties_release.nil?
|
28
29
|
|
@@ -31,5 +32,8 @@ module Labimotion
|
|
31
32
|
update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
|
32
33
|
update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
|
33
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
34
38
|
end
|
35
39
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'labimotion/version'
|
4
3
|
module Labimotion
|
5
4
|
## Generic Utils
|
6
5
|
class Utils
|
@@ -55,36 +54,5 @@ module Labimotion
|
|
55
54
|
def self.element_name_dc(name)
|
56
55
|
Labimotion::Utils.element_name(name)&.downcase
|
57
56
|
end
|
58
|
-
|
59
|
-
def self.next_version(release, current_version)
|
60
|
-
case release
|
61
|
-
when 'draft'
|
62
|
-
current_version
|
63
|
-
when 'major'
|
64
|
-
if current_version.nil? || current_version.split('.').length < 2
|
65
|
-
'1.0'
|
66
|
-
else
|
67
|
-
"#{current_version&.split('.').first.to_i + 1}.0"
|
68
|
-
end
|
69
|
-
when 'minor'
|
70
|
-
if current_version.nil? || current_version&.split('.').length < 2
|
71
|
-
'0.1'
|
72
|
-
else
|
73
|
-
"#{current_version&.split('.').first.to_i.to_s}.#{current_version&.split('.').last.to_i + 1}"
|
74
|
-
end
|
75
|
-
else
|
76
|
-
current_version
|
77
|
-
end
|
78
|
-
rescue StandardError => e
|
79
|
-
Labimotion.log_exception(e)
|
80
|
-
current_version
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.pkg(pkg)
|
84
|
-
pkg = {} if pkg.nil?
|
85
|
-
pkg['eln'] = Chemotion::Application.config.version
|
86
|
-
pkg['labimotion'] = Labimotion::VERSION
|
87
|
-
pkg
|
88
|
-
end
|
89
57
|
end
|
90
58
|
end
|
data/lib/labimotion/version.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Labimotion
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
VERSION = '0.1.18' if Labimotion::IS_RAILS5 == true
|
8
|
-
|
9
|
-
## for Chemotion ELN
|
10
|
-
VERSION = '1.0.5' if Labimotion::IS_RAILS5 == false
|
4
|
+
# VERSION = '0.1.4'
|
5
|
+
VERSION = '0.2.0'
|
6
|
+
IS_RAILS5 = false
|
11
7
|
end
|
data/lib/labimotion.rb
CHANGED
@@ -7,7 +7,7 @@ module Labimotion
|
|
7
7
|
@@labimotion_logger ||= Logger.new(Rails.root.join('log/labimotion.log')) # rubocop:disable Style/ClassVars
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.log_exception(exception, current_user =
|
10
|
+
def self.log_exception(exception, current_user = {})
|
11
11
|
Labimotion.logger.error("version: #{Labimotion::VERSION}; #{Labimotion::IS_RAILS5}, (#{current_user&.id}) \n Exception: #{exception.message}")
|
12
12
|
Labimotion.logger.error(exception.backtrace.join("\n"))
|
13
13
|
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: 0.
|
4
|
+
version: 0.2.0
|
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: 2023-
|
12
|
+
date: 2023-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 6.1.7
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 6.1.7
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- chia-lin.lin@kit.edu
|
@@ -84,7 +84,6 @@ files:
|
|
84
84
|
- lib/labimotion/models/elements_element.rb
|
85
85
|
- lib/labimotion/models/elements_revision.rb
|
86
86
|
- lib/labimotion/models/elements_sample.rb
|
87
|
-
- lib/labimotion/models/hub_log.rb
|
88
87
|
- lib/labimotion/models/segment.rb
|
89
88
|
- lib/labimotion/models/segment_klass.rb
|
90
89
|
- lib/labimotion/models/segment_klasses_revision.rb
|
@@ -115,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
114
|
- !ruby/object:Gem::Version
|
116
115
|
version: '0'
|
117
116
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.1.6
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: Chemotion LabIMotion
|