module SushiFabric
Constants
- GSTORE_DIR
- MODULE_SOURCE
- NO_ROR
- SCRATCH_DIR
- SUSHI_APP_DIR
- VERSION
- WORKFLOW_MANAGER
Public Instance Methods
save_data_set(data_set_arr, headers, rows, user=nil)
click to toggle source
# File lib/sushi_fabric/sushiApp.rb, line 154 def save_data_set(data_set_arr, headers, rows, user=nil) data_set_hash = Hash[*data_set_arr] unless project = Project.find_by_number(data_set_hash['ProjectNumber'].to_i) project = Project.new project.number = data_set_hash['ProjectNumber'].to_i project.save end if project = Project.find_by_number(data_set_hash['ProjectNumber'].to_i) data_set = DataSet.new if user data_set.user = user end data_set.name = data_set_hash['DataSetName'] data_set.project = project if parent_id = data_set_hash['ParentID'] and parent_data_set = DataSet.find_by_id(parent_id.to_i) data_set.data_set = parent_data_set end if comment = data_set_hash['Comment'] and !comment.to_s.empty? data_set.comment = comment end sample_hash = {} rows.each do |row| headers.each_with_index do |header, i| sample_hash[header]=row[i] end sample = Sample.new sample.key_value = sample_hash.to_s sample.save unless sample.saved? data_set.samples << sample end data_set.md5 = data_set.md5hexdigest unless data_set.saved? project.data_sets << data_set parent_data_set.data_sets << data_set if parent_data_set data_set.save if user user.data_sets << data_set user.save end else headers[0] = DataSet.find_by_md5(data_set.md5) end data_set.id end end