Module: SushiFabric

Defined in:
lib/sushi_fabric/version.rb,
lib/sushi_fabric/sushiApp.rb

Defined Under Namespace

Classes: Application, SushiApp

Constant Summary collapse

VERSION =
"1.2.9"
WORKFLOW_MANAGER =
config.workflow_manager
GSTORE_DIR =
config.gstore_dir
SUSHI_APP_DIR =
config.sushi_app_dir
SCRATCH_DIR =
config.scratch_dir
MODULE_SOURCE =
config.module_source
RAILS_HOST =
config.rails_host
NO_ROR =
true

Instance Method Summary collapse

Instance Method Details

#save_data_set(data_set_arr, headers, rows, user = nil) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/sushi_fabric/sushiApp.rb', line 153

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 # skip exact-match search
      data_set.samples << sample
    end

    data_set.md5 = data_set.md5hexdigest
    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
    data_set.id
  end
end