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); } }
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); }
static void createApplicationComponentAbstractInner(IList <object> body_items, IList <Tuple <string, string, EnvironmentPortType> > bindings_application, ref IList <string> port_names) { int port_count = 0; port_names = new List <string> (); foreach (Tuple <string, string, EnvironmentPortType> binding in bindings_application) { string componentRef = binding.Item1; string port_name = binding.Item2; // search for the type of the component connected to the application through the environment port AbstractComponentFunctor acf = backend.DGAC.BackEnd.acfdao.retrieve_libraryPath(componentRef); // search for the type of the environment port in the inner component. InnerComponent ic = backend.DGAC.BackEnd.icdao.retrieve(acf.Id_abstract, port_name); AbstractComponentFunctor acf_inner = backend.DGAC.BackEnd.acfdao.retrieve(ic.Id_abstract_inner); String library_path = acf_inner.Library_path; InnerComponentType ci = new InnerComponentType(); ci.package = acf_inner.Package; ci.name = acf_inner.Name; ci.localRef = port_name + (port_count++); ci.multiple = false; ci.exposed = true; port_names.Add(ci.localRef); body_items.Add(ci); } }
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); }
public new HashComponent loadComponent(ComponentType c, ref IList <ExternalLibraryType> externalLibrary) { this.xc = c; AbstractComponentFunctor absC = (AbstractComponentFunctor)base.loadComponent(c, ref externalLibrary); loadInnerComponents(absC); loadInterfaces(absC); return(absC); }
protected AbstractComponentFunctor lookForAbstractComponentFunctor(string package, string name) { string library_path = package + "." + name; //Console.WriteLine("1"); AbstractComponentFunctorDAO acf = new AbstractComponentFunctorDAO(); AbstractComponentFunctor acfa = acf.retrieve_libraryPath(library_path); // .retrieveByUID(component_UID); return(acfa); }
internal void updateSources(ComponentType ct, AbstractComponentFunctor c) { LoadBodyItems(ct.componentInfo); IDictionary <string, Unit> units = new Dictionary <string, Unit>(); int id_abstract = c.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; // InterfaceDAO idao = new InterfaceDAO(); 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 = 'i'; ss.Id_owner_container = c.Id_abstract; ss.Id_owner = i.Id_interface; ss.Contents = sft.contents; ss.File_type = "dll"; 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); } } } } } }
public override bool componentExists(string library_path, out HashComponent cRef) { AbstractComponentFunctor absC = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.retrieve_libraryPath(library_path); if (absC == null) { cRef = null; return(false); } else { cRef = absC; return(true); } }
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); }
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_); }
static void createSystemComponentAbstractUnit(IList <object> body_items, IDictionary <string, InstanceType> component_refs, IDictionary <ProxyComponentAttribute, string> application_attributes, IDictionary <ProxyComponentAttribute, string> workflow_attributes, IList <Tuple <string, string, EnvironmentPortType> > bindings_application, IList <Tuple <string, string, EnvironmentPortType> > bindings_workflow) { IDictionary <int, SliceList> unit_mapping = new Dictionary <int, SliceList> (); foreach (InstanceType c in component_refs.Values) { string cRef = c.contextual_type.component_ref; foreach (UnitMappingType u in c.unit_mapping) { string uRef = u.unit_id; foreach (int n in u.node) { AbstractComponentFunctor acf = backend.DGAC.BackEnd.acfdao.retrieve_libraryPath(cRef); string qualified_class_name = backend.DGAC.BackEnd.idao.retrieve(acf.Id_abstract, uRef, 0).Class_name; string[] parts_class_name = qualified_class_name.Split(new char[] { '.' }); string iRef = parts_class_name[parts_class_name.Length - 1]; bool hasNode = unit_mapping.ContainsKey(n); SliceList units_at_node = hasNode ? unit_mapping[n] : new SliceList(); units_at_node.Value.Add(new Tuple <string, string, string>(cRef, uRef, iRef)); if (!hasNode) { unit_mapping.Add(n, units_at_node); } } } } IDictionary <SliceList, IList <int> > slice_mapping = new Dictionary <SliceList, IList <int> > (); foreach (KeyValuePair <int, SliceList> r in unit_mapping) { bool hasSlice = slice_mapping.ContainsKey(r.Value); IList <int> node_list = hasSlice ? slice_mapping [r.Value] : new List <int> (); node_list.Add(r.Key); if (!hasSlice) { slice_mapping.Add(r.Value, node_list); } } // PEER UNITS int unit_counter = 0; foreach (KeyValuePair <SliceList, IList <int> > r in slice_mapping) { string uname = "peer" + (unit_counter++); string iname = "IPeer" + (unit_counter++); UnitType cu = new UnitType(); cu.facet = 0; cu.iRef = iname; cu.multiple = true; cu.@private = false; cu.replica = 0; cu.uRef = uname; cu.visibleInterface = true; InterfaceType ct = new InterfaceType(); ct.iRef = iname; ct.nArgs = 0; ct.sources = null; //? IDictionary <Tuple <string, string, string>, int> slice_counter = new Dictionary <Tuple <string, string, string>, int> (); IList <UnitSliceType> uslices_list = new List <UnitSliceType> (); IList <InterfaceSliceType> islices_list = new List <InterfaceSliceType> (); foreach (Tuple <string, string, string> slice in r.Key.Value) { string cRef = component_refs [slice.Item1].instance_ref; bool hasSlice = slice_counter.ContainsKey(slice); int slice_replica = hasSlice ? slice_counter [slice] : 0; if (hasSlice) { slice_counter.Remove(slice); } slice_counter.Add(slice, slice_replica + 1); UnitSliceType us = new UnitSliceType(); us.cRef = cRef; us.uRef = slice.Item2; us.sliceName = cRef; us.slice_replica = slice_replica; us.transitive = false; uslices_list.Add(us); InterfaceSliceType fs = new InterfaceSliceType(); fs.isRef = cRef; fs.originRef = new InterfaceRefType(); fs.originRef.cRef = cRef; fs.originRef.iRef = slice.Item3; islices_list.Add(fs); } cu.slices = new UnitSliceType[uslices_list.Count]; uslices_list.CopyTo(cu.slices, 0); ct.slice = new InterfaceSliceType[islices_list.Count]; islices_list.CopyTo(ct.slice, 0); body_items.Add(ct); body_items.Add(cu); } IList <UnitSliceType> uslices_root_list = new List <UnitSliceType> (); IList <InterfaceSliceType> islices_root_list = new List <InterfaceSliceType> (); // ROOT UNIT UnitType ru = new UnitType(); ru.facet = 0; ru.iRef = "IRoot"; ru.multiple = false; ru.@private = false; ru.replica = 0; ru.uRef = "root"; ru.visibleInterface = true; // APPLICATION UNIT SLICE OF THE ROOT UNIT UnitSliceType u_slice_app = new UnitSliceType(); u_slice_app.cRef = application_attributes[ProxyComponentAttribute.INNER_COMPONENT_NAME]; u_slice_app.uRef = application_attributes[ProxyComponentAttribute.UNIT_NAME_ABSTRACT]; u_slice_app.sliceName = u_slice_app.cRef; u_slice_app.slice_replica = 0; u_slice_app.transitive = false; uslices_root_list.Add(u_slice_app); // WORKFLOW UNIT SLICE OF THE ROOT UNIT UnitSliceType u_slice_wrf = new UnitSliceType(); u_slice_wrf.cRef = workflow_attributes[ProxyComponentAttribute.INNER_COMPONENT_NAME]; u_slice_wrf.uRef = workflow_attributes[ProxyComponentAttribute.UNIT_NAME_ABSTRACT]; u_slice_wrf.sliceName = u_slice_wrf.cRef; u_slice_wrf.slice_replica = 0; u_slice_wrf.transitive = false; uslices_root_list.Add(u_slice_wrf); // ROOT UNIT INTERFACE InterfaceType rt = new InterfaceType(); rt.iRef = "IRoot"; rt.nArgs = 0; rt.sources = null; //?? // APPLICATION INTERFACE SLICE OF THE ROOT UNIT InterfaceSliceType i_slice_app = new InterfaceSliceType(); i_slice_app.isRef = u_slice_app.cRef; i_slice_app.originRef = new InterfaceRefType(); i_slice_app.originRef.cRef = u_slice_app.cRef; i_slice_app.originRef.iRef = application_attributes[ProxyComponentAttribute.INTERFACE_NAME_ABSTRACT]; islices_root_list.Add(i_slice_app); // WORKFLOW INTERFACE SLICE OF THE ROOT UNIT InterfaceSliceType i_slice_wrf = new InterfaceSliceType(); i_slice_wrf.isRef = u_slice_wrf.cRef; i_slice_wrf.originRef = new InterfaceRefType(); i_slice_wrf.originRef.cRef = u_slice_wrf.cRef; i_slice_wrf.originRef.iRef = workflow_attributes[ProxyComponentAttribute.INTERFACE_NAME_ABSTRACT]; islices_root_list.Add(i_slice_wrf); IList <InterfacePortType> iports_root_list = new List <InterfacePortType> (); int counter = 0; // TRANSITIVE SLICES (environment ports) OF THE APPLICATION SLICE foreach (Tuple <string, string, EnvironmentPortType> slice in bindings_application) { string port_name = slice.Item2 + (counter++); // UNIT SLICES UnitSliceType us = new UnitSliceType(); us.cRef = port_name; us.uRef = Constants.envUnitName[slice.Item3]; us.sliceName = port_name; us.slice_replica = 0; us.transitive = true; uslices_root_list.Add(us); // INTERFACE PORTS (TRANSITIVE SLICES) InterfacePortType fs = new InterfacePortType(); fs.name = port_name; fs.slice = new PortSliceType[1]; fs.slice[0].pRef = application_attributes[ProxyComponentAttribute.INNER_COMPONENT_NAME]; fs.slice[0].sRef = port_name; iports_root_list.Add(fs); } counter = 0; // TRANSITIVE SLICES (environment ports) OF THE WORKFLOW SLICE foreach (Tuple <string, string, EnvironmentPortType> slice in bindings_workflow) { string port_name = slice.Item2 + (counter++); // UNIT SLICES UnitSliceType us = new UnitSliceType(); us.cRef = port_name; us.uRef = Constants.envUnitName[slice.Item3]; us.sliceName = port_name; us.slice_replica = 0; us.transitive = true; uslices_root_list.Add(us); // INTERFACE PORTS (TRANSITIVE SLICES) InterfacePortType fs = new InterfacePortType(); fs.name = port_name; fs.slice = new PortSliceType[1]; fs.slice[0].pRef = workflow_attributes[ProxyComponentAttribute.INNER_COMPONENT_NAME]; fs.slice[0].sRef = port_name; iports_root_list.Add(fs); } ru.slices = new UnitSliceType[uslices_root_list.Count]; uslices_root_list.CopyTo(ru.slices, 0); rt.slice = new InterfaceSliceType[islices_root_list.Count]; islices_root_list.CopyTo(rt.slice, 0); rt.port = new InterfacePortType[iports_root_list.Count]; iports_root_list.CopyTo(rt.port, 0); }
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 loadInterfaces(AbstractComponentFunctor absC) { if (unit != null) { int count = 0; // for each interface ... foreach (UnitType u in unit) { string uRef = u.uRef; string iRef = u.iRef; string uRefSuper = u.super == null || u.super.Length == 0 ? "" : u.super[0].uRef; if (u.super != null) { for (int j = 1; j < u.super.Length; j++) { uRefSuper += "+" + u.super[j].uRef; } } InterfaceType ui = lookForInterface(iRef); int nargs = ui.nArgsSpecified ? ui.nArgs : 0; Console.Error.WriteLine("STEP 5.3"); Interface i = new Interface(); i.Id_abstract = absC.Id_abstract; i.Id_interface = uRef; // i.Unit_replica = unit_replica; i.Facet = u.facet; i.Id_interface_super = uRefSuper; i.Class_name = xc.header.packagePath + "." + xc.header.name + "." + iRef; i.Class_nargs = nargs; // TODO i.Assembly_string = i.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. i.Order = ++count; i.Is_parallel = u.multiple; Console.Error.WriteLine("STEP 5.4"); if (ui.parameter != null) { Console.Error.WriteLine("STEP 5.4 - " + ui.parameter); foreach (InterfaceParameterType ipx in ui.parameter) { Console.Error.WriteLine("STEP 5.4 BEGIN 1- " + ipx.parid); InterfaceParameter ip = new InterfaceParameter(); Console.Error.WriteLine("STEP 5.4 BEGIN 2- " + ipx.parid); ip.Id_abstract = i.Id_abstract; ip.Id_interface = i.Id_interface; ip.ParId = ipx.parid; ip.VarId = ipx.varid; ip.Id_interface_parameter = ipx.iname; ip.Id_unit_parameter = ipx.uname; ip.ParOrder = ipx.order; br.ufc.pargo.hpe.backend.DGAC.BackEnd.ipdao.insert(ip); Console.Error.WriteLine("STEP 5.4 END - " + ipx.parid); } } Console.Error.WriteLine("BEFORE STEP 5.5 " + (ui == null)); Console.Error.WriteLine("STEP 5.5 --- " + (ui.sources[ui.sources.Length - 1].file == null)); int order = 0; foreach (SourceFileType sft in ui.sources[ui.sources.Length - 1].file) { Console.Error.WriteLine("STEP 5.5.0"); SourceCode ss = new SourceCode(); ss.Type_owner = 'i'; ss.Id_owner_container = i.Id_abstract; ss.Id_owner = i.Id_interface; ss.Contents = sft.contents; ss.File_name = sft.name; ss.File_type = "dll"; ss.Order = order++; Console.Error.WriteLine("STEP 5.5.1"); br.ufc.pargo.hpe.backend.DGAC.BackEnd.scdao.insert(ss); int size = (sft.externalDependency == null ? 0 : sft.externalDependency.Length) + (ui.externalReferences == null ? 0 : ui.externalReferences.Length); Console.Error.WriteLine("STEP 5.5.2"); if (size > 0) { 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.Error.WriteLine("STEP 5.5.3"); foreach (string extRef in allRefs) { Console.WriteLine("external reference = " + 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.Error.WriteLine("STEP 5.5.4"); } } Console.Error.WriteLine("STEP 5.6"); br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.insert(i); if (u.slices != null) { IList <string> mS = new List <string>(); IList <String> mP = new List <string>(); IDictionary <string, UnitSliceType> m = new Dictionary <string, UnitSliceType>(); // 1st PASS: COLLECT ALL MAPPINGS SLICE/EXPOSED SLICES foreach (UnitSliceType uS in u.slices) { string sliceName = uS.sliceName; if (uS.port != null) { foreach (string portName in uS.port) { mS.Add(sliceName); mP.Add(portName); } } } // 2nd PASS: foreach (UnitSliceType uS in u.slices) { string sliceName = uS.sliceName; if (mP.Contains(sliceName) && !m.ContainsKey(sliceName)) { Console.Error.WriteLine("ADDING " + sliceName + " TO m"); m.Add(sliceName, uS); } } Console.Error.WriteLine("STEP 5.7"); // 3rd PASS: foreach (UnitSliceType uS in u.slices) { string sname = uS.sliceName; string cRefS = uS.cRef; string uRefS = uS.uRef; InnerComponentType innerC = lookForInnerComponent(cRefS); Console.Error.WriteLine("STEP 5.8"); InnerComponent inner = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(absC.Id_abstract, cRefS); Console.Error.WriteLine("STEP 5.9 ---" + absC.Id_abstract + "," + cRefS); Interface iii = br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.retrieveTop(inner.Id_abstract_inner, uRefS); Console.Error.WriteLine("STEP 5.9.5 ---" + (iii == null)); Slice s = new Slice(); s.Id_abstract = absC.Id_abstract; s.Id_inner = innerC.localRef; s.Id_interface_slice = iii == null ? uRefS : iii.Id_interface; s.Id_interface = uRef; s.Transitive = mP.Contains(sname); Console.Error.WriteLine("STEP 5.10"); string property_name = uS.sliceName; string fstletter = property_name.Substring(0, 1); property_name = fstletter.ToUpper() + property_name.Substring(1, property_name.Length - 1); Console.Error.WriteLine("STEP 5.11"); s.PortName = property_name; if (!s.Transitive && uS.port != null) { Console.Error.WriteLine("STEP 5.12"); foreach (string pname in uS.port) { Console.Error.WriteLine("STEP 5.12.1 -- " + pname + ", " + (m.Count)); UnitSliceType usPort = null; m.TryGetValue(pname, out usPort); Console.Error.WriteLine("STEP 5.12.2 -- " + pname + ", " + (usPort == null)); Console.Error.WriteLine("STEP 5.12.5 -- " + usPort.cRef); InnerComponentType innerCPort = lookForInnerComponent(usPort.cRef); Console.Error.WriteLine("STEP 5.13"); InnerComponent inner2 = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(absC.Id_abstract, usPort.cRef); Interface iii2 = br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.retrieveTop(inner2.Id_abstract_inner, usPort.uRef); SliceExposed se = new SliceExposed(); se.Id_abstract = s.Id_abstract; se.Id_inner = innerCPort.localRef; se.Id_inner_owner = s.Id_inner; se.Id_interface_slice_owner = s.Id_interface_slice_top; // mudado de s.Id_interface_slice em 28/06/2011 se.Id_interface_slice = iii2 == null ? usPort.uRef : iii2.Id_interface; // achar innerRenaming para cNewName = usPort.cRef e cRef = cRefS (uS.cRef) -- Id_inner_original = cOldName string id_inner_original = lookForRenamingOld(cRefS, usPort.cRef, usPort.inner_replica); se.Id_inner_original = id_inner_original != null ? id_inner_original : usPort.cRef; se.Id_interface_slice_original = usPort.uRef; // DEVE SER O TOP !!! if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.sedao.retrieve2(se.Id_inner, se.Id_interface_slice, se.Id_abstract, se.Id_interface_slice_owner, se.Id_inner_owner) == null) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.sedao.insert(se); } } } if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.sdao.retrieve(s.Id_abstract, s.Id_inner, s.Id_interface_slice, s.Id_interface) == null) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.sdao.insert(s); Console.WriteLine("SLICE REGISTERED " + s.Id_abstract + "/" + s.Id_inner + "/" + s.Id_interface_slice + " --- " + s.Id_interface); } else { Console.WriteLine("SLICE NOT REGISTERED " + s.Id_abstract + "/" + s.Id_inner + "/" + s.Id_interface_slice + " --- " + s.Id_interface); } } } //if (ui.protocol != null) readProtocol(i, ui); } } }
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); }
private string buildInstantiatorStringOfSystem(string component_ref, int facet_instance, Tuple <int, string>[] facet_address_list, int[] nodes) { IList <AbstractComponentFunctor> acf_list = BackEnd.acfdao.listByKind(Constants.KIND_APPLICATION_NAME); AbstractComponentFunctor acf = acf_list [0]; Instantiator.InstanceType instantiator = new Instantiator.InstanceType(); Instantiator.ComponentFunctorApplicationType contract = new Instantiator.ComponentFunctorApplicationType(); contract.component_ref = component_ref; contract.argument = new Instantiator.ContextArgumentType[0]; instantiator.contextual_type = contract; instantiator.facet_instanceSpecified = true; instantiator.facet_instance = facet_instance; IList <Interface> units = BackEnd.idao.list(acf.Id_abstract); instantiator.unit_mapping = new Instantiator.UnitMappingType[units.Count]; Console.WriteLine("buildInstantiatorStringOfSystem 0 " + units.Count); int iu = 0; foreach (Interface u in units) { instantiator.unit_mapping [iu] = new Instantiator.UnitMappingType(); instantiator.unit_mapping [iu].unit_id = u.Id_interface; instantiator.unit_mapping [iu].unit_index = 0; instantiator.unit_mapping [iu].facet_instanceSpecified = true; instantiator.unit_mapping [iu].facet_instance = instantiator.unit_mapping [iu].facet = u.Facet; int number_of_nodes = nodes[instantiator.unit_mapping [iu].facet_instance]; instantiator.unit_mapping [iu].node = new int[number_of_nodes]; for (int n = 0; n < number_of_nodes; n++) { instantiator.unit_mapping [iu].node [n] = n; } iu++; } Console.WriteLine("buildInstantiatorStringOfSystem 1"); instantiator.facet_address = new Instantiator.FacetAddressType[facet_address_list.Length]; for (int i = 0; i < facet_address_list.Length; i++) { instantiator.facet_address [i] = new Instantiator.FacetAddressType(); instantiator.facet_address [i].facet_instanceSpecified = true; instantiator.facet_address [i].facet_instance = instantiator.facet_address [i].facet = facet_address_list[i].Item1; instantiator.facet_address [i].facetSpecified = true; instantiator.facet_address [i].facet = instantiator.facet_address [i].facet_instance; string platform_address = facet_address_list[i].Item2 != null ? facet_address_list[i].Item2 : "http://127.0.0.1:100"; Uri uri = new Uri(platform_address); instantiator.facet_address [i].address = uri.Host; instantiator.facet_address [i].portSpecified = true; instantiator.facet_address [i].port = uri.Port; } Console.WriteLine("buildInstantiatorStringOfSystem 2"); string instantiator_string = LoaderApp.serializeInstantiator(instantiator); return(instantiator_string); }
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"); }
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); } } }
private CodeCompileUnit createCompileUnit(string package_path, string unit_class_name, out string[] dependencies) { IList <string> dependency_list = new List <string>(); IList <string> usings_list = new List <string>(); CodeCompileUnit compileUnit = new CodeCompileUnit(); #region namespace AbstractComponentFunctor acf = BackEnd.acfdao.retrieve(id_abstract); Interface i = BackEnd.idao.retrieve(id_abstract, id_interface); CodeNamespace globalNamespace = new CodeNamespace(); compileUnit.Namespaces.Add(globalNamespace); CodeNamespace ns = new CodeNamespace(package_path); compileUnit.Namespaces.Add(ns); #endregion #region class IDictionary <string, int> par_order; InterfaceSignature interface_type_descriptor = createSliceAccessorType(i, out par_order); CodeTypeReference type_ref = buildCodeTypeReference(interface_type_descriptor, dependency_list, usings_list); string[] ss = i.Class_name.Split(new char[] { '.' }); string unit_interface_name = ss[ss.Length - 1]; //string unit_class_name = unit_interface_name + wrapper_source_name_suffix; CodeTypeDeclaration unit_class = new CodeTypeDeclaration(unit_class_name); ns.Types.Add(unit_class); #region class / inheritance unit_class.BaseTypes.Add("br.ufc.pargo.hpe.ConnectorImpl.IConnectorImpl"); unit_class.BaseTypes.Add(type_ref); dependency_list.Add(LoaderApp.buildDllName(acf.Library_path, i.Assembly_string) + ".dll"); dependency_list.Add("DGAC.dll"); #endregion #region class / type parameters unit_class.TypeParameters.AddRange(createContextParameters(interface_type_descriptor, par_order, dependency_list, usings_list)); #endregion #region class / public slice accessors IList <Slice> slice_list = BackEnd.sdao.listByInterface(id_abstract, id_interface); foreach (Slice s in slice_list) { if (s.isPublic()) { string slice_accessor_name = s.PortName; InterfaceSignature isig_slice = interface_type_descriptor.slice_types[slice_accessor_name]; CodeTypeReference slice_accessor_type = buildCodeTypeReference(isig_slice, dependency_list, usings_list); CodeMemberField slice_accessor_field = createSliceAccessorField(slice_accessor_name.ToLower(), slice_accessor_type); unit_class.Members.Add(slice_accessor_field); CodeMemberProperty slice_accessor_property = createSliceAccessorProperty(slice_accessor_name, slice_accessor_type); unit_class.Members.Add(slice_accessor_property); } } #endregion #region class / actions and condition IList <InterfaceAction> action_list = BackEnd.iadao.list(id_abstract, id_interface); foreach (InterfaceAction ia in action_list) { if (ia.IsCondition) { unit_class.Members.Add(createConditionMethod(ia.Id_action)); } else { if (!ia.Id_action.Equals("main")) { unit_class.Members.Add(createActionMethod(ia.Id_action)); } else { // The default method "main" is pre-defined in the IConnectorImpl super class. } } } #endregion #region using dependencies foreach (string using_reference in usings_list) { CodeNamespaceImport import = new CodeNamespaceImport(); import.Namespace = using_reference; globalNamespace.Imports.Add(import); } #endregion #endregion dependencies = new string[dependency_list.Count]; dependency_list.CopyTo(dependencies, 0); return(compileUnit); }