# File lib/openshift-origin-controller/app/models/component_instance.rb, line 119
  def elaborate_cartridge(cart, profile, app)
    group_list = profile.groups.map do |g|
       gpath = self.name + cart.get_name_prefix + g.get_name_prefix
       gi = app.working_group_inst_hash[gpath]
       if gi.nil?
         gi = app.group_instance_map[gpath]
         if gi.nil?
           gi = GroupInstance.new(app, cart.name, profile.name, g.name, gpath) 
         else
           gi.merge(cart.name, profile.name, g.name, gpath)
         end
       else
         gi.merge(cart.name, profile.name, g.name, gpath)
       end
       app.group_instance_map[gpath] = gi
       app.working_group_inst_hash[gpath] = gi
       sub_components = gi.elaborate(profile, g, self.name, app)
       self.dependencies += sub_components
       gi
    end

    # make connection_endpoints out of provided connections
    profile.connections.each do |conn|
      inst1 = ComponentInstance::find_component_in_cart(profile, app, conn.components[0], self.name)
      inst2 = ComponentInstance::find_component_in_cart(profile, app, conn.components[1], self.name)
      ComponentInstance::establish_connections(inst1, inst2, app)
    end
    
    profile.group_overrides.each do |n, v|
      from_cinst = ComponentInstance::find_component_in_cart(profile, app, n, self.name)
      to_cinst = ComponentInstance::find_component_in_cart(profile, app, v, self.name)
      next if from_cinst.nil? or to_cinst.nil?
      app.group_override_map[from_cinst.group_instance_name] = to_cinst.group_instance_name
      app.group_override_map[to_cinst.group_instance_name] = from_cinst.group_instance_name
    end

    return group_list
  end