labimotion 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83f0da3d6432a0ba7540d64776e8842517388dd310034ba47fa4009a0098aae1
4
- data.tar.gz: ebdb71841e25f430469989361183eed16bfba8d45574c1e1fbac3094d397a484
3
+ metadata.gz: 9d95cca4c3067ae72420caeba93fbaed69e9e948dfb8e673c395c3ae758b1419
4
+ data.tar.gz: 7c5a469509b6dc448cce12d278c107b913a84d5e9efae2d57585f0b33db12143
5
5
  SHA512:
6
- metadata.gz: d9f45db60f7d2d7c199658dbcda29b2b00b62184d16bbbb60a7318c4e04d52cd13fdf64f8944ac90851c5e584b7a8fe7c1469a019d09f0ae7a4e7b3240294167
7
- data.tar.gz: aeffedf19b1e83fbf15a6cecb634075a496e8f1700c5bed20c7624ccc9a05c8b58836e889e50ec5a1a609e13153bf88b7042f59ac24aaea00acffd6f218a4f54
6
+ metadata.gz: ac1b93bf0e741d492daf65110ae91ffa3ef793852ddb8d7fd4c3f6ba73cc93b125d1a8898d0f79c7bf4aa20dc584e30d14279a04d4cc1ce3af5c0e149b69be2b
7
+ data.tar.gz: 545fb7261afd1e503bb79e0eb0104512cd91545531461766b4efeac81a4a9a9d6d3949866be77966bff45e1f7cae0af4103aaeb722e025f5dbe830b01e977bbb
@@ -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
- present DatasetKlass.all, with: Labimotion::DatasetKlassEntity, root: 'klass'
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
- present ElementKlass.all, with: Labimotion::ElementKlassEntity, root: 'klass'
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'
@@ -283,6 +329,8 @@ module Labimotion
283
329
  attachments: Entities::AttachmentEntity.represent(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
 
@@ -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
- # entities.length > 1 ? de_encode_json(entities) : []
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
- # requires :fqdn, type: Integer, desc: 'FQDN'
32
+ requires :origin, type: String, desc: 'origin'
30
33
  requires :identifier, type: String, desc: 'Identifier'
31
34
  end
32
- get do
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
- # entities.length > 1 ? de_encode_json(entities) : []
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
- present SegmentKlass.all, with: Labimotion::SegmentKlassEntity, root: 'klass'
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
- if Labimotion::DatasetKlass.find_by(ols_term_id: attributes['ols_term_id']).present?
27
- ds = Labimotion::DatasetKlass.find_by(ols_term_id: attributes['ols_term_id'])
28
- ds.update!(attributes)
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 }
@@ -174,8 +174,7 @@ module Labimotion
174
174
  true
175
175
  rescue StandardError => e
176
176
  Labimotion.log_exception(e, current_user)
177
- ## false
178
- raise e
177
+ false
179
178
  end
180
179
 
181
180
  def element_revisions(params)
@@ -290,9 +289,9 @@ module Labimotion
290
289
  raise e
291
290
  end
292
291
 
293
- def create_repo_klass(params, current_user)
294
- response = Labimotion::TemplateHub.fetch_identifier('ElementKlass', params[:identifier])
295
- 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')
296
295
  attributes['properties_release']['identifier'] = attributes['identifier']
297
296
  attributes['properties_template'] = attributes['properties_release']
298
297
  attributes['place'] = ((Labimotion::DatasetKlass.all.length * 10) || 0) + 10
@@ -303,12 +302,24 @@ module Labimotion
303
302
 
304
303
  element_klass = Labimotion::ElementKlass.find_by(identifier: attributes['identifier'])
305
304
  if element_klass.present?
306
- element_klass.update!(attributes)
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
307
312
  else
308
- attributes['created_by'] = current_user.id
309
- element_klass = Labimotion::ElementKlass.create!(attributes)
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
310
322
  end
311
- element_klass.create_klasses_revision(current_user)
312
323
  rescue StandardError => e
313
324
  Labimotion.log_exception(e, current_user)
314
325
  # { error: e.message }
