labimotion 2.0.0 → 2.1.0.rc11

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/labimotion/apis/exporter_api.rb +271 -0
  3. data/lib/labimotion/apis/generic_dataset_api.rb +37 -3
  4. data/lib/labimotion/apis/generic_element_api.rb +106 -4
  5. data/lib/labimotion/apis/generic_klass_api.rb +42 -2
  6. data/lib/labimotion/apis/labimotion_api.rb +1 -0
  7. data/lib/labimotion/apis/segment_api.rb +5 -3
  8. data/lib/labimotion/entities/application_entity.rb +7 -80
  9. data/lib/labimotion/entities/dataset_entity.rb +8 -3
  10. data/lib/labimotion/entities/dataset_klass_entity.rb +3 -2
  11. data/lib/labimotion/entities/element_entity.rb +1 -1
  12. data/lib/labimotion/entities/element_klass_entity.rb +2 -2
  13. data/lib/labimotion/entities/element_revision_entity.rb +3 -1
  14. data/lib/labimotion/entities/eln_element_entity.rb +4 -2
  15. data/lib/labimotion/entities/generic_klass_entity.rb +8 -9
  16. data/lib/labimotion/entities/generic_public_entity.rb +5 -3
  17. data/lib/labimotion/entities/klass_revision_entity.rb +2 -1
  18. data/lib/labimotion/entities/properties_entity.rb +5 -0
  19. data/lib/labimotion/entities/segment_entity.rb +5 -2
  20. data/lib/labimotion/entities/segment_revision_entity.rb +4 -2
  21. data/lib/labimotion/entities/vocabulary_entity.rb +2 -2
  22. data/lib/labimotion/helpers/converter_helpers.rb +16 -3
  23. data/lib/labimotion/helpers/dataset_helpers.rb +31 -6
  24. data/lib/labimotion/helpers/element_helpers.rb +7 -4
  25. data/lib/labimotion/helpers/exporter_helpers.rb +139 -0
  26. data/lib/labimotion/helpers/param_helpers.rb +6 -0
  27. data/lib/labimotion/helpers/segment_helpers.rb +2 -2
  28. data/lib/labimotion/libs/converter.rb +14 -0
  29. data/lib/labimotion/libs/data/layer/StdDataset.json +212 -0
  30. data/lib/labimotion/libs/data/mapper/Chemwiki.json +2 -2
  31. data/lib/labimotion/libs/dataset_builder.rb +2 -1
  32. data/lib/labimotion/libs/export_element.rb +11 -2
  33. data/lib/labimotion/libs/nmr_mapper.rb +13 -0
  34. data/lib/labimotion/libs/properties_handler.rb +12 -2
  35. data/lib/labimotion/libs/sample_association.rb +7 -4
  36. data/lib/labimotion/libs/template_matcher.rb +39 -0
  37. data/lib/labimotion/libs/vocabulary_handler.rb +8 -6
  38. data/lib/labimotion/libs/xlsx_exporter.rb +285 -0
  39. data/lib/labimotion/models/concerns/datasetable.rb +3 -3
  40. data/lib/labimotion/models/concerns/element_fetchable.rb +53 -0
  41. data/lib/labimotion/models/concerns/generic_klass.rb +16 -0
  42. data/lib/labimotion/models/concerns/segmentable.rb +44 -7
  43. data/lib/labimotion/models/dataset_klass.rb +30 -2
  44. data/lib/labimotion/models/device_description.rb +36 -0
  45. data/lib/labimotion/models/element.rb +37 -1
  46. data/lib/labimotion/models/element_klass.rb +12 -1
  47. data/lib/labimotion/models/reaction.rb +36 -0
  48. data/lib/labimotion/models/research_plan.rb +40 -0
  49. data/lib/labimotion/models/sample.rb +36 -0
  50. data/lib/labimotion/models/screen.rb +36 -0
  51. data/lib/labimotion/models/segment_klass.rb +12 -4
  52. data/lib/labimotion/models/wellplate.rb +40 -0
  53. data/lib/labimotion/utils/serializer.rb +2 -0
  54. data/lib/labimotion/utils/units.rb +609 -468
  55. data/lib/labimotion/utils/utils.rb +42 -0
  56. data/lib/labimotion/version.rb +1 -1
  57. data/lib/labimotion.rb +12 -0
  58. metadata +45 -8
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file extends the existing ResearchPlan model in the consuming app
4
+ # and defines a Labimotion::ResearchPlan wrapper for convenient access.
5
+
6
+ # rubocop:disable Style/RedundantConstantBase
7
+
8
+ ActiveSupport.on_load(:active_record) do
9
+ if defined?(::ResearchPlan)
10
+ ::ResearchPlan.class_eval do
11
+ include Labimotion::ElementFetchable
12
+
13
+ def self.element_klass_name
14
+ 'research_plan'
15
+ end
16
+ end
17
+ else
18
+ warn '[Labimotion] ResearchPlan is not defined when Labimotion extension was loaded.'
19
+ end
20
+ end
21
+
22
+ # Namespace wrapper to keep your preferred call style
23
+ module Labimotion
24
+ module ResearchPlan
25
+ # Delegate class methods to ::ResearchPlan
26
+ def self.method_missing(method, *args, &block)
27
+ if ::ResearchPlan.respond_to?(method)
28
+ ::ResearchPlan.public_send(method, *args, &block)
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ def self.respond_to_missing?(method, include_private = false)
35
+ ::ResearchPlan.respond_to?(method, include_private) || super
36
+ end
37
+ end
38
+ end
39
+
40
+ # rubocop:enable Style/RedundantConstantBase
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file extends the existing Sample model in the consuming app
4
+ # and defines a Labimotion::Sample wrapper for convenient access.
5
+
6
+ ActiveSupport.on_load(:active_record) do
7
+ if defined?(::Sample)
8
+ ::Sample.class_eval do
9
+ include Labimotion::ElementFetchable
10
+
11
+ def self.element_klass_name
12
+ 'sample'
13
+ end
14
+ end
15
+ else
16
+ warn "[Labimotion] Sample is not defined when Labimotion extension was loaded."
17
+ end
18
+ end
19
+
20
+ # Namespace wrapper to keep your preferred call style
21
+ module Labimotion
22
+ module Sample
23
+ # Delegate class methods to ::Sample
24
+ def self.method_missing(method, *args, &block)
25
+ if ::Sample.respond_to?(method)
26
+ ::Sample.public_send(method, *args, &block)
27
+ else
28
+ super
29
+ end
30
+ end
31
+
32
+ def self.respond_to_missing?(method, include_private = false)
33
+ ::Sample.respond_to?(method, include_private) || super
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file extends the existing Screen model in the consuming app
4
+ # and defines a Labimotion::Screen wrapper for convenient access.
5
+
6
+ ActiveSupport.on_load(:active_record) do
7
+ if defined?(::Screen)
8
+ ::Screen.class_eval do
9
+ include Labimotion::ElementFetchable
10
+
11
+ def self.element_klass_name
12
+ 'screen'
13
+ end
14
+ end
15
+ else
16
+ warn "[Labimotion] Screen is not defined when Labimotion extension was loaded."
17
+ end
18
+ end
19
+
20
+ # Namespace wrapper to keep your preferred call style
21
+ module Labimotion
22
+ module Screen
23
+ # Delegate class methods to ::Screen
24
+ def self.method_missing(method, *args, &block)
25
+ if ::Screen.respond_to?(method)
26
+ ::Screen.public_send(method, *args, &block)
27
+ else
28
+ super
29
+ end
30
+ end
31
+
32
+ def self.respond_to_missing?(method, include_private = false)
33
+ ::Screen.respond_to?(method, include_private) || super
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'labimotion/models/concerns/generic_klass_revisions'
4
+ require 'labimotion/models/concerns/generic_klass'
3
5
  require 'labimotion/models/concerns/workflow'
