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); } } } } } }
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); } } } } } }
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); } } }
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); }