-
- # Make the graph
- visited_pdhs = []
- all_cr_nodes = [cr] + child_crs.results
-
- # First pass: add the CR nodes with their outputs, because they're
- # referenced by UUID.
- all_cr_nodes.each do |cr_node|
- # CR node
- gr += describe_node(cr_node[:uuid], {href: {controller: 'container_requests',
- id: cr_node[:uuid]},
- label: cr_node[:name],
- shape: 'oval'})
- # Connect child CRs with the main one
- if cr_node != cr
- gr += edge(cr_node[:uuid], cr[:uuid], {label: 'child'})
- end
- # Output collection node
- if cr_node[:output_uuid] and output_cols[cr_node[:output_uuid]]
- c = output_cols[cr_node[:output_uuid]]
- visited_pdhs << c[:portable_data_hash]
- gr += describe_node(c[:portable_data_hash], {label: c[:name]})
- gr += edge(cr_node[:uuid], c[:portable_data_hash], {label: 'output'})
- end
- end
-
- # Second pass: add the input collection nodes.
- all_cr_nodes.each do |cr_node|
- cr_input_pdhs(cr_node).each do |pdh|
- if not visited_pdhs.include?(pdh)
- visited_pdhs << pdh
- if input_cols[pdh]
- # First search for collections within the CR project
- cols = input_cols[pdh].select{|x| x[:owner_uuid] == cr_node[:owner_uuid]}
- if cols.empty?
- # Search for any collection with this PDH
- cols = input_cols[pdh]
- end
- names = cols.collect{|x| x[:name]}.uniq
- input_name = names.first
- if names.length > 1
- input_name += " + #{names.length - 1} others"
- end
- else
- # No collection found by this PDH
- input_name = pdh
- end
- gr += describe_node(pdh, {label: input_name})
+ # Input collection nodes
+ output_pdhs = @opts[:output_collections].values.collect{|c|
+ c[:portable_data_hash]}
+ ProvenanceHelper::cr_input_pdhs(cr).each do |pdh|
+ if not output_pdhs.include?(pdh)
+ # Search for collections on the same project first
+ cols = @opts[:input_collections][pdh].andand.select{|c|
+ c[:owner_uuid] == cr[:owner_uuid]}
+ if not cols or cols.empty?
+ # Search for any collection with this PDH
+ cols = @opts[:input_collections][pdh]
+ end
+ names = cols.collect{|x| x[:name]}.uniq
+ input_name = names.first
+ if names.length > 1
+ input_name += " + #{names.length - 1} more"