1 class CollectionsController < ApplicationController
2 before_filter :ensure_current_user_is_admin
3 skip_before_filter :find_object_by_uuid, :only => [:graph]
10 @links = Link.eager.limit(100).where(head_kind: 'arvados#collection') |
11 Link.eager.limit(100).where(tail_kind: 'arvados#collection')
12 @collections = Collection.limit(100).to_hash
13 @collections.merge!(Collection.
15 where(uuid: @links.select{|x|x.head_kind=='arvados#collection'}.collect(&:head_uuid) |
16 @links.select{|x|x.tail_kind=='arvados#collection'}.collect(&:tail_uuid)).
19 @collections.each do |uuid, c|
20 ci = (@collection_info[uuid] ||= {uuid: uuid})
21 ci[:created_at] = c.created_at
24 if l.head_kind == 'arvados#collection'
25 c = (@collection_info[l.head_uuid] ||= {uuid: l.head_uuid})
26 if l.link_class == 'resources' and l.name == 'wants'
27 if l.head.respond_to? :created_at
28 c[:created_at] = l.head.created_at
31 if l.owner == current_user.uuid
32 c[:wanted_by_me] = true
36 if l.tail_kind == 'arvados#collection'
37 c = (@collection_info[l.tail_uuid] ||= {uuid: l.tail_uuid})
38 if l.link_class == 'group' and l.name == 'member_of'
40 c[:groups][l.tail_uuid] = true
42 if l.link_class == 'data_origin'
50 return super if !@object
53 @output2colorindex = {}
54 @sourcedata = {params[:uuid] => {uuid: params[:uuid]}}
56 whence = `whence #{params[:uuid]}`
58 whence.split("\n").each do |line|
59 if line.match /^(\#\d+@\S+)$/
60 job = Job.where(submit_id: line).first
61 @provenance << {job: job, target: line}
62 elsif (re = line.match /^ +output *= *(\S+)/)
63 if !@provenance.empty?
64 @provenance[-1][:output] = re[1]
65 @output2job[re[1]] = @provenance[-1][:job]
66 if !@output2colorindex[re[1]]
67 @output2colorindex[re[1]] = (colorindex += 1) % 10
69 @sourcedata.delete re[1]
71 elsif (re = line.match /^([0-9a-f]{32}\b)/)
72 @sourcedata[re[1]] ||= {uuid: re[1]}
75 Link.where(head_uuid: @sourcedata.keys | @output2job.keys).each do |link|
76 if link.link_class == 'resources' and link.name == 'wants'
77 @protected[link.head_uuid] = true
80 Link.where(tail_uuid: @sourcedata.keys).each do |link|
81 if link.link_class == 'data_origin'
82 @sourcedata[link.tail_uuid][:data_origins] ||= []
83 @sourcedata[link.tail_uuid][:data_origins] << [link.name, link.head_kind, link.head_uuid]
86 Collection.where(uuid: @sourcedata.keys).each do |collection|
87 if @sourcedata[collection.uuid]
88 @sourcedata[collection.uuid][:collection] = collection