static ParameterRenaming[] traverseParameters(IList <object> body_items, ContextArgumentType[] argument_list)
        {
            IList <ParameterRenaming> parameter_renaming_list = new List <ParameterRenaming> ();

            foreach (ContextArgumentType argument in argument_list)
            {
                ParameterRenaming parameter_renaming = new ParameterRenaming();

                ComponentFunctorApplicationType argument_value = (ComponentFunctorApplicationType)argument.Item;

                string componentRef = argument_value.component_ref;
                string inner_name   = NextArgumentInner;

                string package = null, name = null;
                fetchPackageAndName(componentRef, ref package, ref name);

                InnerComponentType ci = new InnerComponentType();
                body_items.Add(ci);
                ci.package   = package;
                ci.name      = name;
                ci.localRef  = inner_name;
                ci.multiple  = false;
                ci.exposed   = false;
                ci.parameter = traverseParameters(body_items, argument_value.argument);

                ParameterSupplyType supply = new ParameterSupplyType();
                body_items.Add(supply);
                supply.cRef    = inner_name;
                supply.varName = NextVariable;

                parameter_renaming.formFieldId = argument.parameter_id;
                parameter_renaming.varName     = supply.varName;

                parameter_renaming_list.Add(parameter_renaming);
            }

            ParameterRenaming[] parameter_return_array = new ParameterRenaming[parameter_renaming_list.Count];
            parameter_renaming_list.CopyTo(parameter_return_array, 0);
            return(parameter_return_array);
        }
        protected IList <SupplyParameter> loadAbstractComponentFunctorApplicationParameters(ComponentInUseType c,
                                                                                            AbstractComponentFunctorApplication aNew,
                                                                                            AbstractComponentFunctorApplication aNew_context)
        {
            IList <SupplyParameter> pars = new List <SupplyParameter>();

            if (c.parameter != null)
            {
                foreach (ParameterRenaming p in c.parameter)
                {
                    String formFieldId = p.formFieldId;
                    String varName     = p.varName;
                    Console.WriteLine("loadAbstractcomponentFunctorApplicationParameters -1 " + varName + "," + formFieldId);

                    SupplyParameter p_ = null;

                    ParameterType       topParameter = lookForParameterByVarName(varName);
                    ParameterSupplyType s            = lookForSupplyForVarName(varName);

                    if (topParameter != null)
                    {
                        Console.WriteLine("loadAbstractcomponentFunctorApplicationParameters 0 " + topParameter.formFieldId + ", " + varName);
                        p_ = new SupplyParameterParameter();
                        ((SupplyParameterParameter)p_).Id_argument  = topParameter.formFieldId;
                        ((SupplyParameterParameter)p_).FreeVariable = false;
                    }
                    else if (s != null)
                    {
                        Console.WriteLine("loadAbstractcomponentFunctorApplicationParameters 1 " + s.cRef + ", " + varName);
                        String cRef = s.cRef;

                        p_ = new SupplyParameterComponent();
                        // Look for the inner component that supplies that parameter.
                        InnerComponentType inner = lookForInnerComponent(cRef);
                        AbstractComponentFunctorApplication cPar = newAbstractComponentFunctorApplication(inner);
                        if (cPar == null)
                        {
                            throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (context actual parameter) : " + inner.name);
                        }
                        ((SupplyParameterComponent)p_).Id_functor_app_actual = cPar.Id_functor_app;
                    }
                    else
                    {
                        Console.WriteLine("loadAbstractcomponentFunctorApplicationParameters 2 " + varName);
                        p_ = new SupplyParameterParameter();
                        ((SupplyParameterParameter)p_).Id_argument  = null;
                        ((SupplyParameterParameter)p_).FreeVariable = true;
                    }


                    p_.Id_functor_app = aNew.Id_functor_app;
                    p_.Id_abstract    = aNew.Id_abstract;
                    p_.Id_parameter   = formFieldId;

                    //   SupplyParameterDAO p_DAO = new SupplyParameterDAO();
                    br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.insert(p_);

                    pars.Add(p_);
                }
            }

            loadSuppliedParametersOfSupertype(c, aNew, aNew_context);

            return(pars);
        }
        private void importInnerComponentsOfSuper(AbstractComponentFunctor absC, IList <InnerComponentType> includeAsInner)
        {
            Console.WriteLine("importInnerComponentsOfSupper : " + "START");
            IDictionary <string, SupplyParameter> parsSuper = new Dictionary <string, SupplyParameter>();

            // Inner components of the supertype.
            if (absC.Id_functor_app_supertype > 0)
            {
                AbstractComponentFunctorApplication acfa = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(absC.Id_functor_app_supertype);

                // It is a parameter in the subtype. Check if it is supplied in the type.
                IList <SupplyParameter> spList = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list(acfa.Id_functor_app);
                foreach (SupplyParameter sp in spList)
                {
                    Console.WriteLine("Adding to parSuper - key=" + sp.Id_parameter + ", value: " + sp.Id_functor_app + "/" + sp.Id_abstract + "/" + sp.Id_parameter);
                    parsSuper.Add(sp.Id_parameter, sp);
                }

                IList <InnerComponent> iss = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.list(acfa.Id_abstract);
                Console.WriteLine("importInnerComponentsOfSuper: " + iss.Count + " - acfa.Id_abstract=" + acfa.Id_abstract);
                foreach (InnerComponent i in iss)                 //if (!i.IsPublic)
                {
                    Console.WriteLine("importInnerComponentsOfSupper 1: " + i.Id_inner + " , " + i.Id_functor_app + " , " + (i.Parameter_top));

                    InnerComponent iNew = new InnerComponent();
                    if (i.Parameter_top != null && i.Parameter_top != "")
                    {
                        SupplyParameter sp = null;
                        parsSuper.TryGetValue(i.Parameter_top, out sp);
                        Console.WriteLine("importInnerComponentsOfSupper 2: " + i.Parameter_top + "," + i.Id_inner);

                        if (sp is SupplyParameterComponent)
                        {
                            Console.WriteLine("importInnerComponentsOfSupper 3: " + "sp is SupplyParameterComponent");

                            // 1th CASE: It is not a parameter in the current component.
                            // NOT YET TESTED !!!
                            SupplyParameterComponent spc = (SupplyParameterComponent)sp;

                            AbstractComponentFunctorApplication acfaReplace = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(spc.Id_functor_app_actual);
                            if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(absC.Id_abstract, i.Id_inner) == null)
                            {
                                iNew.Id_abstract_inner = acfaReplace.Id_abstract;
                                //iNew.Parameter_top = i.Parameter_top; // TODO: Testando .........
                                iNew.Id_abstract_owner = absC.Id_abstract;
                                iNew.Id_functor_app    = liftFunctorApp(acfaReplace.Id_functor_app, parsSuper);
                                iNew.Id_inner          = i.Id_inner;
                                br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNew);
                            }
                        }
                        else if (sp is SupplyParameterParameter)
                        {
                            Console.WriteLine("importInnerComponentsOfSupper 4: " + "sp is SupplyParameterParameter");
                            // 2nd CASE: It continues to be a parameter in the current component.
                            SupplyParameterParameter spp = (SupplyParameterParameter)sp;

                            String varName = null;
                            foreach (ParameterRenaming pr in parameterRenamingSuper)
                            {
                                if (pr.formFieldId.Equals(i.Parameter_top))
                                {
                                    varName = pr.varName;
                                    ParameterType      parameter = this.lookForParameterByVarName(varName);
                                    InnerComponentType cReplace  = lookForInnerComponent(parameter.componentRef);
                                    //cReplace.localRef = i.Id_inner;
                                    cReplace.exposed  = i.IsPublic;
                                    cReplace.multiple = i.Multiple;
                                    // cReplace.parameter_id = i.Parameter_top; // TODO: Testano
                                    includeAsInner.Add(cReplace);
                                }
                            }

                            ParameterSupplyType supply = lookForSupplyForVarName(varName);
                            if (supply != null)
                            {
                                InnerComponentType cReplace = lookForInnerComponent(supply.cRef);
                                if (cReplace != null)
                                {
                                    includeAsInner.Add(cReplace);
                                }
                            }
                        }
                    }
                    else
                    {
                        // 3rd CASE:
                        // NOT YET TESTED !!!
                        iNew.Id_abstract_inner = i.Id_abstract_inner;
                        iNew.Parameter_top     = null;
                        iNew.Id_abstract_owner = absC.Id_abstract;
                        iNew.Id_functor_app    = liftFunctorApp(i.Id_functor_app, parsSuper);
                        iNew.Id_inner          = i.Id_inner;
                        iNew.IsPublic          = i.IsPublic;
                        br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNew);
                    }
                }
            }
            Console.WriteLine("importInnerComponentsOfSuper : FINISH");
        }