- 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 = {}
+ end
+
+ def self.collection_uuid(uuid)
+ m = /^([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?$/.match(uuid.to_s)
+ if m
+ #if m[2]
+ return m[1]
+ #else
+ # Collection.where(uuid: ['contains', m[1]]).each do |u|
+ # puts "fixup #{uuid} to #{u.uuid}"
+ # return u.uuid
+ # end
+ #end
+ else
+ nil
+ end
+ end
+
+ def determine_fillcolor(n)
+ bgcolor = ""
+ case n
+ when 1
+ bgcolor = "style=filled,fillcolor=\"#88ff88\""
+ when 2
+ bgcolor = "style=filled,fillcolor=\"#8888ff\""
+ when 3
+ bgcolor = "style=filled,fillcolor=\"#88ffff\""
+ end
+ bgcolor
+ end
+
+ def describe_node(uuid)
+ bgcolor = determine_fillcolor @opts[:pips][uuid] if @opts[:pips]
+
+ 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
+ puts uuid
+ if uuid == :"d41d8cd98f00b204e9800998ecf8427e+0"
+ # special case
+ puts "empty!"
+ return "\"#{uuid}\" [label=\"(empty collection)\"];\n"
+ end
+ if @pdata[uuid]
+ #puts @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]