@@ -230,15 +230,16 @@ module Labimotion
230
230
  Chemotion::Generic::Fetch::Template.list(API::TARGET, name)
231
231
  end
232
232
 
233
- def fetch_repo(name)
234
- 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) || []
235
235
  response = Labimotion::TemplateHub.list(name)
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 || []
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']) || []
242
243
  rescue StandardError => e
243
244
  Labimotion.log_exception(e, current_user)
244
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: 'ElementKlass not found' } if element_klass.nil?
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.update!(attributes)
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['created_by'] = current_user.id
91
- segment_klass = Labimotion::SegmentKlass.create!(attributes)
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
@@ -144,8 +144,7 @@ module Labimotion
144
144
  end
145
145
 
146
146
  def self.process(data)
147
- return if data[:a]&.attachable_type != 'Container'
148
-
147
+ return data[:a].con_state if data[:a]&.attachable_type != 'Container'
149
148
  response = nil
150
149
  begin
151
150
  ofile = Rails.root.join(data[:f], data[:a].filename)
@@ -166,12 +165,14 @@ module Labimotion
166
165
  end
167
166
  if response.ok?
168
167
  Labimotion::Converter.handle_response(data[:a], response)
168
+ Labimotion::ConState::PROCESSED
169
169
  else
170
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
171
172
  end
172
- response
173
173
  rescue StandardError => e
174
- raise e
174
+ Labimotion::Converter.logger.error ["process fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
175
+ Labimotion::ConState::ERROR
175
176
  ensure
176
177
  FileUtils.rm_f(ofile)
177
178
  end
@@ -180,14 +181,14 @@ module Labimotion
180
181
  def self.jcamp_converter(id)
181
182
  resp = nil
182
183
  begin
184
+
183
185
  data = Labimotion::Converter.vor_conv(id)
184
186
  return if data.nil?
185
187
 
186
- resp = Labimotion::Converter.process(data)
187
- resp&.success? ? Labimotion::ConState::PROCESSED : Labimotion::ConState::ERROR
188
+ Labimotion::Converter.process(data)
188
189
  rescue StandardError => e
189
- Labimotion::ConState::ERROR
190
190
  Labimotion::Converter.logger.error ["jcamp_converter fail: #{id}", e.message, *e.backtrace].join($INPUT_RECORD_SEPARATOR)
191
+ Labimotion::ConState::ERROR
191
192
  end
192
193
  end
193
194
 
@@ -233,6 +234,8 @@ module Labimotion
233
234
  new_prop = dataset.properties
234
235
  dsr.each do |ds|
235
236
  layer = layers[ds[:layer]]
237
+ next if layer.nil? || layer['fields'].nil?
238
+
236
239
  fields = layer['fields'].select{ |f| f['field'] == ds[:field] }
237
240
  fi = fields&.first
238
241
  idx = layer['fields'].find_index(fi)
@@ -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
- # body = { klass: klass, identifier: identifier }
48
- response = HTTParty.get("#{uri('fetch')}?klass=#{klass}&identifier=#{identifier}", timeout: 10)
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 == 200
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)
@@ -36,6 +36,7 @@ module Labimotion
36
36
  when Labimotion::ConState::WAIT
37
37
  self.con_state = Labimotion::Converter.jcamp_converter(id)
38
38
  end
39
+ update_column(:con_state, con_state)
39
40
  end
40
41
  end
41
42
  end
@@ -7,7 +7,8 @@ module Labimotion
7
7
  class Element < ApplicationRecord
8
8
  acts_as_paranoid
9
9
  self.table_name = :elements
10
- include PgSearch::Model
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
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Labimotion
4
+ class HubLog < ApplicationRecord
5
+ self.table_name = :hub_logs
6
+ belongs_to :klass, polymorphic: true, optional: true
7
+ end
8
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Labimotion
4
- # VERSION = '0.1.4'
5
- VERSION = '1.0.1'
6
4
  IS_RAILS5 = false
5
+ VERSION = '0.1.14' if Labimotion::IS_RAILS5 == true
6
+ VERSION = '1.0.2' if Labimotion::IS_RAILS5 == false
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labimotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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-24 00:00:00.000000000 Z
12
+ date: 2023-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -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