protected IList <AbstractComponentFunctorParameter> loadAbstractComponentFunctorParameters(AbstractComponentFunctor c_)
        {
            IList <AbstractComponentFunctorParameter> pars = new List <AbstractComponentFunctorParameter>();

            if (parameter != null)
            {
                foreach (ParameterType parameter_ in parameter)
                {
                    Console.WriteLine("loadAbstractComponentFunctorParameters : PARAMETER " + parameter_.componentRef + ":" + parameter_.formFieldId);
                    AbstractComponentFunctorParameter p = new AbstractComponentFunctorParameter();

                    p.Id_abstract  = c_.Id_abstract;
                    p.Id_parameter = parameter_.formFieldId;

                    ComponentInUseType cBound = lookForInnerComponent(parameter_.componentRef);
                    AbstractComponentFunctorApplication cApp = newAbstractComponentFunctorApplication(cBound);
                    if (cApp == null)
                    {
                        throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (context parameter bound) : " + cBound.name);
                    }

                    p.Bounds_of = cApp.Id_functor_app;
                    p.Variance  = parameter_.variance;

                    if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(p.Id_abstract, p.Id_parameter) == null)
                    {
                        br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.insert(p);
                    }

                    pars.Add(p);
                }
            }
            Console.WriteLine("loadAbstractComponentFunctorParameters : END");
            return(pars);
        }
        protected AbstractComponentFunctorApplication newAbstractComponentFunctorApplication(ComponentInUseType c)
        {
            AbstractComponentFunctor a = lookForAbstractComponentFunctor(c.package, c.name);

            if (a == null)
            {
                return(null);
            }

            // CREATE AbstractComponentFunctorApplication

            AbstractComponentFunctorApplication aAppNew = new AbstractComponentFunctorApplication();

            aAppNew.Id_functor_app = Connector.nextKey("id_functor_app", "abstractcomponentfunctorapplication");
            //  Console.WriteLine("+++++++++++++++ " +  aAppNew.Id_functor_app);
            aAppNew.Id_abstract = a.Id_abstract;

            br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.insert(aAppNew);

            // REGISTER parameters (follow supply-of, configure formal-parameter)
            loadAbstractComponentFunctorApplicationParameters(c, aAppNew, aAppNew);

            return(aAppNew);
            //     }
        }
        private IList <string> fetchPackages(int id_functor_app)
        {
            IList <string> package_list = new List <string>();
            AbstractComponentFunctorApplication acfa = BackEnd.acfadao.retrieve(id_functor_app);
            AbstractComponentFunctor            acf  = BackEnd.acfdao.retrieve(acfa.Id_abstract);

            package_list.Add(acf.Library_path);

            IList <SupplyParameter> sp_list = BackEnd.spdao.list(id_functor_app);

            foreach (SupplyParameter sp in sp_list)
            {
                if (sp is SupplyParameterComponent)
                {
                    SupplyParameterComponent spc = (SupplyParameterComponent)sp;
                    foreach (string pk in fetchPackages(spc.Id_functor_app_actual))
                    {
                        package_list.Add(pk);
                    }
                }
                else if (sp is SupplyParameterParameter)
                {
                    SupplyParameterParameter spp = (SupplyParameterParameter)sp;
                    // NOTHING TO DO ... the parameter depends on the paramter of the component
                }
            }

            return(package_list);
        }
        private static void calculateDependenciesOf_(int id_functor_app, IDictionary <int, string> dependency_list)
        {
            AbstractComponentFunctorApplication acfaRef = BackEnd.acfadao.retrieve(id_functor_app);
            AbstractComponentFunctor            acfRef  = BackEnd.acfdao.retrieve(acfaRef.Id_abstract);

            IList <SupplyParameter> sp_list = BackEnd.spdao.list(id_functor_app);

            foreach (SupplyParameter sp in sp_list)
            {
                if (sp is SupplyParameterComponent)
                {
                    SupplyParameterComponent spc = (SupplyParameterComponent)sp;
                    calculateDependenciesOf_(spc.Id_functor_app_actual, dependency_list);
                }
            }

            IList <InnerComponent> inner_list = BackEnd.icdao.list(acfRef.Id_abstract);

            foreach (InnerComponent inner in inner_list)
            {
                calculateDependenciesOf_(inner.Id_functor_app, dependency_list);
            }

            if (acfRef.Id_functor_app_supertype > 0)
            {
                calculateDependenciesOf_(acfRef.Id_functor_app_supertype, dependency_list);
            }

            if (!dependency_list.ContainsKey(acfRef.Id_abstract))
            {
                dependency_list.Add(acfRef.Id_abstract, acfRef.Library_path);
            }
        }
        public string[] resolve(string contract)
        {
            AbstractComponentFunctorApplication acfa = build_contract(contract);

            string[] cs = BackEnd.resolveUnit(contract);
            return(cs);
        }
