labimotion 1.5.0.rc4 → 1.5.0.rc6

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: 3afb085685be0c64eb0eca90f28704e5f5305c41cb61c2f6b8a3bd13b5e2c452
4
- data.tar.gz: 0caa5656084de5a97b354cb1f7f10f8ffc016f326feb99b207d5f5a6c6453874
3
+ metadata.gz: 1a8123a3e71db321a6b3efef15ecce3cca9e287bce32a268b5447c25dd6ed55d
4
+ data.tar.gz: 36b88fb09d16d5ac4bc2a8eeae2775d20c9197d871e48df5e6dacc34b2934e23
5
5
  SHA512:
6
- metadata.gz: 2a9d39347435dcbc76a8a400e22bd5d7cd45278ca83c9bf32ff690bca3bed7d714c2f5d8dcab0859f062b14bc5cfbb81e73d097c25829a622ed1f16597164f12
7
- data.tar.gz: b6b346ea8463d6a0a5e70d17a7797ae8db50b25d810e0c37a0de497ce00ff0a725da23490dd7aae9ef709182d0da9497a36ff946d35cfacbfcf2f5878aa93e63
6
+ metadata.gz: 7695e71a516c3fba35fdae8cdb4d4b0081d4ca4da3802eb8703e43189a2dbbdbbe85413650a4d3699f262d9eeb92e6199f87a10a97a52aa7eb0927fab688e536
7
+ data.tar.gz: cb9a7de785d9ddecd6d69d0be45b9323a08c5227cdf7c0e4ed1db2063aaa47b306045534d30a9c5daa5d8c83624b642418badea4810cc9e9fd49a35f6700a753
@@ -12,5 +12,55 @@ module Labimotion
12
12
  def klass_label
13
13
  object&.dataset_klass&.label
14
14
  end
15
+
16
+
17
+ def root_element
18
+ object&.element&.root_element
19
+ end
20
+
21
+ def properties
22
+ properties = object&.properties || {}
23
+ properties[Labimotion::Prop::LAYERS].keys.each do |key|
24
+ layer = properties[Labimotion::Prop::LAYERS][key] || {}
25
+ return properties if layer.empty? || layer[Labimotion::Prop::FIELDS].nil?
26
+
27
+ field_vocs = layer[Labimotion::Prop::FIELDS].select { |ss| ss['is_voc'] == true }
28
+ field_vocs.each do |field|
29
+ idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field)
30
+ next if idx.nil?
31
+
32
+ case field['source']
33
+ when Labimotion::Prop::ELEMENT
34
+ if field['identifier'] == 'element.name'
35
+ byebug
36
+ properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = root_element&.name
37
+ # dic[field.identifier] = currentElement.name
38
+
39
+ end
40
+ when Labimotion::Prop::SEGMENT
41
+ segs = root_element&.segments&.select { |ss| field['source_id'] == ss.segment_klass&.identifier }
42
+ next if segs.empty? || field['layer_id'].blank? || field['field_id'].blank?
43
+
44
+ seg = segs&.first
45
+ seg_fields = seg.properties.dig(Labimotion::Prop::LAYERS, field['layer_id'], Labimotion::Prop::FIELDS).select { |ff| ff['field'] == field['field_id'] }
46
+ seg_field = seg_fields&.first
47
+ properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value'] = seg_field['value']
48
+ when Labimotion::Prop::DATASET
49
+ byebug
50
+ end
51
+ end
52
+
53
+ # layer[Labimotion::Prop::FIELDS].each do |field|
54
+ # end
55
+ end
56
+
57
+ # byebug
58
+ # layers = properties['layers']
59
+
60
+ # properties['vocabularies'].each_with_object({}) do |v, h|
61
+ # h[v['name']] = v['value']
62
+ # end
63
+ properties
64
+ end
15
65
  end
16
66
  end
@@ -17,7 +17,21 @@ module Labimotion
17
17
  # end
18
18
 
19
19
  expose :voc do |obj|
20
- (obj[:properties] && obj[:properties]['voc']) || {}
20
+ ## byebug
21
+ voc = (obj[:properties] && obj[:properties]['voc']) || {}
22
+
23
+ case voc['source']
24
+ when Labimotion::Prop::ELEMENT
25
+ if voc['identifier'] == 'element.name'
26
+ # byebug
27
+ # voc['source_name'] = ElementKlass.find_by(identifier: voc['source_id'])&.name
28
+ end
29
+ when Labimotion::Prop::SEGMENT
30
+ voc['source_name'] = SegmentKlass.find_by(identifier: voc['source_id'])&.label
31
+ when Labimotion::Prop::DATASET
32
+ voc['source_name'] = DatasetKlass.find_by(identifier: voc['source_id'])&.label
33
+ end
34
+ voc
21
35
  end
22
36
  expose :ontology do |obj|