4
6
 
5
7
  module Labimotion
@@ -7,20 +9,26 @@ module Labimotion
7
9
  self.table_name = :segment_klasses
8
10
  acts_as_paranoid
9
11
  include GenericKlassRevisions
12
+ include GenericKlass
10
13
  include Workflow
11
14
  belongs_to :element_klass, class_name: 'Labimotion::ElementKlass'
12
15
  has_many :segments, dependent: :destroy, class_name: 'Labimotion::Segment'
13
16
  has_many :segment_klasses_revisions, dependent: :destroy, class_name: 'Labimotion::SegmentKlassesRevision'
14
17
 
18
+ validates :label, presence: true, uniqueness: { scope: :element_klass_id, conditions: -> { where(deleted_at: nil) }, message: 'is already in use.' }
19
+
20
+ # Scope for displayed_in_list - select only necessary columns for list view
21
+ scope :for_list_display, lambda {
22
+ select(:id, :uuid, :label, :desc, :is_active, :version, :place, :released_at,
23
+ :identifier, :sync_time, :created_at, :updated_at, :element_klass_id)
24
+ }
25
+
15
26
  def self.gen_klasses_json
16
27
  klasses = where(is_active: true)&.pluck(:name) || []
17
28
  rescue ActiveRecord::StatementInvalid, PG::ConnectionBad, PG::UndefinedTable
18
29
  klasses = []
19
30
  ensure
20
- File.write(
21
- Rails.root.join('config', 'segment_klass.json'),
22
- klasses&.to_json || []
23
- )
31
+ Rails.root.join('config', 'segment_klass.json').write(klasses&.to_json || [])
24
32
  end
25
33
  end
26
34
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file extends the existing Wellplate model in the consuming app
4
+ # and defines a Labimotion::Wellplate wrapper for convenient access.
5
+
6
+ # rubocop:disable Style/RedundantConstantBase
7
+
8
+ ActiveSupport.on_load(:active_record) do
9
+ if defined?(::Wellplate)
10
+ ::Wellplate.class_eval do
11
+ include Labimotion::ElementFetchable
12
+
13
+ def self.element_klass_name
14
+ 'wellplate'
15
+ end
16
+ end
17
+ else
18
+ warn '[Labimotion] Wellplate is not defined when Labimotion extension was loaded.'
19
+ end
20
+ end
21
+
22
+ # Namespace wrapper to keep your preferred call style
23
+ module Labimotion
24
+ module Wellplate
25
+ # Delegate class methods to ::Wellplate
26
+ def self.method_missing(method, *args, &block)
27
+ if ::Wellplate.respond_to?(method)
28
+ ::Wellplate.public_send(method, *args, &block)
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ def self.respond_to_missing?(method, include_private = false)
35
+ ::Wellplate.respond_to?(method, include_private) || super
36
+ end
37
+ end
38
+ end
39
+
40
+ # rubocop:enable Style/RedundantConstantBase
@@ -37,6 +37,8 @@ module Labimotion
37
37
  # layer = object.properties[key]
38
38
  field_sample_molecules = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| Labimotion::FieldType::DRAG_ALL.include?(ss['type']) }
39
39
  field_sample_molecules.each do |field|
40
+ next unless field['value'].is_a?(Hash)
41
+
40
42
  idx = object.properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
41
43
  sid = field.dig('value') != '' && field.dig('value', 'el_id')
42
44
  next unless sid.present?