1 class ActionsController < ApplicationController
4 def self.expose_action method, &block
5 @@exposed_actions[method] = true
6 define_method method, block
10 ArvadosBase::resource_class_for_uuid(params[:uuid])
14 params.keys.collect(&:to_sym).each do |param|
15 if @@exposed_actions[param]
16 return self.send(param)
22 expose_action :copy_selections_into_folder do
24 filter([['tail_uuid','=',@object.uuid],
25 ['head_uuid','in',params["selection"]]]).
27 (params["selection"] - already_named).each do |s|
28 Link.create(tail_uuid: @object.uuid,
31 name: "#{s} added #{Time.now}")
36 expose_action :combine_selected_files_into_collection do
39 params["selection"].each do |s|
40 m = CollectionsHelper.match(s)
41 if m and m[1] and m[2]
42 lst.append(m[1] + m[2])
47 collections = Collection.where(uuid: lst)
50 collections.each do |c|
57 mt = chash[m[1]+m[2]].manifest_text
59 IO.popen(['arv-normalize', '--extract', m[4][1..-1]], 'w+b') do |io|
62 while buf = io.read(2**20)
67 combined += chash[m[1]+m[2]].manifest_text
72 IO.popen(['arv-normalize'], 'w+b') do |io|
75 while buf = io.read(2**20)
84 newuuid = "#{d.hexdigest}+#{normalized.length}"
89 $arvados_api_client.arvados_v1_base.
90 sub(/\/arvados\/v1/, '').
91 sub(/^https?:\/\//, ''),
92 'ARVADOS_API_TOKEN' => Thread.current[:arvados_api_token],
93 'ARVADOS_API_HOST_INSECURE' =>
94 Rails.configuration.arvados_insecure_https ? 'true' : 'false'
97 IO.popen([env, 'arv-put', '--raw'], 'w+b') do |io|
100 while buf = io.read(2**20)
105 newc = Collection.new({:uuid => newuuid, :manifest_text => normalized})
112 link_class: "provenance",
118 redirect_to controller: 'collections', action: :show, id: newc.uuid