labimotion 0.2.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labimotion/helpers/element_helpers.rb +4 -6
- data/lib/labimotion/helpers/generic_helpers.rb +9 -10
- data/lib/labimotion/libs/converter.rb +8 -2
- data/lib/labimotion/libs/export_dataset.rb +13 -3
- data/lib/labimotion/libs/nmr_mapper.rb +14 -2
- data/lib/labimotion/libs/nmr_mapper_repo.rb +20 -5
- 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: 83f0da3d6432a0ba7540d64776e8842517388dd310034ba47fa4009a0098aae1
|
4
|
+
data.tar.gz: ebdb71841e25f430469989361183eed16bfba8d45574c1e1fbac3094d397a484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9f45db60f7d2d7c199658dbcda29b2b00b62184d16bbbb60a7318c4e04d52cd13fdf64f8944ac90851c5e584b7a8fe7c1469a019d09f0ae7a4e7b3240294167
|
7
|
+
data.tar.gz: aeffedf19b1e83fbf15a6cecb634075a496e8f1700c5bed20c7624ccc9a05c8b58836e889e50ec5a1a609e13153bf88b7042f59ac24aaea00acffd6f218a4f54
|
@@ -20,12 +20,10 @@ module Labimotion
|
|
20
20
|
uuid = SecureRandom.uuid
|
21
21
|
template = { uuid: uuid, layers: {}, select_options: {} }
|
22
22
|
attributes = declared(params, include_missing: false)
|
23
|
-
if attributes[:properties_template].
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
attributes[:properties_template]['klass'] = 'ElementKlass'
|
28
|
-
end
|
23
|
+
attributes[:properties_template] = template if attributes[:properties_template].nil?
|
24
|
+
attributes[:properties_template]['uuid'] = uuid
|
25
|
+
attributes[:properties_template]['pkg'] = Labimotion::Utils.pkg(attributes[:properties_template]['pkg'])
|
26
|
+
attributes[:properties_template]['klass'] = 'ElementKlass'
|
29
27
|
attributes[:is_active] = false
|
30
28
|
attributes[:uuid] = uuid
|
31
29
|
attributes[:released_at] = DateTime.now
|
@@ -46,10 +46,9 @@ module Labimotion
|
|
46
46
|
uuid = SecureRandom.uuid
|
47
47
|
properties = params[:properties_template]
|
48
48
|
properties['uuid'] = uuid
|
49
|
-
|
50
49
|
klz.version = Labimotion::Utils.next_version(params[:release], klz.version)
|
51
50
|
properties['version'] = klz.version
|
52
|
-
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || klz.properties_template['pkg'])
|
51
|
+
properties['pkg'] = Labimotion::Utils.pkg(params['pkg'] || (klz.properties_template && klz.properties_template['pkg']))
|
53
52
|
properties['klass'] = klz.class.name.split('::').last
|
54
53
|
properties['identifier'] = klz.identifier
|
55
54
|
properties.delete('eln') if properties['eln'].present?
|
@@ -189,37 +188,37 @@ module Labimotion
|
|
189
188
|
raise e
|
190
189
|
end
|
191
190
|
|
192
|
-
def create_attachments(files, del_files, type, id, user_id)
|
191
|
+
def create_attachments(files, del_files, type, id, identifier, user_id)
|
193
192
|
attach_ary = []
|
194
|
-
(files || []).
|
193
|
+
(files || []).each_with_index do |file, index|
|
195
194
|
next unless (tempfile = file[:tempfile])
|
196
195
|
|
197
|
-
|
196
|
+
att = Attachment.new(
|
198
197
|
bucket: file[:container_id],
|
199
198
|
filename: file[:filename],
|
200
199
|
con_state: Labimotion::ConState::NONE,
|
201
200
|
file_path: file[:tempfile],
|
202
201
|
created_by: user_id,
|
203
202
|
created_for: user_id,
|
203
|
+
identifier: identifier[index],
|
204
204
|
content_type: file[:type],
|
205
205
|
attachable_type: type,
|
206
206
|
attachable_id: id,
|
207
207
|
)
|
208
208
|
begin
|
209
|
-
|
210
|
-
attach_ary.push(
|
209
|
+
att.save!
|
210
|
+
attach_ary.push(att.id)
|
211
211
|
ensure
|
212
212
|
tempfile.close
|
213
213
|
tempfile.unlink
|
214
214
|
end
|
215
215
|
end
|
216
216
|
unless (del_files || []).empty?
|
217
|
-
Attachment.where('id IN (?) AND attachable_type = (?)', del_files.map!(&:to_i),
|
218
|
-
type).update_all(attachable_id: nil)
|
217
|
+
Attachment.where('id IN (?) AND attachable_type = (?)', del_files.map!(&:to_i), type).update_all(attachable_id: nil)
|
219
218
|
end
|
220
219
|
attach_ary
|
221
220
|
rescue StandardError => e
|
222
|
-
Labimotion.log_exception(e
|
221
|
+
Labimotion.log_exception(e)
|
223
222
|
raise e
|
224
223
|
end
|
225
224
|
|
@@ -4,6 +4,7 @@ require 'net/http'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'json'
|
6
6
|
require 'date'
|
7
|
+
require 'labimotion/version'
|
7
8
|
require 'labimotion/utils/utils'
|
8
9
|
|
9
10
|
# rubocop: disable Metrics/AbcSize
|
@@ -116,7 +117,7 @@ module Labimotion
|
|
116
117
|
)
|
117
118
|
# att.attachment_attacher.attach(tmp_file)
|
118
119
|
if att.valid? && Labimotion::IS_RAILS5 == false
|
119
|
-
att.attachment_attacher.create_derivatives
|
120
|
+
## att.attachment_attacher.create_derivatives
|
120
121
|
att.save!
|
121
122
|
end
|
122
123
|
if att.valid? && Labimotion::IS_RAILS5 == true
|
@@ -148,7 +149,12 @@ module Labimotion
|
|
148
149
|
response = nil
|
149
150
|
begin
|
150
151
|
ofile = Rails.root.join(data[:f], data[:a].filename)
|
151
|
-
|
152
|
+
if Labimotion::IS_RAILS5 == true
|
153
|
+
FileUtils.cp(data[:a].store.path, ofile)
|
154
|
+
else
|
155
|
+
FileUtils.cp(data[:a].attachment_url, ofile)
|
156
|
+
end
|
157
|
+
|
152
158
|
File.open(ofile, 'r') do |f|
|
153
159
|
body = { file: f }
|
154
160
|
response = HTTParty.post(
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'export_table'
|
3
|
+
require 'labimotion/version'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
## ExportDataset
|
@@ -101,9 +102,18 @@ module Labimotion
|
|
101
102
|
cds.attachments.where(aasm_state: 'csv').each do |att|
|
102
103
|
name = File.basename(att.filename, '.csv')
|
103
104
|
sheet = @xfile.workbook.add_worksheet(name: name)
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
|
106
|
+
if Labimotion::IS_RAILS5 == true
|
107
|
+
File.open(att.store.path) do |fi|
|
108
|
+
fi.each_line do |line|
|
109
|
+
sheet.add_row(line.split(','))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
else
|
113
|
+
File.open(att.attachment_url) do |fi|
|
114
|
+
fi.each_line do |line|
|
115
|
+
sheet.add_row(line.split(','))
|
116
|
+
end
|
107
117
|
end
|
108
118
|
end
|
109
119
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'labimotion/version'
|
3
4
|
require 'labimotion/utils/utils'
|
4
5
|
|
5
6
|
module Labimotion
|
@@ -7,8 +8,8 @@ module Labimotion
|
|
7
8
|
class NmrMapper
|
8
9
|
def self.is_brucker_binary(id)
|
9
10
|
att = Attachment.find(id)
|
10
|
-
if
|
11
|
-
Zip::File.open(att.
|
11
|
+
if Labimotion::IS_RAILS5 == true
|
12
|
+
Zip::File.open(att.store.path) do |zip_file|
|
12
13
|
zip_file.each do |entry|
|
13
14
|
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
14
15
|
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
@@ -16,6 +17,17 @@ module Labimotion
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
20
|
+
else
|
21
|
+
if att&.attachment_attacher&.file&.url
|
22
|
+
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
23
|
+
zip_file.each do |entry|
|
24
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
25
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
26
|
+
return metadata
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
19
31
|
end
|
20
32
|
nil
|
21
33
|
end
|
@@ -1,18 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'labimotion/version'
|
2
3
|
require 'labimotion/utils/utils'
|
3
4
|
|
4
5
|
module Labimotion
|
5
6
|
class NmrMapperRepo
|
6
7
|
def self.is_brucker_binary(id)
|
7
8
|
att = Attachment.find(id)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if Labimotion::IS_RAILS5 == true
|
10
|
+
Zip::File.open(att.store.path) do |zip_file|
|
11
|
+
zip_file.each do |entry|
|
12
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
13
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
14
|
+
return metadata
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
if att&.attachment_attacher&.file&.url
|
20
|
+
Zip::File.open(att.attachment_attacher.file.url) do |zip_file|
|
21
|
+
zip_file.each do |entry|
|
22
|
+
if entry.name.include?('/pdata/') && entry.name.include?('parm.txt')
|
23
|
+
metadata = entry.get_input_stream.read.force_encoding('UTF-8')
|
24
|
+
return metadata
|
25
|
+
end
|
26
|
+
end
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
30
|
+
|
16
31
|
nil
|
17
32
|
end
|
18
33
|
|
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: 0.
|
4
|
+
version: 1.0.1
|
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: 2023-08-
|
12
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|