labimotion 0.2.0 → 0.2.1
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/helpers/dataset_helpers.rb +3 -2
- data/lib/labimotion/helpers/element_helpers.rb +15 -13
- data/lib/labimotion/helpers/generic_helpers.rb +8 -33
- data/lib/labimotion/helpers/segment_helpers.rb +6 -4
- data/lib/labimotion/libs/converter.rb +2 -3
- data/lib/labimotion/libs/nmr_mapper.rb +3 -2
- data/lib/labimotion/libs/nmr_mapper_repo.rb +2 -2
- data/lib/labimotion/libs/template_hub.rb +9 -3
- data/lib/labimotion/models/concerns/datasetable.rb +5 -10
- data/lib/labimotion/models/concerns/generic_klass_revisions.rb +5 -7
- data/lib/labimotion/models/concerns/segmentable.rb +5 -11
- data/lib/labimotion/models/element_klass.rb +0 -4
- data/lib/labimotion/utils/utils.rb +33 -0
- data/lib/labimotion/version.rb +1 -1
- data/lib/labimotion.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80c183c86ccc07a012df8b1aaafdcd4fee0bf2663e1c6096d02792bf42b91d0
|
4
|
+
data.tar.gz: 23bcd1152eed5ceb0d7596e7f60ae6f302d6bef48d2c6972f450ff9b205e0a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b5d9f778ca254357e032fb3c3fad35c87056534cb615f06d867b39dfc107188b8bcf9c01ab9a6fa996d019eaaa2c2b41486f219f7304faf748aa7cb1e1c453
|
7
|
+
data.tar.gz: fb8118dc73c028fd4fe693cf4fbacf8124d474f4ecdbf0c14412deef615ef52648d2ce6b0d919087d72f564e24d22e78cebb0a8cc0ae6b521a8747dee074d762
|
@@ -15,7 +15,7 @@ module Labimotion
|
|
15
15
|
|
16
16
|
def create_repo_klass(params, current_user)
|
17
17
|
response = Labimotion::TemplateHub.fetch_identifier('DatasetKlass', params[:identifier])
|
18
|
-
attributes = response.slice('ols_term_id', 'label', 'desc', 'uuid', 'identifier') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
18
|
+
attributes = response.slice('ols_term_id', 'label', 'desc', 'uuid', 'identifier', 'properties_release', 'version') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
19
19
|
attributes['properties_template'] = response['properties_release']
|
20
20
|
attributes['place'] = ((Labimotion::DatasetKlass.all.length * 10) || 0) + 10
|
21
21
|
attributes['is_active'] = false
|
@@ -27,8 +27,9 @@ module Labimotion
|
|
27
27
|
ds.update!(attributes)
|
28
28
|
else
|
29
29
|
attributes['created_by'] = current_user.id
|
30
|
-
Labimotion::DatasetKlass.create!(attributes)
|
30
|
+
ds = Labimotion::DatasetKlass.create!(attributes)
|
31
31
|
end
|
32
|
+
ds.create_klasses_revision(current_user.id)
|
32
33
|
rescue StandardError => e
|
33
34
|
Labimotion.log_exception(e, current_user)
|
34
35
|
# { error: e.message }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'grape'
|
4
|
-
require 'labimotion/
|
4
|
+
require 'labimotion/utils/utils'
|
5
5
|
# require 'labimotion/models/element_klass'
|
6
6
|
module Labimotion
|
7
7
|
## ElementHelpers
|
@@ -20,11 +20,12 @@ module Labimotion
|
|
20
20
|
uuid = SecureRandom.uuid
|
21
21
|
template = { uuid: uuid, layers: {}, select_options: {} }
|
22
22
|
attributes = declared(params, include_missing: false)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
if attributes[:properties_template].present?
|
24
|
+
attributes[:properties_template]['uuid'] = uuid
|
25
|
+
attributes[:properties_template] = template
|
26
|
+
attributes[:properties_template]['pkg'] = Labimotion::Utils.pkg(attributes[:properties_template]['pkg'])
|
27
|
+
attributes[:properties_template]['klass'] = 'ElementKlass'
|
28
|
+
end
|
28
29
|
attributes[:is_active] = false
|
29
30
|
attributes[:uuid] = uuid
|
30
31
|
attributes[:released_at] = DateTime.now
|
@@ -34,7 +35,7 @@ module Labimotion
|
|
34
35
|
new_klass = Labimotion::ElementKlass.create!(attributes)
|
35
36
|
new_klass.reload
|
36
37
|
new_klass.create_klasses_revision(current_user.id)
|
37
|
-
klass_names_file = Rails.root.join('
|
38
|
+
klass_names_file = Rails.root.join('app/packs/klasses.json')
|
38
39
|
klasses = Labimotion::ElementKlass.where(is_active: true)&.pluck(:name) || []
|
39
40
|
File.write(klass_names_file, klasses)
|
40
41
|
klasses
|
@@ -68,11 +69,11 @@ module Labimotion
|
|
68
69
|
uuid = SecureRandom.uuid
|
69
70
|
params[:properties]['uuid'] = uuid
|
70
71
|
params[:properties]['klass_uuid'] = klass[:uuid]
|
71
|
-
params[:properties]['
|
72
|
-
params[:properties]['labimotion'] = Labimotion::VERSION
|
72
|
+
params[:properties]['pkg'] = Labimotion::Utils.pkg(params[:properties]['pkg'])
|
73
73
|
params[:properties]['klass'] = 'Element'
|
74
74
|
properties = params[:properties]
|
75
75
|
properties.delete('flow') unless properties['flow'].nil?
|
76
|
+
properties.delete('flowObject') unless properties['flowObject'].nil?
|
76
77
|
properties.delete('select_options') unless properties['select_options'].nil?
|
77
78
|
attributes = {
|
78
79
|
name: params[:name],
|
@@ -109,14 +110,14 @@ module Labimotion
|
|
109
110
|
params.delete(:container)
|
110
111
|
params.delete(:properties)
|
111
112
|
attributes = declared(params.except(:segments), include_missing: false)
|
112
|
-
properties['
|
113
|
-
properties['labimotion'] = Labimotion::VERSION
|
113
|
+
properties['pkg'] = Labimotion::Utils.pkg(properties['pkg'])
|
114
114
|
if element.klass_uuid != properties['klass_uuid'] || element.properties != properties || element.name != params[:name]
|
115
115
|
properties['klass'] = 'Element'
|
116
116
|
uuid = SecureRandom.uuid
|
117
117
|
properties['uuid'] = uuid
|
118
118
|
|
119
119
|
properties.delete('flow') unless properties['flow'].nil?
|
120
|
+
properties.delete('flowObject') unless properties['flowObject'].nil?
|
120
121
|
properties.delete('select_options') unless properties['select_options'].nil?
|
121
122
|
|
122
123
|
attributes['properties'] = properties
|
@@ -267,7 +268,7 @@ module Labimotion
|
|
267
268
|
|
268
269
|
def create_repo_klass(params, current_user)
|
269
270
|
response = Labimotion::TemplateHub.fetch_identifier('ElementKlass', params[:identifier])
|
270
|
-
attributes = response.slice('name', 'label', 'desc', 'icon_name', 'klass_prefix', 'is_generic', 'identifier') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
271
|
+
attributes = response.slice('name', 'label', 'desc', 'icon_name', 'klass_prefix', 'is_generic', 'identifier', 'properties_release', 'version') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
271
272
|
attributes['properties_template'] = response['properties_release']
|
272
273
|
attributes['place'] = ((Labimotion::DatasetKlass.all.length * 10) || 0) + 10
|
273
274
|
attributes['is_active'] = false
|
@@ -280,8 +281,9 @@ module Labimotion
|
|
280
281
|
element_klass.update!(attributes)
|
281
282
|
else
|
282
283
|
attributes['created_by'] = current_user.id
|
283
|
-
Labimotion::ElementKlass.create!(attributes)
|
284
|
+
element_klass = Labimotion::ElementKlass.create!(attributes)
|
284
285
|
end
|
286
|
+
element_klass.create_klasses_revision(current_user.id)
|
285
287
|
rescue StandardError => e
|
286
288
|
Labimotion.log_exception(e, current_user)
|
287
289
|
# { error: e.message }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'grape'
|
3
|
-
require 'labimotion/
|
3
|
+
require 'labimotion/utils/utils'
|
4
4
|
# Helper for associated sample
|
5
5
|
module Labimotion
|
6
6
|
## Generic Helpers
|
@@ -45,34 +45,13 @@ module Labimotion
|
|
45
45
|
klz = fetch_klass(params[:klass], params[:id])
|
46
46
|
uuid = SecureRandom.uuid
|
47
47
|
properties = params[:properties_template]
|
48
|
-
|
49
|
-
properties['uuid'] = uuid unless params[:release] != 'draft' && @klz.identifier.present?
|
50
|
-
else
|
51
|
-
properties['uuid'] = uuid
|
52
|
-
end
|
53
|
-
|
54
|
-
klz.version =
|
55
|
-
case params[:release]
|
56
|
-
when 'draft'
|
57
|
-
klz.version
|
58
|
-
when 'major'
|
59
|
-
if klz.version.nil? || klz.version&.split('.').length < 2
|
60
|
-
'1.0'
|
61
|
-
else
|
62
|
-
"#{klz.version&.split('.').first.to_i + 1}.0"
|
63
|
-
end
|
64
|
-
when 'minor'
|
65
|
-
if klz.version.nil? || klz.version&.split('.').length < 2
|
66
|
-
'0.1'
|
67
|
-
else
|
68
|
-
"#{klz.version.split('.').first.to_i.to_s}.#{klz.version.split('.').last.to_i + 1}"
|
69
|
-
end
|
70
|
-
end
|
48
|
+
properties['uuid'] = uuid
|
71
49
|
|
50
|
+
klz.version = Labimotion::Utils.next_version(params[:release], klz.version)
|
72
51
|
properties['version'] = klz.version
|
73
|
-
properties['
|
74
|
-
properties['
|
75
|
-
properties
|
52
|
+
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || klz.properties_template['pkg'])
|
53
|
+
properties['klass'] = klz.class.name.split('::').last
|
54
|
+
properties.delete('eln') if properties['eln'].present?
|
76
55
|
klz.updated_by = current_user.id
|
77
56
|
klz.properties_template = properties
|
78
57
|
klz.save!
|
@@ -117,12 +96,8 @@ module Labimotion
|
|
117
96
|
|
118
97
|
|
119
98
|
###############
|
120
|
-
|
121
|
-
|
122
99
|
def generate_klass_file
|
123
|
-
|
124
|
-
!File.directory?(klass_dir) && FileUtils.mkdir_p(klass_dir)
|
125
|
-
klass_names_file = File.join(klass_dir, 'klasses.json')
|
100
|
+
klass_names_file = Rails.root.join('app/packs/klasses.json')
|
126
101
|
klasses = Labimotion::ElementKlass.where(is_active: true)&.pluck(:name) || []
|
127
102
|
File.write(klass_names_file, klasses)
|
128
103
|
rescue StandardError => e
|
@@ -266,7 +241,7 @@ module Labimotion
|
|
266
241
|
filter_list || []
|
267
242
|
rescue StandardError => e
|
268
243
|
Labimotion.log_exception(e, current_user)
|
269
|
-
|
244
|
+
{ error: 'Cannot connect to Chemotion Repository' }
|
270
245
|
end
|
271
246
|
end
|
272
247
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'grape'
|
3
3
|
require 'labimotion/models/segment_klass'
|
4
|
+
require 'labimotion/utils/utils'
|
5
|
+
|
4
6
|
module Labimotion
|
5
7
|
## ElementHelpers
|
6
8
|
module SegmentHelpers
|
@@ -26,8 +28,7 @@ module Labimotion
|
|
26
28
|
attributes = declared(params, include_missing: false)
|
27
29
|
attributes[:properties_template]['uuid'] = uuid if attributes[:properties_template].present?
|
28
30
|
template = (attributes[:properties_template].presence || template)
|
29
|
-
template['
|
30
|
-
template['labimotion'] = Labimotion::VERSION
|
31
|
+
template['pkg'] = Labimotion::Utils.pkg(template['pkg'])
|
31
32
|
template['klass'] = 'SegmentKlass'
|
32
33
|
attributes.merge!(properties_template: template, element_klass: @klass, created_by: current_user.id,
|
33
34
|
place: place)
|
@@ -64,7 +65,7 @@ module Labimotion
|
|
64
65
|
|
65
66
|
def create_repo_klass(params, current_user)
|
66
67
|
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 = response.slice('label', 'desc', 'uuid', 'identifier', 'released_at', 'properties_release', 'version') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at)
|
68
69
|
attributes['properties_template'] = response['properties_release']
|
69
70
|
attributes['place'] = ((Labimotion::SegmentKlass.all.length * 10) || 0) + 10
|
70
71
|
attributes['is_active'] = false
|
@@ -86,8 +87,9 @@ module Labimotion
|
|
86
87
|
segment_klass.update!(attributes)
|
87
88
|
else
|
88
89
|
attributes['created_by'] = current_user.id
|
89
|
-
Labimotion::SegmentKlass.create!(attributes)
|
90
|
+
segment_klass = Labimotion::SegmentKlass.create!(attributes)
|
90
91
|
end
|
92
|
+
segment_klass.create_klasses_revision(current_user.id)
|
91
93
|
rescue StandardError => e
|
92
94
|
Labimotion.log_exception(e, current_user)
|
93
95
|
raise e
|
@@ -4,7 +4,7 @@ require 'net/http'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'json'
|
6
6
|
require 'date'
|
7
|
-
require 'labimotion/
|
7
|
+
require 'labimotion/utils/utils'
|
8
8
|
|
9
9
|
# rubocop: disable Metrics/AbcSize
|
10
10
|
# rubocop: disable Metrics/MethodLength
|
@@ -209,8 +209,7 @@ module Labimotion
|
|
209
209
|
uuid = SecureRandom.uuid
|
210
210
|
props = klass.properties_release
|
211
211
|
props['uuid'] = uuid
|
212
|
-
props['
|
213
|
-
props['labimotion'] = Labimotion::VERSION
|
212
|
+
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
214
213
|
props['klass'] = 'Dataset'
|
215
214
|
Labimotion::Dataset.create!(
|
216
215
|
uuid: uuid,
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'labimotion/utils/utils'
|
4
|
+
|
3
5
|
module Labimotion
|
4
6
|
## NmrMapper
|
5
7
|
class NmrMapper
|
@@ -247,8 +249,7 @@ module Labimotion
|
|
247
249
|
uuid = SecureRandom.uuid
|
248
250
|
props = klass.properties_release
|
249
251
|
props['uuid'] = uuid
|
250
|
-
props['
|
251
|
-
props['labimotion'] = Labimotion::VERSION
|
252
|
+
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
252
253
|
props['klass'] = 'Dataset'
|
253
254
|
dataset = Labimotion::Dataset.create!(
|
254
255
|
uuid: uuid,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'labimotion/utils/utils'
|
2
3
|
|
3
4
|
module Labimotion
|
4
5
|
class NmrMapperRepo
|
@@ -245,8 +246,7 @@ module Labimotion
|
|
245
246
|
uuid = SecureRandom.uuid
|
246
247
|
props = klass.properties_release
|
247
248
|
props['uuid'] = uuid
|
248
|
-
props['
|
249
|
-
props['labimotion'] = Labimotion::VERSION
|
249
|
+
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
250
250
|
props['klass'] = 'Dataset'
|
251
251
|
dataset = Labimotion::Dataset.create!(
|
252
252
|
uuid: uuid,
|
@@ -20,7 +20,7 @@ module Labimotion
|
|
20
20
|
|
21
21
|
|
22
22
|
def self.header(opt = {})
|
23
|
-
opt || { :
|
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,16 +35,22 @@ 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}", timeout: 10)
|
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)
|
41
44
|
end
|
42
45
|
|
43
46
|
def self.fetch_identifier(klass, identifier)
|
44
47
|
# body = { klass: klass, identifier: identifier }
|
45
|
-
response = HTTParty.get("#{uri('fetch')}?klass=#{klass}&identifier=#{identifier}",
|
48
|
+
response = HTTParty.get("#{uri('fetch')}?klass=#{klass}&identifier=#{identifier}", timeout: 10)
|
46
49
|
# response.parsed_response if response.code == 200
|
47
50
|
JSON.parse(response.body) if response.code == 200
|
51
|
+
rescue StandardError => e
|
52
|
+
Labimotion.log_exception(e)
|
53
|
+
error!('Cannot connect to Chemotion Repository', 401)
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Datasetable concern
|
4
|
+
require 'labimotion/utils/utils'
|
4
5
|
|
5
6
|
module Labimotion
|
6
7
|
## Datasetable concern
|
@@ -21,23 +22,17 @@ module Labimotion
|
|
21
22
|
klass = Labimotion::DatasetKlass.find_by(id: args[:dataset_klass_id])
|
22
23
|
uuid = SecureRandom.uuid
|
23
24
|
props = args[:properties]
|
24
|
-
props['
|
25
|
-
props['
|
25
|
+
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
26
|
+
props['uuid'] = uuid
|
27
|
+
props['klass'] = 'Dataset'
|
28
|
+
|
26
29
|
ds = Labimotion::Dataset.find_by(element_type: self.class.name, element_id: id)
|
27
30
|
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
31
|
ds.update!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], properties: props, klass_uuid: props['klass_uuid'])
|
33
32
|
end
|
34
33
|
return if ds.present?
|
35
34
|
|
36
|
-
props['uuid'] = uuid
|
37
35
|
props['klass_uuid'] = klass.uuid
|
38
|
-
props['eln'] = Chemotion::Application.config.version
|
39
|
-
props['labimotion'] = Labimotion::VERSION
|
40
|
-
props['klass'] = 'Dataset'
|
41
36
|
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)
|
42
37
|
end
|
43
38
|
|
@@ -9,22 +9,20 @@ module Labimotion
|
|
9
9
|
|
10
10
|
def create_klasses_revision(user_id=0)
|
11
11
|
properties_release = properties_template
|
12
|
-
|
13
|
-
# properties_release['layers'][key]['layer'] = properties_release['layers'][key]['key']
|
14
|
-
# end
|
12
|
+
migrate_workflow if properties_release['flow'].present?
|
15
13
|
|
16
|
-
if properties_release['
|
17
|
-
elements = (properties_release['
|
14
|
+
if properties_release['flowObject'].present?
|
15
|
+
elements = (properties_release['flowObject']['nodes'] || []).map do |el|
|
18
16
|
if el['data'].present? && el['data']['lKey'].present?
|
19
17
|
layer = properties_release['layers'][el['data']['lKey']]
|
20
18
|
el['data']['layer'] = layer if layer.present?
|
21
19
|
end
|
22
20
|
el
|
23
21
|
end
|
24
|
-
properties_release['
|
22
|
+
properties_release['flowObject']['nodes'] = elements
|
25
23
|
end
|
26
24
|
|
27
|
-
self.update!({ uuid: properties_template['uuid'], properties_release: properties_release, released_at: DateTime.now })
|
25
|
+
self.update!({ uuid: properties_template['uuid'], properties_template: properties_release, properties_release: properties_release, released_at: DateTime.now })
|
28
26
|
reload
|
29
27
|
attributes = {
|
30
28
|
released_by: user_id,
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'labimotion/utils/utils'
|
4
|
+
|
3
5
|
module Labimotion
|
4
6
|
# Segmentable concern
|
5
7
|
module Segmentable
|
@@ -45,25 +47,17 @@ module Labimotion
|
|
45
47
|
klass = Labimotion::SegmentKlass.find_by(id: seg['segment_klass_id'])
|
46
48
|
uuid = SecureRandom.uuid
|
47
49
|
props = seg['properties']
|
48
|
-
props['
|
49
|
-
props['
|
50
|
+
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
51
|
+
props['uuid'] = uuid
|
52
|
+
props['klass'] = 'Segment'
|
50
53
|
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'])
|
51
54
|
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
|
-
|
57
55
|
segment.update!(properties_release: klass.properties_release, properties: props, uuid: uuid, klass_uuid: props['klass_uuid'])
|
58
56
|
segments.push(segment)
|
59
57
|
end
|
60
58
|
next if segment.present?
|
61
59
|
|
62
|
-
props['uuid'] = uuid
|
63
60
|
props['klass_uuid'] = klass.uuid
|
64
|
-
props['eln'] = Chemotion::Application.config.version
|
65
|
-
props['labimotion'] = Labimotion::VERSION
|
66
|
-
props['klass'] = 'Segment'
|
67
61
|
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)
|
68
62
|
segments.push(segment)
|
69
63
|
end
|
@@ -23,7 +23,6 @@ module Labimotion
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
26
|
def migrate_workflow
|
28
27
|
return if properties_template.nil? || properties_release.nil?
|
29
28
|
|
@@ -32,8 +31,5 @@ module Labimotion
|
|
32
31
|
update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
|
33
32
|
update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
|
34
33
|
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
34
|
end
|
39
35
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'labimotion/version'
|
3
4
|
module Labimotion
|
4
5
|
## Generic Utils
|
5
6
|
class Utils
|
@@ -54,5 +55,37 @@ module Labimotion
|
|
54
55
|
def self.element_name_dc(name)
|
55
56
|
Labimotion::Utils.element_name(name)&.downcase
|
56
57
|
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
|
+
byebug
|
85
|
+
pkg = {} if pkg.nil?
|
86
|
+
pkg['eln'] = Chemotion::Application.config.version
|
87
|
+
pkg['labimotion'] = Labimotion::VERSION
|
88
|
+
pkg
|
89
|
+
end
|
57
90
|
end
|
58
91
|
end
|
data/lib/labimotion/version.rb
CHANGED
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 = nil)
|
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.2.
|
4
|
+
version: 0.2.1
|
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-08-
|
12
|
+
date: 2023-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.4.18
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Chemotion LabIMotion
|