labimotion 1.5.0.rc9 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labimotion/entities/properties_entity.rb +2 -3
- data/lib/labimotion/helpers/element_helpers.rb +3 -3
- data/lib/labimotion/helpers/segment_helpers.rb +1 -1
- data/lib/labimotion/libs/data/vocab/Standard.json +5 -5
- data/lib/labimotion/libs/data/vocab/System.json +13 -13
- data/lib/labimotion/libs/sample_association.rb +4 -0
- data/lib/labimotion/libs/vocabulary_handler.rb +18 -12
- data/lib/labimotion/models/std_layer.rb +2 -2
- data/lib/labimotion/models/std_layers_revision.rb +2 -2
- data/lib/labimotion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ba4a246b95d088b7928826074a223b671bd3ff8ac7c4bce5904ff983aec1534
|
4
|
+
data.tar.gz: c1393205315928947b688566db60ac311eef1fcfccedbb395e521a2dbdfdfbdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf716f60ca698f40f332b318d55747266d23ffa0c066f2afb5eff44f90c54db1402d8b42e251641fa1564aff167c79abe86411c519653c59ffbca36991a85fd
|
7
|
+
data.tar.gz: 4dbeae09a3740df12533e217e11d4fbc003894280ccc9d6f46e2042cf4b0ff4b2ce448215a9d918e38b077458caba39e26c55a31870b9e9e7f753f8d25bfc41b
|
@@ -21,7 +21,7 @@ module Labimotion
|
|
21
21
|
process_sample_and_molecule_fields(key, layer)
|
22
22
|
process_reaction_fields(key, layer)
|
23
23
|
process_table_fields(key, layer)
|
24
|
-
process_voc_fields(key, layer)
|
24
|
+
# process_voc_fields(key, layer)
|
25
25
|
end
|
26
26
|
|
27
27
|
def process_sample_and_molecule_fields(key, layer)
|
@@ -52,7 +52,7 @@ module Labimotion
|
|
52
52
|
fields = layer[Labimotion::Prop::FIELDS]
|
53
53
|
fields = fields.select { |f| types.include?(f['type']) } if types
|
54
54
|
fields = fields.select { |f| f['is_voc'] == true } if is_voc
|
55
|
-
fields.map { |f| [f,
|
55
|
+
fields.map { |f| [f, layer[Labimotion::Prop::FIELDS].index(f)] }
|
56
56
|
end
|
57
57
|
|
58
58
|
def update_sample_or_molecule_field(key, field, idx)
|
@@ -100,7 +100,6 @@ module Labimotion
|
|
100
100
|
|
101
101
|
def update_voc_field(key, field, idx)
|
102
102
|
root_element = get_root_element
|
103
|
-
|
104
103
|
case field['source']
|
105
104
|
when Labimotion::Prop::ELEMENT
|
106
105
|
update_element_voc_field(key, field, idx, root_element)
|
@@ -113,7 +113,6 @@ module Labimotion
|
|
113
113
|
params.delete(:properties)
|
114
114
|
update_element_labels(element, params[:user_labels], current_user.id)
|
115
115
|
params.delete(:user_labels)
|
116
|
-
|
117
116
|
attributes = declared(params.except(:segments), include_missing: false)
|
118
117
|
properties['pkg'] = Labimotion::Utils.pkg(properties['pkg'])
|
119
118
|
if element.klass_uuid != properties['klass_uuid'] || element.properties != properties || element.name != params[:name]
|
@@ -124,15 +123,16 @@ module Labimotion
|
|
124
123
|
properties.delete('flow') unless properties['flow'].nil?
|
125
124
|
properties.delete('flowObject') unless properties['flowObject'].nil?
|
126
125
|
properties.delete('select_options') unless properties['select_options'].nil?
|
127
|
-
|
128
126
|
attributes['properties'] = properties
|
129
127
|
attributes['properties']['uuid'] = uuid
|
130
128
|
attributes['uuid'] = uuid
|
131
129
|
attributes['klass_uuid'] = properties['klass_uuid']
|
132
|
-
|
133
130
|
element.update(attributes)
|
134
131
|
end
|
135
132
|
element.save_segments(segments: params[:segments], current_user_id: current_user.id)
|
133
|
+
element.reload
|
134
|
+
element.properties = update_vocabularies(element.properties, current_user, element)
|
135
|
+
element.save!
|
136
136
|
element
|
137
137
|
rescue StandardError => e
|
138
138
|
Labimotion.log_exception(e, current_user)
|
@@ -72,7 +72,7 @@ module Labimotion
|
|
72
72
|
# el_attributes['properties_template'] = response['element_klass']['properties_release']
|
73
73
|
# Labimotion::ElementKlass.create!(el_attributes)
|
74
74
|
attributes['element_klass_id'] = element_klass.id
|
75
|
-
segment_klass = Labimotion::SegmentKlass.find_by(identifier: attributes['identifier'])
|
75
|
+
segment_klass = Labimotion::SegmentKlass.find_by(identifier: attributes['identifier']) if attributes['identifier'].present?
|
76
76
|
if segment_klass.present?
|
77
77
|
if segment_klass['uuid'] == attributes['uuid'] && segment_klass['version'] == attributes['version']
|
78
78
|
return { status: 'success', message: "This segment: #{attributes['label']} has the latest version!" }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[
|
2
2
|
{
|
3
|
-
"identifier": "atmosphere",
|
3
|
+
"identifier": "std-atmosphere",
|
4
4
|
"name": "atmosphere",
|
5
5
|
"label": "Atmosphere",
|
6
6
|
"field_type": "text",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"source": "Standard"
|
21
21
|
},
|
22
22
|
{
|
23
|
-
"identifier": "calibration",
|
23
|
+
"identifier": "std-calibration",
|
24
24
|
"name": "calibration",
|
25
25
|
"label": "Calibration",
|
26
26
|
"field_type": "text",
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"source": "Standard"
|
41
41
|
},
|
42
42
|
{
|
43
|
-
"identifier": "coating",
|
43
|
+
"identifier": "std-coating",
|
44
44
|
"name": "coating",
|
45
45
|
"label": "Coating",
|
46
46
|
"field_type": "text",
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"source": "Standard"
|
61
61
|
},
|
62
62
|
{
|
63
|
-
"identifier": "coating_material",
|
63
|
+
"identifier": "std-coating_material",
|
64
64
|
"name": "coating_material",
|
65
65
|
"label": "Coating Material",
|
66
66
|
"field_type": "text",
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"source": "Standard"
|
81
81
|
},
|
82
82
|
{
|
83
|
-
"identifier": "wavelength",
|
83
|
+
"identifier": "std-wavelength",
|
84
84
|
"name": "wavelength",
|
85
85
|
"label": "Wavelength",
|
86
86
|
"field_type": "text",
|
@@ -1,8 +1,8 @@
|
|
1
1
|
[
|
2
2
|
{
|
3
3
|
"id": 1,
|
4
|
-
"identifier": "dateTime
|
5
|
-
"name": "
|
4
|
+
"identifier": "dateTime-create",
|
5
|
+
"name": "create_time",
|
6
6
|
"label": "Create Time",
|
7
7
|
"field_type": "datetime",
|
8
8
|
"opid": 9,
|
@@ -27,8 +27,8 @@
|
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"id": 2,
|
30
|
-
"identifier": "dateTime
|
31
|
-
"name": "
|
30
|
+
"identifier": "dateTime-update",
|
31
|
+
"name": "update_time",
|
32
32
|
"label": "Update Time",
|
33
33
|
"field_type": "datetime",
|
34
34
|
"opid": 9,
|
@@ -53,7 +53,7 @@
|
|
53
53
|
},
|
54
54
|
{
|
55
55
|
"id": 4,
|
56
|
-
"identifier": "user
|
56
|
+
"identifier": "user-name",
|
57
57
|
"name": "creator",
|
58
58
|
"label": "creator",
|
59
59
|
"field_type": "text",
|
@@ -79,8 +79,8 @@
|
|
79
79
|
},
|
80
80
|
{
|
81
81
|
"id": 2,
|
82
|
-
"identifier": "element
|
83
|
-
"name": "
|
82
|
+
"identifier": "element-id",
|
83
|
+
"name": "element_id",
|
84
84
|
"label": "Element Id",
|
85
85
|
"field_type": "text",
|
86
86
|
"opid": 9,
|
@@ -92,8 +92,8 @@
|
|
92
92
|
},
|
93
93
|
{
|
94
94
|
"id": 5,
|
95
|
-
"identifier": "element
|
96
|
-
"name": "
|
95
|
+
"identifier": "element-name",
|
96
|
+
"name": "element_name",
|
97
97
|
"label": "Element Name",
|
98
98
|
"field_type": "text",
|
99
99
|
"opid": 8,
|
@@ -105,8 +105,8 @@
|
|
105
105
|
},
|
106
106
|
{
|
107
107
|
"id": 3,
|
108
|
-
"identifier": "element
|
109
|
-
"name": "
|
108
|
+
"identifier": "element-short_label",
|
109
|
+
"name": "element_short_label",
|
110
110
|
"label": "Element Short Label",
|
111
111
|
"field_type": "text",
|
112
112
|
"opid": 9,
|
@@ -118,8 +118,8 @@
|
|
118
118
|
},
|
119
119
|
{
|
120
120
|
"id": 3,
|
121
|
-
"identifier": "element
|
122
|
-
"name": "
|
121
|
+
"identifier": "element-class",
|
122
|
+
"name": "element_class",
|
123
123
|
"label": "Element Class",
|
124
124
|
"field_type": "text",
|
125
125
|
"opid": 9,
|
@@ -78,6 +78,8 @@ module Labimotion
|
|
78
78
|
field_samples = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_SAMPLE }
|
79
79
|
field_samples.each do |field|
|
80
80
|
idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
81
|
+
return if field.is_a?(String) || properties.is_a?(String)
|
82
|
+
|
81
83
|
sid = field.dig('value', 'el_id')
|
82
84
|
next if sid.blank?
|
83
85
|
|
@@ -100,6 +102,8 @@ module Labimotion
|
|
100
102
|
field_elements = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::DRAG_ELEMENT }
|
101
103
|
field_elements.each do |field|
|
102
104
|
idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
|
105
|
+
next if field['value'].is_a?(String)
|
106
|
+
|
103
107
|
sid = field.dig('value', 'el_id')
|
104
108
|
next if element.nil? || sid.blank? || sid == element.id
|
105
109
|
|
@@ -24,7 +24,7 @@ module Labimotion
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def update_layer_vocabularies(layer, key, properties, current_user, element)
|
27
|
-
field_vocabularies = layer[Labimotion::Prop::FIELDS].select { |field| field['is_voc']
|
27
|
+
field_vocabularies = layer[Labimotion::Prop::FIELDS].select { |field| field['is_voc'] }
|
28
28
|
field_vocabularies.each do |field|
|
29
29
|
idx = layer[Labimotion::Prop::FIELDS].index(field)
|
30
30
|
val = get_vocabulary_value(field, current_user, element)
|
@@ -51,29 +51,34 @@ module Labimotion
|
|
51
51
|
def get_system_value(field)
|
52
52
|
current_time = Time.now.strftime('%d/%m/%Y %H:%M')
|
53
53
|
case field['identifier']
|
54
|
-
when 'dateTime
|
54
|
+
when 'dateTime-update'
|
55
55
|
current_time
|
56
|
-
when 'dateTime
|
56
|
+
when 'dateTime-create'
|
57
57
|
current_time if field['value'].blank?
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
def get_user_value(field, current_user)
|
62
|
-
|
62
|
+
current_user.name if field['identifier'] == 'user-name' && current_user.present?
|
63
63
|
end
|
64
64
|
|
65
65
|
def get_element_value(field, element)
|
66
66
|
case field['identifier']
|
67
|
-
when 'element
|
67
|
+
when 'element-id'
|
68
68
|
element.id.to_s
|
69
|
-
when 'element
|
69
|
+
when 'element-short_label'
|
70
70
|
element.short_label if element.has_attribute?(:short_label)
|
71
|
-
when 'element
|
72
|
-
if element.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
when 'element-name'
|
72
|
+
element.name if element.has_attribute?(:name)
|
73
|
+
when 'element-class'
|
74
|
+
element.class.name === 'Labimotion::Element' ? element.element_klass.label : element.class.name
|
75
|
+
else
|
76
|
+
ek = element.element_klass
|
77
|
+
return if ek.nil? || ek.identifier != field['source_id']
|
78
|
+
|
79
|
+
el_prop = element.properties
|
80
|
+
fields = el_prop[Labimotion::Prop::LAYERS][field['layer_id']][Labimotion::Prop::FIELDS]
|
81
|
+
fields.find { |ss| ss['field'] == field['field_id'] }&.dig('value')
|
77
82
|
end
|
78
83
|
end
|
79
84
|
|
@@ -88,6 +93,7 @@ module Labimotion
|
|
88
93
|
|
89
94
|
def update_field_value(properties, key, idx, val)
|
90
95
|
properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = val
|
96
|
+
properties
|
91
97
|
end
|
92
98
|
|
93
99
|
def load_from_files
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Labimotion
|
4
4
|
class StdLayer < ApplicationRecord
|
5
5
|
acts_as_paranoid
|
6
|
-
self.table_name = :
|
7
|
-
has_many :
|
6
|
+
self.table_name = :layers
|
7
|
+
has_many :layer_tracks, primary_key: 'identifier', foreign_key: 'identifier', class_name: 'Labimotion::StdLayersRevision'
|
8
8
|
end
|
9
9
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Labimotion
|
4
4
|
class StdLayersRevision < ApplicationRecord
|
5
5
|
acts_as_paranoid
|
6
|
-
self.table_name = :
|
7
|
-
belongs_to :
|
6
|
+
self.table_name = :layer_tracks
|
7
|
+
belongs_to :layers, primary_key: 'identifier', foreign_key: 'identifier', class_name: 'Labimotion::StdLayer'
|
8
8
|
end
|
9
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:
|
4
|
+
version: 2.0.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-
|
12
|
+
date: 2024-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|