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");
        }
        // NOT YET TESTED
        private int liftFunctorApp(int id_functor_app, IDictionary <string, SupplyParameter> parsSuper)
        {
            AbstractComponentFunctorApplication acfa = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(id_functor_app);

            AbstractComponentFunctorApplication acfaNew = new AbstractComponentFunctorApplication();

            acfaNew.Id_abstract = acfa.Id_abstract;
            br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.insert(acfaNew);

            IList <SupplyParameter> supplyList = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list(id_functor_app);

            foreach (SupplyParameter sp in supplyList)
            {
                SupplyParameter spNew = null;
                if (sp is SupplyParameterComponent)
                {
                    SupplyParameterComponent spc    = (SupplyParameterComponent)sp;
                    SupplyParameterComponent spcNew = new SupplyParameterComponent();
                    spNew = spcNew;
                    spcNew.Id_functor_app        = acfaNew.Id_functor_app;
                    spcNew.Id_functor_app_actual = liftFunctorApp(spc.Id_functor_app_actual, parsSuper);
                    spcNew.Id_abstract           = spc.Id_abstract;
                    spcNew.Id_parameter          = spc.Id_parameter;
                }
                else if (sp is SupplyParameterParameter)
                {
                    SupplyParameterParameter spp     = (SupplyParameterParameter)sp;
                    SupplyParameter          spSuper = null;

                    if (parsSuper.Count > 0)
                    {
                        foreach (KeyValuePair <string, SupplyParameter> p in parsSuper)
                        {
                            Console.WriteLine("Key=" + p.Key + ", Value=" + p.Value.Id_abstract);
                        }
                    }
                    else
                    {
                        Console.WriteLine("parSupers EMPTY !!!!!!");
                    }

                    if (parsSuper.TryGetValue(spp.Id_argument, out spSuper))
                    {
                        if (spSuper is SupplyParameterComponent)
                        {
                            SupplyParameterComponent spcSuper = (SupplyParameterComponent)spSuper;
                            SupplyParameterComponent spcNew   = new SupplyParameterComponent();
                            spNew = spcNew;
                            Console.WriteLine("liftFunctorApp: 1" + (spNew == null));

                            AbstractComponentFunctorApplication acfa_spcSuper = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(spcSuper.Id_functor_app_actual);

                            spcNew.Id_functor_app        = acfaNew.Id_functor_app;
                            spcNew.Id_abstract           = acfa_spcSuper.Id_abstract;
                            spcNew.Id_parameter          = spp.Id_parameter;
                            spcNew.Id_functor_app_actual = spcSuper.Id_functor_app_actual;
                            Console.WriteLine("liftFunctorApp: 2" + (spcNew == null));
                        }
                        else if (spSuper is SupplyParameterParameter)
                        {
                            SupplyParameterParameter sppSuper = (SupplyParameterParameter)spSuper;
                            SupplyParameterParameter sppNew   = new SupplyParameterParameter();
                            spNew = sppNew;
                            Console.WriteLine("liftFunctorApp: 3 " + (spNew == null) + " spp.Id_argument=" + spp.Id_argument + ", spp.Id_parameter=" + spp.Id_parameter);

                            sppNew.Id_functor_app = acfaNew.Id_functor_app;
                            sppNew.Id_abstract    = spSuper.Id_abstract;
                            sppNew.Id_parameter   = spp.Id_parameter;
                            sppNew.Id_argument    = sppSuper.Id_argument;
                            sppNew.FreeVariable   = spp.FreeVariable;
                            Console.WriteLine("liftFunctorApp: 4" + (sppNew == null));
                        }
                        else
                        {
                            Console.WriteLine("liftFunctorApp: 5 " + (spp.Id_argument));
                        }
                    }
                    else
                    {
                        Console.WriteLine("liftFunctorApp: 5 ");
                        SupplyParameterParameter sppSuper = (SupplyParameterParameter)spSuper;
                        SupplyParameterParameter sppNew   = new SupplyParameterParameter();
                        spNew = sppNew;

                        sppNew.Id_argument    = spp.Id_argument;
                        sppNew.FreeVariable   = spp.FreeVariable;
                        sppNew.Id_functor_app = acfaNew.Id_functor_app;
                        sppNew.Id_abstract    = acfaNew.Id_abstract;
                        sppNew.Id_parameter   = spp.Id_parameter;
                        //sppNew.Id_parameter_actual = sppSuper.Id_parameter_actual;
                        //sppNew.FreeVariable = spp.FreeVariable;
                    }
                }
                br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.insert(spNew);
            }
            return(acfaNew.Id_functor_app);
        }
 public Variables(SupplyParameter page)
 {
     _page = page;
 }