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