- def self.describe_node(pdata, uuid)
- rsc = ArvadosBase::resource_class_for_uuid uuid.to_s
- if rsc
- href = "/#{rsc.to_s.underscore.pluralize rsc}/#{uuid}"
-
- #"\"#{uuid}\" [label=\"#{rsc}\\n#{uuid}\",href=\"#{href}\"];\n"
- if rsc == Collection
- if pdata[uuid]
- #puts pdata[uuid]
- if pdata[uuid][:name]
- return "\"#{uuid}\" [label=\"#{pdata[uuid][:name]}\",href=\"#{href}\",shape=oval];\n"
- else
- files = nil
- if pdata[uuid].respond_to? :files
- files = pdata[uuid].files
- elsif pdata[uuid][:files]
- files = pdata[uuid][:files]
- end
-
- if files
- i = 0
- label = ""
- while i < 3 and i < files.length
- label += "\\n" unless label == ""
- label += files[i][1]
- i += 1
+
+ class GenerateGraph
+ def initialize(pdata, opts)
+ @pdata = pdata
+ @opts = opts
+ @visited = {}
+ @jobs = {}
+ @node_extra = {}
+ end
+
+ def self.collection_uuid(uuid)
+ m = CollectionsHelper.match(uuid)
+ if m
+ if m[2]
+ return m[1]+m[2]
+ else
+ return m[1]
+ end
+ else
+ nil
+ end
+ end
+
+ def url_for u
+ p = { :host => @opts[:request].host,
+ :port => @opts[:request].port,
+ :protocol => @opts[:request].protocol }
+ p.merge! u
+ Rails.application.routes.url_helpers.url_for (p)
+ end
+
+ def determine_fillcolor(n)
+ fillcolor = %w(aaaaaa aaffaa aaaaff aaaaaa ffaaaa)[n || 0] || 'aaaaaa'
+ "style=filled,fillcolor=\"##{fillcolor}\""
+ end
+
+ def describe_node(uuid)
+ uuid = uuid.to_sym
+ bgcolor = determine_fillcolor @opts[:pips].andand[uuid]
+
+ rsc = ArvadosBase::resource_class_for_uuid uuid.to_s
+ if rsc
+ href = url_for ({:controller => rsc.to_s.tableize,
+ :action => :show,
+ :id => uuid.to_s })
+
+ #"\"#{uuid}\" [label=\"#{rsc}\\n#{uuid}\",href=\"#{href}\"];\n"
+ if rsc == Collection
+ if Collection.is_empty_blob_locator? uuid.to_s
+ # special case
+ return "\"#{uuid}\" [label=\"(empty collection)\"];\n"
+ end
+ if @pdata[uuid]
+ if @pdata[uuid][:name]
+ return "\"#{uuid}\" [label=\"#{@pdata[uuid][:name]}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
+ else
+ files = nil
+ if @pdata[uuid].respond_to? :files
+ files = @pdata[uuid].files
+ elsif @pdata[uuid][:files]
+ files = @pdata[uuid][:files]