# File lib/openshift-origin-controller/app/models/group_instance.rb, line 225
  def elaborate(profile, group, parent_comp_path, app)
    group_inst_hash = {}
    new_components = []
    group.component_refs.each { |comp_ref|
      if self.cart_name == app.name
        cpath = parent_comp_path + comp_ref.get_name_prefix(profile)
      else
        cpath = parent_comp_path + "/cart-" + self.cart_name + comp_ref.get_name_prefix(profile)
      end
      old_ci = app.comp_instance_map[cpath]
      ci = ComponentInstance.new(self.cart_name, self.profile_name, self.group_name, comp_ref.name, cpath, self)
      ci.cart_data += old_ci.cart_data unless old_ci.nil?
      ci.process_cart_properties(old_ci.cart_properties) unless old_ci.nil?
      new_components << cpath
      self.component_instances << cpath if not self.component_instances.include? cpath
      app.comp_instance_map[cpath] = ci
      app.working_comp_inst_hash[cpath] = ci
      comp_groups = ci.elaborate(app)
      c_comp,c_prof,c_cart = ci.get_component_definition(app)
      c_group = c_prof.groups(ci.parent_cart_group)
      self.supported_min, self.supported_max = GroupInstance::merge_min_max(self.supported_min, @supported_max, c_group.scaling.min, c_group.scaling.max)
      self.min, self.max = GroupInstance::merge_min_max(self.min, @max, c_group.scaling.min, c_group.scaling.max)
      group_inst_hash[comp_ref.name] = comp_groups
    }
    
    # TODO: For FUTURE : if one wants to optimize by merging the groups
    # then pick group_inst_hash and merge them up
    # e.g. first component needs 4 groups, second one needs 3
    #   then, make the first three groups of first component also contain
    #   the second component and discard the second component's 3 groups
    #    (to remove groups, erase them from app.comp_instance_map for sure)

    # remove any entries in component_instances that are not part of 
    # application's working component instance hash, because that indicates
    # deleted components
    self.component_instances.delete_if { |cpath| app.working_comp_inst_hash[cpath].nil? }
    new_components
  end