Ejemplo n.º 6
0
        private AbstractComponentFunctor lookForAbstractComponentFunctorOfConcreteComponent(Component cConc)
        {
            AbstractComponentFunctorApplication acfa = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(cConc.Id_functor_app);

            AbstractComponentFunctor acf = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.retrieve(acfa.Id_abstract);

            return(acf);
        }
Ejemplo n.º 7
0
        internal void updateSources(ComponentType ct, Component c)
        {
            LoadBodyItems(ct.componentInfo);

            IDictionary <string, Unit> units = new Dictionary <string, Unit>();

            AbstractComponentFunctorApplication absCapp = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(c.Id_functor_app);

            int id_abstract = absCapp.Id_abstract;

            // for each unit ...
            foreach (UnitType u in unit)
            {
                string uref = u.uRef;
                string iRef = u.iRef;
                //string urefSuper = u.super == null ? null : u.super.uRef;
                int partition_index = u.replicaSpecified ? u.replica : 0;

                Interface     i  = br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.retrieve(id_abstract, uref);
                InterfaceType ui = lookForInterface(iRef);

                foreach (SourceFileType sft in ui.sources[ui.sources.Length - 1].file)
                {
                    SourceCode ss = new SourceCode();
                    ss.Type_owner         = 'u';
                    ss.Id_owner_container = c.Id_concrete;
                    ss.Id_owner           = uref;
                    ss.Contents           = sft.contents;
                    ss.File_type          = sft.srcType.Equals("user") || sft.srcType.Equals("base") ? "dll" : "platform.settings";
                    ss.File_name          = sft.name;
                    br.ufc.pargo.hpe.backend.DGAC.BackEnd.scdao.update(ss);
                    if (sft.externalDependency != null)
                    {
                        foreach (string extRef in sft.externalDependency)
                        {
                            SourceCodeReference ssr = new SourceCodeReference();
                            ssr.Type_owner         = ss.Type_owner;
                            ssr.Id_owner_container = ss.Id_owner_container;
                            ssr.Id_owner           = ss.Id_owner;
                            ssr.File_name          = ss.File_name;
                            ssr.Reference          = extRef;
                            if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.scrdao.retrieve(ssr) != null)
                            {
                                // DGAC.BackEnd.scrdao.update(ssr);
                            }
                            else
                            {
                                br.ufc.pargo.hpe.backend.DGAC.BackEnd.scrdao.insert(ssr);
                            }
                        }
                    }
                }
            }
        }
        protected IList <AbstractComponentFunctorApplication> newAbstractComponentFunctorApplicationForImplements(ComponentInUseType c)
        {
            IList <AbstractComponentFunctor> ancestrals = new List <AbstractComponentFunctor>();

            AbstractComponentFunctor a_current = lookForAbstractComponentFunctor(c.package, c.name);

            if (a_current == null)
            {
                return(null);
            }

            {
                AbstractComponentFunctor a = a_current;
                ancestrals.Add(a);
                while (a.Id_functor_app_supertype > 0)
                {
                    AbstractComponentFunctorApplication acfa_ancestral = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(a.Id_functor_app_supertype);
                    a = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.retrieve(acfa_ancestral.Id_abstract);
                    ancestrals.Add(a);
                }
            }

            IList <AbstractComponentFunctorApplication> aAppNewList = new List <AbstractComponentFunctorApplication>();

            AbstractComponentFunctorApplication aAppNewOld = null;
            AbstractComponentFunctorApplication aAppNew    = null;

            foreach (AbstractComponentFunctor a in ancestrals)
            {
                // CREATE AbstractComponentFunctorApplication

                aAppNew                = new AbstractComponentFunctorApplication();
                aAppNew.Id_abstract    = a.Id_abstract;
                aAppNew.Id_functor_app = Connector.nextKey("id_functor_app", "abstractcomponentfunctorapplication");
                br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.insert(aAppNew);
                loadAbstractComponentFunctorApplicationParameters(c, aAppNew, aAppNewOld == null ? aAppNew : aAppNewOld);
                aAppNewList.Add(aAppNew);
                if (aAppNewOld != null)
                {
                    br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.updateIdFunctorAppNext(aAppNewOld, aAppNew.Id_functor_app);
                }
                aAppNewOld = aAppNew;
            }

            return(aAppNewList);
            //     }
        }
        void loadSuppliedParametersOfSupertype(ComponentInUseType c, AbstractComponentFunctorApplication aNew, AbstractComponentFunctorApplication aNew_context)
        {
            int id_functor_app_supertype;

            if (aNew_context.Id_abstract != aNew.Id_abstract)
            {
                Console.WriteLine("id_abstract_context != aNew.Id_abstract : " + aNew_context.Id_abstract + " " + aNew.Id_abstract);
                AbstractComponentFunctor acf = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.retrieve(aNew_context.Id_abstract);
                id_functor_app_supertype = acf.Id_functor_app_supertype;
            }
            else
            {
                Console.WriteLine("id_abstract_context == aNew.Id_abstract : " + aNew_context.Id_abstract + " " + aNew.Id_abstract);
                AbstractComponentFunctor acf = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.retrieve(aNew.Id_abstract);
                id_functor_app_supertype = acf.Id_functor_app_supertype;
            }

            while (id_functor_app_supertype > 0)
            {
                AbstractComponentFunctorApplication acfa = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(id_functor_app_supertype);

                IList <SupplyParameter> sp_list = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list(id_functor_app_supertype);
                foreach (SupplyParameter sp in sp_list)
                {
                    if (sp is SupplyParameterComponent)
                    {
                        SupplyParameterComponent spc     = (SupplyParameterComponent)sp;
                        SupplyParameterComponent spc_new = new SupplyParameterComponent();

                        spc_new.Id_functor_app        = aNew.Id_functor_app;
                        spc_new.Id_abstract           = aNew.Id_abstract;
                        spc_new.Id_functor_app_actual = spc.Id_functor_app_actual;
                        spc_new.Id_parameter          = spc.Id_parameter;
                        br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.insert(spc_new);
                    }
                    else if (sp is SupplyParameterParameter)
                    {
                    }
                }

                AbstractComponentFunctor acf = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.retrieve(acfa.Id_abstract);
                id_functor_app_supertype = acf.Id_functor_app_supertype;

                Trace.WriteLineIf(id_functor_app_supertype > 0, "LOOPING TO SUPERTYPE !!!");
            }
        }
        private InterfaceSignature createSliceAccessorType(Interface i, out IDictionary <string, int> par_order)
        {
            par_order = new Dictionary <string, int>();
            IDictionary <string, string> open_pars   = new Dictionary <string, string>();
            IDictionary <string, int>    closed_pars = new Dictionary <string, int>();
            IList <InterfaceParameter>   ip_list     = BackEnd.ipdao.list(i.Id_abstract, i.Id_interface);
//			string[] par_order = new string[ip_list.Count];
            int k = 0;

            foreach (InterfaceParameter ip in ip_list)
            {
                open_pars.Add(ip.ParId, ip.VarId);
                par_order.Add(ip.ParId, k++);
            }

            InterfaceSignature isig = calculateParameters(i, closed_pars, open_pars);

            IDictionary <string, InterfaceSignature> m = new Dictionary <string, InterfaceSignature>();

            foreach (KeyValuePair <string, InterfaceSignature> par in isig.parameters)
            {
                string             par_id = par.Key;
                InterfaceSignature iPar   = par.Value;

                AbstractComponentFunctorParameter   acfp = BackEnd.acfpdao.retrieve(i.Id_abstract, par_id);
                AbstractComponentFunctorApplication acfa = BackEnd.acfadao.retrieve(acfp.Bounds_of);
                AbstractComponentFunctor            acf  = BackEnd.acfdao.retrieve(acfa.Id_abstract);
                Interface i_ = BackEnd.idao.retrieveTop(acfa.Id_abstract, iPar.the_interface.Id_interface_super_top);

                iPar.package_path  = acf.Library_path;
                iPar.the_interface = i_;
                m.Add(par_id, iPar);
            }

            foreach (KeyValuePair <string, InterfaceSignature> par in m)
            {
                isig.parameters.Remove(par.Key);
                isig.parameters.Add(par.Key, par.Value);
            }


            return(isig);
        }
        public static void invokeDeployContracts(SAFeSWL_Architecture arch_desc,
                                                 string arch_ref,
                                                 IDictionary <string, Instantiator.ComponentFunctorApplicationType> contracts,
                                                 object platform_address)
        {
            br.ufc.pargo.hpe.backend.DGAC.database.Connector.openConnection();

            IPlatformServices platform_access = null;

            if (platform_address is string)
            {
                // Deploy the components of the system.
                ServiceUtils.PlatformServices.PlatformServices platform_access_ = new ServiceUtils.PlatformServices.PlatformServices((string)platform_address);
                platform_access_.Timeout = int.MaxValue;
                platform_access          = (IPlatformServices)platform_access_;
            }
            else if (platform_address is IPlatformServices)
            {
                platform_access = (IPlatformServices)platform_address;
            }

            IDictionary <string, int[]> cs = LoaderSystem.componentsInPlatform(arch_desc, arch_ref);

            foreach (string c in cs.Keys)
            {
                if (contracts.ContainsKey(c))
                {
                    AbstractComponentFunctorApplication acfaRef = BackEnd.loadACFAFromInstantiator(contracts[c]);

                    string[] config_dependencies = calculateDependenciesOf(acfaRef.Id_functor_app);

                    foreach (string cRef in config_dependencies)
                    {
                        string config_filename = Constants.PATH_TEMP_WORKER + cRef + ".hpe";
                        string config_contents = File.ReadAllText(config_filename);

                        platform_access.deploy(config_contents);
                    }
                }
            }
            br.ufc.pargo.hpe.backend.DGAC.database.Connector.closeConnection();
        }
        // 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);
        }
