Module: ResourceTrees
- Included in:
 - Resource
 - Defined in:
 - backend/app/model/resource_trees_ext.rb,
backend/app/model/mixins/resource_trees.rb 
Instance Method Summary (collapse)
- 
  
    
      - (Object) build_node_query 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      - (Object) load_node_properties(node, properties, ids_of_interest = :all) 
    
    
  
  
  
  
  
  
  
  
  
    
If we’re being asked to load an entire tree, don’t bother loading all of the instances that go with each node.
 - 
  
    
      - (Object) load_root_properties(properties, ids_of_interest = :all) 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      - (Object) set_node_instances(node, properties) 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      - (Object) set_node_instances_pre_container_management 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      - (Object) set_node_level(node, properties) 
    
    
  
  
  
  
  
  
  
  
  
    
 
Instance Method Details
- (Object) build_node_query
      3 4 5 6  | 
    
      # File 'backend/app/model/mixins/resource_trees.rb', line 3 def build_node_query node_query = super node_query.eager(:instance => :container) end  | 
  
- (Object) load_node_properties(node, properties, ids_of_interest = :all)
If we’re being asked to load an entire tree, don’t bother loading all of the instances that go with each node. This is a performance optimisation, since there can be tens of thousands of instances. The only place that pulls down the entire tree is the indexer, and it doesn’t need instance/container information from the tree anyway.
      47 48 49 50 51 52 53 54  | 
    
      # File 'backend/app/model/mixins/resource_trees.rb', line 47 def load_node_properties(node, properties, ids_of_interest = :all) super properties[node.id][:title] = node.display_string set_node_level(node, properties[node.id]) set_node_instances(node, properties[node.id]) if ids_of_interest != :all end  | 
  
- (Object) load_root_properties(properties, ids_of_interest = :all)
      57 58 59 60 61 62  | 
    
      # File 'backend/app/model/mixins/resource_trees.rb', line 57 def load_root_properties(properties, ids_of_interest = :all) super set_node_level(self, properties) set_node_instances(self, properties) if ids_of_interest != :all end  | 
  
- (Object) set_node_instances(node, properties)
      3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34  | 
    
      # File 'backend/app/model/resource_trees_ext.rb', line 3 def set_node_instances(node, properties) if node.instance.length > 0 properties[:instance_types] = node.instance.map {|instance| instance.values[:instance_type] } properties[:containers] = node.instance.collect {|instance| instance.sub_container }.flatten.compact.map {|sub_container| properties = {} top_container = sub_container.(:top_container_link) if (top_container) properties["type_1"] = "Container" properties["indicator_1"] = top_container.indicator if top_container. properties["indicator_1"] += " [#{top_container.barcode}]" end end properties["type_2"] = BackendEnumSource.value_for_id("container_type", sub_container.type_2_id) properties["indicator_2"] = sub_container.indicator_2 properties["type_3"] = BackendEnumSource.value_for_id("container_type", sub_container.type_3_id) properties["indicator_3"] = sub_container.indicator_3 properties } end end  | 
  
- (Object) set_node_instances_pre_container_management
      2  | 
    
      # File 'backend/app/model/resource_trees_ext.rb', line 2 alias_method :set_node_instances_pre_container_management, :set_node_instances  | 
  
- (Object) set_node_level(node, properties)
      9 10 11 12 13 14 15  | 
    
      # File 'backend/app/model/mixins/resource_trees.rb', line 9 def set_node_level(node, properties) if node.level === 'otherlevel' properties[:level] = node.other_level else properties[:level] = node.level end end  |