23
37
  (obj[:properties] && obj[:properties]['ontology']) || {}
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "id": 9,
4
+ "identifier": "solvent",
5
+ "name": "Solvent",
6
+ "label": "NMR Solvent",
7
+ "field_type": "text",
8
+ "opid": 7,
9
+ "term_id": "NMR:1000330",
10
+ "source": "Standard"
11
+ },
12
+ {
13
+ "id": 11,
14
+ "identifier": "temperature",
15
+ "name": "Temperature",
16
+ "label": "Temperature",
17
+ "field_type": "text",
18
+ "opid": 0,
19
+ "term_id": "NMR:1400025",
20
+ "source": "Standard"
21
+ }
22
+ ]
@@ -0,0 +1,119 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "identifier": "dateTime.create",
5
+ "name": "Create Time",
6
+ "label": "Create Time",
7
+ "field_type": "datetime",
8
+ "opid": 9,
9
+ "term_id": "NCIT_C164483",
10
+ "ontology": {
11
+ "id": "ncit:class:http://purl.obolibrary.org/obo/NCIT_C164483",
12
+ "iri": "http://purl.obolibrary.org/obo/NCIT_C164483",
13
+ "type": "class",
14
+ "label": "Created Date",
15
+ "obo_id": "NCIT:C164483",
16
+ "short_form": "NCIT_C164483",
17
+ "description": [
18
+ "The date on which the activity or entity is created."
19
+ ],
20
+ "ontology_name": "ncit",
21
+ "ontology_prefix": "NCIT"
22
+ },
23
+ "source": "System",
24
+ "voc": {
25
+ "source": "System"
26
+ }
27
+ },
28
+ {
29
+ "id": 2,
30
+ "identifier": "dateTime.update",
31
+ "name": "Update Time",
32
+ "label": "Update Time",
33
+ "field_type": "datetime",
34
+ "opid": 9,
35
+ "term_id": "NCIT_C25164",
36
+ "ontology": {
37
+ "id": "ncit:class:http://purl.obolibrary.org/obo/NCIT_C25710",
38
+ "iri": "http://purl.obolibrary.org/obo/NCIT_C25710",
39
+ "short_form": "NCIT_C25710",
40
+ "obo_id": "NCIT:C25710",
41
+ "label": "Update",
42
+ "description": [
43
+ "Make current; supply with recent information or technology."
44
+ ],
45
+ "ontology_name": "ncit",
46
+ "ontology_prefix": "NCIT",
47
+ "type": "class"
48
+ },
49
+ "source": "System",
50
+ "voc": {
51
+ "source": "System"
52
+ }
53
+ },
54
+ {
55
+ "id": 4,
56
+ "identifier": "user.name",
57
+ "name": "creator",
58
+ "label": "creator",
59
+ "field_type": "text",
60
+ "opid": 9,
61
+ "term_id": "NCIT_C42628",
62
+ "ontology": {
63
+ "id": "ncit:class:http://purl.obolibrary.org/obo/NCIT_C42628",
64
+ "iri": "http://purl.obolibrary.org/obo/NCIT_C42628",
65
+ "type": "class",
66
+ "label": "Created By",
67
+ "obo_id": "NCIT:C42628",
68
+ "short_form": "NCIT_C42628",
69
+ "description": [
70
+ "Indicates the person or authoritative body who brought the item into existence."
71
+ ],
72
+ "ontology_name": "ncit",
73
+ "ontology_prefix": "NCIT"
74
+ },
75
+ "source": "User",
76
+ "voc": {
77
+ "source": "User"
78
+ }
79
+ },
80
+ {
81
+ "id": 2,
82
+ "identifier": "element.id",
83
+ "name": "Element Id",
84
+ "label": "Element Id",
85
+ "field_type": "text",
86
+ "opid": 9,
87
+ "term_id": "NCIT_C25364",
88
+ "source": "Element",
89
+ "voc": {
90
+ "source": "Element"
91
+ }
92
+ },
93
+ {
94
+ "id": 5,
95
+ "identifier": "element.name",
96
+ "name": "Element Name",
97
+ "label": "Element Name",
98
+ "field_type": "text",
99
+ "opid": 8,
100
+ "term_id": "NCIT_C42694",
101
+ "source": "Element",
102
+ "voc": {
103
+ "source": "Element"
104
+ }
105
+ },
106
+ {
107
+ "id": 3,
108
+ "identifier": "element.short_label",
109
+ "name": "Element Short Label",
110
+ "label": "Element Short Label",
111
+ "field_type": "text",
112
+ "opid": 9,
113
+ "term_id": "NCIT_C45561",
114
+ "source": "Element",
115
+ "voc": {
116
+ "source": "Element"
117
+ }
118
+ }
119
+ ]
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '1.5.0.rc4'
5
+ VERSION = '1.5.0.rc6'
6
6
  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.5.0.rc4
4
+ version: 1.5.0.rc6
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-10-04 00:00:00.000000000 Z
12
+ date: 2024-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -75,6 +75,8 @@ files:
75
75
  - lib/labimotion/helpers/vocabulary_helpers.rb
76
76
  - lib/labimotion/libs/attachment_handler.rb
77
77
  - lib/labimotion/libs/converter.rb
78
+ - lib/labimotion/libs/data/vocab/Standard.json
79
+ - lib/labimotion/libs/data/vocab/System.json
78
80
  - lib/labimotion/libs/export_dataset.rb
79
81
  - lib/labimotion/libs/export_element.rb
80
82
  - lib/labimotion/libs/nmr_mapper.rb