Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
gy4443
chemotion_eln_server
Commits
2aeff7d9
Commit
2aeff7d9
authored
Oct 04, 2017
by
PiTrem
Browse files
upd import sample from xlsx
parent
380171e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
db/migrate/20171004132647_remove_density_null_on_sample.rb
0 → 100644
View file @
2aeff7d9
class
RemoveDensityNullOnSample
<
ActiveRecord
::
Migration
def
change
change_column_null
:samples
,
:density
,
true
end
end
db/schema.rb
View file @
2aeff7d9
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2017
0928124229
)
do
ActiveRecord
::
Schema
.
define
(
version:
2017
1004132647
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -589,7 +589,7 @@ ActiveRecord::Schema.define(version: 20170928124229) do
t
.
string
"sample_svg_file"
t
.
integer
"user_id"
t
.
string
"identifier"
t
.
float
"density"
,
default:
0.0
,
null:
false
t
.
float
"density"
,
default:
0.0
t
.
float
"melting_point"
t
.
float
"boiling_point"
t
.
integer
"fingerprint_id"
...
...
@@ -679,14 +679,14 @@ ActiveRecord::Schema.define(version: 20170928124229) do
t
.
datetime
"deleted_at"
t
.
hstore
"counters"
,
default:
{
"samples"
=>
"0"
,
"reactions"
=>
"0"
,
"wellplates"
=>
"0"
},
null:
false
t
.
string
"name_abbreviation"
,
limit:
5
t
.
string
"type"
,
default:
"Person"
t
.
boolean
"is_templates_moderator"
,
default:
false
,
null:
false
t
.
string
"type"
,
default:
"Person"
t
.
string
"reaction_name_prefix"
,
limit:
3
,
default:
"R"
t
.
hstore
"layout"
,
default:
{
"sample"
=>
"1"
,
"screen"
=>
"4"
,
"reaction"
=>
"2"
,
"wellplate"
=>
"3"
,
"research_plan"
=>
"5"
},
null:
false
t
.
string
"confirmation_token"
t
.
datetime
"confirmed_at"
t
.
datetime
"confirmation_sent_at"
t
.
string
"unconfirmed_email"
t
.
hstore
"layout"
,
default:
{
"sample"
=>
"1"
,
"screen"
=>
"4"
,
"reaction"
=>
"2"
,
"wellplate"
=>
"3"
,
"research_plan"
=>
"5"
},
null:
false
t
.
integer
"selected_device_id"
end
...
...
lib/import/import_samples.rb
View file @
2aeff7d9
...
...
@@ -180,12 +180,9 @@ class Import::ImportSamples
sample
.
molfile
=
molfile
sample
.
molecule
=
molecule
# Populate new sample
sample_attr
=
Sample
.
attribute_names
header
.
each_with_index
do
|
field
,
index
|
next
if
excluded_field
.
include?
(
field
)
next
unless
sample_attr
.
include?
(
field
)
field_assign
=
field
+
"="
sample
.
send
(
field_assign
,
row
[
field
])
next
unless
included_fields
.
include?
(
field
)
sample
[
field
]
=
row
[
field
]
end
sample
.
collections
<<
Collection
.
find
(
collection_id
)
sample
.
collections
<<
Collection
.
get_all_collection_for_user
(
current_user_id
)
...
...
@@ -193,8 +190,46 @@ class Import::ImportSamples
processed
.
push
(
sample
)
end
def
excluded_field
[
"ancestry"
,
"short_label"
]
def
excluded_fields
[
'id'
,
# 'name',
# 'target_amount_value',
# 'target_amount_unit',
'created_at'
,
'updated_at'
,
# 'description',
'molecule_id'
,
'molfile'
,
# 'purity',
# 'solvent',
'impurities'
,
# 'location',
'is_top_secret'
,
'ancestry'
,
# 'external_label',
'created_by'
,
'short_label'
,
# 'real_amount_value',
# 'real_amount_unit',
# 'imported_readout',
'deleted_at'
,
'sample_svg_file'
,
'user_id'
,
'identifier'
,
# 'density',
# 'melting_point',
# 'boiling_point',
'fingerprint_id'
,
'xref'
,
# 'molarity_value',
# 'molarity_unit',
'molecule_name_id'
,
]
end
def
included_fields
Sample
.
attribute_names
-
excluded_fields
end
def
error_process_file
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment