labimotion 2.0.3 → 2.1.0.rc1
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/apis/generic_dataset_api.rb +20 -3
- data/lib/labimotion/apis/generic_element_api.rb +22 -2
- data/lib/labimotion/apis/generic_klass_api.rb +40 -1
- data/lib/labimotion/apis/labimotion_api.rb +1 -3
- data/lib/labimotion/apis/labimotion_hub_api.rb +10 -83
- data/lib/labimotion/apis/segment_api.rb +5 -3
- data/lib/labimotion/constants.rb +0 -7
- data/lib/labimotion/entities/application_entity.rb +7 -80
- data/lib/labimotion/entities/dataset_entity.rb +8 -3
- data/lib/labimotion/entities/dataset_klass_entity.rb +3 -2
- data/lib/labimotion/entities/element_entity.rb +1 -1
- data/lib/labimotion/entities/element_klass_entity.rb +2 -2
- data/lib/labimotion/entities/element_revision_entity.rb +1 -1
- data/lib/labimotion/entities/eln_element_entity.rb +2 -2
- data/lib/labimotion/entities/generic_klass_entity.rb +8 -9
- data/lib/labimotion/entities/generic_public_entity.rb +5 -3
- data/lib/labimotion/entities/klass_revision_entity.rb +9 -4
- data/lib/labimotion/entities/properties_entity.rb +1 -0
- data/lib/labimotion/entities/segment_entity.rb +5 -2
- data/lib/labimotion/entities/segment_revision_entity.rb +2 -2
- data/lib/labimotion/entities/vocabulary_entity.rb +2 -2
- data/lib/labimotion/helpers/dataset_helpers.rb +6 -4
- data/lib/labimotion/helpers/element_helpers.rb +6 -4
- data/lib/labimotion/helpers/segment_helpers.rb +2 -2
- data/lib/labimotion/libs/data/mapper/Chemwiki.json +2 -2
- data/lib/labimotion/libs/properties_handler.rb +10 -0
- data/lib/labimotion/libs/template_hub.rb +10 -28
- data/lib/labimotion/libs/vocabulary_handler.rb +8 -6
- data/lib/labimotion/models/concerns/datasetable.rb +3 -3
- data/lib/labimotion/models/concerns/generic_klass.rb +16 -0
- data/lib/labimotion/models/concerns/segmentable.rb +44 -7
- data/lib/labimotion/models/dataset_klass.rb +15 -2
- data/lib/labimotion/models/dataset_klasses_revision.rb +1 -4
- data/lib/labimotion/models/element.rb +7 -1
- data/lib/labimotion/models/element_klass.rb +10 -1
- data/lib/labimotion/models/element_klasses_revision.rb +2 -3
- data/lib/labimotion/models/segment_klass.rb +10 -4
- data/lib/labimotion/models/segment_klasses_revision.rb +1 -4
- data/lib/labimotion/version.rb +2 -2
- metadata +5 -7
- data/lib/labimotion/libs/data/layer/StdDataset.json +0 -212
- data/lib/labimotion/models/concerns/klass_revision.rb +0 -23
- data/lib/labimotion/models/template_submission.rb +0 -52
|
@@ -93,8 +93,8 @@ module Labimotion
|
|
|
93
93
|
all_coll = Collection.get_all_collection_for_user(current_user.id)
|
|
94
94
|
element.collections << all_coll
|
|
95
95
|
element.save!
|
|
96
|
-
|
|
97
|
-
element.properties = update_vocabularies(_properties, current_user, element)
|
|
96
|
+
element.properties = update_sample_association(params[:properties], current_user, element)
|
|
97
|
+
# element.properties = update_vocabularies(_properties, current_user, element)
|
|
98
98
|
element.container = update_datamodel(params[:container], current_user)
|
|
99
99
|
element.save!
|
|
100
100
|
update_element_labels(element, params[:user_labels], current_user.id)
|
|
@@ -129,11 +129,13 @@ module Labimotion
|
|
|
129
129
|
attributes['klass_uuid'] = properties['klass_uuid']
|
|
130
130
|
element.update_columns(attributes)
|
|
131
131
|
end
|
|
132
|
+
# element.save_segments(segments: params[:segments], current_user_id: current_user.id)
|
|
133
|
+
element.reload
|
|
132
134
|
element.save_segments(segments: params[:segments], current_user_id: current_user.id)
|
|
133
135
|
element.reload
|
|
134
|
-
element.properties = update_vocabularies(element.properties, current_user, element)
|
|
136
|
+
# element.properties = update_vocabularies(element.properties, current_user, element)
|
|
135
137
|
## element.user_for_revision = current_user
|
|
136
|
-
element.save!
|
|
138
|
+
# element.save!
|
|
137
139
|
element
|
|
138
140
|
rescue StandardError => e
|
|
139
141
|
Labimotion.log_exception(e, current_user)
|
|
@@ -8,8 +8,8 @@ module Labimotion
|
|
|
8
8
|
module SegmentHelpers
|
|
9
9
|
extend Grape::API::Helpers
|
|
10
10
|
|
|
11
|
-
def klass_list(el_klass, is_active=false)
|
|
12
|
-
scope = Labimotion::SegmentKlass.all
|
|
11
|
+
def klass_list(el_klass, is_active = false, displayed_in_list = false)
|
|
12
|
+
scope = displayed_in_list ? Labimotion::SegmentKlass.for_list_display : Labimotion::SegmentKlass.all
|
|
13
13
|
scope = scope.where(is_active: is_active) if is_active.present? && is_active == true
|
|
14
14
|
scope = scope.joins(:element_klass).where(klass_element: params[:element], is_active: true).preload(:element_klass) if el_klass.present?
|
|
15
15
|
scope.order('place') || []
|
|
@@ -91,5 +91,15 @@ module Labimotion
|
|
|
91
91
|
Labimotion.log_exception(e)
|
|
92
92
|
properties
|
|
93
93
|
end
|
|
94
|
+
|
|
95
|
+
# Update field with value
|
|
96
|
+
def self.update_field_value!(properties, layer_key, field_index, value)
|
|
97
|
+
properties[Labimotion::Prop::LAYERS][layer_key][Labimotion::Prop::FIELDS][field_index]['value'] = value
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Delete field key
|
|
101
|
+
def self.delete_field_key!(properties, layer_key, field_index, key)
|
|
102
|
+
properties[Labimotion::Prop::LAYERS][layer_key][Labimotion::Prop::FIELDS][field_index].delete(key)
|
|
103
|
+
end
|
|
94
104
|
end
|
|
95
105
|
end
|
|
@@ -5,6 +5,9 @@ require 'uri'
|
|
|
5
5
|
require 'json'
|
|
6
6
|
require 'date'
|
|
7
7
|
|
|
8
|
+
# rubocop: disable Metrics/AbcSize
|
|
9
|
+
# rubocop: disable Metrics/MethodLength
|
|
10
|
+
|
|
8
11
|
module Labimotion
|
|
9
12
|
## TemplateHub
|
|
10
13
|
class TemplateHub
|
|
@@ -15,11 +18,12 @@ module Labimotion
|
|
|
15
18
|
"#{url}api/v1/labimotion_hub/#{api_name}"
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
|
|
18
22
|
def self.header(opt = {})
|
|
19
23
|
opt || { timeout: 10, headers: { 'Content-Type' => 'text/json' } }
|
|
20
24
|
end
|
|
21
25
|
|
|
22
|
-
def self.handle_response(oat, response)
|
|
26
|
+
def self.handle_response(oat, response) # rubocop: disable Metrics/PerceivedComplexity
|
|
23
27
|
begin
|
|
24
28
|
response&.success? ? 'OK' : 'ERROR'
|
|
25
29
|
rescue StandardError => e
|
|
@@ -52,32 +56,10 @@ module Labimotion
|
|
|
52
56
|
Labimotion.log_exception(e)
|
|
53
57
|
error!('Cannot connect to Chemotion Repository', 401)
|
|
54
58
|
end
|
|
55
|
-
|
|
56
|
-
def self.send_to_central_hub(klass, template, metadata, origin)
|
|
57
|
-
body = {
|
|
58
|
-
template_klass: klass,
|
|
59
|
-
template: template,
|
|
60
|
-
metadata: metadata,
|
|
61
|
-
origin: origin
|
|
62
|
-
}
|
|
63
|
-
response = HTTParty.post(
|
|
64
|
-
Labimotion::TemplateHub.uri('template_submissions'),
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type' => 'application/json',
|
|
67
|
-
'X-Origin-URL' => origin
|
|
68
|
-
},
|
|
69
|
-
body: body.to_json,
|
|
70
|
-
timeout: 10
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
if [200, 201].include?(response.code)
|
|
74
|
-
parsed_response = JSON.parse(response.body)
|
|
75
|
-
return { mc: 'ss00', data: { id: parsed_response['id'] } }
|
|
76
|
-
end
|
|
77
|
-
{ mc: 'se00', msg: "HTTP #{response.code}: #{response.message}", data: {} }
|
|
78
|
-
rescue StandardError => e
|
|
79
|
-
Labimotion.log_exception(e)
|
|
80
|
-
{ mc: 'se00', msg: "Connection failure: #{e.message}", data: {} }
|
|
81
|
-
end
|
|
82
59
|
end
|
|
83
60
|
end
|
|
61
|
+
|
|
62
|
+
# rubocop: enable Metrics/AbcSize
|
|
63
|
+
# rubocop: enable Metrics/MethodLength
|
|
64
|
+
# rubocop: enable Metrics/ClassLength
|
|
65
|
+
# rubocop: enable Metrics/CyclomaticComplexity
|
|
@@ -4,8 +4,10 @@ module Labimotion
|
|
|
4
4
|
class VocabularyHandler
|
|
5
5
|
class << self
|
|
6
6
|
def update_vocabularies(properties, current_user, element)
|
|
7
|
+
return properties if properties.nil? || !properties.is_a?(Hash) || properties[Labimotion::Prop::LAYERS].nil?
|
|
8
|
+
|
|
7
9
|
properties[Labimotion::Prop::LAYERS].each do |key, layer|
|
|
8
|
-
update_layer_vocabularies(layer, key, properties, current_user, element)
|
|
10
|
+
update_layer_vocabularies!(layer, key, properties, current_user, element)
|
|
9
11
|
end
|
|
10
12
|
properties
|
|
11
13
|
rescue StandardError => e
|
|
@@ -23,12 +25,12 @@ module Labimotion
|
|
|
23
25
|
|
|
24
26
|
private
|
|
25
27
|
|
|
26
|
-
def update_layer_vocabularies(layer, key, properties, current_user, element)
|
|
28
|
+
def update_layer_vocabularies!(layer, key, properties, current_user, element)
|
|
27
29
|
field_vocabularies = layer[Labimotion::Prop::FIELDS].select { |field| field['is_voc'] }
|
|
28
30
|
field_vocabularies.each do |field|
|
|
29
31
|
idx = layer[Labimotion::Prop::FIELDS].index(field)
|
|
30
32
|
val = get_vocabulary_value(field, current_user, element)
|
|
31
|
-
update_field_value(properties, key, idx, val)
|
|
33
|
+
update_field_value!(properties, key, idx, val)
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
36
|
|
|
@@ -44,6 +46,7 @@ module Labimotion
|
|
|
44
46
|
get_segment_value(field, element)
|
|
45
47
|
when 'Dataset'
|
|
46
48
|
# TODO: Implement Dataset logic here
|
|
49
|
+
# TODO: Update datasetable.save_dataset
|
|
47
50
|
nil
|
|
48
51
|
end
|
|
49
52
|
end
|
|
@@ -91,9 +94,8 @@ module Labimotion
|
|
|
91
94
|
fields.find { |ss| ss['field'] == field['field_id'] }&.dig('value')
|
|
92
95
|
end
|
|
93
96
|
|
|
94
|
-
def update_field_value(properties, key, idx, val)
|
|
95
|
-
|
|
96
|
-
properties
|
|
97
|
+
def update_field_value!(properties, key, idx, val)
|
|
98
|
+
Labimotion::PropertiesHandler.update_field_value!(properties, key, idx, val)
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
def load_from_files
|
|
@@ -42,15 +42,15 @@ module Labimotion
|
|
|
42
42
|
props['identifier'] = klass.identifier if klass.identifier.present?
|
|
43
43
|
props['uuid'] = uuid
|
|
44
44
|
props['klass'] = 'Dataset'
|
|
45
|
+
props['klass_uuid'] = klass.uuid
|
|
45
46
|
props = Labimotion::VocabularyHandler.update_vocabularies(props, args[:current_user], args[:element])
|
|
46
47
|
|
|
47
48
|
ds = Labimotion::Dataset.find_by(element_type: self.class.name, element_id: id)
|
|
48
|
-
if ds.present? && (ds.klass_uuid !=
|
|
49
|
-
ds.update!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], properties: props, klass_uuid:
|
|
49
|
+
if ds.present? && (ds.klass_uuid != klass.uuid || ds.properties != props)
|
|
50
|
+
ds.update!(properties_release: klass.properties_release, uuid: uuid, dataset_klass_id: args[:dataset_klass_id], properties: props, klass_uuid: klass.uuid)
|
|
50
51
|
end
|
|
51
52
|
return if ds.present?
|
|
52
53
|
|
|
53
|
-
props['klass_uuid'] = klass.uuid
|
|
54
54
|
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)
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Labimotion
|
|
4
|
+
## Generic Klass Helpers
|
|
5
|
+
module GenericKlass
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
# Scope for active and released templates
|
|
10
|
+
scope :active_and_released, -> { for_list_display.where(is_active: true).where.not(released_at: nil) }
|
|
11
|
+
|
|
12
|
+
# Scope for active, released, and generic templates (primarily for ElementKlass)
|
|
13
|
+
scope :active_released_generic, -> { active_and_released.where(is_generic: true) }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -46,11 +46,17 @@ module Labimotion
|
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
def touch_vocabulary(current_user)
|
|
50
|
+
touch_element_properties(current_user) if instance_of?(::Labimotion::Element)
|
|
51
|
+
touch_segments_properties(current_user)
|
|
52
|
+
touch_analyses_properties(current_user)
|
|
53
|
+
end
|
|
54
|
+
|
|
49
55
|
def save_segments(**args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
50
|
-
|
|
56
|
+
args_segments = args[:segments] || []
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
current_user = User.find_by(id: args[:current_user_id])
|
|
59
|
+
args_segments.each do |seg|
|
|
54
60
|
klass = Labimotion::SegmentKlass.find_by(id: seg['segment_klass_id'])
|
|
55
61
|
uuid = SecureRandom.uuid
|
|
56
62
|
props = seg['properties']
|
|
@@ -59,21 +65,52 @@ module Labimotion
|
|
|
59
65
|
props['uuid'] = uuid
|
|
60
66
|
props['klass'] = 'Segment'
|
|
61
67
|
props = Labimotion::SampleAssociation.update_sample_association(props, args[:current_user_id])
|
|
62
|
-
|
|
63
|
-
props = Labimotion::VocabularyHandler.update_vocabularies(props, current_user, self)
|
|
68
|
+
# props = Labimotion::VocabularyHandler.update_vocabularies(props, current_user, self)
|
|
64
69
|
segment = Labimotion::Segment.where(element_type: self.class.name, element_id: self.id, segment_klass_id: seg['segment_klass_id']).order(id: :desc).first
|
|
65
70
|
if segment.present? && (segment.klass_uuid != props['klass_uuid'] || segment.properties != props)
|
|
66
71
|
segment.update!(properties_release: klass.properties_release, properties: props, uuid: uuid, klass_uuid: props['klass_uuid'])
|
|
67
|
-
segments.push(segment)
|
|
72
|
+
# segments.push(segment)
|
|
68
73
|
Labimotion::Segment.where(element_type: self.class.name, element_id: self.id, segment_klass_id: seg['segment_klass_id']).where.not(id: segment.id).destroy_all
|
|
69
74
|
end
|
|
70
75
|
next if segment.present?
|
|
71
76
|
|
|
72
77
|
props['klass_uuid'] = klass.uuid
|
|
73
78
|
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)
|
|
74
|
-
segments.push(segment)
|
|
79
|
+
# segments.push(segment)
|
|
75
80
|
end
|
|
81
|
+
|
|
82
|
+
self.reload
|
|
83
|
+
touch_vocabulary(current_user)
|
|
84
|
+
self.reload
|
|
76
85
|
segments
|
|
77
86
|
end
|
|
87
|
+
|
|
88
|
+
def touch_element_properties(current_user)
|
|
89
|
+
touch_properties_for_object(self, current_user)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def touch_segments_properties(current_user)
|
|
93
|
+
segments.each do |segment|
|
|
94
|
+
touch_properties_for_object(segment, current_user)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def touch_analyses_properties(current_user)
|
|
99
|
+
analyses.each do |analysis|
|
|
100
|
+
analysis.children.each do |child|
|
|
101
|
+
dataset = child.dataset
|
|
102
|
+
next if dataset.nil?
|
|
103
|
+
|
|
104
|
+
touch_properties_for_object(dataset, current_user)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# NOTE: Update bypassing validations, callbacks, and timestamp updates
|
|
110
|
+
def touch_properties_for_object(object, current_user)
|
|
111
|
+
props_dup = object.properties.deep_dup
|
|
112
|
+
Labimotion::VocabularyHandler.update_vocabularies(props_dup, current_user, self)
|
|
113
|
+
object.update_column(:properties, props_dup) if props_dup != object.properties
|
|
114
|
+
end
|
|
78
115
|
end
|
|
79
116
|
end
|
|
@@ -1,22 +1,35 @@
|
|
|
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
|
|
|
4
6
|
module Labimotion
|
|
5
7
|
class DatasetKlass < ApplicationRecord
|
|
6
8
|
acts_as_paranoid
|
|
7
9
|
self.table_name = :dataset_klasses
|
|
8
10
|
include GenericKlassRevisions
|
|
11
|
+
include GenericKlass
|
|
9
12
|
has_many :datasets, dependent: :destroy, class_name: 'Labimotion::Dataset'
|
|
10
13
|
has_many :dataset_klasses_revisions, dependent: :destroy, class_name: 'Labimotion::DatasetKlassesRevision'
|
|
11
14
|
|
|
15
|
+
# Scope for displayed_in_list - select only necessary columns for list view
|
|
16
|
+
scope :for_list_display, lambda {
|
|
17
|
+
select(:id, :uuid, :label, :desc, :is_active, :version, :place, :released_at,
|
|
18
|
+
:identifier, :sync_time, :created_at, :updated_at, :ols_term_id)
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
def self.init_seeds
|
|
13
|
-
|
|
22
|
+
gem_spec = Gem.loaded_specs['labimotion']
|
|
23
|
+
gem_root = gem_spec.gem_dir if gem_spec
|
|
24
|
+
seeds_path = File.join(gem_root, 'db', 'seeds', 'dataset_klasses.json')
|
|
14
25
|
seeds = JSON.parse(File.read(seeds_path))
|
|
15
26
|
|
|
16
27
|
seeds['chmo'].each do |term|
|
|
17
28
|
next if Labimotion::DatasetKlass.where(ols_term_id: term['id']).count.positive?
|
|
18
29
|
|
|
19
|
-
attributes = { ols_term_id: term['id'], label: "#{term['label']} (#{term['synonym']})",
|
|
30
|
+
attributes = { ols_term_id: term['id'], label: "#{term['label']} (#{term['synonym']})",
|
|
31
|
+
desc: "#{term['label']} (#{term['synonym']})", place: term['position'],
|
|
32
|
+
created_by: Admin.first&.id || 0 }
|
|
20
33
|
Labimotion::DatasetKlass.create!(attributes)
|
|
21
34
|
end
|
|
22
35
|
true
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'labimotion/models/concerns/klass_revision'
|
|
4
|
-
|
|
5
3
|
module Labimotion
|
|
6
4
|
class DatasetKlassesRevision < ApplicationRecord
|
|
7
5
|
self.table_name = :dataset_klasses_revisions
|
|
8
6
|
acts_as_paranoid
|
|
9
|
-
|
|
10
|
-
belongs_to :dataset_klass, class_name: 'Labimotion::DatasetKlass'
|
|
7
|
+
has_one :dataset_klass, class_name: 'Labimotion::DatasetKlass'
|
|
11
8
|
end
|
|
12
9
|
end
|
|
@@ -31,6 +31,7 @@ module Labimotion
|
|
|
31
31
|
|
|
32
32
|
belongs_to :element_klass, class_name: 'Labimotion::ElementKlass'
|
|
33
33
|
|
|
34
|
+
# has_ancestry ancestry_format: :materialized_path2
|
|
34
35
|
has_ancestry orphan_strategy: :adopt
|
|
35
36
|
|
|
36
37
|
has_many :collections_elements, inverse_of: :element, dependent: :destroy, class_name: 'Labimotion::CollectionsElement'
|
|
@@ -49,6 +50,7 @@ module Labimotion
|
|
|
49
50
|
scope :elements_updated_time_to, ->(time) { where('elements.updated_at <= ?', time) }
|
|
50
51
|
|
|
51
52
|
belongs_to :creator, foreign_key: :created_by, class_name: 'User'
|
|
53
|
+
before_validation :set_root_ancestry_if_nil
|
|
52
54
|
validates :creator, presence: true
|
|
53
55
|
|
|
54
56
|
has_many :elements_elements, foreign_key: :parent_id, class_name: 'Labimotion::ElementsElement'
|
|
@@ -71,7 +73,7 @@ module Labimotion
|
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
def analyses
|
|
74
|
-
container ? container.analyses :
|
|
76
|
+
container ? container.analyses : Container.none
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
def auto_set_short_label
|
|
@@ -148,5 +150,9 @@ module Labimotion
|
|
|
148
150
|
attachments.each(&:destroy!)
|
|
149
151
|
end
|
|
150
152
|
end
|
|
153
|
+
|
|
154
|
+
def set_root_ancestry_if_nil
|
|
155
|
+
self.ancestry ||= '/'
|
|
156
|
+
end
|
|
151
157
|
end
|
|
152
158
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'labimotion/conf'
|
|
3
4
|
require 'labimotion/models/concerns/generic_klass_revisions'
|
|
5
|
+
require 'labimotion/models/concerns/generic_klass'
|
|
4
6
|
require 'labimotion/models/concerns/workflow'
|
|
5
7
|
|
|
6
8
|
module Labimotion
|
|
@@ -8,11 +10,19 @@ module Labimotion
|
|
|
8
10
|
self.table_name = :element_klasses
|
|
9
11
|
acts_as_paranoid
|
|
10
12
|
include GenericKlassRevisions
|
|
13
|
+
include GenericKlass
|
|
11
14
|
include Workflow
|
|
12
15
|
has_many :elements, dependent: :destroy, class_name: 'Labimotion::Element'
|
|
13
16
|
has_many :segment_klasses, dependent: :destroy, class_name: 'Labimotion::SegmentKlass'
|
|
14
17
|
has_many :element_klasses_revisions, dependent: :destroy, class_name: 'Labimotion::ElementKlassesRevision'
|
|
15
18
|
|
|
19
|
+
# Scope for displayed_in_list - select only necessary columns for list view
|
|
20
|
+
scope :for_list_display, lambda {
|
|
21
|
+
select(:id, :uuid, :label, :desc, :is_active, :version, :place, :released_at,
|
|
22
|
+
:identifier, :sync_time, :created_at, :updated_at, :name, :icon_name,
|
|
23
|
+
:klass_prefix, :is_generic)
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
def self.gen_klasses_json
|
|
17
27
|
klasses = where(is_active: true, is_generic: true).order('place')&.pluck(:name) || []
|
|
18
28
|
rescue ActiveRecord::StatementInvalid, PG::ConnectionBad, PG::UndefinedTable
|
|
@@ -24,6 +34,5 @@ module Labimotion
|
|
|
24
34
|
klasses&.to_json || []
|
|
25
35
|
)
|
|
26
36
|
end
|
|
27
|
-
|
|
28
37
|
end
|
|
29
38
|
end
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'labimotion/models/concerns/workflow'
|
|
4
|
-
require 'labimotion/models/concerns/klass_revision'
|
|
5
4
|
|
|
6
5
|
module Labimotion
|
|
7
6
|
class ElementKlassesRevision < ApplicationRecord
|
|
8
7
|
acts_as_paranoid
|
|
9
8
|
self.table_name = :element_klasses_revisions
|
|
10
9
|
include Workflow
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
has_one :element_klass, class_name: 'Labimotion::ElementKlass'
|
|
11
|
+
|
|
13
12
|
|
|
14
13
|
def migrate_workflow
|
|
15
14
|
return if properties_release.nil? || properties_release['flow'].nil?
|
|
@@ -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,24 @@ 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
|
+
# Scope for displayed_in_list - select only necessary columns for list view
|
|
19
|
+
scope :for_list_display, lambda {
|
|
20
|
+
select(:id, :uuid, :label, :desc, :is_active, :version, :place, :released_at,
|
|
21
|
+
:identifier, :sync_time, :created_at, :updated_at, :element_klass_id)
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
def self.gen_klasses_json
|
|
16
25
|
klasses = where(is_active: true)&.pluck(:name) || []
|
|
17
26
|
rescue ActiveRecord::StatementInvalid, PG::ConnectionBad, PG::UndefinedTable
|
|
18
27
|
klasses = []
|
|
19
28
|
ensure
|
|
20
|
-
|
|
21
|
-
Rails.root.join('config', 'segment_klass.json'),
|
|
22
|
-
klasses&.to_json || []
|
|
23
|
-
)
|
|
29
|
+
Rails.root.join('config', 'segment_klass.json').write(klasses&.to_json || [])
|
|
24
30
|
end
|
|
25
31
|
end
|
|
26
32
|
end
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'labimotion/models/concerns/klass_revision'
|
|
4
|
-
|
|
5
3
|
module Labimotion
|
|
6
4
|
class SegmentKlassesRevision < ApplicationRecord
|
|
7
5
|
acts_as_paranoid
|
|
8
6
|
self.table_name = :segment_klasses_revisions
|
|
9
|
-
|
|
10
|
-
belongs_to :segment_klass, class_name: 'Labimotion::SegmentKlass'
|
|
7
|
+
has_one :segment_klass, class_name: 'Labimotion::SegmentKlass'
|
|
11
8
|
end
|
|
12
9
|
end
|
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: 2.0.
|
|
4
|
+
version: 2.1.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: 2025-
|
|
12
|
+
date: 2025-08-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -76,7 +76,6 @@ files:
|
|
|
76
76
|
- lib/labimotion/helpers/vocabulary_helpers.rb
|
|
77
77
|
- lib/labimotion/libs/attachment_handler.rb
|
|
78
78
|
- lib/labimotion/libs/converter.rb
|
|
79
|
-
- lib/labimotion/libs/data/layer/StdDataset.json
|
|
80
79
|
- lib/labimotion/libs/data/mapper/Chemwiki.json
|
|
81
80
|
- lib/labimotion/libs/data/mapper/Source.json
|
|
82
81
|
- lib/labimotion/libs/data/vocab/Standard.json
|
|
@@ -92,9 +91,9 @@ files:
|
|
|
92
91
|
- lib/labimotion/models/collections_element.rb
|
|
93
92
|
- lib/labimotion/models/concerns/attachment_converter.rb
|
|
94
93
|
- lib/labimotion/models/concerns/datasetable.rb
|
|
94
|
+
- lib/labimotion/models/concerns/generic_klass.rb
|
|
95
95
|
- lib/labimotion/models/concerns/generic_klass_revisions.rb
|
|
96
96
|
- lib/labimotion/models/concerns/generic_revisions.rb
|
|
97
|
-
- lib/labimotion/models/concerns/klass_revision.rb
|
|
98
97
|
- lib/labimotion/models/concerns/linked_properties.rb
|
|
99
98
|
- lib/labimotion/models/concerns/segmentable.rb
|
|
100
99
|
- lib/labimotion/models/concerns/workflow.rb
|
|
@@ -115,7 +114,6 @@ files:
|
|
|
115
114
|
- lib/labimotion/models/segments_revision.rb
|
|
116
115
|
- lib/labimotion/models/std_layer.rb
|
|
117
116
|
- lib/labimotion/models/std_layers_revision.rb
|
|
118
|
-
- lib/labimotion/models/template_submission.rb
|
|
119
117
|
- lib/labimotion/models/vocabulary.rb
|
|
120
118
|
- lib/labimotion/utils/con_state.rb
|
|
121
119
|
- lib/labimotion/utils/export_utils.rb
|
|
@@ -146,9 +144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
146
144
|
version: '0'
|
|
147
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
146
|
requirements:
|
|
149
|
-
- - "
|
|
147
|
+
- - ">"
|
|
150
148
|
- !ruby/object:Gem::Version
|
|
151
|
-
version:
|
|
149
|
+
version: 1.3.1
|
|
152
150
|
requirements: []
|
|
153
151
|
rubygems_version: 3.1.6
|
|
154
152
|
signing_key:
|