labimotion 0.2.2 → 0.3.1
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 +4 -3
- data/lib/labimotion/apis/generic_element_api.rb +56 -8
- data/lib/labimotion/apis/labimotion_hub_api.rb +13 -4
- data/lib/labimotion/apis/segment_api.rb +4 -3
- data/lib/labimotion/entities/generic_public_entity.rb +2 -0
- data/lib/labimotion/helpers/dataset_helpers.rb +14 -6
- data/lib/labimotion/helpers/element_helpers.rb +34 -16
- data/lib/labimotion/helpers/generic_helpers.rb +18 -18
- data/lib/labimotion/helpers/segment_helpers.rb +20 -8
- data/lib/labimotion/libs/converter.rb +18 -9
- data/lib/labimotion/libs/export_dataset.rb +14 -4
- data/lib/labimotion/libs/nmr_mapper.rb +14 -2
- data/lib/labimotion/libs/nmr_mapper_repo.rb +20 -5
- data/lib/labimotion/libs/template_hub.rb +8 -4
- data/lib/labimotion/models/concerns/attachment_converter.rb +1 -0
- data/lib/labimotion/models/concerns/datasetable.rb +1 -1
- data/lib/labimotion/models/concerns/segmentable.rb +3 -4
- data/lib/labimotion/models/concerns/workflow.rb +9 -0
- data/lib/labimotion/models/element.rb +4 -2
- data/lib/labimotion/models/element_klass.rb +0 -8
- data/lib/labimotion/models/hub_log.rb +8 -0
- data/lib/labimotion/models/segment_klass.rb +2 -0
- data/lib/labimotion/utils/export.rb +20 -0
- data/lib/labimotion/version.rb +3 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b8192a47d907ab3aab31d14c951ccfe6a9552f04cc57896dffc592d850c90d0
|
4
|
+
data.tar.gz: 54be5a8e125a16ebbb8ee8ac48de31e42678c9473da2c7c2e32394585b746ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cb3dd9177e8799a2a07c3454587f6ae7d925e99dd22ce0423a3513cf8992def50d7f900992d9c4db217617473b4ec87b0dcdc02551e3841ba66183efae6159d
|
7
|
+
data.tar.gz: 595b810eee22f50e8ef15db20b2a8b37dc6ad14b2d05d0362568cd235be2cf7358b0ca089722ac09c364a57a5d9e64992fbba5afa342182f9647a602b292467e
|
@@ -30,7 +30,7 @@ module Labimotion
|
|
30
30
|
namespace :fetch_repo do
|
31
31
|
desc 'fetch Generic Dataset Klass from Chemotion Repository'
|
32
32
|
get do
|
33
|
-
fetch_repo('DatasetKlass')
|
33
|
+
fetch_repo('DatasetKlass', current_user)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -40,8 +40,9 @@ module Labimotion
|
|
40
40
|
requires :identifier, type: String, desc: 'Identifier'
|
41
41
|
end
|
42
42
|
post do
|
43
|
-
create_repo_klass(params, current_user)
|
44
|
-
|
43
|
+
msg = create_repo_klass(params, current_user, request.headers['Origin'])
|
44
|
+
klass = Labimotion::DatasetKlassEntity.represent(DatasetKlass.all)
|
45
|
+
{ status: msg[:status], message: msg[:message], klass: klass }
|
45
46
|
rescue StandardError => e
|
46
47
|
Labimotion.log_exception(e, current_user)
|
47
48
|
{ error: e.message }
|
@@ -21,6 +21,9 @@ module Labimotion
|
|
21
21
|
get do
|
22
22
|
ek = Labimotion::ElementKlass.find_by(name: params[:name])
|
23
23
|
present ek, with: Labimotion::ElementKlassEntity, root: 'klass'
|
24
|
+
rescue StandardError => e
|
25
|
+
Labimotion.log_exception(e, current_user)
|
26
|
+
{ klass: [] }
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
@@ -32,6 +35,9 @@ module Labimotion
|
|
32
35
|
get do
|
33
36
|
list = klass_list(params[:generic_only])
|
34
37
|
present list, with: Labimotion::ElementKlassEntity, root: 'klass'
|
38
|
+
rescue StandardError => e
|
39
|
+
Labimotion.log_exception(e, current_user)
|
40
|
+
{ klass: [] }
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
@@ -67,6 +73,9 @@ module Labimotion
|
|
67
73
|
post do
|
68
74
|
authenticate_admin!('elements')
|
69
75
|
update_element_klass(current_user, params)
|
76
|
+
rescue StandardError => e
|
77
|
+
Labimotion.log_exception(e, current_user)
|
78
|
+
raise e
|
70
79
|
end
|
71
80
|
end
|
72
81
|
|
@@ -79,6 +88,9 @@ module Labimotion
|
|
79
88
|
get do
|
80
89
|
list = list_klass_revisions(params)
|
81
90
|
present list, with: Labimotion::KlassRevisionEntity, root: 'revisions'
|
91
|
+
rescue StandardError => e
|
92
|
+
Labimotion.log_exception(e, current_user)
|
93
|
+
[]
|
82
94
|
end
|
83
95
|
end
|
84
96
|
|
@@ -90,6 +102,9 @@ module Labimotion
|
|
90
102
|
get do
|
91
103
|
list = element_revisions(params)
|
92
104
|
present list, with: Labimotion::ElementRevisionEntity, root: 'revisions'
|
105
|
+
rescue StandardError => e
|
106
|
+
Labimotion.log_exception(e, current_user)
|
107
|
+
[]
|
93
108
|
end
|
94
109
|
end
|
95
110
|
|
@@ -104,6 +119,9 @@ module Labimotion
|
|
104
119
|
authenticate_admin!(params[:klass].gsub(/(Klass)/, 's').downcase)
|
105
120
|
delete_klass_revision(params)
|
106
121
|
status 201
|
122
|
+
rescue StandardError => e
|
123
|
+
Labimotion.log_exception(e, current_user)
|
124
|
+
raise e
|
107
125
|
end
|
108
126
|
end
|
109
127
|
|
@@ -117,6 +135,9 @@ module Labimotion
|
|
117
135
|
post do
|
118
136
|
delete_revision(params)
|
119
137
|
status 201
|
138
|
+
rescue StandardError => e
|
139
|
+
Labimotion.log_exception(e, current_user)
|
140
|
+
raise e
|
120
141
|
end
|
121
142
|
end
|
122
143
|
|
@@ -129,6 +150,9 @@ module Labimotion
|
|
129
150
|
klass = Labimotion::Segment.find(params[:id])
|
130
151
|
list = klass.segments_revisions unless klass.nil?
|
131
152
|
present list&.sort_by(&:created_at).reverse, with: Labimotion::SegmentRevisionEntity, root: 'revisions'
|
153
|
+
rescue StandardError => e
|
154
|
+
Labimotion.log_exception(e, current_user)
|
155
|
+
[]
|
132
156
|
end
|
133
157
|
end
|
134
158
|
|
@@ -152,6 +176,9 @@ module Labimotion
|
|
152
176
|
post do
|
153
177
|
upload_generics_files(current_user, params)
|
154
178
|
true
|
179
|
+
rescue StandardError => e
|
180
|
+
Labimotion.log_exception(e, current_user)
|
181
|
+
raise e
|
155
182
|
end
|
156
183
|
end
|
157
184
|
|
@@ -160,13 +187,19 @@ module Labimotion
|
|
160
187
|
get do
|
161
188
|
list = Labimotion::ElementKlass.all.sort_by { |e| e.place }
|
162
189
|
present list, with: Labimotion::ElementKlassEntity, root: 'klass'
|
190
|
+
rescue StandardError => e
|
191
|
+
Labimotion.log_exception(e, current_user)
|
192
|
+
[]
|
163
193
|
end
|
164
194
|
end
|
165
195
|
|
166
196
|
namespace :fetch_repo do
|
167
197
|
desc 'fetch Generic Element Klass from Chemotion Repository'
|
168
198
|
get do
|
169
|
-
fetch_repo('ElementKlass')
|
199
|
+
fetch_repo('ElementKlass', current_user)
|
200
|
+
rescue StandardError => e
|
201
|
+
Labimotion.log_exception(e, current_user)
|
202
|
+
[]
|
170
203
|
end
|
171
204
|
end
|
172
205
|
|
@@ -176,8 +209,9 @@ module Labimotion
|
|
176
209
|
requires :identifier, type: String, desc: 'Identifier'
|
177
210
|
end
|
178
211
|
post do
|
179
|
-
create_repo_klass(params, current_user)
|
180
|
-
|
212
|
+
msg = create_repo_klass(params, current_user, request.headers['Origin'])
|
213
|
+
klass = Labimotion::ElementKlassEntity.represent(ElementKlass.all)
|
214
|
+
{ status: msg[:status], message: msg[:message], klass: klass }
|
181
215
|
rescue StandardError => e
|
182
216
|
Labimotion.log_exception(e, current_user)
|
183
217
|
{ error: e.message }
|
@@ -197,6 +231,9 @@ module Labimotion
|
|
197
231
|
end
|
198
232
|
post do
|
199
233
|
deactivate_klass(params)
|
234
|
+
rescue StandardError => e
|
235
|
+
Labimotion.log_exception(e, current_user)
|
236
|
+
raise e
|
200
237
|
end
|
201
238
|
end
|
202
239
|
|
@@ -209,6 +246,9 @@ module Labimotion
|
|
209
246
|
delete ':id' do
|
210
247
|
delete_klass(params)
|
211
248
|
status 201
|
249
|
+
rescue StandardError => e
|
250
|
+
Labimotion.log_exception(e, current_user)
|
251
|
+
raise e
|
212
252
|
end
|
213
253
|
end
|
214
254
|
|
@@ -226,6 +266,9 @@ module Labimotion
|
|
226
266
|
end
|
227
267
|
post do
|
228
268
|
update_template(params, current_user)
|
269
|
+
rescue StandardError => e
|
270
|
+
Labimotion.log_exception(e, current_user)
|
271
|
+
raise e
|
229
272
|
end
|
230
273
|
end
|
231
274
|
|
@@ -256,6 +299,9 @@ module Labimotion
|
|
256
299
|
end
|
257
300
|
end
|
258
301
|
{ generic_elements: generic_elements }
|
302
|
+
rescue StandardError => e
|
303
|
+
Labimotion.log_exception(e, current_user)
|
304
|
+
{ generic_elements: [] }
|
259
305
|
end
|
260
306
|
|
261
307
|
desc 'Return serialized element by id'
|
@@ -272,7 +318,7 @@ module Labimotion
|
|
272
318
|
if Labimotion::IS_RAILS5 == true
|
273
319
|
{
|
274
320
|
element: ElementPermissionProxy.new(current_user, element, user_ids).serialized,
|
275
|
-
attachments:
|
321
|
+
attachments: attach_thumbnail(element&.attachments)
|
276
322
|
}
|
277
323
|
else
|
278
324
|
{
|
@@ -280,9 +326,11 @@ module Labimotion
|
|
280
326
|
element,
|
281
327
|
detail_levels: ElementDetailLevelCalculator.new(user: current_user, element: element).detail_levels,
|
282
328
|
),
|
283
|
-
attachments:
|
329
|
+
attachments: attach_thumbnail(element&.attachments)
|
284
330
|
}
|
285
331
|
end
|
332
|
+
rescue StandardError => e
|
333
|
+
Labimotion.log_exception(e, current_user)
|
286
334
|
end
|
287
335
|
end
|
288
336
|
|
@@ -302,7 +350,7 @@ module Labimotion
|
|
302
350
|
if Labimotion::IS_RAILS5 == true
|
303
351
|
{
|
304
352
|
element: ElementPermissionProxy.new(current_user, element, user_ids).serialized,
|
305
|
-
attachments:
|
353
|
+
attachments: attach_thumbnail(element&.attachments)
|
306
354
|
}
|
307
355
|
else
|
308
356
|
present(
|
@@ -338,7 +386,7 @@ module Labimotion
|
|
338
386
|
if Labimotion::IS_RAILS5 == true
|
339
387
|
{
|
340
388
|
element: ElementPermissionProxy.new(current_user, element, user_ids).serialized,
|
341
|
-
attachments:
|
389
|
+
attachments: attach_thumbnail(element&.attachments)
|
342
390
|
}
|
343
391
|
else
|
344
392
|
{
|
@@ -346,7 +394,7 @@ module Labimotion
|
|
346
394
|
element,
|
347
395
|
detail_levels: ElementDetailLevelCalculator.new(user: current_user, element: element).detail_levels,
|
348
396
|
),
|
349
|
-
attachments:
|
397
|
+
attachments: attach_thumbnail(element&.attachments),
|
350
398
|
}
|
351
399
|
end
|
352
400
|
rescue StandardError => e
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'open-uri'
|
4
|
+
require 'labimotion/models/hub_log'
|
4
5
|
|
5
6
|
# Belong to Chemotion module
|
6
7
|
module Labimotion
|
@@ -19,20 +20,25 @@ module Labimotion
|
|
19
20
|
list = "Labimotion::#{params[:klass]}".constantize.where(is_active: true).where.not(released_at: nil)
|
20
21
|
list = list.where(is_generic: true) if params[:klass] == 'ElementKlass'
|
21
22
|
entities = Labimotion::GenericPublicEntity.represent(list, displayed: params[:with_props])
|
22
|
-
|
23
|
+
rescue StandardError => e
|
24
|
+
Labimotion.log_exception(e, current_user)
|
25
|
+
[]
|
23
26
|
end
|
24
27
|
end
|
25
28
|
namespace :fetch do
|
26
29
|
desc "get active generic templates"
|
27
30
|
params do
|
28
31
|
requires :klass, type: String, desc: 'Klass', values: %w[ElementKlass SegmentKlass DatasetKlass]
|
29
|
-
|
32
|
+
requires :origin, type: String, desc: 'origin'
|
30
33
|
requires :identifier, type: String, desc: 'Identifier'
|
31
34
|
end
|
32
|
-
|
35
|
+
post do
|
33
36
|
entity = "Labimotion::#{params[:klass]}".constantize.find_by(identifier: params[:identifier])
|
37
|
+
Labimotion::HubLog.create(klass: entity, origin: params[:origin], uuid: entity.uuid, version: entity.version)
|
34
38
|
"Labimotion::#{params[:klass]}Entity".constantize.represent(entity)
|
35
|
-
|
39
|
+
rescue StandardError => e
|
40
|
+
Labimotion.log_exception(e, current_user)
|
41
|
+
raise e
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
@@ -45,6 +51,9 @@ module Labimotion
|
|
45
51
|
list = Labimotion::ElementKlass.where(is_active: true) if params[:generic_only].present? && params[:generic_only] == true
|
46
52
|
list = Labimotion::ElementKlass.where(is_active: true) unless params[:generic_only].present? && params[:generic_only] == true
|
47
53
|
list.pluck(:name)
|
54
|
+
rescue StandardError => e
|
55
|
+
Labimotion.log_exception(e, current_user)
|
56
|
+
[]
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
@@ -118,7 +118,7 @@ module Labimotion
|
|
118
118
|
namespace :fetch_repo do
|
119
119
|
desc 'fetch Generic Segment Klass from Chemotion Repository'
|
120
120
|
get do
|
121
|
-
fetch_repo('SegmentKlass')
|
121
|
+
fetch_repo('SegmentKlass', current_user)
|
122
122
|
rescue StandardError => e
|
123
123
|
Labimotion.log_exception(e, current_user)
|
124
124
|
{ error: e.message }
|
@@ -131,8 +131,9 @@ module Labimotion
|
|
131
131
|
requires :identifier, type: String, desc: 'Identifier'
|
132
132
|
end
|
133
133
|
post do
|
134
|
-
create_repo_klass(params, current_user)
|
135
|
-
|
134
|
+
msg = create_repo_klass(params, current_user, request.headers['Origin'])
|
135
|
+
klass = Labimotion::SegmentKlassEntity.represent(SegmentKlass.all)
|
136
|
+
{ status: msg[:status], message: msg[:message], klass: klass }
|
136
137
|
rescue StandardError => e
|
137
138
|
Labimotion.log_exception(e, current_user)
|
138
139
|
## { error: e.message }
|
@@ -5,6 +5,7 @@ require 'labimotion/entities/application_entity'
|
|
5
5
|
# Entity module
|
6
6
|
module Labimotion
|
7
7
|
class GenericPublicEntity < Labimotion::ApplicationEntity
|
8
|
+
expose! :uuid
|
8
9
|
expose! :name
|
9
10
|
expose! :desc
|
10
11
|
expose! :icon_name
|
@@ -12,6 +13,7 @@ module Labimotion
|
|
12
13
|
expose! :klass_name
|
13
14
|
expose! :label
|
14
15
|
expose! :identifier
|
16
|
+
expose! :version
|
15
17
|
expose! :released_at
|
16
18
|
expose! :properties_release, if: :displayed
|
17
19
|
expose :element_klass do |obj|
|
@@ -13,8 +13,8 @@ module Labimotion
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def create_repo_klass(params, current_user)
|
17
|
-
response = Labimotion::TemplateHub.fetch_identifier('DatasetKlass', params[:identifier])
|
16
|
+
def create_repo_klass(params, current_user, origin)
|
17
|
+
response = Labimotion::TemplateHub.fetch_identifier('DatasetKlass', params[:identifier], origin)
|
18
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_release']['identifier'] = attributes['identifier']
|
20
20
|
attributes['properties_template'] = attributes['properties_release']
|
@@ -23,14 +23,22 @@ module Labimotion
|
|
23
23
|
attributes['updated_by'] = current_user.id
|
24
24
|
attributes['sync_by'] = current_user.id
|
25
25
|
attributes['sync_time'] = DateTime.now
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
dataset_klass = Labimotion::DatasetKlass.find_by(ols_term_id: attributes['ols_term_id'])
|
27
|
+
if dataset_klass.present?
|
28
|
+
if dataset_klass['uuid'] == attributes['uuid'] && dataset_klass['version'] == attributes['version']
|
29
|
+
{ status: 'success', message: "This dataset: #{attributes['label']} has the latest version!" }
|
30
|
+
else
|
31
|
+
ds = Labimotion::DatasetKlass.find_by(ols_term_id: attributes['ols_term_id'])
|
32
|
+
ds.update!(attributes)
|
33
|
+
ds.create_klasses_revision(current_user)
|
34
|
+
{ status: 'success', message: "This dataset: [#{attributes['label']}] has been upgraded to the version: #{attributes['version']}!" }
|
35
|
+
end
|
29
36
|
else
|
30
37
|
attributes['created_by'] = current_user.id
|
31
38
|
ds = Labimotion::DatasetKlass.create!(attributes)
|
39
|
+
ds.create_klasses_revision(current_user)
|
40
|
+
{ status: 'success', message: "The dataset: #{attributes['label']} has been created using version: #{attributes['version']}!" }
|
32
41
|
end
|
33
|
-
ds.create_klasses_revision(current_user)
|
34
42
|
rescue StandardError => e
|
35
43
|
Labimotion.log_exception(e, current_user)
|
36
44
|
# { error: e.message }
|
@@ -20,12 +20,10 @@ module Labimotion
|
|
20
20
|
uuid = SecureRandom.uuid
|
21
21
|
template = { uuid: uuid, layers: {}, select_options: {} }
|
22
22
|
attributes = declared(params, include_missing: false)
|
23
|
-
if attributes[:properties_template].
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
attributes[:properties_template]['klass'] = 'ElementKlass'
|
28
|
-
end
|
23
|
+
attributes[:properties_template] = template if attributes[:properties_template].nil?
|
24
|
+
attributes[:properties_template]['uuid'] = uuid
|
25
|
+
attributes[:properties_template]['pkg'] = Labimotion::Utils.pkg(attributes[:properties_template]['pkg'])
|
26
|
+
attributes[:properties_template]['klass'] = 'ElementKlass'
|
29
27
|
attributes[:is_active] = false
|
30
28
|
attributes[:uuid] = uuid
|
31
29
|
attributes[:released_at] = DateTime.now
|
@@ -161,7 +159,7 @@ module Labimotion
|
|
161
159
|
att_ary = create_attachments(
|
162
160
|
params[:attfiles],
|
163
161
|
params[:delfiles],
|
164
|
-
params[:att_type],
|
162
|
+
"Labimotion::#{params[:att_type]}",
|
165
163
|
params[:att_id],
|
166
164
|
params[:attfilesIdentifier],
|
167
165
|
current_user.id
|
@@ -176,8 +174,7 @@ module Labimotion
|
|
176
174
|
true
|
177
175
|
rescue StandardError => e
|
178
176
|
Labimotion.log_exception(e, current_user)
|
179
|
-
|
180
|
-
raise e
|
177
|
+
false
|
181
178
|
end
|
182
179
|
|
183
180
|
def element_revisions(params)
|
@@ -292,9 +289,9 @@ module Labimotion
|
|
292
289
|
raise e
|
293
290
|
end
|
294
291
|
|
295
|
-
def create_repo_klass(params, current_user)
|
296
|
-
response = Labimotion::TemplateHub.fetch_identifier('ElementKlass', params[:identifier])
|
297
|
-
attributes = response.slice('name', 'label', 'desc', 'icon_name', 'klass_prefix', 'is_generic', 'identifier', 'properties_release', 'version')
|
292
|
+
def create_repo_klass(params, current_user, origin)
|
293
|
+
response = Labimotion::TemplateHub.fetch_identifier('ElementKlass', params[:identifier], origin)
|
294
|
+
attributes = response.slice('name', 'label', 'desc', 'icon_name', 'uuid', 'klass_prefix', 'is_generic', 'identifier', 'properties_release', 'version')
|
298
295
|
attributes['properties_release']['identifier'] = attributes['identifier']
|
299
296
|
attributes['properties_template'] = attributes['properties_release']
|
300
297
|
attributes['place'] = ((Labimotion::DatasetKlass.all.length * 10) || 0) + 10
|
@@ -305,17 +302,38 @@ module Labimotion
|
|
305
302
|
|
306
303
|
element_klass = Labimotion::ElementKlass.find_by(identifier: attributes['identifier'])
|
307
304
|
if element_klass.present?
|
308
|
-
element_klass
|
305
|
+
if element_klass['uuid'] == attributes['uuid'] && element_klass['version'] == attributes['version']
|
306
|
+
{ status: 'success', message: "This element: #{attributes['name']} has the latest version!" }
|
307
|
+
else
|
308
|
+
element_klass.update!(attributes)
|
309
|
+
element_klass.create_klasses_revision(current_user)
|
310
|
+
{ status: 'success', message: "This element: [#{attributes['name']}] has been upgraded to the version: #{attributes['version']}!" }
|
311
|
+
end
|
309
312
|
else
|
310
|
-
attributes['
|
311
|
-
|
313
|
+
exist_klass = Labimotion::ElementKlass.find_by(name: attributes['name'])
|
314
|
+
if exist_klass.present?
|
315
|
+
{ status: 'error', message: "The name [#{attributes['name']}] is already in use." }
|
316
|
+
else
|
317
|
+
attributes['created_by'] = current_user.id
|
318
|
+
element_klass = Labimotion::ElementKlass.create!(attributes)
|
319
|
+
element_klass.create_klasses_revision(current_user)
|
320
|
+
{ status: 'success', message: "The element: #{attributes['name']} has been created using version: #{attributes['version']}!" }
|
321
|
+
end
|
312
322
|
end
|
313
|
-
element_klass.create_klasses_revision(current_user)
|
314
323
|
rescue StandardError => e
|
315
324
|
Labimotion.log_exception(e, current_user)
|
316
325
|
# { error: e.message }
|
317
326
|
raise e
|
318
327
|
end
|
319
328
|
|
329
|
+
def attach_thumbnail(_attachments)
|
330
|
+
attachments = _attachments&.map do |attachment|
|
331
|
+
_att = Entities::AttachmentEntity.represent(attachment, serializable: true)
|
332
|
+
_att[:thumbnail] = attachment.thumb ? Base64.encode64(attachment.read_thumbnail) : nil
|
333
|
+
_att
|
334
|
+
end
|
335
|
+
attachments
|
336
|
+
end
|
337
|
+
|
320
338
|
end
|
321
339
|
end
|
@@ -46,10 +46,9 @@ module Labimotion
|
|
46
46
|
uuid = SecureRandom.uuid
|
47
47
|
properties = params[:properties_template]
|
48
48
|
properties['uuid'] = uuid
|
49
|
-
|
50
49
|
klz.version = Labimotion::Utils.next_version(params[:release], klz.version)
|
51
50
|
properties['version'] = klz.version
|
52
|
-
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || klz.properties_template['pkg'])
|
51
|
+
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || (klz.properties_template && klz.properties_template['pkg']))
|
53
52
|
properties['klass'] = klz.class.name.split('::').last
|
54
53
|
properties['identifier'] = klz.identifier
|
55
54
|
properties.delete('eln') if properties['eln'].present?
|
@@ -189,37 +188,37 @@ module Labimotion
|
|
189
188
|
raise e
|
190
189
|
end
|
191
190
|
|
192
|
-
def create_attachments(files, del_files, type, id, user_id)
|
191
|
+
def create_attachments(files, del_files, type, id, identifier, user_id)
|
193
192
|
attach_ary = []
|
194
|
-
(files || []).
|
193
|
+
(files || []).each_with_index do |file, index|
|
195
194
|
next unless (tempfile = file[:tempfile])
|
196
195
|
|
197
|
-
|
196
|
+
att = Attachment.new(
|
198
197
|
bucket: file[:container_id],
|
199
198
|
filename: file[:filename],
|
200
199
|
con_state: Labimotion::ConState::NONE,
|
201
200
|
file_path: file[:tempfile],
|
202
201
|
created_by: user_id,
|
203
202
|
created_for: user_id,
|
203
|
+
identifier: identifier[index],
|
204
204
|
content_type: file[:type],
|
205
205
|
attachable_type: type,
|
206
206
|
attachable_id: id,
|
207
207
|
)
|
208
208
|
begin
|
209
|
-
|
210
|
-
attach_ary.push(
|
209
|
+
att.save!
|
210
|
+
attach_ary.push(att.id)
|
211
211
|
ensure
|
212
212
|
tempfile.close
|
213
213
|
tempfile.unlink
|
214
214
|
end
|
215
215
|
end
|
216
216
|
unless (del_files || []).empty?
|
217
|
-
Attachment.where('id IN (?) AND attachable_type = (?)', del_files.map!(&:to_i),
|
218
|
-
type).update_all(attachable_id: nil)
|
217
|
+
Attachment.where('id IN (?) AND attachable_type = (?)', del_files.map!(&:to_i), type).update_all(attachable_id: nil)
|
219
218
|
end
|
220
219
|
attach_ary
|
221
220
|
rescue StandardError => e
|
222
|
-
Labimotion.log_exception(e
|
221
|
+
Labimotion.log_exception(e)
|
223
222
|
raise e
|
224
223
|
end
|
225
224
|
|
@@ -231,15 +230,16 @@ module Labimotion
|
|
231
230
|
Chemotion::Generic::Fetch::Template.list(API::TARGET, name)
|
232
231
|
end
|
233
232
|
|
234
|
-
def fetch_repo(name)
|
235
|
-
current_klasses = "Labimotion::#{name}".constantize.where.not(identifier: nil)&.pluck(:identifier) || []
|
233
|
+
def fetch_repo(name, current_user)
|
234
|
+
# current_klasses = "Labimotion::#{name}".constantize.where.not(identifier: nil)&.pluck(:identifier) || []
|
236
235
|
response = Labimotion::TemplateHub.list(name)
|
237
|
-
if response && response['list'].present? && response['list'].length.positive?
|
238
|
-
filter_list = response['list']&.reject do |ds|
|
239
|
-
|
240
|
-
end || []
|
241
|
-
end
|
242
|
-
filter_list || []
|
236
|
+
# if response && response['list'].present? && response['list'].length.positive?
|
237
|
+
# filter_list = response['list']&.reject do |ds|
|
238
|
+
# current_klasses.include?(ds['identifier'])
|
239
|
+
# end || []
|
240
|
+
# end
|
241
|
+
# filter_list || []
|
242
|
+
(response && response['list']) || []
|
243
243
|
rescue StandardError => e
|
244
244
|
Labimotion.log_exception(e, current_user)
|
245
245
|
{ error: 'Cannot connect to Chemotion Repository' }
|
@@ -63,8 +63,8 @@ module Labimotion
|
|
63
63
|
raise e
|
64
64
|
end
|
65
65
|
|
66
|
-
def create_repo_klass(params, current_user)
|
67
|
-
response = Labimotion::TemplateHub.fetch_identifier('SegmentKlass', params[:identifier])
|
66
|
+
def create_repo_klass(params, current_user, origin)
|
67
|
+
response = Labimotion::TemplateHub.fetch_identifier('SegmentKlass', params[:identifier], origin)
|
68
68
|
attributes = response.slice('label', 'desc', 'uuid', 'identifier', 'released_at', 'properties_release', 'version')
|
69
69
|
attributes['properties_release']['identifier'] = attributes['identifier']
|
70
70
|
attributes['properties_template'] = attributes['properties_release']
|
@@ -75,8 +75,8 @@ module Labimotion
|
|
75
75
|
attributes['sync_time'] = DateTime.now
|
76
76
|
|
77
77
|
element_klass = Labimotion::ElementKlass.find_by(identifier: response['element_klass']['identifier'])
|
78
|
-
element_klass = Labimotion::ElementKlass.find_by(name: response['element_klass']['name']) if element_klass.nil?
|
79
|
-
return { error: '
|
78
|
+
element_klass = Labimotion::ElementKlass.find_by(name: response['element_klass']['name'], is_generic: false) if element_klass.nil?
|
79
|
+
return { status: 'error', message: "The element [#{response['element_klass']['name']}] does not exist in this instance" } if element_klass.nil?
|
80
80
|
|
81
81
|
# el_attributes = response['element_klass'].slice('name', 'label', 'desc', 'uuid', 'identifier', 'icon_name', 'klass_prefix', 'is_generic', 'released_at')
|
82
82
|
# el_attributes['properties_template'] = response['element_klass']['properties_release']
|
@@ -85,12 +85,24 @@ module Labimotion
|
|
85
85
|
attributes['element_klass_id'] = element_klass.id
|
86
86
|
segment_klass = Labimotion::SegmentKlass.find_by(identifier: attributes['identifier'])
|
87
87
|
if segment_klass.present?
|
88
|
-
segment_klass
|
88
|
+
if segment_klass['uuid'] == attributes['uuid'] && segment_klass['version'] == attributes['version']
|
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
|
89
95
|
else
|
90
|
-
attributes['
|
91
|
-
|
96
|
+
exist_klass = Labimotion::SegmentKlass.find_by(label: attributes['label'], element_klass_id: element_klass.id)
|
97
|
+
if exist_klass.present?
|
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
|
92
105
|
end
|
93
|
-
segment_klass.create_klasses_revision(current_user)
|
94
106
|
rescue StandardError => e
|
95
107
|
Labimotion.log_exception(e, current_user)
|
96
108
|
raise e
|
@@ -4,6 +4,7 @@ require 'net/http'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'json'
|
6
6
|
require 'date'
|
7
|
+
require 'labimotion/version'
|
7
8
|
require 'labimotion/utils/utils'
|
8
9
|
|
9
10
|
# rubocop: disable Metrics/AbcSize
|
@@ -116,7 +117,7 @@ module Labimotion
|
|
116
117
|
)
|
117
118
|
# att.attachment_attacher.attach(tmp_file)
|
118
119
|
if att.valid? && Labimotion::IS_RAILS5 == false
|
119
|
-
att.attachment_attacher.create_derivatives
|
120
|
+
## att.attachment_attacher.create_derivatives
|
120
121
|
att.save!
|
121
122
|
end
|
122
123
|
if att.valid? && Labimotion::IS_RAILS5 == true
|
@@ -143,12 +144,16 @@ module Labimotion
|
|
143
144
|
end
|
144
145
|
|
145
146
|
def self.process(data)
|
146
|
-
return if data[:a]&.attachable_type != 'Container'
|
147
|
-
|
147
|
+
return data[:a].con_state if data[:a]&.attachable_type != 'Container'
|
148
148
|
response = nil
|
149
149
|
begin
|
150
150
|
ofile = Rails.root.join(data[:f], data[:a].filename)
|
151
|
-
|
151
|
+
if Labimotion::IS_RAILS5 == true
|
152
|
+
FileUtils.cp(data[:a].store.path, ofile)
|
153
|
+
else
|
154
|
+
FileUtils.cp(data[:a].attachment_url, ofile)
|
155
|
+
end
|
156
|
+
|
152
157
|
File.open(ofile, 'r') do |f|
|
153
158
|
body = { file: f }
|
154
159
|
response = HTTParty.post(
|
@@ -160,12 +165,14 @@ module Labimotion
|
|
160
165
|
end
|
161
166
|
if response.ok?
|
162
167
|
Labimotion::Converter.handle_response(data[:a], response)
|
168
|
+
Labimotion::ConState::PROCESSED
|
163
169
|
else
|
164
170
|
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
|
165
172
|
end
|
166
|
-
response
|
167
173
|
rescue StandardError => e
|
168
|
-
|
174
|
+
Labimotion::Converter.logger.error ["process fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
|
175
|
+
Labimotion::ConState::ERROR
|
169
176
|
ensure
|
170
177
|
FileUtils.rm_f(ofile)
|
171
178
|
end
|
@@ -174,14 +181,14 @@ module Labimotion
|
|
174
181
|
def self.jcamp_converter(id)
|
175
182
|
resp = nil
|
176
183
|
begin
|
184
|
+
|
177
185
|
data = Labimotion::Converter.vor_conv(id)
|
178
186
|
return if data.nil?
|
179
187
|
|
180
|
-
|
181
|
-
resp&.success? ? Labimotion::ConState::PROCESSED : Labimotion::ConState::ERROR
|
188
|
+
Labimotion::Converter.process(data)
|
182
189
|
rescue StandardError => e
|
183
|
-
Labimotion::ConState::ERROR
|
184
190
|
Labimotion::Converter.logger.error ["jcamp_converter fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
|
191
|
+
Labimotion::ConState::ERROR
|
185
192
|
end
|
186
193
|
end
|
187
194
|
|
@@ -227,6 +234,8 @@ module Labimotion
|
|
227
234
|
new_prop = dataset.properties
|
228
235
|
dsr.each do |ds|
|
229
236
|
layer = layers[ds[:layer]]
|
237
|
+
next if layer.nil? || layer['fields'].nil?
|
238
|
+
|
230
239
|
fields = layer['fields'].select{ |f| f['field'] == ds[:field] }
|
231
240
|
fi = fields&.first
|
232
241
|
idx = layer['fields'].find_index(fi)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'export_table'
|
3
|
+
require 'labimotion/version'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
## ExportDataset
|
@@ -100,10 +101,19 @@ module Labimotion
|
|
100
101
|
cds = Container.find(id)
|
101
102
|
cds.attachments.where(aasm_state: 'csv').each do |att|
|
102
103
|
name = File.basename(att.filename, '.csv')
|
103
|
-
sheet = @xfile.workbook.add_worksheet(name: name)
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
sheet = @xfile.workbook.add_worksheet(name: name.slice(0, 25))
|
105
|
+
|
106
|
+
if Labimotion::IS_RAILS5 == true
|
107
|
+
File.open(att.store.path) do |fi|
|
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
|
107
117
|
end
|
108
118
|
end
|
109
119
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'labimotion/version'
|
3
4
|
require 'labimotion/utils/utils'
|
4
5
|
|
5
6
|
module Labimotion
|
@@ -7,8 +8,8 @@ module Labimotion
|
|
7
8
|
class NmrMapper
|
8
9
|
def self.is_brucker_binary(id)
|
9
10
|
att = Attachment.find(id)
|
10
|
-
if
|
11
|
-
Zip::File.open(att.
|
11
|
+
if Labimotion::IS_RAILS5 == true
|
12
|
+
Zip::File.open(att.store.path) do |zip_file|
|
12
13
|
zip_file.each do |entry|
|
13
14
|
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
14
15
|
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
@@ -16,6 +17,17 @@ module Labimotion
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
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
|
19
31
|
end
|
20
32
|
nil
|
21
33
|
end
|
@@ -1,18 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'labimotion/version'
|
2
3
|
require 'labimotion/utils/utils'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
class NmrMapperRepo
|
6
7
|
def self.is_brucker_binary(id)
|
7
8
|
att = Attachment.find(id)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if Labimotion::IS_RAILS5 == true
|
10
|
+
Zip::File.open(att.store.path) do |zip_file|
|
11
|
+
zip_file.each do |entry|
|
12
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
13
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
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
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
30
|
+
|
16
31
|
nil
|
17
32
|
end
|
18
33
|
|
@@ -43,11 +43,15 @@ module Labimotion
|
|
43
43
|
error!('Cannot connect to Chemotion Repository', 401)
|
44
44
|
end
|
45
45
|
|
46
|
-
def self.fetch_identifier(klass, identifier)
|
47
|
-
|
48
|
-
response = HTTParty.
|
46
|
+
def self.fetch_identifier(klass, identifier, origin)
|
47
|
+
body = { klass: klass, identifier: identifier, origin: origin }
|
48
|
+
response = HTTParty.post(
|
49
|
+
uri('fetch'),
|
50
|
+
body: body,
|
51
|
+
timeout: 10
|
52
|
+
)
|
49
53
|
# response.parsed_response if response.code == 200
|
50
|
-
JSON.parse(response.body) if response.code ==
|
54
|
+
JSON.parse(response.body) if response.code == 201
|
51
55
|
rescue StandardError => e
|
52
56
|
Labimotion.log_exception(e)
|
53
57
|
error!('Cannot connect to Chemotion Repository', 401)
|
@@ -23,7 +23,7 @@ module Labimotion
|
|
23
23
|
uuid = SecureRandom.uuid
|
24
24
|
props = args[:properties]
|
25
25
|
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
26
|
-
props['identifier'] = klass.identifier
|
26
|
+
props['identifier'] = klass.identifier if klass.identifier.present?
|
27
27
|
props['uuid'] = uuid
|
28
28
|
props['klass'] = 'Dataset'
|
29
29
|
|
@@ -41,14 +41,13 @@ module Labimotion
|
|
41
41
|
|
42
42
|
def save_segments(**args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
43
43
|
return if args[:segments].nil?
|
44
|
-
|
45
44
|
segments = []
|
46
|
-
args[:segments]
|
45
|
+
args[:segments]&.each do |seg|
|
47
46
|
klass = Labimotion::SegmentKlass.find_by(id: seg['segment_klass_id'])
|
48
47
|
uuid = SecureRandom.uuid
|
49
48
|
props = seg['properties']
|
50
49
|
props['pkg'] = Labimotion::Utils.pkg(props['pkg'])
|
51
|
-
props['identifier'] = identifier
|
50
|
+
props['identifier'] = klass.identifier if klass.identifier.present?
|
52
51
|
props['uuid'] = uuid
|
53
52
|
props['klass'] = 'Segment'
|
54
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'])
|
@@ -59,7 +58,7 @@ module Labimotion
|
|
59
58
|
next if segment.present?
|
60
59
|
|
61
60
|
props['klass_uuid'] = klass.uuid
|
62
|
-
segment = Labimotion::Segment.create!(properties_release: klass.properties_release, segment_klass_id: seg['segment_klass_id'], element_type:
|
61
|
+
segment = Labimotion::Segment.create!(properties_release: klass.properties_release, segment_klass_id: seg['segment_klass_id'], element_type: self.class.name, element_id: self.id, properties: props, created_by: args[:current_user_id], uuid: uuid, klass_uuid: klass.uuid)
|
63
62
|
segments.push(segment)
|
64
63
|
end
|
65
64
|
segments
|
@@ -23,5 +23,14 @@ module Labimotion
|
|
23
23
|
end
|
24
24
|
properties
|
25
25
|
end
|
26
|
+
|
27
|
+
def migrate_workflow
|
28
|
+
return if properties_template.nil? || properties_release.nil?
|
29
|
+
|
30
|
+
return if properties_template['flow'].nil? && properties_release['flow'].nil?
|
31
|
+
|
32
|
+
update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
|
33
|
+
update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
@@ -7,10 +7,12 @@ module Labimotion
|
|
7
7
|
class Element < ApplicationRecord
|
8
8
|
acts_as_paranoid
|
9
9
|
self.table_name = :elements
|
10
|
-
include PgSearch::
|
10
|
+
include PgSearch if Labimotion::IS_RAILS5 == true
|
11
|
+
include PgSearch::Model if Labimotion::IS_RAILS5 == false
|
11
12
|
include ElementUIStateScopes
|
12
13
|
include Collectable
|
13
14
|
## include AnalysisCodes
|
15
|
+
include ElementCodes
|
14
16
|
include Taggable
|
15
17
|
include Workflow
|
16
18
|
include Segmentable
|
@@ -57,7 +59,7 @@ module Labimotion
|
|
57
59
|
|
58
60
|
|
59
61
|
def attachments
|
60
|
-
Attachment.where(attachable_id: self.id, attachable_type:
|
62
|
+
Attachment.where(attachable_id: self.id, attachable_type: self.class.name)
|
61
63
|
end
|
62
64
|
|
63
65
|
def self.get_associated_samples(element_ids)
|
@@ -23,13 +23,5 @@ module Labimotion
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
-
def migrate_workflow
|
27
|
-
return if properties_template.nil? || properties_release.nil?
|
28
|
-
|
29
|
-
return if properties_template['flow'].nil? && properties_release['flow'].nil?
|
30
|
-
|
31
|
-
update_column(:properties_template, split_workflow(properties_template)) if properties_template['flow']
|
32
|
-
update_column(:properties_release, split_workflow(properties_release)) if properties_release['flow']
|
33
|
-
end
|
34
26
|
end
|
35
27
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'labimotion/models/concerns/generic_klass_revisions'
|
3
|
+
require 'labimotion/models/concerns/workflow'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
class SegmentKlass < ApplicationRecord
|
6
7
|
self.table_name = :segment_klasses
|
7
8
|
acts_as_paranoid
|
8
9
|
include GenericKlassRevisions
|
10
|
+
include Workflow
|
9
11
|
belongs_to :element_klass, class_name: 'Labimotion::ElementKlass'
|
10
12
|
has_many :segments, dependent: :destroy, class_name: 'Labimotion::Segment'
|
11
13
|
has_many :segment_klasses_revisions, dependent: :destroy, class_name: 'Labimotion::SegmentKlassesRevision'
|
@@ -22,6 +22,26 @@ module Labimotion
|
|
22
22
|
fetch_many.call(klasses, {'created_by' => 'User'})
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.fetch_elements(collection, segments, attachments, fetch_many, fetch_one, fetch_containers)
|
26
|
+
fetch_many.call(collection.elements, {
|
27
|
+
'element_klass_id' => 'Labimotion::ElementKlass',
|
28
|
+
'created_by' => 'User',
|
29
|
+
})
|
30
|
+
fetch_many.call(collection.collections_elements, {
|
31
|
+
'collection_id' => 'Collection',
|
32
|
+
'element_id' => 'Labimotion::Element',
|
33
|
+
})
|
34
|
+
collection.elements.each do |element|
|
35
|
+
|
36
|
+
element, attachments = Labimotion::Export.fetch_properties(element, attachments, &fetch_one)
|
37
|
+
fetch_containers.call(element)
|
38
|
+
segment, @attachments = Labimotion::Export.fetch_segments(element, attachments, &fetch_one)
|
39
|
+
segments += segment if segment.present?
|
40
|
+
end
|
41
|
+
|
42
|
+
[segments, attachments]
|
43
|
+
|
44
|
+
end
|
25
45
|
|
26
46
|
def self.fetch_segments(element, attachments, &fetch_one)
|
27
47
|
element_type = element.class.name
|
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: 0.
|
4
|
+
version: 0.3.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-
|
12
|
+
date: 2023-09-10 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: 5.2.0
|
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: 5.2.0
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- chia-lin.lin@kit.edu
|
@@ -84,6 +84,7 @@ 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
|
87
88
|
- lib/labimotion/models/segment.rb
|
88
89
|
- lib/labimotion/models/segment_klass.rb
|
89
90
|
- lib/labimotion/models/segment_klasses_revision.rb
|