Ejemplo n.º 13
0
        private IDictionary <string, Unit> loadUnits(Component c)
        {
            IDictionary <string, Unit> units = new Dictionary <string, Unit>();

            AbstractComponentFunctorApplication absCapp_ = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(c.Id_functor_app);
            AbstractComponentFunctorApplication absCapp  = null;

            while (absCapp_ != null)
            {
                absCapp  = absCapp_;
                absCapp_ = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve_next(absCapp_.Id_functor_app);
            }

            int id_abstract = absCapp.Id_abstract;

            // for each unit ...
            foreach (UnitType u in unit)
            {
                string uref            = u.uRef;
                string iRef            = u.iRef;
                int    partition_index = u.replicaSpecified ? u.replica : 0;

                string uRefSuper = u.super.Length == 0 ? "" : u.super[0].uRef;
                for (int j = 1; j < u.super.Length; j++)
                {
                    uRefSuper += "+" + u.super[j].uRef;
                }


                Interface i = br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.retrieve(id_abstract, uref);

                InterfaceType ui = lookForInterface(iRef);

                Unit uu = new Unit();
                uu.Id_concrete   = c.Id_concrete;
                uu.Id_unit       = uref;
                uu.Id_abstract   = id_abstract;
                uu.Id_interface  = uref;
                uu.Id_unit_super = uRefSuper;
                //  uu.Unit_replica = partition_index;
                uu.Class_name      = xc.header.packagePath + "." + xc.header.name + "." + iRef;
                uu.Class_nargs     = i.Class_nargs;
                uu.Assembly_string = uu.Class_name + ", Culture=neutral, Version=0.0.0.0"; // In the current implementation, the name of the dll is the name of the class of the unit.
                uu.Order           = i.Order;

                units.Add(uu.Id_unit, uu);

                //Console.WriteLine("ui.sources={0}",ui.sources);
                //Console.WriteLine("ui.protocol={0}",ui.protocol);
                //Console.WriteLine("{0}={1}", c.Kind, Constants.KIND_COMPUTATION_NAME);

                if (ui.sources == null && (c.Kind.Equals(Constants.KIND_COMPUTATION_NAME) ||
                                           c.Kind.Equals(Constants.KIND_SYNCHRONIZER_NAME)))
                {
                    Console.WriteLine("ENTER WRAPPER GENERATOR " + c.Library_path);

                    IWrapperGenerator wg           = new WrapperGenerator();
                    string[]          dependencies = null;
                    CodeCompileUnit   compile_unit = wg.create_wrapper(c.Library_path, ui.iRef, uu.Id_abstract, uu.Id_interface, out dependencies);
                    string            source_code  = wg.generate_source_code(ui.iRef, compile_unit);

                    Console.WriteLine(source_code);

                    SourceCode ss = new SourceCode();
                    ss.Type_owner         = 'u';
                    ss.Id_owner_container = uu.Id_concrete;
                    ss.Id_owner           = uu.Id_unit;
                    ss.Contents           = source_code;
                    ss.File_type          = "dll";
                    ss.File_name          = ui.iRef + ".cs";
                    ss.Order = 0;
                    br.ufc.pargo.hpe.backend.DGAC.BackEnd.scdao.insert(ss);
                }
                else if (ui.sources != null)
                {
                    int order = 0;
                    foreach (SourceFileType sft in ui.sources[ui.sources.Length - 1].file)
                    {
                        if (sft.srcType.Equals("user") || sft.srcType.Equals("base"))
                        {
                            Console.WriteLine("loadUnits - 1 " + sft.name);
                            SourceCode ss = new SourceCode();
                            ss.Type_owner         = 'u';
                            ss.Id_owner_container = uu.Id_concrete;
                            ss.Id_owner           = uu.Id_unit;
                            ss.Contents           = sft.contents;
                            ss.File_type          = "dll";
                            ss.File_name          = sft.name;
                            ss.Order = order++;
                            br.ufc.pargo.hpe.backend.DGAC.BackEnd.scdao.insert(ss);
                            Console.WriteLine("loadUnits - 2");

                            int size = (sft.externalDependency == null ? 0 : sft.externalDependency.Length) +
                                       (ui.externalReferences == null ? 0 : ui.externalReferences.Length);

                            Console.WriteLine("loadUnits - 3");

                            if (size > 0)
                            {
                                Console.WriteLine("loadUnits - 4");
                                string[] allRefs = new string[size];
                                if (ui.externalReferences != null)
                                {
                                    ui.externalReferences.CopyTo(allRefs, 0);
                                }

                                if (sft.externalDependency != null)
                                {
                                    sft.externalDependency.CopyTo(allRefs, ui.externalReferences == null ? 0 : ui.externalReferences.Length);
                                }

                                Console.WriteLine("loadUnits - 5");

                                foreach (string extRef in allRefs)
                                {
                                    Console.WriteLine("loadUnits - 6 - " + extRef);
                                    SourceCodeReference ssr = new SourceCodeReference();
                                    ssr.Type_owner         = ss.Type_owner;
                                    ssr.Id_owner_container = ss.Id_owner_container;
                                    ssr.Id_owner           = ss.Id_owner;
                                    ssr.File_name          = ss.File_name;
                                    ssr.Reference          = extRef;
                                    if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.scrdao.retrieve(ssr) == null)
                                    {
                                        br.ufc.pargo.hpe.backend.DGAC.BackEnd.scrdao.insert(ssr);
                                    }
                                    Console.WriteLine("loadUnits - 7 - " + extRef);
                                }
                            }
                        }
                        else if (sft.srcType.Equals("platform.settings"))
                        {
                            SourceCode ss = new SourceCode();
                            ss.Type_owner         = 'u';
                            ss.Id_owner_container = uu.Id_concrete;
                            ss.Id_owner           = uu.Id_unit;
                            ss.Contents           = sft.contents;
                            ss.File_type          = "platform.settings";
                            ss.File_name          = sft.name;
                            ss.Order = order++;
                            br.ufc.pargo.hpe.backend.DGAC.BackEnd.scdao.insert(ss);
                        }
                    }
                }
                else
                {
                    throw new Exception("Unit " + uu.Id_unit + " neither has a source code nor is a connector.");
                }

                UnitDAO udao = new UnitDAO();
                udao.insert(uu);
            }

            return(units);
        }
        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 InterfaceSignature calculateParameters(Interface i, IDictionary <string, int> closed_pars, IDictionary <string, string> open_pars)
        {
            // id_abstract, id_interface, partition_index, id_interface_super, partition_index_super, uri_source, class_nargs, id_interface_super_top, partition_index_super_top, order
            // '43', 'compute_rhs', '0', '', '0', 'adi.ComputeRHS.IComputeRHS', '', '2', 'compute_rhs', '0', '1'

            InterfaceSignature isig;

            AbstractComponentFunctor acf = (AbstractComponentFunctor)BackEnd.acfdao.retrieve(i.Id_abstract);

            isig.package_path  = acf.Library_path;
            isig.the_interface = i;
            isig.parameters    = new Dictionary <string, InterfaceSignature>();
            isig.varId         = new Dictionary <string, string>();
            isig.slice_types   = new Dictionary <string, InterfaceSignature>();

            IList <Slice> slice_list = BackEnd.sdao.listByInterface(i.Id_abstract, i.Id_interface);

            // id_abstract, id_inner, id_interface_slice, partition_index, id_interface, property_name, transitive
            // '43', 'cells_info', 'cells', '0', 'compute_rhs', 'Cells', '0'
            // '43', 'problem_data', 'problem', '0', 'compute_rhs', 'Problem', '0'

            foreach (Slice s in slice_list)
            {
                InnerComponent ic = BackEnd.icdao.retrieve(s.Id_abstract, s.Id_inner);
                // id_abstract_owner, id_functor_app, id_inner, id_abstract_inner, parameter_top, transitive, public
                // 1st loop:
                // '43', '131', 'cells_info', '31', '', '0', '-1'
                // 2nd loop:
                // '43', '132', 'problem_data', '40', '', '0', '-1'

                int id_functor_app_actual = ic.Id_functor_app;
                // 1st loop: id_functor_app_actual = 131
                // 2nd loop: id_functor_app_actual = 132

                Interface i_ = BackEnd.idao.retrieve(ic.Id_abstract_inner, s.Id_interface_slice);
                // id_abstract, id_interface, partition_index, id_interface_super, partition_index_super, uri_source, class_nargs, id_interface_super_top, partition_index_super_top, order
                // 1st loop:
                // '31', 'cells', '0', '', '0', 'common.datapartition.MultiPartitionCells.ICells', '', '0', 'cells', '0', '1', NULL, NULL, NULL
                // 2nd loop:
                // '40', 'problem', '0', '', '0', 'adi.data.ProblemDefinition.IProblemDefinition', '', '2', 'problem', '0', '1', NULL, NULL, NULL

                if (!ic.Parameter_top.Equals(""))                 // 1st loop: FALSE  2nd loop: FALSE
                {
                    if (closed_pars.ContainsKey(ic.Parameter_top))
                    {
                        id_functor_app_actual = closed_pars[ic.Parameter_top];
                    }
                    InterfaceParameter ip = BackEnd.ipdao.retrieve(i.Id_abstract, i.Id_interface, ic.Parameter_top);
                    AbstractComponentFunctorApplication acfa = BackEnd.acfadao.retrieve(id_functor_app_actual);
                    i_ = BackEnd.idao.retrieveTop(acfa.Id_abstract, ip.Id_unit_parameter);
                }

                IList <string>               parameters   = new List <string>();
                IDictionary <string, int>    closed_pars_ = new Dictionary <string, int>();
                IDictionary <string, string> open_pars_   = new Dictionary <string, string>();
                IList <SupplyParameter>      sp_list      = BackEnd.spdao.list(id_functor_app_actual);
                // id_parameter, id_functor_app, id_abstract
                // 1st loop: empty
                // 2nd loop:
                // 'class', '132', '40'
                // 'instance_type', '132', '40'
                foreach (SupplyParameter sp in sp_list)
                {
                    if (sp is SupplyParameterComponent)                     // always false
                    {
                        SupplyParameterComponent spc = (SupplyParameterComponent)sp;
                        if (!closed_pars_.ContainsKey(spc.Id_parameter))
                        {
                            closed_pars_.Add(spc.Id_parameter, spc.Id_functor_app_actual);
                        }
                    }
                    else if (sp is SupplyParameterParameter)
                    {
                        SupplyParameterParameter spp = (SupplyParameterParameter)sp;
                        // id_parameter, id_functor_app, id_parameter_actual, freeVariable
                        // 2nd outer loop / 1st inner loop:
                        // 'class', '132', 'class', '0'
                        // 2nd outer loop / 2nd inner loop
                        // 'instance_type', '132', 'instance_type', '0'
                        int id_functor_app_actual_parameter;
                        if (closed_pars.ContainsKey(spp.Id_argument))                         // ALWAYS FALSE
                        {
                            id_functor_app_actual_parameter = closed_pars[spp.Id_argument];
                            if (!closed_pars_.ContainsKey(spp.Id_parameter))
                            {
                                closed_pars_.Add(spp.Id_parameter, id_functor_app_actual_parameter);
                            }
                        }
                        else if (open_pars.ContainsKey(spp.Id_argument))
                        {
                            if (!open_pars_.ContainsKey(spp.Id_parameter))
                            {
                                open_pars_.Add(spp.Id_parameter, open_pars[spp.Id_argument]);
                            }
                            // 2nd outer loop / 1st inner loop: add 'class' -> 'C'
                            // 2nd outer loop / 2nd inner loop: add 'instance_type' -> 'I'
                        }
                        else
                        {
                            // NEVER REACH THIS ARM ...
                        }

                        parameters.Add(spp.Id_parameter);
                        // 2nd outer loop / 1st inner loop: add 'class'
                        // 2nd outer loop / 2nd inner loop: add 'instance_type'
                    }
                }

                InterfaceSignature par_ic = calculateParameters(i_, closed_pars_, open_pars_);
                if (!isig.slice_types.ContainsKey(s.PortName))
                {
                    isig.slice_types.Add(s.PortName, par_ic);
                }
                else
                {
                    Console.WriteLine("EXISTENTE {0}", s.PortName);
                }
                // 1st loop:
                // InterfaceSignature [
                //    the_interface = ('31', 'cells', '0', '', '0', 'common.datapartition.MultiPartitionCells.ICells', '', '0', 'cells', '0', '1')
                //    parameters = {}
                //    parId = {}
                // ]
                // 2nd loop:
                // InterfaceSignature [
                //    the_interface = ('40', 'problem', '0', '', '0', 'adi.data.ProblemDefinition.IProblemDefinition', '', '2', 'problem', '0', '1')
                //    parameters = {C -> InterfaceSignature [ IClass ... ] , I -> InterfaceSignature [ IInstance ... ]}
                //    parId = {C -> class, I -> instance_type}
                // ]
                foreach (KeyValuePair <string, InterfaceSignature> is_par in par_ic.parameters)
                {
                    string par_id = is_par.Key;
                    // 2nd outer loop / 1st inner loop: var_id = C, par_id = class
                    // 2nd outer loop / 2nd inner loop: var_id = I, par_id = instance_type
                    if (parameters.Contains(par_id))
                    {
                        if (!isig.parameters.ContainsKey(par_id))
                        {
                            isig.parameters.Add(par_id, is_par.Value);
                        }
                        else
                        {
                            ;
                        }
                        // 2nd outer loop / 1st inner loop: add (class, InterfaceSignature [ IClass ... ])
                        // 2nd outer loop / 2nd inner loop: add (instance_type, InterfaceSignature [ IInstance[C] ... ])
                        if (open_pars_.ContainsKey(par_id) && !isig.varId.ContainsKey(par_id))
                        {
                            isig.varId.Add(par_id, open_pars_[par_id]);
                        }
                        // 2nd outer loop / 1st inner loop: add (class, C)
                        // 2nd outer loop / 2nd inner loop: add (instance_type, I)
                    }
                }

                if (!ic.Parameter_top.Equals(""))                 // never
                {
                    if (isig.parameters.ContainsKey(ic.Parameter_top))
                    {
                        isig.parameters.Remove(ic.Parameter_top);
                    }
                    isig.parameters.Add(ic.Parameter_top, par_ic);

                    if (open_pars.ContainsKey(ic.Parameter_top))
                    {
                        if (isig.varId.ContainsKey(ic.Parameter_top))
                        {
                            isig.varId.Remove(ic.Parameter_top);
                        }
                        isig.varId.Add(ic.Parameter_top, open_pars[ic.Parameter_top]);
                    }
                }
            }


            return(isig);
        }
        private void loadInnerComponents(AbstractComponentFunctor absC)
        {
            IList <InnerComponentType> includeAsInner = new List <InnerComponentType>();

            IDictionary <string, InnerComponentType> innersByVarName = new Dictionary <string, InnerComponentType>();

            if (parameter != null)
            {
                foreach (ParameterType ir in parameter)
                {
                    InnerComponentType ic = this.lookForInnerComponent(ir.componentRef);
                    if (ic == null)
                    {
                        Console.WriteLine("LOOK FOR INNER COMPONENT RETURNED NULL " + ir.componentRef);
                    }
                    if (!innersByVarName.ContainsKey(ir.varName))
                    {
                        innersByVarName[ir.varName] = ic;
                    }
                    else
                    {
                        Console.WriteLine("ALREADY EXISTS - key=" + ir.varName + ", value=" + ic.localRef);
                    }
                }
            }

            if (parameterSupply != null)
            {
                foreach (ParameterSupplyType ir in parameterSupply)
                {
                    InnerComponentType ic = this.lookForInnerComponent(ir.cRef);
                    if (!innersByVarName.ContainsKey(ir.varName))
                    {
                        innersByVarName[ir.varName] = ic;
                    }
                    else
                    {
                        Console.WriteLine("ALREADY EXISTS - key=" + ir.varName + ", value=" + ic.localRef);
                    }
                }
            }

            importInnerComponentsOfSuper(absC, includeAsInner);

            if (inner != null)
            {
                foreach (InnerComponentType c in inner)
                {
                    Console.WriteLine("BEGIN loadInnerComponent : " + c.localRef + " :: " + c.package + "." + c.name);

                    // innerAll.Add(c);
                    if (((isNotInSupply(c) || this.findInSlices(c.localRef)) && (isNotParameter(c) || this.findInSlices(c.localRef))) || includeAsInner.Contains(c))
                    {
                        // CREATE INNER COMPONENT
                        InnerComponent iNew = new InnerComponent();
                        iNew.Id_abstract_owner = absC.Id_abstract;
                        iNew.Id_inner          = c.localRef; // localRef is used to uniquely identify the inner component among the inner components....

                        // FOLLOW arrow has-parameters
                        AbstractComponentFunctorApplication app = newAbstractComponentFunctorApplication(c);
                        if (app == null)
                        {
                            throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (inner component) : " + c.name);
                        }

                        iNew.Id_functor_app    = app.Id_functor_app;
                        iNew.Id_abstract_inner = app.Id_abstract;

                        // CHECKS IF IT IS A TOP PARAMETER
                        ParameterType p = lookForParameterByCRef(c.localRef);
                        iNew.Parameter_top = p != null ? p.formFieldId : null;

                        iNew.Transitive = false;
                        iNew.IsPublic   = c.exposed;
                        iNew.Multiple   = c.multipleSpecified ? c.multiple : false;

                        // LOAD EXPOSED INNER COMPONENTS
                        if (c.port != null)
                        {
                            foreach (InnerComponentType port in c.port)
                            {
                                Console.WriteLine("loadInnerComponent - BEGIN PORT " + port.localRef);
                                // --------------------------------------------------
                                string varName          = null;
                                int    id_abstract_port = app.Id_abstract;
                                string id_inner_port    = port.localRef;

                                InnerComponent ic_port = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(id_abstract_port, id_inner_port);

                                Console.WriteLine("loadInnerComponent - STEP 1");

                                if (c.parameter != null && ic_port != null)
                                {
                                    foreach (ParameterRenaming par in c.parameter)
                                    {
                                        Console.WriteLine("loadInnerComponent - STEP 2 begin " + par.formFieldId + " - " + par.varName);
                                        if (par.formFieldId.Equals(ic_port.Parameter_top))
                                        {
                                            varName = par.varName;
                                        }
                                        Console.WriteLine("loadInnerComponent - STEP 2 end " + par.formFieldId + " - " + par.varName);
                                    }
                                }

                                InnerComponentType port_replace = port;
                                if (varName != null)
                                {
                                    Console.WriteLine("loadInnerComponent - STEP 3 " + varName);
                                    foreach (KeyValuePair <string, InnerComponentType> iii in innersByVarName)
                                    {
                                        Console.WriteLine("loadInnerComponent x " + iii.Key);
                                        Console.WriteLine("loadInnerComponent y " + (iii.Value == null));
                                        Console.WriteLine("loadInnerComponent z " + c.package);
                                        Console.WriteLine("loadInnerComponent w " + c.name);
                                    }
                                    port_replace = innersByVarName[varName];
                                }
                                else
                                {
                                    Console.WriteLine("loadInnerComponent - STEP 3 ");
                                }

                                // --------------------------------------------------

                                innerAll.Add(port);

                                InnerComponent iNewPort = new InnerComponent();
                                iNewPort.Id_abstract_owner = absC.Id_abstract;
                                string old_port_localRef = port.localRef;
                                port.localRef          = lookForRenamingNew(c.localRef, old_port_localRef, port.index_replica);
                                iNewPort.Id_inner      = port.localRef;
                                iNewPort.Parameter_top = port_replace.parameter_id;
                                iNewPort.Transitive    = true;
                                iNewPort.IsPublic      = port.exposed;
                                iNewPort.Multiple      = port.multipleSpecified ? port.multiple : false;

                                AbstractComponentFunctorApplication appPort = newAbstractComponentFunctorApplication(port_replace);
                                if (appPort == null)
                                {
                                    throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (public inner component) : " + port.name);
                                }

                                iNewPort.Id_functor_app    = appPort.Id_functor_app;
                                iNewPort.Id_abstract_inner = appPort.Id_abstract;

                                InnerComponentExposed ice = new InnerComponentExposed();
                                ice.Id_abstract     = absC.Id_abstract;
                                ice.Id_inner_rename = iNewPort.Id_inner;
                                ice.Id_inner_owner  = iNew.Id_inner;
                                ice.Id_inner        = old_port_localRef;

                                br.ufc.pargo.hpe.backend.DGAC.BackEnd.icedao.insert(ice);

                                InnerComponent ic_port_exists = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(iNewPort.Id_abstract_owner, iNewPort.Id_inner);

                                if (ic_port_exists == null && (fusion == null || !fusion.ContainsKey(port.localRef) || (fusion.ContainsKey(port.localRef) && fusion[port.localRef].Equals(c.localRef))))
                                {
                                    br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNewPort);
                                }

                                Console.WriteLine("loadInnerComponent - END PORT " + port.localRef);
                            }
                        }


                        InnerComponent ic = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(iNew.Id_abstract_owner, iNew.Id_inner);

                        if (ic != null && includeAsInner.Contains(c))
                        {
                            Console.WriteLine("loadInnerComponent - BLOCK 2 OPEN");
                            br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.remove(iNew.Id_abstract_owner, iNew.Id_inner);
                            br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNew);
                            Console.WriteLine("loadInnerComponent - BLOCK 2 CLOSE");
                        }
                        else if (ic == null)
                        {
                            Console.WriteLine("loadInnerComponent - BLOCK 3 OPEN");
                            br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNew);
                            Console.WriteLine("loadInnerComponent - BLOCK 3 CLOSE");
                        }
                    }

                    Console.WriteLine("END loadInnerComponent : " + c.localRef + " :: " + c.package + "." + c.name);
                }
            }
        }
        protected override HashComponent loadComponent_(ComponentType c)
        {
            // CREATE Component

            AbstractComponentFunctor c_ = new AbstractComponentFunctor();

            c_.Id_abstract        = Connector.nextKey("id_abstract", "abstractcomponentfunctor");
            c_.Hash_component_UID = c.header.hash_component_UID;
            c_.Library_path       = c.header.packagePath + "." + c.header.name;
            c_.Kind = c.header.kind.ToString();


            if (c.header.baseType != null)
            {
                ExtensionTypeType  extType = c.header.baseType.extensionType;
                ComponentInUseType baseC   = null;

                if (extType.ItemElementName == ItemChoiceType.extends && extType.Item)
                {
                    baseC = c.header.baseType.component;

                    parameterRenamingSuper = baseC.parameter;

                    AbstractComponentFunctorApplication baseCapp = newAbstractComponentFunctorApplication(baseC);

                    // FOLLOW arrow subtype
                    if (baseCapp == null)
                    {
                        throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (extends) : " + baseC.name);
                    }

                    c_.Id_functor_app_supertype = baseCapp.Id_functor_app;
                }

                br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.insert(c_);

                // LOAD EXPOSED INNER COMPONENTS OF THE BASE
                if (baseC.port != null)
                {
                    foreach (InnerComponentType port in baseC.port)
                    {
                        innerAll.Add(port);

                        InnerComponent iNewPort = new InnerComponent();
                        iNewPort.Id_abstract_owner = c_.Id_abstract;
                        string old_port_localRef = port.localRef;
                        port.localRef          = lookForRenamingNew(baseC.localRef, old_port_localRef, port.index_replica);
                        iNewPort.Id_inner      = port.localRef;
                        iNewPort.Parameter_top = port.parameter_id;
                        iNewPort.Transitive    = true;
                        iNewPort.IsPublic      = true;
                        iNewPort.Multiple      = port.multipleSpecified ? port.multiple : false;

                        AbstractComponentFunctorApplication appPort = newAbstractComponentFunctorApplication(port);
                        if (appPort == null)
                        {
                            throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (public inner component) : " + port.name);
                        }

                        iNewPort.Id_functor_app    = appPort.Id_functor_app;
                        iNewPort.Id_abstract_inner = appPort.Id_abstract;

                        InnerComponentExposed ice = new InnerComponentExposed();
                        ice.Id_abstract     = c_.Id_abstract;
                        ice.Id_inner_rename = iNewPort.Id_inner;
                        ice.Id_inner_owner  = null;
                        ice.Id_inner        = old_port_localRef;

                        br.ufc.pargo.hpe.backend.DGAC.BackEnd.icedao.insert(ice);

                        if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(iNewPort.Id_abstract_owner, iNewPort.Id_inner) == null)
                        {
                            br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNewPort);
                        }
                    }
                }
            }
            else
            {
                br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.insert(c_);
            }



            loadAbstractComponentFunctorParameters(c_);

            return(c_);
        }
        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");
        }