labimotion 1.3.1.1 → 1.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45876f170c9ebeb8292483cd8d6de0c56f5b341b22ce861a3994c93a6344e665
4
- data.tar.gz: ac171314ea6ce8b2c9c04bf03b3f84eddf84c10508381bf088d658a5a511c11e
3
+ metadata.gz: 04e8244e35f9f07197148e331748e527451dae61be8352729f04b9e7be923e6f
4
+ data.tar.gz: 334b4f9d71132b30884e522a38cc11e770048d20d8ff4e34bc0f60ddaf45d3df
5
5
  SHA512:
6
- metadata.gz: caab23ae23ce25b9b4472b23f58ee7b86e3f4fc9813ceac5a9dda0810c053f1fdc1f2f7ada3f294c826091246b167646085301a336c34cb9f72e70f9a3fc854e
7
- data.tar.gz: 60befb364746e5f8a0ea6ea89fe7713857f61ca20c013b51eb744fb0c9152ef315e83546ccb5a61ec9e33f989be473d16869eec582628651a86e49f0a13489b6
6
+ metadata.gz: faf260b294017c7b504aa9eef458736d1076cd5f7198ba15b073f593bc5649d7c6bf892bf9deb3be449ee51ffb3b44b4936719eb1134353fdf9a4535f1d1f9ad
7
+ data.tar.gz: 5ca488c82012a85bdf51b37c2210ce0a9171935b387a1e6cd31ac8008398be89539c43d1c5f42825834aa013f65b5ae31de14e25d745c505fc361f5e66b5e314
@@ -10,6 +10,7 @@ module Labimotion
10
10
  helpers ContainerHelpers
11
11
  helpers ParamsHelpers
12
12
  helpers CollectionHelpers
13
+ helpers UserLabelHelpers
13
14
  helpers Labimotion::SampleAssociationHelpers
14
15
  helpers Labimotion::GenericHelpers
15
16
  helpers Labimotion::ElementHelpers
@@ -327,7 +328,7 @@ module Labimotion
327
328
  Labimotion.log_exception(e, current_user)
328
329
  { error: e.message }
329
330
  end
330
- end
331
+ end
331
332
 
332
333
  desc 'Return serialized elements of current user'
333
334
  params do
@@ -336,6 +337,7 @@ module Labimotion
336
337
  optional :el_type, type: String, desc: 'element klass name'
337
338
  optional :from_date, type: Integer, desc: 'created_date from in ms'
338
339
  optional :to_date, type: Integer, desc: 'created_date to in ms'
340
+ optional :user_label, type: Integer, desc: 'user label'
339
341
  optional :filter_created_at, type: Boolean, desc: 'filter by created at or updated at'
340
342
  optional :sort_column, type: String, desc: 'sort by updated_at or selected layers property'
341
343
  end
@@ -426,7 +428,7 @@ module Labimotion
426
428
  raise e
427
429
  end
428
430
  end
429
- end
431
+ end
430
432
  end
431
433
  end
432
434
  end
@@ -95,6 +95,7 @@ module Labimotion
95
95
  element.properties = update_sample_association(params[:properties], current_user, element)
96
96
  element.container = update_datamodel(params[:container], current_user)
97
97
  element.save!
98
+ update_element_labels(element, params[:user_labels], current_user.id)
98
99
  element.save_segments(segments: params[:segments], current_user_id: current_user.id)
99
100
  element
100
101
  rescue StandardError => e
@@ -108,6 +109,9 @@ module Labimotion
108
109
  properties = update_sample_association(params[:properties], current_user, element)
109
110
  params.delete(:container)
110
111
  params.delete(:properties)
112
+ update_element_labels(element, params[:user_labels], current_user.id)
113
+ params.delete(:user_labels)
114
+
111
115
  attributes = declared(params.except(:segments), include_missing: false)
112
116
  properties['pkg'] = Labimotion::Utils.pkg(properties['pkg'])
113
117
  if element.klass_uuid != properties['klass_uuid'] || element.properties != properties || element.name != params[:name]
@@ -288,6 +292,7 @@ module Labimotion
288
292
  scope = scope.elements_created_time_to(Time.at(to) + 1.day) if to && by_created_at
289
293
  scope = scope.elements_updated_time_from(Time.at(from)) if from && !by_created_at
290
294
  scope = scope.elements_updated_time_to(Time.at(to) + 1.day) if to && !by_created_at
295
+ scope = scope.by_user_label(params[:user_label]) if params[:user_label]
291
296
  scope
292
297
  rescue StandardError => e
293
298
  Labimotion.log_exception(e, current_user)
@@ -315,7 +320,7 @@ module Labimotion
315
320
  return { status: 'success', message: "The element: #{attributes['name']} has been created using version: #{attributes['version']}!" }
316
321
  end
317
322
  end
318
-
323
+
319
324
  rescue StandardError => e
320
325
  Labimotion.log_exception(e, current_user)
321
326
  return { status: 'error', message: e.message }
@@ -22,7 +22,7 @@ module Labimotion
22
22
  optional :sync_time, type: DateTime, desc: 'Klass sync_time'
23
23
  optional :version, type: String, desc: 'Klass version'
24
24
  end
25
-
25
+
26
26
  params :create_element_klass_params do
27
27
  requires :name, type: String, desc: 'Element Klass Name'
28
28
  requires :label, type: String, desc: 'Element Klass Label'
@@ -40,7 +40,7 @@ module Labimotion
40
40
  optional :desc, type: String, desc: 'Element Klass Desc'
41
41
  optional :place, type: String, desc: 'Element Klass Place'
42
42
  end
43
-
43
+
44
44
  ## Element Params
45
45
  params :create_element_params do
46
46
  requires :element_klass, type: Hash
@@ -49,18 +49,20 @@ module Labimotion
49
49
  optional :properties_release, type: Hash
50
50
  optional :collection_id, type: Integer
51
51
  requires :container, type: Hash
52
+ optional :user_labels, type: Array
52
53
  optional :segments, type: Array, desc: 'Segments'
53
54
  end
54
-
55
+
55
56
  params :update_element_params do
56
57
  requires :id, type: Integer, desc: 'element id'
57
58
  optional :name, type: String
58
59
  requires :properties, type: Hash
59
60
  optional :properties_release, type: Hash
60
61
  requires :container, type: Hash
62
+ optional :user_labels, type: Array
61
63
  optional :segments, type: Array, desc: 'Segments'
62
64
  end
63
-
65
+
64
66
  ## Segment Klass Params
65
67
  params :upload_segment_klass_params do
66
68
  requires :label, type: String, desc: 'Klass label'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'labimotion/version'
3
+
4
+ module Labimotion
5
+ ## ExportDataset
6
+ class AttachmentHandler
7
+ def self.copy(original_attach, element_id, element_type, current_user_id)
8
+ copy_attach = Attachment.new(
9
+ attachable_id: element_id,
10
+ attachable_type: element_type,
11
+ aasm_state: original_attach.aasm_state,
12
+ created_by: current_user_id,
13
+ created_for: current_user_id,
14
+ filename: original_attach.filename,
15
+ )
16
+ copy_attach.save
17
+
18
+ copy_io = original_attach.attachment_attacher.get.to_io
19
+ attacher = copy_attach.attachment_attacher
20
+ attacher.attach copy_io
21
+ copy_attach.file_path = copy_io.path
22
+ copy_attach.save
23
+
24
+ Usecases::Attachments::Copy.update_annotation(original_attach.id, copy_attach.id) if (original_attach.attachment_data && original_attach.attachment_data['derivatives'])
25
+ copy_attach
26
+ end
27
+
28
+ end
29
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'labimotion/utils/utils'
4
+ require 'labimotion/libs/attachment_handler'
4
5
 
5
6
  module Labimotion
6
7
  # Segmentable concern
@@ -29,7 +30,8 @@ module Labimotion
29
30
 
30
31
  att = Attachment.find_by(id: aid)
31
32
  att = Attachment.find_by(identifier: uid) if att.nil?
32
- copied_att = att&.copy(attachable_type: Labimotion::Prop::SEGMENTPROPS, attachable_id: segment.id, transferred: true)
33
+ copied_att = Labimotion::AttachmentHandler.copy(att, segment.id, Labimotion::Prop::SEGMENTPROPS, args[:current_user_id])
34
+
33
35
  if copied_att.nil?
34
36
  properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['files'].delete_at(fdx)
35
37
  else
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '1.3.1.1'
5
+ VERSION = '1.4.0.rc1'
6
6
  end
data/lib/labimotion.rb CHANGED
@@ -62,6 +62,7 @@ module Labimotion
62
62
  autoload :ExportDataset, 'labimotion/libs/export_dataset'
63
63
  autoload :SampleAssociation, 'labimotion/libs/sample_association'
64
64
  autoload :PropertiesHandler, 'labimotion/libs/properties_handler'
65
+ autoload :AttachmentHandler, 'labimotion/libs/attachment_handler'
65
66
 
66
67
  ######## Utils
67
68
  autoload :Prop, 'labimotion/utils/prop'
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.3.1.1
4
+ version: 1.4.0.rc1
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: 2024-05-07 00:00:00.000000000 Z
12
+ date: 2024-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - lib/labimotion/helpers/sample_association_helpers.rb
67
67
  - lib/labimotion/helpers/search_helpers.rb
68
68
  - lib/labimotion/helpers/segment_helpers.rb
69
+ - lib/labimotion/libs/attachment_handler.rb
69
70
  - lib/labimotion/libs/converter.rb
70
71
  - lib/labimotion/libs/export_dataset.rb
71
72
  - lib/labimotion/libs/export_element.rb
@@ -121,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
122
  version: '0'
122
123
  required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  requirements:
124
- - - ">="
125
+ - - ">"
125
126
  - !ruby/object:Gem::Version
126
- version: '0'
127
+ version: 1.3.1
127
128
  requirements: []
128
129
  rubygems_version: 3.1.6
129
130
  signing_key: